/* ============================================================
   Abdullah Dairy Farm — Management System
   Branded to match abdullahdairyfarm.com: warm cream / brown / gold
   palette + Outfit (Google Fonts) + the real cow-badge logo.
   ============================================================ */
:root {
  /* Brand palette — from abdullahdairyfarm.com (warm cream / brown / gold).
     NB: the --green-* names are kept so existing rules pick up the new hues;
     they now hold the brand's browns, and primary/nav/focus all read brown. */
  --green-900: #1a0e08; /* sidebar darkest  */
  --green-800: #2a1810; /* deep brown ink   */
  --green-700: #4a2c1f; /* button hover     */
  --green-600: #5c3829; /* primary / active */
  --green-500: #7a5040; /* focus ring base  */
  --green-100: #f5ebd9; /* cream pill / icon tile */
  --cream: #fbf6ec;
  --cream-2: #ecdcc2;
  --sand: #d9c29d;
  --gold: #c8a876;
  --gold-deep: #a8864d;
  --copper: #b87c4c;
  --ink: #2a1810;
  --ink-soft: #5c4438;
  --line: #ecdcc2;
  --bg: #fbf6ec;
  --surface: #ffffff;
  --input-bg: #ffffff;
  --th-bg: #faf8f2;
  --row-hover: #faf9f4;
  --topbar-bg: rgba(247,243,234,.85);
  --logo-tile: #f5ebd9;      /* stays light in both themes so the dark logo reads */
  --danger: #c0392b;
  --danger-bg: #fbe9e6;
  --warn: #a8864d;
  --warn-bg: #f7ecd6;
  --ok: #2f7d4f;
  --ok-bg: #e6f0e7;
  --info: #8a6a3a;
  --info-bg: #f1e6d3;
  --shadow: 0 2px 10px rgba(42, 24, 16, .06), 0 18px 40px -18px rgba(42, 24, 16, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 244px;
  font-family: 'Outfit', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--green-700); }
code { background: rgba(20,40,25,.07); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--ink-soft); }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(200,168,118,.28), transparent 60%),
    linear-gradient(160deg, #fbf6ec, #f5ebd9 55%, #ecdcc2);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow); padding: 34px 30px;
  border: 1px solid var(--line);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo { width: 66px; height: 66px; }
.login-brand h1 { font-size: 22px; margin-top: 10px; color: var(--green-800); }
.login-form { display: grid; gap: 14px; }
.login-form label, .field label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.login-form input {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: var(--input-bg); color: var(--ink);
}
.login-form input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(200,168,118,.30);
}
.login-hint {
  margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line);
  display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-soft);
}
.login-hint strong { color: var(--ink); }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: 9px; font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--green-900);
  color: #e8dcc8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 18px 18px 14px; }
