:root {
  --green: #1F3A2E;
  --green-2: #2C5140;
  --brass: #B08D57;
  --brass-soft: #F1E8D8;
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --text: #1D2420;
  --muted: #6B736E;
  --line: #E4E0D6;
  --red: #B4432F;
  --red-soft: #F8E5E1;
  --ok: #2F7A4E;
  --ok-soft: #E2F1E7;
  --amber: #9A6A12;
  --amber-soft: #FBF0D9;
  --blue: #2F5E8A;
  --blue-soft: #E3EDF6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714; --card: #1A211D; --text: #E8ECE9; --muted: #98A29C; --line: #2B3530;
    --brass-soft: #3A3122; --red-soft: #3D2420; --ok-soft: #1E3326; --amber-soft: #3A2F18; --blue-soft: #1D2B38;
    --green-2: #3D6B55;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--green-2); text-decoration: none; }
@media (prefers-color-scheme: dark) { a { color: #9FC7B1; } }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
small { font-size: 12px; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.ico { flex: none; }

/* ---------- header / nav ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--green); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 16px; white-space: nowrap; }
.brand b { color: var(--brass); font-weight: 700; }
.mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brass); color: var(--green); font-weight: 700; font-family: Georgia, serif; font-size: 18px;
}
.brand.big { justify-content: center; font-size: 22px; color: var(--text); margin-bottom: 16px; }
.brand.big .mark { width: 44px; height: 44px; font-size: 24px; color: #fff; background: var(--green); }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a, .bottomnav a { position: relative; color: rgba(255, 255, 255, .78); }
.topnav a { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.topnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.topnav a.on { background: rgba(255, 255, 255, .14); color: #fff; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.tools form { margin: 0; }
.langs { display: flex; gap: 2px; background: rgba(255, 255, 255, .1); border-radius: 9px; padding: 3px; }
.langs a { color: rgba(255, 255, 255, .75); font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 7px; }
.langs a.on { background: var(--brass); color: var(--green); }
.langs.center { justify-content: center; width: max-content; margin: 0 auto 16px; background: var(--bg); }
.langs.center a { color: var(--muted); }
.iconbtn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: rgba(255, 255, 255, .8); cursor: pointer;
}
.iconbtn:hover, .iconbtn.on { background: rgba(255, 255, 255, .12); color: #fff; }
.dot {
  position: absolute; top: 2px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font: 700 11px/18px Manrope, sans-serif; text-align: center; font-style: normal;
}
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--green); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; padding: 4px 0; }
.bottomnav a.on { color: var(--brass); }
.bottomnav .dot { right: calc(50% - 22px); }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .topnav { display: flex; }
  .bottomnav { display: none; }
}

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; margin: 40px auto; }
.narrow-form { max-width: 760px; }
.phead { margin: 4px 0 16px; }
.phead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.card.login { padding: 28px 22px; }
.section { margin: 22px 0 10px; font-size: 15px; }
.section small { color: var(--muted); font-weight: 600; margin-left: 4px; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--green); color: #fff; font: 600 14px Manrope, sans-serif; padding: 10px 16px; border-radius: 10px;
  min-height: 42px; white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .btn { background: var(--green-2); } }
.btn:hover { filter: brightness(1.08); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.wide { width: 100%; }
input, select, textarea {
  width: 100%; font: 15px Manrope, sans-serif; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; border-color: var(--brass); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--green); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; min-height: 44px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field .req { color: var(--red); }
.hint { color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.stack { display: grid; gap: 14px; }
.danger-zone { margin: 8px 0 24px; }

/* ---------- filters / chips ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters form { margin: 0; }
.filters input[type=search] { flex: 1 1 220px; }
.filters select { width: auto; flex: 0 1 auto; }
.filters .short { width: 120px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips a {
  flex: none; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; font-weight: 600;
}
.chips a b { color: var(--muted); margin-left: 2px; }
.chips a.on { background: var(--green); color: #fff; border-color: var(--green); }
.chips a.on b { color: var(--brass); }
.monthnav { display: flex; align-items: center; gap: 8px; }
.monthnav b { min-width: 120px; text-align: center; }

/* ---------- lists ---------- */
.list { display: grid; gap: 8px; }
.item {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.item:hover { border-color: var(--brass); }
.item.inactive { opacity: .55; }
.list.compact .item { padding: 10px 12px; background: transparent; }
.item-main { min-width: 0; }
.item-title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.item-side { text-align: right; flex: none; max-width: 45%; }
.meta { color: var(--muted); font-size: 13px; }
.price { font-weight: 700; }
.who { font-size: 13px; font-weight: 600; }
.who.warn { color: var(--amber); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.b-lead_status-new, .b-deal_stage-negotiation { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.b-lead_status-contacted, .b-lead_status-showing, .b-deal_stage-reservation, .b-prop_status-reserved { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.b-lead_status-offer { background: var(--brass-soft); color: var(--brass); border-color: transparent; }
.b-lead_status-won, .b-deal_stage-signed, .b-deal_stage-paid, .b-prop_status-available { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.b-lead_status-lost, .b-deal_stage-cancelled { background: var(--red-soft); color: var(--red); border-color: transparent; }
.b-excl, .b-role-owner, .b-deal_type-sale { background: var(--brass-soft); color: var(--brass); border-color: transparent; }

/* ---------- alerts ---------- */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--red-soft); color: var(--red); }
.alert.warn { background: var(--amber-soft); color: var(--amber); }
.alert.block { display: block; margin-top: 12px; }

/* ---------- quick contact ---------- */
.quick { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.qbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.qbtn:first-child { background: var(--green); border-color: var(--green); color: #fff; }
.owner-line { margin-bottom: 8px; }
.links > div { margin-bottom: 8px; }
.links .quick { margin-bottom: 8px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.kpi > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.kpi > b { font-size: 24px; line-height: 1.1; }
.kpi > b small { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi > em { font-style: normal; font-size: 12px; color: var(--muted); }
.kpi.accent { background: var(--green); border-color: var(--green); color: #fff; }
.kpi.accent > span, .kpi.accent > em { color: rgba(255, 255, 255, .75); }
@media (max-width: 899px) { .kpi.accent { grid-column: 1 / -1; } }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--red); border-radius: 3px; }
.bar.mid span { background: var(--brass); }
.bar.done span { background: var(--ok); }
.kpi.accent .bar { background: rgba(255, 255, 255, .2); }
.kpi.accent .bar span { background: var(--brass); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 18px; }
.pipeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pipeline a { background: var(--bg); border-radius: 10px; padding: 8px 10px; color: var(--text); }
.pipeline b { display: block; font-size: 20px; }
.pipeline span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl .r { text-align: right; }

/* ---------- deal calc ---------- */
.calc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--brass-soft); }
.calc span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.calc b { font-size: 16px; }

/* ---------- tasks ---------- */
.tasks { list-style: none; margin: 0; padding: 0; }
ul.tasks.card { padding: 4px 14px; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task form { margin: 0; }
.tick {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); background: var(--card); cursor: pointer;
  color: #fff; font-weight: 700; line-height: 1; padding: 0; margin-top: 1px;
}
.tick:hover { border-color: var(--green-2); }
.task.is-done .tick { background: var(--ok); border-color: var(--ok); }
.task.is-done .ttitle { text-decoration: line-through; color: var(--muted); }
.task.is-overdue .meta { color: var(--red); font-weight: 600; }
.ttitle { font-weight: 600; }
.task-add { display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 12px; }
@media (min-width: 700px) { .task-add { grid-template-columns: 2fr 1fr auto auto; } section .task-add { grid-template-columns: 1fr 1fr; } section .task-add .btn { grid-column: 1 / -1; } }
.inline-form { display: grid; gap: 8px; margin-bottom: 12px; }
.inline-form .btn { justify-self: start; }

/* ---------- notes ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 14px; border-left: 2px solid var(--brass-soft); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--brass); }
.timeline .meta { font-size: 12px; }
.timeline .body { overflow-wrap: anywhere; }

pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12px; white-space: pre; }

@media (max-width: 520px) {
  .brand span:last-child { display: none; }
  .item { flex-direction: column; gap: 4px; }
  .item-side { text-align: left; max-width: none; }
  h1 { font-size: 20px; }
}
