/* theme.css - the dashboard's design system (2026-10-15: "make this feel like a serious tool to run their robo food
   empire"). Loaded after style.css and before the page sheets; it re-points style.css's tokens and restyles the shell
   and shared components. Neutral greys, one brand red used sparingly (primary actions, the active item), Inter with
   tabular numbers, flat bordered surfaces, line icons (public/js/icons.js) instead of emoji. Both themes. */

/* ---------- tokens: dark ---------- */
:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rb-red: #F04438; --rb-red-dark: #D92D20; --rb-red-light: rgba(240, 68, 56, .16);
  --rb-green: #32D583; --rb-green-light: rgba(50, 213, 131, .14);
  --rb-blue: #53B1FD; --rb-blue-light: rgba(83, 177, 253, .14);
  --rb-orange: #FDB022; --rb-yellow: #FDB022;
  --gradient-brand: linear-gradient(var(--rb-red), var(--rb-red));
  --surface-0: #0A0C0F; --surface-1: #0E1114; --surface-2: #101317; --surface-3: #13171C; --surface-4: #1A1F26; --surface-5: #252B33;
  --text-primary: #E6E8EB; --text-secondary: #A3ABB6; --text-muted: #737C88;
  --status-success: #32D583; --status-success-bg: rgba(50, 213, 131, .12);
  --status-warning: #FDB022; --status-warning-bg: rgba(253, 176, 34, .12);
  --status-danger: #F97066; --status-danger-bg: rgba(249, 112, 102, .12);
  --status-info: #53B1FD; --status-info-bg: rgba(83, 177, 253, .12);
  --radius-lg: 10px; --radius-xl: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 4px 12px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-glow: none;
  --focus: 0 0 0 3px rgba(83, 177, 253, .35);
}
/* ---------- tokens: light ---------- */
[data-theme="light"] {
  --rb-red: #D92D20; --rb-red-dark: #B42318; --rb-red-light: #FEE4E2;
  --rb-green: #079455; --rb-green-light: #DCFAE6;
  --rb-blue: #1570EF; --rb-blue-light: #D1E9FF;
  --rb-orange: #DC6803; --rb-yellow: #DC6803;
  --surface-0: #F5F6F8; --surface-1: #FFFFFF; --surface-2: #FFFFFF; --surface-3: #FFFFFF; --surface-4: #F2F4F7; --surface-5: #E4E7EC;
  --text-primary: #101828; --text-secondary: #475467; --text-muted: #667085;
  --status-success: #079455; --status-success-bg: #ECFDF3;
  --status-warning: #B54708; --status-warning-bg: #FFFAEB;
  --status-danger: #D92D20; --status-danger-bg: #FEF3F2;
  --status-info: #1570EF; --status-info-bg: #EFF8FF;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05); --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08); --shadow-lg: 0 12px 24px -4px rgba(16, 24, 40, .12);
  --focus: 0 0 0 3px rgba(21, 112, 239, .22);
}

/* ---------- base ---------- */
body { font-family: var(--font-sans); font-feature-settings: "cv11", "ss01"; letter-spacing: -0.003em; background: var(--surface-0); }
.value, .rs-num, td, .stat-card .value, .unit-card-stat .val, .kpi, .num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* icons (icons.js) */
.rb-ic { width: 1.05em; height: 1.05em; vertical-align: -0.17em; flex: none; }
.rb-ic-wrap { display: inline-flex; align-items: center; margin-right: .35em; color: inherit; }
.rb-dot { display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: .4em; vertical-align: .08em; background: var(--text-muted); }
.rb-dot.ok { background: var(--status-success); } .rb-dot.warn { background: var(--status-warning); } .rb-dot.bad { background: var(--status-danger); }
.rb-dot.info { background: var(--status-info); } .rb-dot.violet { background: #9E77ED; }
.rb-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--rb-red); color: #fff;
  font: 800 11px/1 var(--font-sans); letter-spacing: .02em; flex: none; }