.sidebar-logo { width: 42px; height: 42px; background: var(--logo-tile); border-radius: 50%; padding: 3px; object-fit: contain; }
.sidebar-brand strong { display: block; color: #fff; font-size: 15px; }
.sidebar-brand .muted { color: #b8a48c; font-size: 11.5px; }
.nav { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: #d8c7ac; text-decoration: none; font-size: 14px; font-weight: 550; cursor: pointer;
}
.nav a .ico { width: 20px; text-align: center; font-size: 16px; opacity: .95; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--green-600); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .nav-sep { margin: 8px 12px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #a08862; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #3a2a06;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.user-meta strong { color: #fff; font-size: 13.5px; display: block; }
.user-meta .muted { color: #b8a48c; font-size: 11.5px; text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--topbar-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
}
.topbar h1 { font-size: 19px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill { background: var(--green-100); color: var(--green-800); border-radius: 999px; padding: 5px 13px; font-size: 12.5px; font-weight: 600; }
.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); padding: 4px 8px; border-radius: 8px; }
.menu-toggle { display: none; }
.content { padding: 22px 24px 60px; max-width: 1200px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font-size: 14px;
  font-weight: 600; cursor: pointer; background: var(--surface); color: var(--ink); transition: .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost.on-dark { border-color: rgba(255,255,255,.18); color: #e8dcc8; }
.btn-ghost.on-dark:hover { background: rgba(255,255,255,.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-outline { background: var(--surface); border-color: var(--line); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15.5px; }
.card-head .sub { font-size: 12.5px; color: var(--ink-soft); }

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.kpi .kpi-value { font-size: 27px; font-weight: 720; margin-top: 4px; letter-spacing: -.02em; }
.kpi .kpi-value small { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.kpi .kpi-foot { font-size: 12px; margin-top: 6px; color: var(--ink-soft); }
.kpi .kpi-ico {
  position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; font-size: 20px; background: var(--green-100);
}
.kpi.k-green .kpi-ico { background: var(--ok-bg); }
.kpi.k-gold .kpi-ico { background: #fbf1da; }
.kpi.k-blue .kpi-ico { background: var(--info-bg); }
.kpi.k-red .kpi-ico { background: var(--danger-bg); }
.pos { color: var(--ok); } .neg { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); background: var(--th-bg); position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--row-hover); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { text-align: center; padding: 30px; color: var(--ink-soft); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.badge.milking { background: var(--ok-bg); color: var(--ok); }
.badge.dry { background: #eee; color: #555; }
.badge.pregnant { background: #e3f2e6; color: #2f7d4f; }
.badge.heifer { background: var(--info-bg); color: var(--info); }
.badge.sold, .badge.dead { background: var(--danger-bg); color: var(--danger); }
.badge.income, .badge.in { background: var(--ok-bg); color: var(--ok); }
.badge.expense, .badge.out { background: var(--danger-bg); color: var(--danger); }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.unpaid { background: var(--warn-bg); color: var(--warn); }
.badge.admin { background: #fbf1da; color: var(--gold); }
.badge.staff { background: var(--info-bg); color: var(--info); }
.badge.cow { background: var(--green-100); color: var(--green-700); }
.badge.buffalo { background: #e9e4f5; color: #5a4b8a; }
.badge.neutral { background: #eee; color: #555; }

/* ---------- Alerts / lists ---------- */
.alert { display: flex; gap: 10px; padding: 11px 13px; border-radius: 10px; font-size: 13.5px; align-items: flex-start; }
.alert.warn { background: var(--warn-bg); color: #7a5207; }
.alert.danger { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--green-800); }
.list { display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow .t { font-weight: 600; font-size: 13.5px; }
.list-row .grow .s { font-size: 12px; color: var(--ink-soft); }
.list-row .when { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.input, select.input, textarea.input {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: var(--input-bg); color: var(--ink);
}
.search { min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--input-bg); }
.seg button { border: none; background: none; padding: 8px 13px; font-size: 13px; cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.seg button.active { background: var(--green-600); color: #fff; }

/* ---------- Forms / modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20,35,25,.42); z-index: 40; opacity: 0; pointer-events: none; transition: .16s; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -48%) scale(.98);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.28); opacity: 0;
  pointer-events: none; transition: .16s;
}
.modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: var(--input-bg); color: var(--ink); width: 100%;
}
.field textarea { resize: vertical; min-height: 62px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); animation: toastin .2s ease; }
.toast.ok { background: var(--green-700); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Chart ---------- */
.chart-wrap { width: 100%; }
canvas { display: block; width: 100%; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 4px 0 10px; font-weight: 700; }
.spacer { height: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mini { font-size: 12px; color: var(--ink-soft); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}

/* ============================================================
   DARK MODE  — activated by data-theme="dark" on <html>
   Warm charcoal to match the brand (not pure black).
   ============================================================ */
:root[data-theme="dark"] {
  --bg: #0f0c09;                    /* deep warm charcoal (darker → cards pop) */
  --surface: #262019;              /* cards clearly lighter than bg */
  --input-bg: #1a1511;            /* distinct from card */
  --th-bg: #2f271e;               /* table header a touch lighter than card */
  --row-hover: #322a20;
  --topbar-bg: rgba(15,12,9,.88);
  --logo-tile: #f5ebd9;            /* keep light so the dark logo stays visible */
  --ink: #f7f1e7;                 /* brighter warm off-white text */
  --ink-soft: #c6b8a3;            /* readable secondary text */
  --line: #473b2d;                /* clearer borders/separators */
  --cream: #262019;
  --cream-2: #322a20;
  --green-100: #2f2419;            /* pill / default KPI icon tint */
  --ok:  #6ad493;  --ok-bg:  #16301f;
  --danger: #f08376; --danger-bg: #341c18;
  --warn: #e6be6c; --warn-bg: #2f2814;
  --info: #d9bd84; --info-bg: #2a2114;
  --shadow: 0 2px 10px rgba(0,0,0,.45), 0 18px 40px -18px rgba(0,0,0,.7);
}

/* component fixes for dark (rules that used dark-on-light literals) */
:root[data-theme="dark"] a { color: #e6c489; }
:root[data-theme="dark"] code { background: rgba(255,255,255,.09); }
:root[data-theme="dark"] .pill { background: rgba(200,168,118,.16); color: #e6c489; }
:root[data-theme="dark"] .login-brand h1 { color: var(--ink); }
:root[data-theme="dark"] .kpi.k-gold .kpi-ico { background: #2a2415; }
:root[data-theme="dark"] .badge.cow { background: rgba(200,168,118,.16); color: #e6c489; }
:root[data-theme="dark"] .badge.dry, :root[data-theme="dark"] .badge.neutral { background: #33291f; color: #cdbfaa; }
:root[data-theme="dark"] .alert.ok { color: #8fd8a8; }
:root[data-theme="dark"] .alert.warn { color: #e6c98a; }
:root[data-theme="dark"] .alert.danger { color: #eda99f; }
:root[data-theme="dark"] .login-body {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(200,168,118,.14), transparent 60%),
    linear-gradient(160deg, #1a140f, #16110d 55%, #120d09);
}
/* theme toggle button */
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 7px 10px; color: var(--ink); }
.theme-toggle:hover { background: var(--row-hover); }


/* ---------- Icon system ---------- */
.ico-svg { display: block; flex: 0 0 auto; }
.ico-svg .ico-accent { stroke: var(--gold-deep); }
[data-theme="dark"] .ico-svg .ico-accent { stroke: var(--gold); }
.ico-tile {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--green-100); color: var(--green-600);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.ico-tile.tone-gold  { background: #fbf1da; color: var(--gold-deep); }
.ico-tile.tone-green { background: var(--ok-bg);     color: var(--ok); }
.ico-tile.tone-blue  { background: var(--info-bg);   color: var(--info); }
.ico-tile.tone-red   { background: var(--danger-bg); color: var(--danger); }
[data-theme="dark"] .ico-tile { border-color: color-mix(in srgb, #fff 10%, transparent); }
#mainNav .ico { display: inline-grid; place-items: center; width: 20px; height: 20px; }
#mainNav .ico .ico-svg .ico-accent { stroke: currentColor; opacity: .7; }

/* ============================================================
   Dashboard v2 — hero band, glass surfaces, weather + promo
   ============================================================ */

/* ---------- Hero band (photo across the top) ---------- */
.dash-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--line);
  padding: 20px 22px 16px;
  display: grid; gap: 14px;
  color: #f7eedf;
  background-image: url('/assets/farm-hero.jpg');
  background-size: cover;
  background-position: center 58%;
  min-height: 132px;
}
/* Left-weighted scrim: the sunrise blows out the right side of the photo, so
   the text needs cover on the left while the herd stays visible. */
.dash-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(20,11,6,.94) 0%, rgba(20,11,6,.80) 30%, rgba(20,11,6,.30) 58%, rgba(20,11,6,.20) 100%),
    linear-gradient(180deg, rgba(20,11,6,.18), rgba(20,11,6,.42));
}
.dash-hero > * { position: relative; z-index: 1; }
.dash-hero-row { display: flex; align-items: flex-start; gap: 16px; }
.dash-hero-text { min-width: 0; }
.dash-hero h2 { font-size: 26px; letter-spacing: -.025em; color: #fff; text-shadow: 0 2px 16px rgba(0,0,0,.5); }
.dash-hero p { margin: 4px 0 0; font-size: 13.5px; opacity: .86; text-shadow: 0 1px 10px rgba(0,0,0,.5); }
.dash-hero-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.hero-search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; min-width: 210px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.20);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: #f7eedf;
}
.hero-search input {
  border: none; background: none; outline: none; color: inherit; font: inherit; font-size: 13px; width: 100%;
}
.hero-search input::placeholder { color: rgba(247,238,223,.65); }

.hero-bell {
  position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.20); color: #f7eedf; text-decoration: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.hero-bell .ico-svg .ico-accent { stroke: currentColor; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; min-width: 17px; padding: 0 4px;
  border-radius: 999px; text-align: center; border: 2px solid rgba(20,11,6,.6);
}

.dash-farm {
  display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 13.5px; color: #f7eedf;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.20);
  padding: 5px 14px 5px 5px; border-radius: 999px;
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.dash-farm .ico-tile { width: 26px; height: 26px; border-radius: 999px; border: none; background: #f7d9a0; }

.dash-hero-foot { display: flex; align-items: flex-end; gap: 12px; }
.hero-tag {
  font-family: 'Outfit', cursive; font-style: italic; font-size: 14px; opacity: .92;
  text-shadow: 0 1px 10px rgba(0,0,0,.5); max-width: 260px; line-height: 1.25;
}
.dash-date { font-size: 12px; opacity: .85; text-align: right; text-shadow: 0 1px 8px rgba(0,0,0,.5); }

/* ---------- Glass surfaces ----------
   The reference is a dark, glassy UI: translucent panels with a blurred
   backdrop, a hairline top highlight and a soft drop shadow. Applied in dark
   theme only — in light theme flat white cards read better and blur just
   muddies them. */
[data-theme="dark"] .card {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid color-mix(in srgb, #fff 9%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 7%, transparent) inset, 0 18px 40px -22px rgba(0,0,0,.8);
}
[data-theme="dark"] .kpi2,
[data-theme="dark"] .stat-card { background: color-mix(in srgb, var(--surface) 66%, transparent); }
[data-theme="dark"] .qa-row {
  background: color-mix(in srgb, #fff 4%, transparent);
  border-color: color-mix(in srgb, #fff 8%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .qa-row:hover { background: color-mix(in srgb, #fff 8%, transparent); }

/* ---------- KPI cards ---------- */
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpi2 { display: grid; gap: 9px; align-content: start; text-decoration: none; color: inherit; transition: .16s; }
.kpi2:hover { transform: translateY(-2px); border-color: var(--sand); }
.kpi2-top { display: flex; align-items: center; gap: 10px; }
.kpi2-top > .ico-svg { color: var(--ink-soft); opacity: .55; }
.kpi2-label { font-size: 13px; font-weight: 650; color: var(--ink-soft); }
.kpi2-mid { display: flex; align-items: flex-end; gap: 12px; }
.kpi2-value { font-size: 29px; font-weight: 720; letter-spacing: -.03em; line-height: 1.05; }
.kpi2-value small { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.kpi2-foot { font-size: 11.5px; color: var(--ink-soft); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; padding: 3px 9px 3px 6px; border-radius: 999px; }
.delta.up   { background: var(--ok-bg);     color: var(--ok); }
.delta.down { background: var(--danger-bg); color: var(--danger); }
.delta .ico-svg .ico-accent { stroke: currentColor; }

.spark { width: 100px; height: 30px; flex: 0 0 auto; opacity: .95; }
.spark.up   { color: var(--ok); }
.spark.down { color: var(--danger); }

/* ---------- Card heads ---------- */
.head-with-ico { display: flex; align-items: center; gap: 10px; min-width: 0; }
.link-more { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; font-size: 12px; font-weight: 650; text-decoration: none; color: var(--green-600); }
[data-theme="dark"] .link-more { color: var(--gold); }
.link-more:hover { text-decoration: underline; }
.range-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--input-bg); color: var(--ink-soft);
}

/* ---------- Layout ---------- */
.dash-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1.05fr) minmax(250px, .82fr); gap: 16px; align-items: start; }
.dash-side { display: grid; gap: 16px; align-content: start; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Promo panel ---------- */
.promo {
  position: relative; overflow: hidden; border-radius: 12px; margin-top: 12px;
  min-height: 190px; display: flex; align-items: center;
  background-image: url('/assets/farm-promo.jpg');
  background-size: cover; background-position: 62% center;
}
.promo::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(24,14,8,.92) 0%, rgba(24,14,8,.62) 46%, rgba(24,14,8,.06) 78%);
}
.promo-text { position: relative; padding: 20px; display: grid; gap: 1px; color: #f7eedf; }
.promo-text strong { font-size: 19px; font-weight: 500; font-style: italic; letter-spacing: -.01em; line-height: 1.18; }
.promo-text span { margin-top: 9px; font-size: 9.5px; letter-spacing: .16em; opacity: .75; }

/* ---------- Weather ---------- */
.weather-card {
  position: relative; overflow: hidden; color: #f7eedf; border: 1px solid var(--line);
  background-image: url('/assets/farm-weather.jpg'); background-size: cover; background-position: center;
  min-height: 116px;
}
.weather-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(20,11,6,.90) 0%, rgba(20,11,6,.66) 52%, rgba(20,11,6,.22) 100%);
}
.weather-card > * { position: relative; z-index: 1; }
.wx { display: grid; gap: 7px; }
.wx-main { display: flex; align-items: center; gap: 11px; }
.wx-main .ico-tile { background: rgba(247,217,160,.92); border: none; }
.wx-temp { font-size: 27px; font-weight: 720; letter-spacing: -.03em; line-height: 1; }
.wx-temp small { font-size: 13px; font-weight: 600; opacity: .8; }
.wx-desc { font-size: 12.5px; opacity: .86; margin-top: 2px; }
.wx-meta { display: flex; gap: 14px; font-size: 11.5px; opacity: .84; }
.wx-place { font-size: 11.5px; opacity: .72; }
.wx-load { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Quick actions ---------- */
.qa-list { display: grid; gap: 7px; }
.qa-row {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--th-bg);
  font-size: 13px; font-weight: 600; transition: .14s;
}
.qa-row:hover { border-color: var(--sand); transform: translateX(2px); }
.qa-row .ico-tile { width: 28px; height: 28px; border-radius: 8px; }
.qa-row > .ico-svg { color: var(--ink-soft); opacity: .5; }

/* ---------- Stat strip ---------- */
.stat-card .stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { min-width: 58px; }
.stat-v { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.stat-v.pos { color: var(--ok); }
.stat-v.neg { color: var(--danger); }
.stat-l { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }

/* ---------- Mobile ---------- */
.bottom-nav { display: none; }

@media (max-width: 1150px) {
  .dash-main { grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); }
  .dash-side { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; display: grid; }
}

@media (max-width: 900px) {
  .dash-main { grid-template-columns: 1fr; }
  .dash-side { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi2-value { font-size: 22px; }
  .kpi2-foot { font-size: 10.5px; }
  .spark { display: none; }
  .dash-hero { background-image: url('/assets/farm-hero-sm.jpg'); padding: 16px; min-height: 150px; }
  .dash-hero h2 { font-size: 20px; }
  .dash-hero p { font-size: 12.5px; }
  .hero-search { display: none; }
  .dash-hero-tools { gap: 8px; }
  .dash-farm { font-size: 12px; padding: 4px 11px 4px 4px; }
  .promo { min-height: 150px; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav a {
    position: relative; flex: 1; display: grid; justify-items: center; gap: 3px; padding: 7px 2px;
    text-decoration: none; color: var(--ink-soft); font-size: 10.5px; font-weight: 650; border-radius: 11px;
  }
  .bottom-nav a.active { color: var(--green-600); background: var(--green-100); }
  [data-theme="dark"] .bottom-nav a.active { color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); }
  .bottom-nav .bn-ico { display: grid; place-items: center; }
  .content { padding-bottom: 88px; }
}

@media (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr; }
  .dash-hero-foot .hero-tag { display: none; }
}
