/* ============================================================
   FarmScope Web — read-only analytics platform
   Design tokens distilled from the mobile app theme.
   Light + dark, emerald identity, executive density.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --brand: #00512D;
  --brand-700: #00633A;
  --brand-deep: #003D1F;
  --accent: #0E9F66;
  --accent-soft: rgba(14, 159, 102, 0.12);

  /* Surfaces (light) */
  --bg: #EAF0EC;
  --surface: #F4F8F5;
  --card: #FFFFFF;
  --card-elev: #F8FBF9;
  --border: #E0E8E3;
  --hairline: #EBF1ED;

  /* Ink */
  --ink-1: #14211C;
  --ink-2: #51635A;
  --ink-3: #899890;

  /* Status */
  --success: #0E9F66;
  --success-soft: rgba(14, 159, 102, 0.12);
  --warning: #D9831F;
  --warning-soft: rgba(217, 131, 31, 0.14);
  --error: #E14434;
  --error-soft: rgba(225, 68, 52, 0.12);
  --info: #2F6DD0;
  --info-soft: rgba(47, 109, 208, 0.12);

  /* Chart palette */
  --c1: #0E9F66;
  --c2: #1E8A82;
  --c3: #84B622;
  --c4: #E0A12E;
  --c5: #D9663B;
  --c6: #6C5CE0;
  --c7: #2F8FD0;

  /* Sidebar (always deep emerald in light mode) */
  --side-bg: #06281A;
  --side-bg-2: #04231600;
  --side-grad-1: #0A3322;
  --side-grad-2: #052015;
  --side-ink: #EAF3EE;
  --side-ink-dim: rgba(234, 243, 238, 0.58);
  --side-faint: rgba(255, 255, 255, 0.07);
  --side-active: rgba(14, 159, 102, 0.22);
  --side-active-bar: #3FBF86;

  /* Geometry */
  --r-xs: 10px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 35, 35, 0.04), 0 1px 3px rgba(16, 35, 35, 0.06);
  --shadow-md: 0 2px 8px rgba(16, 35, 35, 0.06), 0 6px 20px rgba(16, 35, 35, 0.05);
  --shadow-lg: 0 8px 24px rgba(16, 35, 35, 0.08), 0 24px 60px rgba(16, 35, 35, 0.08);

  --sidebar-w: 256px;
  --topbar-h: 68px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-ui: 'Manrope', system-ui, sans-serif;
}

[data-theme='dark'] {
  --bg: #0F1317;
  --surface: #161B21;
  --card: #1A2027;
  --card-elev: #20272F;
  --border: #2C333D;
  --hairline: #242B33;

  --ink-1: #DCE0E6;
  --ink-2: #99A0AB;
  --ink-3: #6B737D;

  --brand: #15512F;
  --accent: #3FBF86;
  --accent-soft: rgba(63, 191, 134, 0.16);

  --success: #3FBF86;
  --success-soft: rgba(63, 191, 134, 0.16);
  --warning: #E5C07B;
  --warning-soft: rgba(229, 192, 123, 0.16);
  --error: #E8736B;
  --error-soft: rgba(232, 115, 107, 0.16);
  --info: #79AEE8;
  --info-soft: rgba(121, 174, 232, 0.16);

  --c1: #3FBF86;
  --c2: #4FB6A0;
  --c3: #A6C957;
  --c4: #E5C07B;
  --c5: #E29470;
  --c6: #9A8CE8;
  --c7: #79AEE8;

  --side-bg: #0A0F13;
  --side-grad-1: #10201A;
  --side-grad-2: #0A0F13;
  --side-ink: #E4ECE7;
  --side-ink-dim: rgba(228, 236, 231, 0.5);
  --side-faint: rgba(255, 255, 255, 0.05);
  --side-active: rgba(63, 191, 134, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { transition: background 0.3s ease, color 0.3s ease; }

::selection { background: var(--accent-soft); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ============================================================
   App layout
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--side-grad-1), var(--side-grad-2) 64%);
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.2);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
}
.brand__logo {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  flex-shrink: 0;
}
.brand__logo img { width: 100%; height: 100%; object-fit: cover; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.4px; line-height: 1; }
.brand__tag { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--side-ink-dim); margin-top: 4px; font-weight: 600; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }
.nav::-webkit-scrollbar { width: 0; }
.nav__group { margin-top: 18px; }
.nav__label {
  font-size: 10px; letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--side-ink-dim); font-weight: 700;
  padding: 0 12px 8px;
}
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--side-ink-dim); text-decoration: none;
  font-size: 13.5px; font-weight: 600;
  position: relative;
  transition: background 0.16s ease, color 0.16s ease;
  margin-bottom: 1px;
}
.nav__item:hover { background: var(--side-faint); color: var(--side-ink); }
.nav__item.is-active { background: var(--side-active); color: #fff; }
.nav__item.is-active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--side-active-bar);
}
.nav__icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.92; }
.nav__item.is-active .nav__icon { opacity: 1; }
.nav__badge {
  margin-left: auto; font-size: 10.5px; font-weight: 800;
  background: var(--error); color: #fff; border-radius: var(--r-pill);
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
}

