/* =========================================================================
   MarketLens Global — design tokens
   Brand chrome = navy/teal (from the MarketLens Global logo).
   Data-encoding colors (trend pills, chart line, status) come from the
   validated dataviz reference palette — kept separate from brand chrome
   so chart/status color always passes the accessibility gates.
   ========================================================================= */

:root {
  color-scheme: light;

  /* brand chrome */
  --brand-navy-deep: #0b1f33;
  --brand-navy: #123a5c;
  --brand-navy-mid: #17496f;
  --brand-teal: #1f9c8f;
  --brand-teal-bright: #2fc3b2;
  /* #1f9c8f only clears 3.38:1 on a white card (fails WCAG AA 4.5:1 for
     normal text) — fine for backgrounds/buttons (paired with white text)
     but links/hover text need this darker, text-safe shade instead */
  --brand-teal-text: #157064;

  /* page surfaces */
  --surface-page: #f6f8fa;
  --surface-card: #ffffff;
  --surface-sunken: #f0f2f5;
  --surface-hover: #eef1f4;
  --border-hairline: rgba(11, 31, 51, 0.10);

  /* ink */
  --text-primary: #101828;
  --text-secondary: #4b5768;
  --text-muted: #8a94a3;
  --text-on-brand: #ffffff;

  /* dataviz roles (see references/palette.md) */
  --viz-surface: #fcfcfb;
  --viz-sequential: #2a78d6;
  --viz-sequential-fill: rgba(42, 120, 214, 0.12);
  --status-good: #0ca30c;
  --status-good-bg: rgba(12, 163, 12, 0.10);
  --status-critical: #d03b3b;
  --status-critical-bg: rgba(208, 59, 59, 0.10);
  --status-warning: #b8790f;
  --status-warning-bg: rgba(250, 178, 25, 0.16);
  --gridline: #e1e0d9;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --radius: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-page: #0d1117;
    --surface-card: #151b23;
    --surface-sunken: #1a2129;
    --surface-hover: #1e2731;
    --border-hairline: rgba(255, 255, 255, 0.10);

    --text-primary: #f0f3f7;
    --text-secondary: #b7c0cc;
    --text-muted: #7c8798;
    --brand-teal-text: #1f9c8f;

    --viz-surface: #1a1a19;
    --viz-sequential: #3987e5;
    --viz-sequential-fill: rgba(57, 135, 229, 0.16);
    --status-good: #16c116;
    --status-good-bg: rgba(22, 193, 22, 0.14);
    --status-critical: #e66767;
    --status-critical-bg: rgba(230, 103, 103, 0.14);
    --status-warning: #d9a53c;
    --status-warning-bg: rgba(217, 165, 60, 0.16);
    --gridline: #2c2c2a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #0d1117;
  --surface-card: #151b23;
  --surface-sunken: #1a2129;
  --surface-hover: #1e2731;
  --border-hairline: rgba(255, 255, 255, 0.10);

  --text-primary: #f0f3f7;
  --text-secondary: #b7c0cc;
  --text-muted: #7c8798;
  --brand-teal-text: #1f9c8f;

  --viz-surface: #1a1a19;
  --viz-sequential: #3987e5;
  --viz-sequential-fill: rgba(57, 135, 229, 0.16);
  --status-good: #16c116;
  --status-good-bg: rgba(22, 193, 22, 0.14);
  --status-critical: #e66767;
  --status-critical-bg: rgba(230, 103, 103, 0.14);
  --status-warning: #d9a53c;
  --status-warning-bg: rgba(217, 165, 60, 0.16);
  --gridline: #2c2c2a;
}

/* =========================================================================
   Reset & base
   ========================================================================= */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--brand-teal); color: #fff; }

.tabular-nums { font-variant-numeric: tabular-nums; }

/* =========================================================================
   App shell: sidebar + topbar + content
   ========================================================================= */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 39;
}
.sidebar-overlay.open { display: block; }