/* ---------- top bar (modes) ---------- */
.mode-bar { background: var(--surface-2); border-bottom: 1px solid var(--surface-5); }
.mode-bar-inner { height: 44px; gap: 14px; }
.mode-bar-brand { display: flex; align-items: center; gap: 8px; font: 650 14px/1 var(--font-sans); color: var(--text-primary); letter-spacing: -.01em; }
.mode-bar-brand .rb-ic-wrap { display: none; }
.mode-tabs { background: var(--surface-4); border: 1px solid var(--surface-5); border-radius: 8px; padding: 2px; gap: 0; }
.mode-tab { font: 600 12.5px/1 var(--font-sans); padding: 7px 14px; border-radius: 6px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.mode-tab:hover { background: transparent; color: var(--text-primary); }
.mode-tab.active { background: var(--surface-2); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.mode-tab .rb-ic-wrap { margin-right: 0; color: var(--text-muted); }
.mode-tab.active .rb-ic-wrap { color: var(--rb-red); }
.mode-bar-user { font-size: 12.5px; color: var(--text-secondary); }

/* ---------- sidebar ---------- */
.sidebar { background: var(--surface-2); border-right: 1px solid var(--surface-5); box-shadow: none !important; padding: 12px 0; }
.sidebar-brand { padding: 4px 18px 14px !important; border-bottom: 1px solid var(--surface-5); margin-bottom: 8px; }
.sidebar-brand h1 { display: flex; align-items: center; gap: 10px; font: 700 15px/1.2 var(--font-sans) !important; color: var(--text-primary) !important; letter-spacing: -.01em; margin: 0; }
.sidebar-brand h1 .rb-ic-wrap { display: none; }
.sidebar-brand p { font-size: 12px !important; color: var(--text-muted) !important; margin: 4px 0 0 34px !important; }
.nav-group-header { font: 600 11px/1 var(--font-sans) !important; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted) !important; padding: 14px 18px 6px !important; }
.nav-group-header .rb-ic-wrap { display: none; }
.nav-item { font: 500 13.5px/1.2 var(--font-sans); color: var(--text-secondary); padding: 7px 12px; margin: 1px 8px; border-radius: 7px; border-left: 0; gap: 10px; }
.nav-item:hover { background: var(--surface-4); color: var(--text-primary); }
.nav-item.active { background: var(--surface-4); color: var(--text-primary); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--rb-red); }
.nav-item .icon { width: 18px; font-size: 16px; color: var(--text-muted); display: inline-flex; justify-content: center; }
.nav-item .icon .rb-ic-wrap { margin: 0; }
.nav-item:hover .icon, .nav-item.active .icon { color: var(--text-primary); }
.theme-toggle { border-radius: 7px !important; }

/* ---------- header ---------- */
.header { background: var(--surface-2); border-bottom: 1px solid var(--surface-5); }
.header-title { font: 600 14px/1.2 var(--font-sans); color: var(--text-secondary); }
@media (min-width: 769px) {
  .header-title { display: none; }                 /* the page header below already names the page */
  .sidebar-brand { display: none; }                /* the top bar carries the brand */
  .header-right > .header-icon-btn[title^="Search"] { display: none; }   /* the search bar replaces the icon */
}
.header-search { display: flex; align-items: center; gap: 10px; height: 36px; width: min(420px, 100%); padding: 0 10px 0 12px; border-radius: 8px;
  border: 1px solid var(--surface-5); background: var(--surface-0); color: var(--text-muted); font: 500 13.5px/1 var(--font-sans); cursor: pointer; text-align: left; }
.header-search:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.header-search .txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-search kbd { font: 600 11px/1 var(--font-sans); padding: 4px 6px; border-radius: 5px; border: 1px solid var(--surface-5); background: var(--surface-2); color: var(--text-muted); }
@media (max-width: 768px) { .header-search { display: none; } }
.header-icon-btn, .btn-icon { border: 1px solid var(--surface-5) !important; background: var(--surface-2) !important; color: var(--text-secondary) !important;
  border-radius: 8px !important; width: 34px; height: 34px; display: inline-grid !important; place-items: center; font-size: 16px; }
.header-icon-btn:hover, .btn-icon:hover { background: var(--surface-4) !important; color: var(--text-primary) !important; }
.header-icon-btn .rb-ic-wrap, .btn-icon .rb-ic-wrap { margin: 0; }
.user-avatar, #header-avatar { background: var(--surface-4) !important; color: var(--text-primary) !important; border: 1px solid var(--surface-5); font-weight: 650 !important; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); border-bottom: 1px solid var(--surface-5); background: var(--surface-0); }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