.side-foot { padding: 14px; border-top: 1px solid var(--side-faint); }
.side-card {
  background: var(--side-faint); border-radius: var(--r-md);
  padding: 12px 13px; display: flex; gap: 10px; align-items: center;
}
.side-card__icon { width: 34px; height: 34px; border-radius: 9px; background: rgba(63,191,134,0.2); display: grid; place-items: center; flex-shrink: 0; }
.side-card__t { font-size: 12px; font-weight: 700; color: var(--side-ink); }
.side-card__s { font-size: 10.5px; color: var(--side-ink-dim); margin-top: 2px; }

/* ---- Main column ---- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
}
.topbar__title { display: flex; flex-direction: column; }
.topbar__crumb { font-size: 11px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.2px; }
.topbar__h { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -0.4px; }
.topbar__spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 8px 14px;
  width: 230px; color: var(--ink-3);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: none; background: none; outline: none; font: inherit; font-size: 13px; color: var(--ink-1); width: 100%; }
.search input::placeholder { color: var(--ink-3); }
.search kbd {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700; color: var(--ink-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface);
}

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--ink-1); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); border: 2px solid var(--card); }

/* Pill controls (farm switcher, range, lang) */
.pill-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 7px 12px 7px 9px;
  cursor: pointer; color: var(--ink-1); font: inherit; font-size: 13px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.pill-btn:hover { background: var(--surface); }
.pill-btn .chev { color: var(--ink-3); }
.pill-btn .flag, .pill-btn .dotmark { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 800; }

.avatar {
  width: 38px; height: 38px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--accent), var(--brand-700));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  cursor: pointer; border: 2px solid var(--card); box-shadow: var(--shadow-sm);
  appearance: none; -webkit-appearance: none; padding: 0; font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.avatar:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ---- Content ---- */
.content { padding: 26px 28px 56px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-weight: 600; font-size: 27px; letter-spacing: -0.8px; }
.page-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 5px; max-width: 60ch; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }

.seg {
  display: inline-flex; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 3px;
}
.seg button {
  border: none; background: none; font: inherit; font-size: 12.5px; font-weight: 700;
  color: var(--ink-2); padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button.is-active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
[data-theme='dark'] .seg button.is-active { background: var(--accent); color: #06140d; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--r-sm); padding: 9px 15px; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s; text-decoration: none;
}
.btn--ghost { background: var(--card); border-color: var(--border); color: var(--ink-1); }
.btn--ghost:hover { background: var(--surface); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-700); }
[data-theme='dark'] .btn--primary { background: var(--accent); color: #06140d; }

/* ============================================================
   Grid + cards
   ============================================================ */
.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.col-12 { grid-column: span 12; }
.g12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card--pad { padding: 18px 20px; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 20px 0; }
.card__head + .card__body { padding-top: 12px; }
.card__title { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; letter-spacing: -0.2px; }
.card__sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-weight: 500; }
.card__body { padding: 16px 20px 20px; }
.card__act { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }

/* KPI card */
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 17px 18px 16px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi__spark { width: 64px; height: 26px; }
.kpi__label { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.2px; text-transform: uppercase; }
.kpi__value { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -1px; line-height: 1; }
.kpi__sub { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 12px; }
.trend--up { color: var(--success); }
.trend--down { color: var(--error); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-pill); }
.chip--ok { background: var(--success-soft); color: var(--success); }
.chip--warn { background: var(--warning-soft); color: var(--warning); }
.chip--err { background: var(--error-soft); color: var(--error); }
.chip--info { background: var(--info-soft); color: var(--info); }
.chip--muted { background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.legend__item { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); font-weight: 600; color: var(--ink-1); }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .muted { color: var(--ink-3); font-weight: 600; }
.tbl .lead { display: flex; align-items: center; gap: 11px; }
.tbl .ent-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: 15px; }