.sidebar {
  background: linear-gradient(180deg, var(--brand-navy-deep), var(--brand-navy));
  color: var(--text-on-brand);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.sidebar-brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 11px; color: rgba(255,255,255,0.55); letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar-section-label {
  padding: 18px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.82);
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: var(--brand-teal); color: #fff; font-weight: 600; }
.sidebar-link .count { font-size: 11px; color: rgba(255,255,255,0.5); font-variant-numeric: tabular-nums; }
.sidebar-link.active .count { color: rgba(255,255,255,0.85); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.10);
  font-size: 11.5px;
  color: rgba(255,255,255,0.45);
}

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-search { position: relative; flex: 1; max-width: 440px; }
.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-sunken);
  color: var(--text-primary);
  font-size: 13.5px;
}
.topbar-search input:focus { outline: 2px solid var(--brand-teal); outline-offset: 1px; }
.topbar-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}
.search-suggest.open { display: block; }
.search-suggest-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-hairline);
  font-size: 13px;
}
.search-suggest-item:last-child { border-bottom: none; }
.search-suggest-item:hover { background: var(--surface-hover); }
.search-suggest-item .name { font-weight: 600; }
.search-suggest-item .meta { color: var(--text-muted); font-size: 11.5px; }
.search-suggest-empty { padding: 14px; color: var(--text-muted); font-size: 13px; }

.topbar-spacer { flex: 1; }

.theme-toggle, .icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  cursor: pointer;
}
.theme-toggle:hover, .icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.theme-toggle svg, .icon-btn svg { width: 17px; height: 17px; }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 20px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-hairline);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-teal), var(--brand-navy-mid));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface-card); border: 1px solid var(--border-hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 170px; padding: 6px; display: none; z-index: 50;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
  display: block; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--text-secondary);
}
.user-dropdown a:hover { background: var(--surface-hover); color: var(--text-primary); }

.page-body { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* =========================================================================
   Cards, stat tiles, KPI row
   ========================================================================= */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-subtitle { color: var(--text-secondary); font-size: 13.5px; margin: 0; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile { padding: 18px 20px; }
.stat-tile .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-tile .stat-delta { font-size: 12.5px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }

/* =========================================================================
   Source cards grid (overview)
   ========================================================================= */

.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.source-card {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.source-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.source-card-top { display: flex; align-items: center; justify-content: space-between; }
.source-card-name { font-weight: 600; font-size: 14.5px; }
.source-card-code { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.source-card-count { font-size: 24px; font-weight: 700; }
.source-card-meta { font-size: 12px; color: var(--text-muted); }
.badge-active {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
  background: var(--status-good-bg); color: var(--status-good);
}

/* =========================================================================
   Data table
   ========================================================================= */

.table-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-search { flex: 1; min-width: 220px; max-width: 340px; }
.table-search input {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border-hairline); background: var(--surface-sunken);
  color: var(--text-primary); font-size: 13.5px;
}
.table-count { font-size: 12.5px; color: var(--text-muted); margin-left: auto; }
.table-count-lead { font-size: 12.5px; color: var(--text-muted); }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--border-hairline); border-radius: var(--radius-lg); background: var(--surface-card); }
/* wide enough that the date/price range filters never crush the columns
   they sit under — narrower viewports scroll the wrapper instead */
.data-table { min-width: 1040px; }
.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--border-hairline);
  background: var(--surface-sunken); white-space: nowrap; position: sticky; top: 0;
}
.data-table th a { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.data-table td { padding: 12px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border-hairline); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-hover); }
.data-table .col-desc { font-weight: 600; color: var(--text-primary); }
.data-table .col-desc a:hover { color: var(--brand-teal-text); }
.data-table .col-country { color: var(--text-secondary); }
.data-table .col-price { font-weight: 600; }

/* source link column */
.data-table .col-link a {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: var(--brand-teal-text);
}
.data-table .col-link a:hover { text-decoration: underline; }
.data-table .col-link svg { width: 13px; height: 13px; }
.data-table .col-link { color: var(--text-muted); }

/* per-column filter row, sitting directly under the column headers */
.data-table .filter-row td {
  padding: 7px 10px; background: var(--surface-sunken);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky; top: 41px;
}
.data-table tr.filter-row:hover td { background: var(--surface-sunken); }

