/* Hiive Arts Garden (styles copied from Property Management)
   Hiive Arts brand: gold #BD802C (from the logo) on near-black, Instrument Serif titles, Inter text.
   Dark is the default; [data-theme="light"] on <html> switches to the light edition. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark edition: true black and greys; the colours on top are earthy (owner, 2026-11-09) */
  --bg:         #0a0a0a;
  --surface:    #111111;
  --surface2:   #171717;
  --border:     #242424;
  --border-strong: #333333;
  --text:       #f0f0f0;
  --muted:      #8c8c8c;
  --gold:       #BD802C;
  --gold-light: #D4A04F;
  --gold-deep:  #8A5A1C;
  --gold-text:  #D4A04F;          /* gold used for text: readable on the background */
  --gold-soft:  rgba(189,128,44,0.12);
  --on-gold:    #0a0a0a;
  /* Chosen view button + chart bars: gold in dark mode, chocolate brown in light (owner, 2026-11-09) */
  --choc:       var(--gold);
  --on-choc:    var(--on-gold);
  --choc-hover: var(--gold-light);
  --choc-glow:  rgba(189,128,44,0.25);
  --green:      #7DB38A;          /* sage */
  --green-soft: rgba(125,179,138,0.12);
  --red:        #DE7F68;          /* terracotta */
  --red-soft:   rgba(222,127,104,0.12);
  --nav-bg:     rgba(10,10,10,0.88);
  --shadow:     0 10px 40px rgba(0,0,0,0.5);
  --font:       'Inter', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;
  --radius:     10px;
  --tr:         0.2s ease;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:         #f7f4ee;
  --surface:    #ffffff;
  --surface2:   #f1ece3;
  --border:     #e4dccd;
  --border-strong: #cfc3ad;
  --text:       #1a1712;
  --muted:      #6e665a;
  --gold-text:  #8A5A1C;
  --choc:       #84644A;          /* soft milk-chocolate so it sits in the cream page */
  --on-choc:    #FBF6EE;
  --choc-hover: #765840;
  --choc-glow:  rgba(132,100,74,0.22);
  --gold-soft:  rgba(189,128,44,0.14);
  --green:      #0f8a4b;
  --green-soft: rgba(15,138,75,0.1);
  --red:        #c62828;
  --red-soft:   rgba(198,40,40,0.08);
  --nav-bg:     rgba(247,244,238,0.9);
  --shadow:     0 10px 40px rgba(60,40,10,0.15);
  color-scheme: light;
}

html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; transition: background var(--tr), color var(--tr); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ── Nav ── */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100; height: 60px;
  background: var(--nav-bg); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 8px; }
