/* Layout: dark-green sidebar (right, RTL) + field banner + card dashboard; the monthly grid stays the working surface.
   Palette: Oren 2005 brand — field green + wheat gold; status colors kept semantic. */
/* Google Sans, served from our own server (no external font host; also works on a closed office network) */
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-700.woff2") format("woff2"); font-weight: 600 800; font-style: normal; font-display: swap; }
:root {
  --bg: #f3f5f0;
  --surface: #ffffff;
  --surface-2: #eef3ec;
  --line: #d9e2d6;
  --line-soft: #e8eee5;
  --fg: #1a2a1f;
  --muted: #5d6e61;
  --brand: #75b885;
  --wheat: #eecc44;
  --wheat-deep: #e2b51d;
  --wheat-soft: #fbf4d6;
  --wheat-ink: #3b2f00;
  --accent: #2f6d47;
  --accent-soft: #e2f0e5;
  --accent-ink: #ffffff;
  --side: #10402a;
  --side-2: #0b2f1f;
  --side-fg: #dfeee2;
  --side-muted: #9fc2a8;
  --paid: #23824d;      --paid-bg: #dcf1e2;
  --pend: #876400;      --pend-bg: #faefc6;
  --over: #b42a20;      --over-bg: #fbe1de;
  --soon: #b8530b;      --soon-bg: #fce8d8;
  --info: #4b6a86;      --info-bg: #e6eef5;
  --shadow: 0 1px 2px rgba(25,45,30,.05), 0 4px 16px rgba(25,45,30,.07);
  --shadow-lg: 0 2px 4px rgba(25,45,30,.08), 0 16px 40px rgba(25,45,30,.14);
  --f-body: "Google Sans", "Segoe UI", Arial, system-ui, sans-serif;
  --r: 12px;
  --side-w: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1410; --surface: #161e19; --surface-2: #1c2720; --line: #2b3a30; --line-soft: #222d26;
    --fg: #e4ece5; --muted: #96a79a; --wheat-soft: #3a3216; --wheat-ink: #2a2100;
    --accent: #8fd0a0; --accent-soft: #1d3424; --accent-ink: #0d1a12;
    --side: #0b2a1c; --side-2: #071d13;
    --paid: #74cf98; --paid-bg: #173525; --pend: #ebc94f; --pend-bg: #3a3114;
    --over: #ff8b80; --over-bg: #3b1916; --soon: #f4a060; --soon-bg: #382313; --info: #9cbad6; --info-bg: #1b2834;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1410; --surface: #161e19; --surface-2: #1c2720; --line: #2b3a30; --line-soft: #222d26;
  --fg: #e4ece5; --muted: #96a79a; --wheat-soft: #3a3216; --wheat-ink: #2a2100;
  --accent: #8fd0a0; --accent-soft: #1d3424; --accent-ink: #0d1a12;
  --side: #0b2a1c; --side-2: #071d13;
  --paid: #74cf98; --paid-bg: #173525; --pend: #ebc94f; --pend-bg: #3a3114;
  --over: #ff8b80; --over-bg: #3b1916; --soon: #f4a060; --soon-bg: #382313; --info: #9cbad6; --info-bg: #1b2834;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--f-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--side); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num, td.m, .kpi b, .money { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--wheat-deep); outline-offset: 2px; }
.gutter { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }

/* ---------- app layout ---------- */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100%; transition: grid-template-columns .2s; }
.layout.collapsed { --side-w: 76px; }

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: env(safe-area-inset-top, 0px); height: calc(100vh - env(safe-area-inset-top, 0px)); z-index: 30;
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%); color: var(--side-fg);
  display: flex; flex-direction: column; overflow: hidden;
  padding-right: env(safe-area-inset-right, 0px);
}
.side .logo-box { padding: 22px 20px 18px; display: grid; justify-items: center; gap: 4px; text-decoration: none; color: var(--side-fg); border-bottom: 1px solid rgba(255,255,255,.08); }
.side .logo-box img { width: 150px; height: auto; display: block; }
.side .logo-box span { font-size: 12px; color: var(--side-muted); letter-spacing: .3px; }
.layout.collapsed .side .logo-box img { width: 44px; height: 52px; object-fit: cover; object-position: left center; }
.layout.collapsed .side .logo-box span, .layout.collapsed .side .lbl, .layout.collapsed .side .soon-tag, .layout.collapsed .side .sec { display: none; }
.side nav { display: grid; gap: 2px; padding: 14px 0; }
.side nav a {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 11px 24px; color: var(--side-fg);
  text-decoration: none; font-weight: 500; font-size: 15px;
}
.side nav a svg.i { color: var(--side-muted); }
.side nav a .lbl { white-space: nowrap; }
.side nav a:hover { background: rgba(255,255,255,.06); }
.side nav a.on { background: linear-gradient(to left, rgba(238,204,68,.22), rgba(238,204,68,.04)); color: #fff; font-weight: 700; }
.side nav a.on::before { content: ""; position: absolute; right: 0; top: 6px; bottom: 6px; width: 4px; border-radius: 4px 0 0 4px; background: var(--wheat); }
.side nav a.on svg.i { color: var(--wheat); }
.side nav a.disabled { opacity: .55; cursor: default; }
.side nav a.disabled:hover { background: none; }
.side .nbadge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--over); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.layout.collapsed .side .nbadge { position: absolute; top: 4px; left: 12px; min-width: 18px; height: 18px; font-size: 11px; }
.side .soon-tag { margin-inline-start: auto; font-size: 10px; background: rgba(255,255,255,.1); color: var(--side-muted); padding: 1px 8px; border-radius: 10px; }
.side .sec { font-size: 11px; letter-spacing: .6px; color: var(--side-muted); padding: 14px 24px 4px; }
.layout.collapsed .side nav a { justify-content: center; padding: 12px 0; }
.side .deco { margin-top: auto; height: 170px; opacity: .22; pointer-events: none; }
.side .deco svg { width: 100%; height: 100%; display: block; }
.side-toggle {
  position: absolute; z-index: 35; top: 22px; right: calc(var(--side-w) - 17px); width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer; transition: right .2s;
}
.side-toggle svg { transition: transform .2s; }
.layout.collapsed .side-toggle svg { transform: rotate(180deg); }