.col-filter {
  width: 100%; padding: 6px 9px; border-radius: 7px;
  border: 1px solid var(--border-hairline); background: var(--surface-card);
  color: var(--text-primary); font-size: 12.5px; font-family: inherit;
}
.col-filter:focus { outline: 2px solid var(--brand-teal); outline-offset: 1px; }
.col-filter::placeholder { color: var(--text-muted); }
/* Chrome renders the type=search clear button and the date picker glyph in
   near-black, which disappears against the dark theme's card surface. */
.col-filter::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.55); cursor: pointer; }
.col-filter::-webkit-calendar-picker-indicator { opacity: 0.5; cursor: pointer; }
.col-filter:hover::-webkit-calendar-picker-indicator { opacity: 0.85; }
:root[data-theme="dark"] .col-filter::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] .col-filter::-webkit-search-cancel-button { filter: invert(1) opacity(0.6); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .col-filter::-webkit-calendar-picker-indicator,
  :root:where(:not([data-theme="light"])) .col-filter::-webkit-search-cancel-button { filter: invert(1) opacity(0.6); }
}

/* text filters carry the magnifier inside the box */
.filter-input { position: relative; display: block; min-width: 150px; }
.filter-input svg {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--text-muted); pointer-events: none;
}
.filter-input .col-filter { padding-left: 26px; }

.filter-date { min-width: 138px; }
.filter-price { min-width: 96px; }

.filter-hint { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.filter-hint kbd {
  font-family: inherit; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-hairline); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; background: var(--surface-card);
  color: var(--text-secondary);
}

.table-no-match { text-align: center; color: var(--text-muted); padding: 34px 16px; }
.table-no-match a { color: var(--brand-teal-text); font-weight: 600; margin-left: 6px; }
.table-no-match a:hover { text-decoration: underline; }

.trend-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px;
}
.trend-up { color: var(--status-good); background: var(--status-good-bg); }
.trend-down { color: var(--status-critical); background: var(--status-critical-bg); }
.trend-flat { color: var(--text-muted); background: var(--surface-sunken); }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-state svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: 0.5; }

/* pagination */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.pagination a, .pagination span {
  min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 12.5px; color: var(--text-secondary); border: 1px solid var(--border-hairline);
  padding: 0 8px;
}
.pagination a:hover { background: var(--surface-hover); }
.pagination .current { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); font-weight: 600; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-hairline); background: var(--surface-card); color: var(--text-primary);
  cursor: pointer;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; }
.btn-primary:hover { background: var(--brand-teal-bright); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface-card); border: 1px solid var(--border-hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 160px; padding: 6px; display: none; z-index: 40;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button, .dropdown-menu a {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  font-size: 13px; background: none; border: none; color: var(--text-secondary); cursor: pointer;
}
.dropdown-menu button:hover, .dropdown-menu a:hover { background: var(--surface-hover); color: var(--text-primary); }

/* =========================================================================
   Breadcrumb / back link
   ========================================================================= */

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumb a:hover { color: var(--brand-teal-text); }

/* =========================================================================
   Commodity detail page
   ========================================================================= */

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.detail-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.detail-meta .sep { color: var(--border-hairline); }

.price-hero { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 2px; }
.price-hero .value { font-size: 34px; font-weight: 700; letter-spacing: -0.01em; }
.price-hero .currency { font-size: 14px; color: var(--text-muted); }

.chart-card { padding: 20px 22px 12px; margin-bottom: 20px; }
.chart-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.chart-legend { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--viz-sequential); display: inline-block; }
/* Chart.js with maintainAspectRatio:false sizes the canvas from its
   PARENT's box — the parent needs a real, fixed height or the two feed
   back into each other and the canvas balloons (seen growing to 700px+
   instead of staying at 280px, pushing most of the chart off-screen). */
.chart-canvas-wrap { position: relative; width: 100%; height: 280px; }
#trend-chart { width: 100% !important; height: 100% !important; }

/* =========================================================================
   Login page
   ========================================================================= */

.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(11,31,51,0.72), rgba(11,31,51,0.86)), url('/static/img/login-bg.png') center/cover no-repeat;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: rgba(21, 27, 35, 0.55);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-lg);
  padding: 32px 30px 28px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
  color: #fff;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 6px; }