.nav-logo { display: flex; align-items: center; gap: 10px; margin-right: 18px; font-family: var(--font-display); font-size: 1.25rem; white-space: nowrap; }
.nav-logo img { width: 30px; height: 30px; object-fit: contain; }
.nav-logo small { font-family: var(--font); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.nav-link { padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: 500; color: var(--muted); transition: all var(--tr); }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--gold-soft); }
.nav-links { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links .nav-link { flex: none; white-space: nowrap; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.nav-user { font-size: 0.8rem; color: var(--muted); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); transition: all var(--tr);
}
.icon-btn:hover { color: var(--gold-text); border-color: var(--gold); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Page ── */
.page { max-width: 1200px; margin: 0 auto; padding: 88px 20px 64px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; margin-bottom: 26px; }
.page-title { font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; line-height: 1.1; }
.page-sub { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.crumb { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; display: inline-block; }
.crumb:hover { color: var(--gold-text); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.section-title { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; margin: 30px 0 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1;
  padding: 10px 18px; border-radius: 7px; font-size: 0.85rem; font-weight: 600; border: 1px solid transparent;
  transition: all var(--tr); white-space: nowrap;
}
.btn-primary { background: var(--choc); color: var(--on-choc); }
.btn-primary:hover { background: var(--choc-hover); transform: translateY(-1px); box-shadow: 0 4px 20px var(--choc-glow); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-text); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.link-btn { background: none; border: none; color: var(--muted); padding: 4px 6px; border-radius: 5px; font-size: 0.8rem; }
.link-btn:hover { color: var(--gold-text); background: var(--gold-soft); }
.link-btn.danger:hover { color: var(--red); background: var(--red-soft); }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.cur-code { font-size: 0.45em; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); vertical-align: 0.35em; margin-left: 4px; }

.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.prop-card { display: block; transition: border-color var(--tr), transform var(--tr); position: relative; overflow: hidden; }
.prop-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-light)); }
.prop-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.prop-name { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.15; }
.prop-meta { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.prop-rows { margin-top: 16px; display: grid; gap: 8px; font-size: 0.85rem; }
.prop-row { display: flex; justify-content: space-between; gap: 10px; }
.prop-row span:first-child { color: var(--muted); }
.prop-card.archived { opacity: 0.55; }
.add-card { display: flex; align-items: center; justify-content: center; min-height: 190px; border-style: dashed; color: var(--muted); font-weight: 600; cursor: pointer; }
.add-card:hover { color: var(--gold-text); border-color: var(--gold); }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge-draft { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.badge-finalized { background: transparent; color: var(--gold-text); border: 1px solid var(--gold); }
.badge-sent  { background: var(--gold-soft); color: var(--gold-text); }
.badge-paid  { background: var(--green-soft); color: var(--green); }

/* ── Colour-coded totals (owner's choice: purple, blue, green, red, orange; checked for
   contrast on both themes). Each also has its own icon + label, so colour is never the only clue.
   purple = reserve now · blue = reserve for the chosen period · green = money in · red = money out · orange = needs action */
:root {
  --c-purple: #B191C9; --c-blue: #7FA3C8; --c-green: #6FA97C; --c-red: #D2735C; --c-orange: #CC8A4A;
  --c-blue-soft: #A8C3DE;
}
:root[data-theme="light"] {
  --c-purple: #7A4BC4; --c-blue: #2069AD; --c-green: #1B7F47; --c-red: #C4382E; --c-orange: #A65A00;
  --c-blue-soft: #3F86C6;
}
.kpi { position: relative; overflow: hidden; --c: var(--gold); }
.kpi::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }
.kpi .stat-label { display: flex; align-items: center; gap: 8px; line-height: 1.4; min-height: calc(2 * 1.4em); }
/* Every heading takes two lines' room, so the big figures and the notes under them line up across a row */
.kpi .stat-sub { font-size: 0.85rem; line-height: 1.45; margin-top: 6px; }
.kpi-ico { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.kpi-ico svg { width: 13px; height: 13px; }
.kpi .stat-value { color: var(--c); }
.kpi-neutral .stat-value { color: var(--text); }
.kpi-purple { --c: var(--c-purple); } .kpi-blue { --c: var(--c-blue); } .kpi-green { --c: var(--c-green); }
.kpi-red { --c: var(--c-red); } .kpi-orange { --c: var(--c-orange); } .kpi-neutral { --c: var(--border-strong); }
.kpi-ok { --c: var(--c-green); }
/* Starting balance under a reserve total: its own label, a bigger figure in a lighter blue */
.kpi-start { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.kpi-start-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-start-value { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; color: var(--c-blue-soft); margin-top: 2px; }

/* ── Dashboard ── */
:root { --warn: #D9955E; --warn-soft: rgba(217,149,94,0.12); --chart-grid: #222222; }
:root[data-theme="light"] { --warn: #b4532a; --warn-soft: rgba(180,83,42,0.1); --chart-grid: #e8e1d3; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-title h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; }
.panel-title .muted { font-size: 0.8rem; }
.attn { display: grid; gap: 8px; }
.attn-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border); }
.attn-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; }
.attn-critical .attn-icon { background: var(--red-soft); color: var(--red); }
.attn-warning  .attn-icon { background: var(--warn-soft); color: var(--warn); }
.attn-info     .attn-icon { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.attn-body { flex: 1; min-width: 0; font-size: 0.86rem; }
.attn-body small { display: block; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.attn-critical .attn-body small { color: var(--red); }
.attn-warning .attn-body small { color: var(--warn); }
.all-clear { padding: 18px; text-align: center; color: var(--muted); }

.status-board td, .status-board th { padding: 8px 6px; text-align: center; }
.status-board td:first-child, .status-board th:first-child { text-align: left; padding-left: 12px; min-width: 170px; }
.sc { display: block; min-width: 44px; padding: 5px 2px; border-radius: 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
a.sc:hover { outline: 1px solid var(--gold); }
.sc-draft { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.sc-finalized { color: var(--gold-text); border: 1px solid var(--gold); }
.sc-sent { background: var(--gold-soft); color: var(--gold-text); border: 1px solid transparent; }
.sc-paid { background: var(--green-soft); color: var(--green); border: 1px solid transparent; }
.sc-missing { color: var(--warn); border: 1px dashed var(--warn); }
.sc-future { color: var(--border-strong); }
.sc-now { box-shadow: 0 0 0 2px var(--gold) inset; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); margin-top: 10px; align-items: center; }
.legend .sc { display: inline-block; min-width: 0; padding: 2px 7px; }

.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 0.78rem; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -100%); opacity: 0; transition: opacity 0.12s; z-index: 5; }
.chart-tip b { display: block; font-size: 0.9rem; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }

.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; align-items: center; font-size: 0.82rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { height: 14px; background: var(--choc); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.dep-list { display: grid; gap: 2px; font-size: 0.85rem; }
.dep-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.dep-row:last-child { border-bottom: none; }
.table-toggle { margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.table-toggle summary { cursor: pointer; }
.table-toggle table { margin-top: 8px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-wrap .hit.clickable { cursor: pointer; }
.panel-link { font-size: 0.8rem; color: var(--gold-text); white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }
.hbar.clickable { cursor: pointer; border-radius: 6px; margin: -3px -6px; padding: 3px 6px; }
.hbar.clickable:hover, .hbar.selected { background: var(--gold-soft); }

/* ── Reports ── */
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; padding: 3px; gap: 2px; background: var(--surface); }
.seg button { border: none; background: none; padding: 7px 14px; border-radius: 6px; font-weight: 600; font-size: 0.84rem; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--choc); color: var(--on-choc); }
.period-nav { display: inline-flex; align-items: center; gap: 4px; }
.period-nav .label { min-width: 150px; text-align: center; font-family: var(--font-display); font-size: 1.35rem; }
.delta { font-size: 0.75rem; margin-top: 4px; color: var(--muted); }
.delta .up { color: var(--warn); font-weight: 700; }
.delta .down { color: var(--green); font-weight: 700; }
.q-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.q-card { cursor: pointer; transition: border-color var(--tr); padding: 14px 16px; }
.q-card:hover { border-color: var(--gold); }
.q-card .stat-value { font-size: 1.2rem; }
.hbar-share { color: var(--muted); font-size: 0.72rem; margin-left: 4px; }
.heat td.num { position: relative; }
.heat td.cell-hot { background: rgba(189,128,44, var(--a)); }
.heat td:first-child, .heat th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.heat thead th:first-child, .heat tfoot td:first-child { background: var(--surface2); }
.heat tbody tr { cursor: pointer; }
.heat tbody tr:hover td:first-child, .heat tbody tr.selected td:first-child { color: var(--gold-text); }
.mini-list { display: grid; gap: 0; font-size: 0.84rem; margin-top: 12px; border-top: 1px solid var(--border); }
.mini-list .row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 700px) {
  .q-grid { grid-template-columns: 1fr 1fr; }
  .period-nav .label { min-width: 120px; font-size: 1.15rem; }
}

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab { padding: 10px 16px; border: none; background: none; color: var(--muted); font-weight: 600; font-size: 0.88rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-text); border-bottom-color: var(--gold); }

/* ── Tables ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { text-align: left; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface2); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--gold-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--surface2); border-top: 1px solid var(--border-strong); }
.muted { color: var(--muted); }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* Inline-editable cells */
.cell-input {
  width: 100%; min-width: 60px; background: transparent; border: 1px solid transparent; border-radius: 5px;
  padding: 6px 7px; transition: border-color var(--tr), background var(--tr);
}
.cell-input:hover { border-color: var(--border); }
.cell-input:focus { outline: none; border-color: var(--gold); background: var(--surface2); }
.cell-input.num { text-align: right; }
.cell-input:disabled { color: var(--text); cursor: default; border-color: transparent; }
select.cell-input { cursor: pointer; }
.w-qty { width: 80px; } .w-rate { width: 110px; } .w-amt { width: 120px; } .w-unit { width: 100px; }
.cell-input[data-f=service]  { min-width: 200px; }
.cell-input[data-f=provider] { min-width: 190px; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; cursor: pointer; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface2); transition: border-color var(--tr);
}
.form-input:focus { outline: none; border-color: var(--gold); }
textarea.form-input { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 0.75rem; color: var(--muted); margin-top: 5px; }
.error-box { background: var(--red-soft); color: var(--red); border-radius: 7px; padding: 10px 12px; font-size: 0.85rem; margin-bottom: 14px; }

/* ── Dropdowns (Hiive-styled; built by enhanceSelect in app.js) ── */
.dd { position: relative; display: inline-block; vertical-align: middle; }
.dd[hidden] { display: none; }
.form-group .dd, .dd[style*="width"] { display: block; }
.dd-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px; overflow: hidden; }
.dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 8px 10px 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface2); color: var(--text); font-weight: 600; font-size: 0.9rem; text-align: left;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-group .dd-btn { font-weight: 400; padding: 10px 10px 10px 12px; }
.dd-btn:hover, .dd.open .dd-btn { border-color: var(--gold); }
.dd-btn:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.dd-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chev { display: inline-flex; color: var(--gold-text); transition: transform var(--tr); }
.dd-chev svg { width: 16px; height: 16px; }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd-list {
  position: fixed; z-index: 400; max-height: 300px; overflow-y: auto; padding: 5px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow); animation: dd-in 0.12s ease-out;
}
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }
.dd-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; color: var(--muted); white-space: nowrap;
}
.dd-opt.act { background: var(--surface2); color: var(--text); }
.dd-opt.sel { background: var(--gold-soft); color: var(--gold-text); font-weight: 700; }
.dd-opt.sel.act { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.dd-tick { font-size: 0.8rem; }
/* Small in-table selects stay native; at least give their lists the app's colours */
select option { background: var(--surface); color: var(--text); }

/* ── Receipts & invoices ── */
dialog.docs-dlg { width: min(560px, calc(100vw - 24px)); }
dialog.docs-dlg.wide { width: min(820px, calc(100vw - 24px)); }
dialog.docs-dlg.view-dlg { width: min(1100px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 20px 14px; margin-bottom: 16px;
  border: 1.5px dashed var(--border-strong); border-radius: 10px; cursor: pointer; transition: border-color var(--tr), background var(--tr); font-size: 0.86rem; }
.drop:hover, .drop.over { border-color: var(--gold); background: var(--gold-soft); }
.drop.has { border-style: solid; border-color: var(--gold); }
.drop-icon svg { width: 26px; height: 26px; color: var(--gold-text); }
.drop-files { font-size: 0.78rem; word-break: break-word; }
.docs-table td { padding: 8px 10px; }
.doc-thumb-cell { width: 58px; }
.doc-thumb { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2) center / cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center; color: var(--gold-text); }
.doc-thumb svg { width: 22px; height: 22px; }
.doc-thumb:hover { border-color: var(--gold); }
.badge-doc-receipt { background: var(--gold-soft); color: var(--gold-text); }
.badge-doc-invoice { background: transparent; color: var(--gold-text); border: 1px solid var(--gold); }
.badge-doc-deposit { background: var(--green-soft); color: var(--green); }
.badge-doc-other { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.viewer { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); max-height: calc(100vh - 40px); }
.viewer-file { background: #000; display: flex; align-items: center; justify-content: center; min-height: 420px; overflow: auto; }
:root[data-theme="light"] .viewer-file { background: #e9e4da; }
.viewer-file img { max-width: 100%; max-height: calc(100vh - 40px); object-fit: contain; display: block; }
.viewer-file iframe { width: 100%; height: calc(100vh - 40px); border: 0; background: #fff; }
.viewer-file .all-clear svg { width: 40px; height: 40px; }
.viewer-side { padding: 22px; overflow-y: auto; max-height: calc(100vh - 40px); }
.clip { display: inline-flex; align-items: center; gap: 3px; padding: 4px 7px; border-radius: 6px; border: 1px solid transparent; background: none;
  color: var(--border-strong); font-size: 0.75rem; font-weight: 700; }
.clip svg { width: 15px; height: 15px; }
.clip:hover { color: var(--gold-text); border-color: var(--border); }
.clip.has { color: var(--gold-text); background: var(--gold-soft); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: none; color: var(--muted); border-radius: 20px; padding: 5px 12px; font-size: 0.8rem; font-weight: 600; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--choc); border-color: var(--choc); color: var(--on-choc); }
.eyebrow { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-text); margin-bottom: 4px; }
@media (max-width: 800px) {
  .viewer { grid-template-columns: 1fr; max-height: none; overflow-y: auto; }
  dialog.docs-dlg.view-dlg { overflow-y: auto; max-height: calc(100vh - 24px); }
  .viewer-file { min-height: 240px; }
  .viewer-file img, .viewer-file iframe { max-height: 60vh; height: 60vh; }
  .viewer-side { max-height: none; }
}

/* ── Dialogs ── */
dialog { margin: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 26px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }
dialog h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Statement editor ── */
.totals-card { display: grid; gap: 8px; font-size: 0.92rem; max-width: 380px; margin-left: auto; }
.totals-card .row { display: flex; justify-content: space-between; gap: 20px; }
.totals-card .grand { border-top: 1px solid var(--border-strong); padding-top: 10px; margin-top: 4px; font-size: 1.2rem; font-weight: 700; }
.totals-card .grand span:last-child { color: var(--gold-text); white-space: nowrap; }
.totals-card .grand { align-items: baseline; }
.fee-row td { color: var(--muted); }
.fee-input { width: 64px; display: inline-block; }
.notice { background: var(--gold-soft); border: 1px solid rgba(189,128,44,0.3); color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.add-line { margin-top: 10px; }

/* ── Auth ── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: min(400px, 100%); }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { width: 64px; height: 64px; object-fit: contain; }
.auth-logo .wordmark { font-family: var(--font-display); font-size: 2rem; display: block; margin-top: 6px; }
.auth-logo small { display: block; font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-text); margin-top: 2px; }
.auth-corner { position: fixed; top: 16px; right: 16px; }

/* ── Toast ── */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--surface); border: 1px solid var(--gold); color: var(--text); padding: 10px 18px; border-radius: 8px; font-size: 0.85rem; box-shadow: var(--shadow); transition: all 0.25s ease; z-index: 300; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--red); color: var(--red); }