/* statement rows */
.stmt { width: 100%; font-size: 13.5px; }
.stmt-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 4px; border-bottom: 1px solid var(--hairline); }
.stmt-row .lbl { color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 9px; }
.stmt-row .val { font-weight: 700; color: var(--ink-1); }
.stmt-row.is-sub { font-size: 14.5px; padding: 13px 4px; border-top: 2px solid var(--border); border-bottom: none; }
.stmt-row.is-sub .lbl { color: var(--ink-1); font-weight: 800; }
.stmt-row.is-sub .val { font-weight: 800; }
.stmt-row.is-total { font-size: 16px; padding: 15px 12px; margin-top: 6px; background: var(--surface); border-radius: var(--r-md); border: none; }
.stmt-row.is-total .lbl { color: var(--ink-1); font-family: var(--font-display); font-weight: 600; }
.stmt-row.is-total .val { font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.stmt-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.stmt-indent { padding-left: 22px; }

/* Progress / runway bars */
.bar-row { display: grid; grid-template-columns: 150px 1fr 64px; gap: 12px; align-items: center; padding: 8px 0; }
.bar-row .nm { font-size: 13px; font-weight: 600; color: var(--ink-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; border-radius: var(--r-pill); background: var(--surface); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); width: 0; transition: width 1s cubic-bezier(0.22, 1, 0.36, 1); }
.bar-row .qty { font-size: 12.5px; font-weight: 700; text-align: right; color: var(--ink-2); }

/* gauge ring labels */
.ring-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.ring { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ring__label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ring__sub { font-size: 11px; color: var(--ink-3); font-weight: 600; }

/* small stat list */
.minis { display: grid; gap: 1px; }
.mini { display: flex; align-items: center; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--hairline); }
.mini:last-child { border-bottom: none; }
.mini__l { display: flex; align-items: center; gap: 11px; }
.mini__ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.mini__t { font-size: 13px; font-weight: 700; color: var(--ink-1); }
.mini__s { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-top: 1px; }
.mini__v { font-family: var(--font-display); font-weight: 600; font-size: 16px; }

/* tooltip */
.chart-tip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--ink-1); color: var(--card);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s; white-space: nowrap;
}
.chart-tip.show { opacity: 1; transform: translateY(0); }
.chart-tip b { font-family: var(--font-display); font-weight: 600; }
.chart-tip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.chart-tip .tt-dot { width: 8px; height: 8px; border-radius: 2px; }

/* banner */
.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-radius: var(--r-md); border: 1px solid; margin-bottom: 18px;
}
.banner--warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.banner--err { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.banner__ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.banner__t { font-weight: 800; font-size: 13.5px; }
.banner__s { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; font-weight: 500; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  border: none; background: none; font: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--ink-3); padding: 11px 16px; cursor: pointer; position: relative; transition: color 0.15s;
}
.tab:hover { color: var(--ink-1); }
.tab.is-active { color: var(--brand); }
[data-theme='dark'] .tab.is-active { color: var(--accent); }
.tab.is-active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px; border-radius: 2px; background: currentColor; }
.tab-panel { display: none; animation: fade 0.3s ease; }
.tab-panel.is-active { display: block; }

/* dropdown menu */
.menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 60;
  opacity: 0; transform: translateY(-6px) scale(0.98); pointer-events: none;
  transition: opacity 0.14s, transform 0.14s;
}
.menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.menu__item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--ink-1); cursor: pointer; text-decoration: none;
}
.menu__item:hover { background: var(--surface); }
.menu__item.is-active { background: var(--accent-soft); color: var(--accent); }
.menu__check { margin-left: auto; color: var(--accent); }
.menu__sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu__head { font-size: 10.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding: 8px 11px 5px; }
.pos-rel { position: relative; }

/* misc */
.dim { color: var(--ink-2); }
.muted { color: var(--ink-3); }
.up { color: var(--success); } .down { color: var(--error); }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.wrap { flex-wrap: wrap; }

@keyframes fade { from { transform: translateY(8px); } to { transform: translateY(0); } }
@keyframes rise { from { transform: translateY(16px); } to { transform: translateY(0); } }
/* Transform-only entrance — base opacity stays 1 so static captures & reduced-motion always show content */
.rise { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* responsive */
@media (max-width: 1180px) {
  .span-3, .span-4 { grid-column: span 6; }
  .span-5, .span-7, .span-8, .span-9 { grid-column: span 12; }
  .span-6 { grid-column: span 12; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 920px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform 0.25s; width: 256px; }
  .sidebar.open { transform: translateX(0); }
  .app { grid-template-columns: 1fr; }
  .search { display: none; }
}
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 0 16px; }
}

/* app loading overlay (shown while the dashboard fetches its data) */
.fs-loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg);
  transition: opacity 0.35s ease;
}
.fs-loader.is-hiding { opacity: 0; pointer-events: none; }
.fs-loader__logo { width: 54px; height: 54px; border-radius: 15px; overflow: hidden; box-shadow: var(--shadow-md); }
.fs-loader__logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fs-loader__spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: fs-spin 0.8s linear infinite;
}
.fs-loader__text { font-size: 13.5px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.2px; }
@keyframes fs-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Page-load orchestration + interaction polish
   ============================================================ */
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Cards and KPI tiles rise into place on load. Both opacity and transform
   reset to their natural state, and the reduced-motion rule below collapses
   the duration to ~0 so the final (fully visible) state always wins. */
.content .card,
.content .kpi { animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* Light left-to-right stagger across each grid row for a sense of sequence. */
.g12 > .card:nth-child(2) { animation-delay: 0.06s; }
.g12 > .card:nth-child(3) { animation-delay: 0.12s; }
.g12 > .card:nth-child(4) { animation-delay: 0.18s; }

/* Accessible keyboard focus — visible ring only for keyboard users. */
:focus-visible { outline: none; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
.icon-btn:focus-visible,
.pill-btn:focus-visible,
.avatar:focus-visible,
.tab:focus-visible,
.seg button:focus-visible,
.menu__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Nav links get a slightly larger affordance on hover (subtle slide). */
.nav__item { transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease; }
.nav__item:hover { transform: translateX(2px); }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .nav__item:hover { transform: none; }
}