/* ---------- page header ---------- */
.page-header { margin-bottom: 20px; align-items: flex-end; }
.page-title { font: 650 22px/1.25 var(--font-sans) !important; letter-spacing: -.015em; color: var(--text-primary); }
.page-subtitle { font-size: 13.5px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- surfaces ---------- */
.card, .stat-card, .unit-card, .chat-conv-card, .hc-conv-card, .dropdown-panel, .user-menu-panel {
  background: var(--surface-3); border: 1px solid var(--surface-5) !important; border-radius: 10px; box-shadow: var(--shadow-sm) !important; }
.card:hover, .unit-card:hover { box-shadow: var(--shadow-md) !important; }
.card-header, .card > h3:first-child, .card .card-title { font: 600 12px/1.2 var(--font-sans); letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); }
.page-info-card { background: var(--surface-3) !important; border: 1px solid var(--surface-5) !important; border-left: 3px solid var(--status-info) !important; border-radius: 10px; box-shadow: none !important; color: var(--text-secondary); }
.page-info-card .rb-ic-wrap { color: var(--status-info); }

/* KPI tiles: the number in ink, the colour as a thin edge (not four colours of large digits) */
.stat-card { position: relative; overflow: hidden; padding: 16px 18px !important; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--surface-5); }
.stat-card.green::before { background: var(--status-success); } .stat-card.red::before { background: var(--status-danger); }
.stat-card.blue::before { background: var(--status-info); } .stat-card.orange::before, .stat-card.yellow::before { background: var(--status-warning); }
.stat-card .label { font: 600 11.5px/1.2 var(--font-sans) !important; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted) !important; }
.stat-card .value, .stat-card.green .value, .stat-card.red .value, .stat-card.blue .value, .stat-card.orange .value, .stat-card.yellow .value {
  color: var(--text-primary) !important; font: 650 28px/1.15 var(--font-sans) !important; letter-spacing: -.02em; margin: 8px 0 4px; }
.stat-card .sub { font-size: 12.5px; color: var(--text-muted); }
.stat-card.clickable:hover { transform: none; box-shadow: var(--shadow-md) !important; border-color: var(--text-muted) !important; }

/* tables */
.data-table th { font: 600 11.5px/1.2 var(--font-sans) !important; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted) !important; background: transparent !important; border-bottom: 1px solid var(--surface-5) !important; }
.data-table td { font-size: 13.5px; border-bottom: 1px solid var(--surface-5) !important; }
.data-table tbody tr:hover td { background: var(--surface-4); }

/* buttons, tabs, badges */
.btn { font: 600 13px/1 var(--font-sans); border-radius: 8px; height: 34px; padding: 0 14px; border: 1px solid var(--surface-5); background: var(--surface-2); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--surface-4); }
.btn-primary, .btn.primary { background: var(--rb-red) !important; border-color: var(--rb-red) !important; color: #fff !important; }
.btn-primary:hover, .btn.primary:hover { background: var(--rb-red-dark) !important; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.tab-btn { font: 600 13px/1 var(--font-sans); color: var(--text-secondary); border-radius: 0; border-bottom: 2px solid transparent; background: transparent !important; }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }
.unit-badge { font: 600 11px/1 var(--font-sans); letter-spacing: .04em; border-radius: 999px; padding: 4px 9px; }
.unit-card-header h3, .unit-card-header .unit-name { font: 650 15px/1.2 var(--font-sans); }

/* charts and toasts keep their own colours; toasts get the quieter surface */
.toast { border-radius: 10px; border: 1px solid var(--surface-5); box-shadow: var(--shadow-lg) !important; }

/* phones: the top bar keeps the mark and the mode switch only */
@media (max-width: 768px) {
  .mode-bar-inner { gap: 8px; padding: 0 10px; }
  .mode-bar-brand { font-size: 0; gap: 0; }
  .mode-bar-user { display: none; }
  .mode-tab { padding: 7px 10px; }
}
@media (max-width: 380px) { .mode-tab .rb-ic-wrap { display: none; } }