/* ---------- top banner ---------- */
.main-col { min-width: 0; position: relative; display: flex; flex-direction: column; }
.hero {
  position: relative; height: 92px; background-color: #e9dcae; background-size: cover; background-position: center bottom;
  display: flex; align-items: center; gap: 16px; border-bottom-left-radius: 28px;
}
.hero .search { position: relative; width: min(380px, 50%); }
.hero .search input {
  width: 100%; border: 0; border-radius: 26px; padding: 11px 44px 11px 16px; background: rgba(255,255,255,.95); box-shadow: 0 2px 10px rgba(0,0,0,.12); color: #1a2a1f;
}
.hero .search input::placeholder { color: #6b7a6f; }
.hero .search svg { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #33473a; }
.search-pop { position: absolute; top: calc(100% + 6px); right: 0; left: 0; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40; border: 1px solid var(--line); }
.search-pop a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line-soft); }
.search-pop a:last-child { border-bottom: 0; }
.search-pop a:hover, .search-pop a.act { background: var(--accent-soft); }
.search-pop small { color: var(--muted); }
.hero .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.92); border-radius: 30px; padding: 5px 6px 5px 14px; box-shadow: 0 2px 10px rgba(0,0,0,.12); color: #1a2a1f; }
.userbox .bell { position: relative; border: 0; background: none; padding: 6px; cursor: pointer; color: #1a2a1f; display: grid; }
.userbox .bell .nbadge { position: absolute; top: -2px; left: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--over); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.userbox .who { line-height: 1.2; text-align: right; }
.userbox .who b { font-size: 14px; display: block; }
.userbox .who small { font-size: 11px; color: #5d6e61; }
.userbox .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--side); color: var(--wheat); display: grid; place-items: center; font-weight: 800; }
.userbox .out { border: 0; background: none; cursor: pointer; color: #5d6e61; padding: 6px; display: grid; }
.userbox .out:hover { color: var(--over); }
.demo-flag { background: var(--wheat); color: var(--wheat-ink); font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 700; }
.menu-btn { display: none; border: 0; background: rgba(255,255,255,.92); width: 40px; height: 40px; border-radius: 50%; place-items: center; cursor: pointer; color: #1a2a1f; box-shadow: 0 2px 10px rgba(0,0,0,.12); }

main { padding-block: 22px 60px; }
h1 { font-weight: 800; font-size: 26px; margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 17px; margin: 0; font-weight: 700; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .acts { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.stack { display: grid; gap: 18px; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none; color: var(--fg);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: var(--wheat); color: var(--wheat-ink); border-color: var(--wheat); box-shadow: 0 2px 6px rgba(226,181,29,.35); }
.btn.gold:hover { background: var(--wheat-deep); }
.btn.danger { color: var(--over); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--over-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.paid-btn { color: var(--paid); border-color: var(--paid-bg); background: var(--paid-bg); }
.icon-btn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn.ok:hover { background: var(--paid-bg); color: var(--paid); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=month], input[type=search], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 11px; min-width: 0; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; }
.kpi .txt { display: grid; gap: 2px; min-width: 0; }
.kpi span { font-size: 15px; font-weight: 700; color: var(--fg); }
.kpi b { font-size: 26px; font-weight: 800; line-height: 1.15; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi .ic { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--info-bg); color: var(--info); }
.kpi .ic svg.i { width: 28px; height: 28px; }
.kpi.paid b { color: var(--paid); } .kpi.paid .ic { background: var(--paid-bg); color: var(--paid); }
.kpi.over b { color: var(--over); } .kpi.over .ic { background: var(--over-bg); color: var(--over); }
.kpi.soon b { color: var(--soon); } .kpi.soon .ic { background: var(--wheat-soft); color: var(--wheat-deep); }
.kpi .bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.kpi .bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* ---------- cards / panels ---------- */
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.panel-b { padding: 18px 20px; }
.panel.marked { border-right: 5px solid var(--wheat); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

/* alerts card with tabs */
.tabs { display: flex; gap: 2px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: 1px solid transparent; border-bottom: 0; background: none; padding: 10px 18px; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 600; color: var(--muted);
  display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; position: relative; top: 1px;
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { background: var(--surface); border-color: var(--line); color: var(--fg); box-shadow: inset 0 3px 0 var(--over); }
.tabs .cnt { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--over); color: #fff; font-size: 12px; display: inline-grid; place-items: center; }
.tabs .cnt.soon { background: var(--soon); }
.tabs .cnt.mute { background: var(--surface-2); color: var(--muted); }
.alert-table-wrap { max-height: 268px; overflow: auto; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
.list th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.list td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list td.n, .list th.n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list td.acts { white-space: nowrap; text-align: left; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: var(--accent-soft); }
.list a { font-weight: 600; }
.scroll-x { overflow-x: auto; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.paid { background: var(--paid-bg); color: var(--paid); }
.chip.pending { background: var(--pend-bg); color: var(--pend); }
.chip.overdue { background: var(--over-bg); color: var(--over); }
.chip.soon { background: var(--soon-bg); color: var(--soon); }
.chip.expected { background: var(--surface-2); color: var(--muted); }
.chip.field { background: var(--accent-soft); color: var(--accent); }

/* ---------- grid card ---------- */
.grid-card .panel-h h2 { display: flex; align-items: center; gap: 10px; }
.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; padding: 14px 20px 6px; }
.toolbar .grow { flex: 1 1 200px; }
.toolbar label.f { flex: 0 0 auto; }
.toolbar select, .toolbar input[type=month] { width: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -3px; margin-inline-end: 6px; }
.lg-paid { background: var(--paid-bg); box-shadow: inset 0 0 0 1px var(--paid); }
.lg-pend { background: var(--pend-bg); box-shadow: inset 0 0 0 1px var(--pend); }
.lg-over { background: var(--over-bg); box-shadow: inset 0 0 0 1px var(--over); }
.lg-soon { background: var(--soon-bg); box-shadow: inset 0 0 0 1px var(--soon); }
.lg-exp { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.grid-hint { font-size: 12px; color: var(--muted); padding: 0 20px 10px; }

.grid-wrap { overflow: auto; border-top: 1px solid var(--line); background: var(--surface); max-height: calc(100vh - 200px); min-height: 320px; border-radius: 0 0 var(--r) var(--r); }
.grid-wrap.tall { max-height: calc(100vh - 290px); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.grid th, .grid td { border-bottom: 1px solid var(--line-soft); border-inline-start: 1px solid var(--line-soft); padding: 0; white-space: nowrap; }
.grid thead th { position: sticky; z-index: 3; background: var(--surface-2); font-weight: 700; font-size: 12px; padding: 7px 8px; text-align: center; color: var(--muted); }
.grid thead tr.yrs th { top: 0; height: 28px; padding: 4px 10px; color: var(--accent); font-size: 13px; font-weight: 800; text-align: right; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.grid thead tr.mos th { top: 28px; border-bottom: 1px solid var(--line); }
.grid thead tr.mos th.fix, .grid thead tr.mos th.plain-h { color: var(--fg); }
.grid th.yr-start, .grid td.yr-start { border-inline-start: 2px solid var(--line) !important; }
.grid thead th.now { color: var(--wheat-ink); background: var(--wheat); }
.grid td.fix, .grid th.fix { position: sticky; z-index: 2; background: var(--surface); }
.grid thead th.fix { z-index: 4; background: var(--surface-2); }
.grid .c-client { right: 0; width: 170px; min-width: 170px; max-width: 170px; }
.grid .c-det { right: 170px; width: 130px; min-width: 130px; max-width: 130px; box-shadow: -1px 0 0 var(--line); }
.grid td.c-client, .grid td.c-det { padding: 6px 12px; overflow: hidden; text-overflow: ellipsis; }
.grid td.c-client a { color: var(--fg); font-weight: 700; text-decoration: none; }
.grid td.c-client a:hover { color: var(--accent); text-decoration: underline; }
.grid td.c-det button { all: unset; cursor: pointer; color: var(--muted); }
.grid td.c-det button:hover { color: var(--accent); text-decoration: underline; }
.grid td.plain { padding: 6px 10px; text-align: center; color: var(--muted); }
.grid td.total { padding: 6px 10px; text-align: left; font-weight: 800; background: var(--wheat-soft); }
.grid th.total-h { background: var(--wheat-soft) !important; color: var(--fg) !important; }
.grid td.diff { padding: 6px 8px; text-align: left; }
.grid td.diff .warn { color: var(--soon); font-weight: 700; }
.grid td.diff .ok { color: var(--muted); }
.grid td.note-c { padding: 6px 10px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.grid td.m { padding: 0; min-width: 84px; text-align: left; }
.grid td.m.out { background: var(--surface-2); }
.grid td.m button { all: unset; box-sizing: border-box; display: block; width: 100%; height: 100%; min-height: 32px; padding: 6px 8px; cursor: pointer; text-align: left; }
.grid td.m button:hover, .grid td.m button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.grid td.m .add { color: transparent; text-align: center; }
.grid td.m button:hover .add { color: var(--accent); }
.grid td.m button.st-paid { background: var(--paid-bg); color: var(--paid); font-weight: 600; }
.grid td.m button.st-pending { background: var(--pend-bg); color: var(--pend); font-weight: 600; }
.grid td.m button.st-overdue { background: var(--over-bg); color: var(--over); font-weight: 700; }
.grid td.m button.st-soon { background: var(--soon-bg); color: var(--soon); font-weight: 700; }
.grid td.m button.st-expected { color: var(--fg); }
.grid tbody tr:hover td.fix, .grid tbody tr:hover td.plain, .grid tbody tr:hover td.diff, .grid tbody tr:hover td.note-c { background: var(--accent-soft); }
.grid tfoot td { position: sticky; z-index: 2; background: var(--surface-2); font-weight: 800; padding: 7px 8px; text-align: left; border-top: 1px solid var(--line); }
.grid tfoot tr.f1 td { bottom: 62px; background: var(--wheat-soft); }
.grid tfoot tr.f2 td { bottom: 31px; color: var(--paid); font-weight: 600; }
.grid tfoot tr.f3 td { bottom: 0; color: var(--muted); font-weight: 600; }
.grid tfoot td.fix { z-index: 4; text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* client page */
.dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 9px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.dl dd.none { color: var(--muted); font-weight: 400; }
.deal-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.deal-card + .deal-card { margin-top: 12px; }
.deal-card header { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--surface-2); flex-wrap: wrap; }
.deal-card header .t { font-weight: 700; }
.deal-card header .spacer { flex: 1; }
.deal-card .note { padding: 8px 14px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line-soft); }
.progress { height: 7px; border-radius: 4px; background: var(--surface); overflow: hidden; width: 120px; }
.progress i { display: block; height: 100%; background: var(--brand); }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); transition: background .15s, border-color .15s; }
.drop.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.drop .row select { width: auto; }
.doc-list { display: grid; gap: 8px; margin-top: 14px; }
.doc { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 8px; }
.doc .ext { width: 38px; height: 44px; border-radius: 5px; background: var(--surface-2); display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; border: 1px solid var(--line); }
.doc .ext.pdf { color: var(--over); }
.doc .ext.doc, .doc .ext.docx { color: var(--info); }
.doc .ext.xls, .doc .ext.xlsx, .doc .ext.xlsb, .doc .ext.csv { color: var(--paid); }
.doc .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc .acts { display: flex; gap: 4px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 25, 15, .5); display: grid; place-items: start center; overflow: auto;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 24px max(12px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(940px, 100%); border-top: 5px solid var(--brand); }
.modal.narrow { width: min(460px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); gap: 12px; }
.modal-h h2 { font-weight: 800; font-size: 20px; }
.modal-b { padding: 18px 20px; display: grid; gap: 16px; }
.modal-f { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.modal-f .spacer { flex: 1; }
.sched { width: 100%; border-collapse: collapse; }
.sched th { font-size: 12px; color: var(--muted); text-align: right; font-weight: 700; padding: 6px; border-bottom: 1px solid var(--line); }
.sched td { padding: 4px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.sched tr.hl td { background: var(--wheat-soft); }
.sched td input, .sched td select { padding: 6px 8px; }
.sched .c-date { width: 150px; } .sched .c-amt { width: 130px; } .sched .c-st { width: 170px; } .sched .c-pd { width: 150px; }
.sched-sum { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 13px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.sched-sum b { font-variant-numeric: tabular-nums; }
.sched-sum .warn { color: var(--soon); font-weight: 700; }
.sched-sum .ok { color: var(--paid); font-weight: 700; }
.splitter { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: end; background: var(--wheat-soft); }
.splitter label.f { width: 150px; }
@media (max-width: 720px) {
  .sched thead { display: none; }
  .sched tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .sched td { border: 0; padding: 0; width: auto !important; }
}

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 60; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 8px; max-width: min(400px, calc(100vw - 32px)); }
.toast { background: var(--fg); color: var(--bg); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--over); color: #fff; }
.toast.alert { background: var(--surface); color: var(--fg); border-right: 5px solid var(--over); }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding-block: 40px; background: linear-gradient(180deg, var(--side) 0 38%, var(--bg) 38%); }
.auth .card { width: min(410px, 100%); background: var(--surface); border-radius: 16px; padding: 30px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); border-top: 5px solid var(--wheat); }
.auth .logo { height: 100px; width: auto; justify-self: center; }
.auth h1 { font-size: 26px; text-align: center; }
.auth p { margin: 0; color: var(--muted); text-align: center; }
.err-msg { color: var(--over); font-size: 13px; min-height: 1em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- narrow screens: sidebar becomes a drawer ---------- */
@media (max-width: 900px) {
  .layout, .layout.collapsed { grid-template-columns: minmax(0, 1fr); --side-w: 260px; }
  .side { position: fixed; top: 0; right: 0; bottom: 0; height: auto; width: 260px; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow-lg); padding-top: env(safe-area-inset-top, 0px); }
  .layout.drawer .side { transform: none; }
  .layout.collapsed .side .lbl, .layout.collapsed .side .logo-box span, .layout.collapsed .side .soon-tag, .layout.collapsed .side .sec { display: initial; }
  .layout.collapsed .side .logo-box img { width: 150px; }
  .layout.collapsed .side nav a { justify-content: flex-start; padding: 11px 24px; }
  .side-toggle { display: none; }
  .menu-btn { display: grid; }
  .hero { border-bottom-left-radius: 0; height: 80px; }
  .hero .search { display: none; }
  .userbox .who { display: none; }
}
@media (max-width: 640px) {
  .gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .grid .c-client { width: 118px; min-width: 118px; max-width: 118px; }
  .grid .c-det { right: 118px; width: 90px; min-width: 90px; max-width: 90px; }
  .grid-wrap { max-height: 70vh; }
  h1 { font-size: 22px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { grid-template-columns: 1fr; padding: 14px; }
  .kpi .ic { display: none; }
  .kpi b { font-size: 19px; }
}
.auth .btn { justify-content: center; }

/* ================= v2: auth extras ================= */
.link-btn { all: unset; cursor: pointer; color: var(--accent); font-size: 13px; text-align: center; justify-self: center; padding: 4px 8px; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--wheat-deep); }
.note-box { background: var(--info-bg); color: var(--info); border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.55; }
.note-box.ok { background: var(--paid-bg); color: var(--paid); }
.note-box.warn { background: var(--wheat-soft); color: var(--fg); border-right: 4px solid var(--wheat-deep); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-left: 40px; }
.pw-eye { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.pw-eye:hover { color: var(--fg); background: var(--surface-2); }
.pw-meter { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: -6px; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .7; cursor: progress; }

/* ================= sortable tables ================= */
th.sortable { padding: 0 !important; }
th.sortable button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 6px; width: 100%; padding: 9px 12px; white-space: nowrap; }
.list th.sortable.n button { justify-content: flex-end; }
th.sortable .arr { font-size: 10px; color: var(--muted); opacity: .45; }
th.sortable:hover .arr { opacity: 1; }
th.sortable.on { color: var(--accent); }
th.sortable.on .arr { opacity: 1; color: var(--accent); }
th.sortable button:focus-visible { outline: 2px solid var(--wheat-deep); outline-offset: -2px; }
.grid thead th.sortable button { padding: 7px 8px; justify-content: center; font-weight: 700; }
.grid thead th.fix.sortable button { justify-content: flex-start; }
.list tfoot td { padding: 10px 12px; background: var(--surface-2); border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.over-t { color: var(--over); }
tr.dim td { opacity: .55; }

/* grid: open-balance column */
.grid td.open-c { padding: 6px 10px; text-align: left; font-weight: 700; background: var(--accent-soft); }
.grid td.open-c.has-over { color: var(--over); }
.grid td.open-c .ok { color: var(--paid); }
.grid th.open-h { background: var(--accent-soft) !important; color: var(--fg) !important; }

/* receive-payment dialog */
.rc-sum { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; display: grid; gap: 2px; }
.rc-partial { border: 1px dashed var(--soon); background: var(--soon-bg); color: var(--fg); border-radius: 8px; padding: 10px 14px; display: grid; gap: 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: 12px; }

/* read-only deal editor */
.modal.ro #sp-toggle, .modal.ro #add-row, .modal.ro [data-rm], .modal.ro #fill-last, .modal.ro .splitter, .modal.ro #d-newc-w { display: none !important; }
.modal.ro input:disabled, .modal.ro select:disabled { background: var(--surface-2); color: var(--fg); opacity: 1; -webkit-text-fill-color: var(--fg); }

/* client statement */
.statement .panel-h h2 { display: flex; align-items: center; gap: 8px; }
.st-tot { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; padding: 10px 20px; font-size: 13px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.st-tot b { font-variant-numeric: tabular-nums; font-size: 15px; }
.st-tot .t-paid b { color: var(--paid); }
.st-tot .t-over b { color: var(--over); }
.st-table { max-height: 420px; overflow: auto; }

/* audit list */
.au-list { list-style: none; margin: 0; padding: 0; display: grid; }
.au-list > li { padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.au-list > li:last-child { border-bottom: 0; }
.au-h { display: flex; gap: 8px; align-items: baseline; }
.au-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); flex: none; transform: translateY(-1px); }
.au.create .au-dot { background: var(--paid); }
.au.delete .au-dot { background: var(--over); }
.au.login .au-dot, .au.password .au-dot { background: var(--muted); }
.au-m { font-size: 12px; color: var(--muted); margin: 2px 16px 0 0; }
.au details { margin: 6px 16px 0 0; font-size: 12px; }
.au summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.au-ch { border-collapse: collapse; margin-top: 6px; width: 100%; max-width: 720px; }
.au-ch td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.au-ch td:first-child { color: var(--muted); white-space: nowrap; }
.au-ch .o { color: var(--over); text-decoration: line-through; }
.au-ch .nn { color: var(--paid); font-weight: 600; }
.au-ch .arr { color: var(--muted); width: 1%; }

/* users */
.avatar.sm { width: 26px; height: 26px; border-radius: 50%; background: var(--side); color: var(--wheat); display: inline-grid; place-items: center; font-weight: 800; font-size: 12px; vertical-align: middle; }
.chip.role-admin { background: var(--side); color: var(--wheat); }
.chip.role-editor { background: var(--accent-soft); color: var(--accent); }
.chip.role-viewer { background: var(--info-bg); color: var(--info); }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.role-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; }
.role-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.role-pick { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.role-pick legend { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; padding: 0; }
.role-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.role-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-opt input { margin-top: 3px; }
.role-opt span { display: grid; gap: 2px; }
.role-opt small { color: var(--muted); }
.role-pick:disabled .role-opt { opacity: .6; cursor: default; }

/* reports */
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 18px; }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; align-items: end; height: 210px; }
.bar-col { display: grid; grid-template-rows: auto 1fr auto; height: 100%; align-items: end; text-align: center; min-width: 0; }
.bar-col i { display: block; width: 100%; min-height: 2px; border-radius: 5px 5px 0 0; background: var(--brand); align-self: end; }
.bars.fwd .bar-col i { background: var(--wheat); }
.bar-col .bv { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.bar-col .bl { font-size: 11px; color: var(--muted); padding-top: 4px; line-height: 1.2; display: grid; }
.bar-col .bl small { font-size: 9px; opacity: .8; }
.bar-col:hover i { filter: brightness(.9); }
.aging td.late-b30 { color: var(--soon); }
.aging td.late-b60 { color: var(--soon); font-weight: 600; }
.aging td.late-b90, .aging td.late-b90p { color: var(--over); font-weight: 700; }
.progress.inline { display: inline-block; vertical-align: middle; width: 80px; background: var(--surface-2); }
@media (max-width: 640px) { .bars { height: 170px; gap: 3px; } .bar-col .bv { display: none; } }

/* ================= print ================= */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { background: #fff !important; color: #000 !important; }
  body.printing::before { display: none; }
  body.printing #print-root { display: block; font: 11pt/1.45 Arial, sans-serif; color: #000; direction: rtl; }
  #print-root .p-head { display: flex; gap: 16px; align-items: center; border-bottom: 2px solid #2f6d47; padding-bottom: 10px; margin-bottom: 14px; }
  #print-root .p-head img { height: 54px; width: auto; }
  #print-root .p-head h1 { font-size: 18pt; margin: 0 0 2px; }
  #print-root .p-head > div:nth-child(2) { flex: 1; }
  #print-root .p-meta { font-size: 9pt; color: #444; text-align: left; }
  #print-root h2 { font-size: 13pt; margin: 18px 0 6px; }
  #print-root .p-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  #print-root .p-table th { background: #e2f0e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; text-align: right; padding: 5px 6px; border-bottom: 1px solid #2f6d47; }
  #print-root .p-table td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
  #print-root .p-table .n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
  #print-root .p-table tfoot td { font-weight: 700; border-top: 1.5px solid #000; border-bottom: 0; }
  #print-root .p-table tr { break-inside: avoid; }
  #print-root .p-table thead { display: table-header-group; }
  #print-root .p-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
  #print-root .p-kpis div { border: 1px solid #ccc; border-radius: 6px; padding: 6px 8px; font-size: 9pt; }
  #print-root .p-kpis b { display: block; font-size: 12pt; }
}
.aging td:first-child { white-space: nowrap; }
.list td[dir=ltr] { unicode-bidi: plaintext; }
.kpi b { font-size: clamp(19px, 2.1vw, 26px); }
.kpi .txt b { overflow-wrap: anywhere; }
.st-table td { white-space: nowrap; }
.note-box.err-box { background: var(--over-bg); color: var(--over); }
.note-box ol { margin: 6px 0 0; padding-inline-start: 20px; display: grid; gap: 2px; }
.note-box a { color: inherit; font-weight: 700; }

/* ================= several systems: start screen and areas ================= */
.side nav a.nav-start { margin: 0 12px 6px; padding: 9px 12px; border-radius: 10px; background: rgba(255,255,255,.07); font-size: 14px; }
.side nav a.nav-start.on { background: rgba(255,255,255,.14); }
.side nav a.nav-start.on::before { display: none; }
.layout.collapsed .side nav a.nav-start { margin: 0 8px 6px; padding: 10px 0; }
.start-head { margin: 6px 0 22px; }
.start-head p { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.start-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 22px; max-width: 1100px; }
.start-card { display: grid; grid-template-rows: auto 1fr; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: var(--fg); transition: box-shadow .15s, transform .15s; }
.start-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.start-card .sc-img { position: relative; display: block; height: 120px; background-size: cover; background-position: center bottom; }
.start-card .sc-ic { position: absolute; bottom: -26px; right: 22px; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--side); color: var(--wheat); box-shadow: 0 0 0 4px var(--surface); }
.start-card .sc-ic svg.i { width: 28px; height: 28px; }
.start-card .sc-b { display: grid; gap: 8px; padding: 36px 22px 22px; align-content: start; }
.start-card .sc-t { font-size: 24px; font-weight: 800; }
.start-card .sc-s { color: var(--muted); }
.start-card .sc-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.start-card .sc-stats > span { display: grid; gap: 0; padding: 8px 14px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--muted); min-width: 110px; }
.start-card .sc-stats b { font-size: 22px; color: var(--fg); font-variant-numeric: tabular-nums; }
.start-card .sc-stats .over b { color: var(--over); }
.start-card .sc-stats .soon b { color: var(--soon); }
.start-card .sc-go { justify-self: start; padding: 10px 20px; }

/* ---------- main panel: system name + locked ("in development") systems ---------- */
.start-sys { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; margin-bottom: 8px; }
.start-card.locked { cursor: default; opacity: .78; }
.start-card.locked:hover { transform: none; box-shadow: var(--shadow); }
.start-card.locked .sc-img { filter: grayscale(.85); }
.start-card.locked .sc-ic { background: var(--muted); color: var(--surface); }
.start-card .sc-badge { position: absolute; top: 12px; left: 12px; background: var(--wheat); color: var(--wheat-ink); font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 12px; }
.start-card.locked .sc-go { background: var(--surface-2); color: var(--muted); border-color: var(--line); cursor: default; }

/* ---------- client card: grouped fields ---------- */
.cf-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.cf-group + .cf-group { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.cf-group legend { font-weight: 800; font-size: 14px; color: var(--accent); padding: 0; margin-bottom: 10px; }
.cd-group + .cd-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.cd-group h3 { margin: 0 0 10px; font-size: 13px; font-weight: 800; color: var(--accent); }

/* ---------- Excel import ---------- */
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 18px; align-items: start; }
.imp-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.imp-pick label.btn { cursor: pointer; }
.imp-fname { overflow-wrap: anywhere; min-width: 0; }
.imp-report:not(:empty) { margin-top: 16px; }
.imp-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); display: grid; gap: 8px; min-width: 0; }
.imp-card.done { border-color: var(--paid); background: var(--paid-bg); }
.imp-title { font-weight: 800; display: flex; gap: 6px; align-items: center; }
.imp-card h4 { margin: 8px 0 0; font-size: 13px; }
.imp-card h4.warn { color: var(--soon); }
.imp-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-stats span { display: grid; background: var(--surface); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); min-width: 92px; }
.imp-stats b { font-size: 18px; color: var(--fg); font-variant-numeric: tabular-nums; }
.imp-stats .warn b { color: var(--soon); }
.imp-list { max-height: 240px; overflow: auto; background: var(--surface); border-radius: 8px; }