/* ── Phones ── */
@media (max-width: 700px) {
  .nav-logo small, .nav-user, .nav-logo-text { display: none; }
  .nav-logo { margin-right: 2px; }
  .nav-inner { padding: 0 12px; gap: 4px; }
  .nav-link { padding: 6px 8px; font-size: 0.8rem; }
  .nav-right { gap: 5px; }
  .icon-btn { width: 32px; height: 32px; }
  .grid-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-stats .card { padding: 14px; }
  .grid-stats .card:first-child { grid-column: 1 / -1; }
  .stat-value { font-size: 1.25rem; }
  .page { padding: 80px 16px 56px; }
  .page-title { font-size: 1.8rem; }
  .form-row { grid-template-columns: 1fr; }
  .prop-grid { grid-template-columns: 1fr; }
  .totals-card { max-width: none; }
}
.dep-row.dep-total { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: none; }
/* Six totals in one row on wide screens, three on tablets, two on phones */
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-6 .card { padding: 18px 16px; }
.grid-6 .stat-value { font-size: 1.4rem; }
@media (max-width: 1150px) { .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-6 { grid-template-columns: 1fr 1fr; } }

/* ---- Garden additions ---- */
.badge-open      { background: var(--gold-soft); color: var(--gold-text); }
.badge-delivered { background: var(--green-soft); color: var(--green); }
.badge-cancelled { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); text-decoration: line-through; }
.badge-low  { background: var(--red-soft); color: var(--red); }
.badge-off  { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.neg  { color: var(--red); }
.pos  { color: var(--green); }
.owe  { color: var(--red); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .form-input { width: auto; }
.toolbar input.form-input[type=search] { min-width: 220px; flex: 1 1 220px; }
.lines-table td { vertical-align: middle; }
.lines-table .cell-input { width: 100%; }
.lines-table td.num { white-space: nowrap; }
.row-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 4px 8px; }
.row-del:hover { color: var(--red); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.info-grid .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.info-grid .v { margin-top: 2px; word-break: break-word; }
.harvest-grid { display: grid; grid-template-columns: 1fr 110px; gap: 6px 12px; align-items: center; max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.harvest-grid .cat { grid-column: 1 / -1; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }
.short-list { margin: 10px 0 0 18px; }
.short-list li { margin: 4px 0; }
.kind-in { color: var(--green); }
.kind-out { color: var(--red); }
@media print {
  .nav, .no-print, #toast { display: none !important; }
}
[hidden] { display: none !important; }