.login-logo img { width: 84px; height: 84px; object-fit: contain; }
.login-title { text-align: center; font-size: 18px; font-weight: 700; margin: 6px 0 2px; }
.login-sub { text-align: center; font-size: 12.5px; color: rgba(255,255,255,0.65); margin-bottom: 24px; }

.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12.5px; color: rgba(255,255,255,0.75); margin-bottom: 6px; }
.form-field input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08);
  color: #fff; font-size: 13.5px;
}
.form-field input::placeholder { color: rgba(255,255,255,0.4); }
.form-field input:focus { outline: 2px solid var(--brand-teal-bright); outline-offset: 1px; }

.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-size: 12.5px; color: rgba(255,255,255,0.7); }
.login-btn {
  width: 100%; padding: 11px; border-radius: 8px; border: none;
  background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-bright));
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.login-btn:hover { filter: brightness(1.06); }

.flash-stack { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.flash {
  padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-md);
  background: var(--surface-card); border: 1px solid var(--border-hairline); color: var(--text-primary);
}
.flash-error { border-color: var(--status-critical); color: var(--status-critical); }
.flash-info { border-color: var(--brand-teal); color: var(--brand-navy); }
.flash-success { border-color: var(--status-good); color: var(--status-good); }
.login-shell .flash-stack .flash { background: rgba(21,27,35,0.85); color: #fff; border-color: rgba(255,255,255,0.2); }
.login-shell .flash-stack .flash-error { color: #ffb4b4; }

/* =========================================================================
   Admin: users & access
   ========================================================================= */

.sidebar-empty { padding: 4px 14px 8px; font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.45; }
.user-dropdown-sep { height: 1px; background: var(--border-hairline); margin: 4px 0; }

.tag {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px; letter-spacing: 0.02em; margin-left: 6px;
}
.tag-brand { background: var(--brand-teal); color: #fff; margin-left: 0; }
.tag-muted { background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border-hairline); }
.access-note { color: var(--text-secondary); }
.access-none { color: var(--status-warning); font-weight: 600; }

.data-table .col-actions { white-space: nowrap; }
.data-table td.col-actions { display: flex; gap: 6px; align-items: center; }
.btn-danger { color: var(--status-critical); border-color: var(--border-hairline); }
.btn-danger:hover { background: var(--status-critical-bg); }

/* The .form-field styling further up is scoped to the dark login card, so
   the admin forms restate the parts that assume white-on-glass. */
.admin-form { display: flex; flex-direction: column; gap: 16px; }
.form-card { padding: 20px 22px; }
.form-section-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.form-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.form-section-actions { display: flex; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 14px 0 4px; }
.admin-form .form-field { margin-bottom: 0; }
.admin-form .form-field label { color: var(--text-secondary); font-weight: 600; }
.admin-form .form-field input[type="text"],
.admin-form .form-field input[type="password"] {
  background: var(--surface-sunken); border-color: var(--border-hairline); color: var(--text-primary);
}
.admin-form .form-field input::placeholder { color: var(--text-muted); }
.field-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 5px; font-weight: 400; }

.form-toggles { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 18px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; cursor: pointer; }
.check-row input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--brand-teal); }
.check-row .field-hint { margin-top: 2px; }

.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.access-item {
  display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border-hairline);
  border-radius: var(--radius); background: var(--surface-sunken); font-size: 13.5px;
}
.access-item:hover { background: var(--surface-hover); }
.access-item input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--brand-teal); }
.access-item:has(input:checked) { border-color: var(--brand-teal); background: var(--surface-card); }
.access-name { display: block; font-weight: 600; }

.admin-note {
  font-size: 12.5px; color: var(--status-warning); background: var(--status-warning-bg);
  border-radius: var(--radius); padding: 9px 12px; margin-bottom: 14px;
}
.is-dimmed .access-grid { opacity: 0.45; }

.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* =========================================================================
   Error page
   ========================================================================= */
.error-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; text-align: center; padding: 20px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--brand-navy); }

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 260px; height: 100vh;
    transform: translateX(-100%); transition: transform 0.18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex !important; }
  .page-body { padding: 18px 16px 40px; }
}
.menu-btn { display: none; }
