/* Life & Business Growth — mobile-first styles.
 * Design: light = "Colourful & lively" (Plus Jakarta Sans), dark = "Dark & modern" (Manrope).
 * Theme tokens on :root; dark tokens under prefers-color-scheme (guarded) and [data-theme="dark"].
 * Each category element gets .cat + --c50…--c700 from palette.js; the .cat block maps them to roles. */

@font-face { font-family: "Plus Jakarta Sans"; src: url(../fonts/plus-jakarta-sans-latin.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(../fonts/manrope-latin.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }

/* ---------- light (Option 2: colourful & lively) ---------- */
:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f3f0ff;
  --page-bg: linear-gradient(165deg, #fdf2ff 0%, #eef0ff 45%, #e8fbff 100%);
  --surface: #ffffff;
  --surface-2: #f3f1fd;
  --glass: rgba(250, 248, 255, .86);
  --text: #1b1838;
  --muted: #5d5a78;
  --border: #e6e3fa;
  --track: #efeefb;
  --primary: #6d28d9;
  --primary-soft: #ede9fe;
  --btn-primary-bg: linear-gradient(135deg, #4f46e5, #7c3aed);
  --btn-primary-fg: #ffffff;
  --hero-bg: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
  --hero-fg: #ffffff;
  --hero-muted: rgba(255, 255, 255, .88);
  --hero-track: rgba(255, 255, 255, .25);
  --hero-ring: #ffffff;
  --hero-shadow: 0 16px 34px -14px rgba(124, 58, 237, .6);
  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --on-danger: #ffffff;
  --ok: #047857;
  --warn: #b45309;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 2px 4px rgba(76, 52, 170, .05), 0 14px 30px -14px rgba(76, 52, 170, .30);
  --card-border: 1px solid transparent;
  --chart-grid: #ece9fb;
  --chart-axis: #d9d5f3;
  --total-line: #7c3aed;
  --nav-h: 66px;
  --tap: 44px;
  color-scheme: light;
}

/* ---------- dark (Option 3: dark & modern) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bg: #0b1020;
    --page-bg: radial-gradient(120% 60% at 0% 0%, #1c2550 0%, rgba(11,16,32,0) 60%), radial-gradient(90% 50% at 100% 30%, #2a1747 0%, rgba(11,16,32,0) 55%), #0b1020;
    --surface: #131a2e; --surface-2: #1a2340; --glass: rgba(11, 16, 32, .84);
    --text: #e8ebf4; --muted: #a3abc2; --border: #252f4d; --track: rgba(255,255,255,.08);
    --primary: #5eead4; --primary-soft: rgba(94, 234, 212, .14);
    --btn-primary-bg: #5eead4; --btn-primary-fg: #062a26;
    --hero-bg: linear-gradient(140deg, #1d2a5c, #131a2e 70%); --hero-fg: #e8ebf4; --hero-muted: #a3abc2;
    --hero-track: rgba(255,255,255,.08); --hero-ring: #5eead4; --hero-shadow: 0 12px 30px -12px rgba(0,0,0,.6);
    --danger: #fb7185; --danger-soft: rgba(251, 113, 133, .14); --on-danger: #2a0a12; --ok: #34d399; --warn: #fbbf24;
    --shadow: 0 12px 30px -12px rgba(0, 0, 0, .6); --card-border: 1px solid rgba(255,255,255,.07);
    --chart-grid: rgba(255,255,255,.07); --chart-axis: rgba(255,255,255,.14); --total-line: #5eead4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #0b1020;
  --page-bg: radial-gradient(120% 60% at 0% 0%, #1c2550 0%, rgba(11,16,32,0) 60%), radial-gradient(90% 50% at 100% 30%, #2a1747 0%, rgba(11,16,32,0) 55%), #0b1020;
  --surface: #131a2e; --surface-2: #1a2340; --glass: rgba(11, 16, 32, .84);
  --text: #e8ebf4; --muted: #a3abc2; --border: #252f4d; --track: rgba(255,255,255,.08);
  --primary: #5eead4; --primary-soft: rgba(94, 234, 212, .14);
  --btn-primary-bg: #5eead4; --btn-primary-fg: #062a26;
  --hero-bg: linear-gradient(140deg, #1d2a5c, #131a2e 70%); --hero-fg: #e8ebf4; --hero-muted: #a3abc2;
  --hero-track: rgba(255,255,255,.08); --hero-ring: #5eead4; --hero-shadow: 0 12px 30px -12px rgba(0,0,0,.6);
  --danger: #fb7185; --danger-soft: rgba(251, 113, 133, .14); --on-danger: #2a0a12; --ok: #34d399; --warn: #fbbf24;
  --shadow: 0 12px 30px -12px rgba(0, 0, 0, .6); --card-border: 1px solid rgba(255,255,255,.07);
  --chart-grid: rgba(255,255,255,.07); --chart-axis: rgba(255,255,255,.14); --total-line: #5eead4;
  color-scheme: dark;
}

/* ---------- category roles (light) ---------- */
.cat {
  --cat-ink: var(--c700);
  --cat-icon-bg: linear-gradient(135deg, var(--c600), var(--c700));
  --cat-icon-fg: #ffffff;
  --cat-btn-bg: linear-gradient(135deg, var(--c700), var(--c700d));
  --cat-btn-fg: #ffffff;
  --cat-fill: linear-gradient(90deg, var(--c400), var(--c600));
  --cat-glow: none;
  --cat-ring: var(--c600);
  --cat-chip-bg: var(--c50);
}
/* ---------- category roles (dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat {
    --cat-ink: var(--c300); --cat-icon-bg: var(--c-soft); --cat-icon-fg: var(--c300);
    --cat-btn-bg: var(--c-soft); --cat-btn-fg: var(--c300); --cat-fill: var(--c400);
    --cat-glow: 0 0 12px var(--c-glow); --cat-ring: var(--c400); --cat-chip-bg: var(--c-soft2);
  }
}
:root[data-theme="dark"] .cat {
  --cat-ink: var(--c300); --cat-icon-bg: var(--c-soft); --cat-icon-fg: var(--c300);
  --cat-btn-bg: var(--c-soft); --cat-btn-fg: var(--c300); --cat-fill: var(--c400);
  --cat-glow: 0 0 12px var(--c-glow); --cat-ring: var(--c400); --cat-chip-bg: var(--c-soft2);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--page-bg); background-attachment: fixed; color: var(--text);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.08rem; font-weight: 700; }
h3 { font-size: .95rem; margin-top: 1.25rem; color: var(--muted); }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }
small, .hint { color: var(--muted); font-size: .85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
svg { display: block; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; }
.main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.main:focus { outline: none; }
.loading { color: var(--muted); }

.sidebar {
  position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.brand { display: none; }
.nav { display: flex; height: var(--nav-h); padding: 0 4px; }
.nav-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; min-width: 0;
}
.nav-icon { width: 36px; height: 26px; border-radius: 99px; display: grid; place-items: center; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-link.active { color: var(--primary); }
.nav-link.active .nav-icon { background: var(--primary-soft); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .sidebar {
    position: sticky; inset: 0 auto auto auto; height: 100vh; padding: 22px 14px;
    border-top: 0; border-right: 1px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; line-height: 1.2; padding: 0 8px 24px; letter-spacing: -.01em; }
  .brand-mark { width: 36px; height: 36px; border-radius: 12px; background: var(--hero-bg); flex: none; box-shadow: var(--hero-shadow); display: grid; place-items: center; color: #fff; }
  .brand-mark svg { width: 20px; height: 20px; }
  .nav { flex-direction: column; height: auto; gap: 4px; padding: 0; }
  .nav-link { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 10px; border-radius: 14px; font-size: .95rem; }
  .nav-link:hover { background: var(--surface-2); }
  .nav-link.active { background: var(--primary-soft); }
  .nav-link.active .nav-icon { background: transparent; }
  .nav-icon { width: 24px; height: 24px; }
  .main { padding: 30px 34px 48px; width: 100%; }
}

/* ---------- components ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.card {
  background: var(--surface); border: var(--card-border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: .5rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.empty { text-align: center; padding: 36px 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--btn-primary-bg); border-color: transparent; color: var(--btn-primary-fg); }
.btn-primary:hover { background: var(--btn-primary-bg); filter: brightness(1.07); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 12px; }
.btn-block { width: 100%; flex-direction: column; align-items: flex-start; padding: 12px 16px; text-align: left; }
.btn-block small { font-weight: 400; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link-btn { background: none; border: 0; padding: 0 0 0 8px; color: var(--primary); font: inherit; font-size: .85rem; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .88rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  min-height: var(--tap); padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.row2 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .row2 { grid-template-columns: 1fr 1fr; } }

.badge { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.badge-current { background: var(--primary-soft); color: var(--primary); }
.badge-scheduled { color: var(--warn); }

/* category pieces */
.cat-icon { width: 40px; height: 40px; border-radius: 13px; display: inline-grid; place-items: center; flex: none; background: var(--cat-icon-bg); color: var(--cat-icon-fg); }
.cat-icon svg { width: 21px; height: 21px; }
.cat-icon-sm { width: 22px; height: 22px; border-radius: 8px; }
.cat-icon-sm svg { width: 13px; height: 13px; }
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--track); }
.ring .ring-fill { stroke: var(--cat-ring, var(--primary)); transition: stroke-dasharray .25s; }
.ring b { position: relative; font-size: .64rem; font-weight: 800; }
.ring-lg b { font-size: 1.3rem; }
@media (prefers-reduced-motion: reduce) { .ring .ring-fill, .bar-fill { transition: none !important; } }

/* ---------- dialog ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0;
  border: var(--card-border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(15, 12, 40, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.choice { display: grid; gap: 8px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: 8px; width: min(480px, calc(100vw - 32px)); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: opacity .3s; font-weight: 500; }
.toast-error { background: var(--danger); color: var(--on-danger); }
.toast.out { opacity: 0; }

/* ---------- settings ---------- */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.cat-row:first-child { border-top: 0; }
.cat-row.archived .cat-name { color: var(--muted); }
.cat-main { min-width: 0; flex: 1 1 220px; display: flex; gap: 12px; align-items: center; }
.cat-name { font-weight: 700; }
.cat-meta { font-size: .86rem; }
.cat-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.targets { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 4px 0 0; }
.targets legend { font-weight: 700; padding: 0 4px; }
.target-list { list-style: none; margin: 0 0 12px; padding: 0; }
.target-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.target-list li > span:first-child { flex: 1; }
.target-add { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
.target-add .btn { grid-column: 1 / -1; margin-bottom: 12px; }
@media (min-width: 520px) { .target-add { grid-template-columns: 1fr 1fr auto; } .target-add .btn { grid-column: auto; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.swatches, .icon-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.swatch {
  width: 38px; height: 38px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; padding: 0;
  background: var(--cat-icon-bg); box-shadow: 0 0 0 1px var(--border);
}
.swatch[aria-checked="true"] { border-color: var(--surface); box-shadow: 0 0 0 3px var(--primary); }
.icon-choice {
  width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.icon-choice svg { width: 20px; height: 20px; }
.icon-choice[aria-checked="true"] { background: var(--cat-icon-bg); color: var(--cat-icon-fg); border-color: transparent; }

/* ---------- tests page ---------- */
.tests { padding-bottom: 32px; }
.test-list { padding-left: 1.25rem; }
.test-list li { padding: 3px 0; }
.pass { color: var(--ok); }
.fail { color: var(--danger); }
.card.pass, .card.fail { font-weight: 700; }

/* ---------- daily log ---------- */
.log-view { max-width: 640px; margin: 0 auto; }
.log-head {
  position: sticky; top: 0; z-index: 10; margin: -16px -16px 12px; padding: 12px 16px 10px;
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) { .log-head { margin: -30px 0 16px; padding-top: 18px; border-radius: 0 0 var(--radius) var(--radius); } }
.date-nav { display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; gap: 8px; }
.nav-btn {
  height: 50px; border-radius: 16px; border: var(--card-border); background: var(--surface); box-shadow: var(--shadow);
  color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer; font-family: inherit;
}
.nav-btn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.date-btn { position: relative; min-height: 50px; border-radius: 16px; border: var(--card-border); background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; text-align: center; }
.date-btn:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.date-label { display: flex; flex-direction: column; align-items: center; line-height: 1.2; pointer-events: none; }
.date-text { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.date-sub { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.date-sub .link-btn { pointer-events: auto; position: relative; z-index: 2; }
.date-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; min-height: 0; }
.date-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.day-sum { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: .9rem; flex-wrap: wrap; }
.day-total { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: .84rem; color: var(--muted); min-height: 1.2em; display: flex; align-items: center; font-weight: 600; }
.save-saved { color: var(--ok); }
.save-error { color: var(--danger); }
.day-warn { margin: 6px 0 0; color: var(--danger); font-size: .88rem; font-weight: 600; }
.log-hint { margin: 0 2px 10px; }

.entries { list-style: none; margin: 0; padding: 0; }
.entry { padding: 14px; margin-bottom: 12px; }
.entry-top { display: flex; align-items: center; gap: 12px; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 6px; line-height: 1.25; }
.entry-val { font-size: .84rem; color: var(--muted); }
.entry-val b { color: var(--cat-ink); font-weight: 700; }
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin: 12px 0; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--cat-fill, var(--primary)); box-shadow: var(--cat-glow, none); border-radius: 99px; transition: width .25s; }
.entry-ctrl { display: grid; grid-template-columns: minmax(64px, 1fr) repeat(4, 48px); gap: 6px; }
.min-input { min-height: 48px; font-size: 1.25rem; font-weight: 800; text-align: center; padding: 4px; font-variant-numeric: tabular-nums; }
.min-input::placeholder { color: var(--muted); font-weight: 500; }
.min-input[aria-invalid="true"], .entry-note [aria-invalid="true"] { border-color: var(--danger); outline-color: var(--danger); }
.q-btn {
  min-height: 48px; border-radius: var(--radius-sm); border: 0; background: var(--cat-btn-bg, var(--surface-2));
  color: var(--cat-btn-fg, var(--text)); font: inherit; font-weight: 700; cursor: pointer; padding: 0; touch-action: manipulation;
}
.q-btn:active { transform: scale(.95); }
.q-clear { background: transparent; color: var(--muted); font-weight: 500; border: 1.5px solid var(--border); }
.field-err { color: var(--danger); font-size: .85rem; margin: 6px 0 0; }
.entry-note { margin-top: 10px; }
.entry-note summary {
  cursor: pointer; font-size: .86rem; color: var(--muted); display: flex; gap: 8px; align-items: center;
  min-height: 36px; list-style: none; font-weight: 600;
}
.entry-note summary::-webkit-details-marker { display: none; }
.entry-note summary::before { content: '▸'; transition: transform .15s; color: var(--cat-ink); }
.entry-note[open] summary::before { transform: rotate(90deg); }
.note-label { flex: none; }
.note-preview { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-weight: 500; }
.entry-note[open] .note-preview { display: none; }
.entry-note textarea, .entry-note input { margin-top: 4px; }
.entry-note textarea { min-height: 64px; }

.cal .card-head { margin-bottom: 8px; }
.cal-nav { display: flex; gap: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: .74rem; color: var(--muted); padding-bottom: 2px; font-weight: 700; }
.cal-day {
  aspect-ratio: 1 / 1; min-height: 40px; border-radius: 12px; border: 1.5px solid transparent; background: var(--surface-2);
  color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 0;
}
.cal-day i { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.cal-day:disabled { opacity: .35; cursor: default; background: transparent; }
.cal-day.lv-empty i { background: var(--muted); }
.cal-day.lv-active i { background: var(--warn); }
.cal-day.lv-complete { background: var(--primary-soft); }
.cal-day.lv-complete i { background: var(--ok); }
.cal-day.is-today .cal-num { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.cal-day.is-selected { border-color: var(--primary); }
@media (min-width: 520px) { .cal-grid { gap: 6px; } .cal-day { aspect-ratio: auto; height: 48px; } }
.cal-foot { margin: 10px 0 6px; font-size: .88rem; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; border: 1px solid var(--border); }
.cal-legend .lv-empty { background: var(--muted); border-color: var(--muted); }
.cal-legend .lv-active { background: var(--warn); border-color: var(--warn); }
.cal-legend .lv-complete { background: var(--ok); border-color: var(--ok); }
.log-foot { justify-content: center; margin-top: 8px; }

/* ---------- dashboards ---------- */
.dash-head { margin-bottom: 14px; }
.dash-head .page-head { margin-bottom: 12px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 2px; }
.tab { padding: 8px 16px; border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 600; min-height: 38px; display: inline-flex; align-items: center; }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 700; }
.period { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; max-width: 520px; }
.period .nav-btn { height: 46px; font-size: 1.5rem; }
.period-selects { display: flex; gap: 8px; }
.period-selects select { font-weight: 700; min-width: 0; }
.period-selects select:first-child { flex: 3 1 0; }
.period-selects select:last-child { flex: 2 1 0; }
.period-reset { margin: 6px 0 0; font-size: .88rem; }
.period.year-only { max-width: 300px; }

.tiles { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--surface); border: var(--card-border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 1.65rem; font-weight: 800; line-height: 1.15; margin-top: 2px; letter-spacing: -.02em; }
.tile-sub { font-size: .78rem; color: var(--muted); }
.tile-hero { background: var(--hero-bg); color: var(--hero-fg); box-shadow: var(--hero-shadow); grid-row: span 2; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.tile-hero .tile-label, .tile-hero .tile-sub { color: var(--hero-muted); }
.tile-hero .ring .ring-track { stroke: var(--hero-track); }
.tile-hero .ring .ring-fill { stroke: var(--hero-ring); }
@media (min-width: 640px) { .tile-hero { grid-row: auto; flex-direction: row; text-align: left; justify-content: flex-start; } }

.chart-box { position: relative; width: 100%; margin-top: 4px; }
.chart-box.h-line { height: 240px; }
.chart-box.h-tall { height: 380px; }
@media (min-width: 900px) { .chart-box.h-line { height: 300px; } .chart-box.h-tall { height: 420px; } }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.legend-actions { display: flex; gap: 4px; }
.legend-actions .link-btn { min-height: 32px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 6px; border-radius: 99px;
  border: 0; background: var(--cat-chip-bg, var(--surface-2)); color: var(--cat-ink, var(--text)); font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer;
}
.legend-item[aria-pressed="false"] { opacity: .45; }
.legend-item[aria-pressed="false"] span:last-child { text-decoration: line-through; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; flex: none; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .86rem; font-weight: 600; padding: 0 12px; min-height: 34px; cursor: pointer; border-radius: 9px; }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px -16px 0; padding: 0 16px; }
.table-wrap:focus-visible { outline-offset: -3px; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { vertical-align: middle; padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data thead th { color: var(--muted); font-weight: 700; font-size: .78rem; vertical-align: bottom; white-space: normal; min-width: 64px; }
table.data .num { text-align: right; }
table.data tbody th, table.data tfoot th { font-weight: 600; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.data thead th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; }
table.data tfoot th, table.data tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--border); }
table.data tr.future td, table.data tr.future th { color: var(--muted); }
table.data .badge { margin-left: 6px; }
.area-cell { display: inline-flex; align-items: center; gap: 8px; }
.cell-sub { display: block; color: var(--muted); font-size: .76rem; font-weight: 500; }
.pct { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.pct-bar { width: 56px; height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; display: inline-block; }
.pct-bar span { display: block; height: 100%; background: var(--cat-fill, var(--primary)); border-radius: 99px; }
.empty-icon { font-size: 2.5rem; color: var(--muted); line-height: 1; margin-bottom: 8px; }
.scroll-hint { font-size: .8rem; color: var(--muted); margin: 10px 0 -6px; text-align: right; }
.notice { background: var(--primary-soft); color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; font-size: .92rem; font-weight: 500; }

/* ---------- trackers (shared) ---------- */
.pill { display: inline-flex; align-items: center; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--cat-chip-bg); color: var(--cat-ink); white-space: nowrap; flex: none; }
.due { font-size: .8rem; color: var(--muted); font-weight: 600; }
.due-over { color: var(--danger); font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters select { flex: 1 1 150px; width: auto; }
.filters input[type="search"] { flex: 2 1 220px; width: auto; }
.filters-in { margin: 4px 0 12px; }
.chip-toggle { min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.chip-toggle[aria-pressed="true"] { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.tile-alert .tile-value { color: var(--danger); }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 519px) { .tiles-3 .tile { padding: 10px; } .tiles-3 .tile-value { font-size: 1.35rem; } }
.actions-split { align-items: center; }
.actions-split .grow { flex: 1; }
.grow { flex: 1; }

/* ---------- project tracker ---------- */
.project-card { padding: 16px 14px 12px; }
.project-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.project-main { flex: 1; min-width: 0; }
.project-main h2 { margin: 0; font-size: 1.12rem; }
.project-sub { font-size: .82rem; color: var(--muted); font-weight: 500; }
.ring-md b { font-size: .78rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.task {
  width: 100%; text-align: left; display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.task:hover { border-color: var(--cat-ring); }
.task.is-overdue { border-color: var(--danger); background: var(--danger-soft); }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-title { font-weight: 700; line-height: 1.3; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; color: var(--muted); }
.task-bar { display: flex; align-items: center; gap: 8px; }
.task-bar .bar { flex: 1; margin: 0; height: 7px; }
.task-bar b { font-size: .78rem; min-width: 3ch; text-align: right; }
.task-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-next { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.add-in { margin-top: 10px; }
.quick-sub { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot-sm { width: 10px; height: 10px; border-radius: 4px; background: var(--cat-ring); flex: none; }
.quick-due { margin: 0 0 12px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-btn { min-height: 46px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.status-btn[aria-checked="true"] { background: var(--cat-btn-bg); color: var(--cat-btn-fg); border-color: transparent; }
.progress-edit { display: flex; align-items: center; gap: 12px; }
.range { flex: 1; min-height: 44px; padding: 0; border: 0; background: transparent; accent-color: var(--cat-ring); }
.pct-wrap { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.pct-input { width: 64px; text-align: center; font-weight: 800; }
.quick-pcts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick-pcts .btn { flex: 1; padding: 0 6px; }

/* ---------- agri BD ---------- */
.fu-card { border: 1.5px solid var(--primary-soft); }
.fu-group + .fu-group { margin-top: 12px; }
.fu-group h3 { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: .9rem; color: var(--text); }
.fu-over h3 { color: var(--danger); }
.count { font-size: .72rem; font-weight: 800; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.fu-over .count { background: var(--danger-soft); color: var(--danger); }
.fu-list, .deal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fu-none { margin: 0; font-size: .86rem; }
.fu-item, .deal {
  width: 100%; text-align: left; display: grid; gap: 4px; padding: 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.fu-item.is-overdue { border-color: var(--danger); background: var(--danger-soft); }
.fu-top, .deal-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fu-client, .deal-client { font-weight: 700; }
.fu-meta { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.fu-act { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.deal { border-left: 4px solid var(--cat-ring); }
.deal-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; color: var(--muted); }
.deal-date { white-space: nowrap; }
.deal-money { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; font-variant-numeric: tabular-nums; }
.deal-money small { color: var(--muted); font-size: .76rem; }
.deal-fu { font-size: .82rem; color: var(--muted); }
.deal-note { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-none { padding: 12px; }
.money-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 520px) { .money-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- sign-in ---------- */
body.signed-out .sidebar { display: none; }
body.signed-out .main { padding-bottom: 32px; }
@media (min-width: 900px) { body.signed-out .shell { display: block; } }
.login-view { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 24px 20px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand h1 { font-size: 1.25rem; margin: 0; }
.login-brand p { margin: 0; }
.login-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--hero-bg); box-shadow: var(--hero-shadow); display: grid; place-items: center; color: #fff; flex: none; }
.login-mark svg { width: 22px; height: 22px; }
.btn-wide { width: 100%; margin-top: 6px; }
.login-foot { margin: 14px 0 0; text-align: center; }
.move-note { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
