/* O'Niel Caribbean Kitchen — design system
 * Single CSS, two themes via [data-theme]. No framework.
 * Tokens → primitives → components → page utilities.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap');

/* ─────────────── tokens (dark default) ─────────────── */
:root, [data-theme="dark"] {
  --bg:           #0b0d0f;
  --surface:      #15181c;
  --surface-2:    #1d2127;
  --surface-3:    #262a31;
  --border:       #272b32;
  --border-strong:#363b43;
  --text:         #f4f4f0;
  --text-muted:   #9aa0a6;
  --text-faint:   #6c7178;
  --brand:        #34d3a8;
  --brand-soft:   rgba(52, 211, 168, 0.12);
  --accent:       #ff8a5a;
  --accent-soft:  rgba(255, 138, 90, 0.14);
  --success:      #4ade80;
  --warning:      #facc15;
  --danger:       #f87171;
  --info:         #60a5fa;
  --kbd-bg:       #1f2329;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.30);
  --shadow:       0 4px 16px rgba(0,0,0,.30);
  --shadow-lg:    0 12px 48px rgba(0,0,0,.40);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:           #fafaf7;
  --surface:      #ffffff;
  --surface-2:    #f4f3ee;
  --surface-3:    #ebe9e2;
  --border:       #e8e6df;
  --border-strong:#d3d0c5;
  --text:         #1a1a1a;
  --text-muted:   #6b6b6b;
  --text-faint:   #9a9a9a;
  --brand:        #0d6e62;
  --brand-soft:   rgba(13, 110, 98, 0.10);
  --accent:       #e36a3b;
  --accent-soft:  rgba(227, 106, 59, 0.12);
  --success:      #2f9e6e;
  --warning:      #d97706;
  --danger:       #dc2626;
  --info:         #2563eb;
  --kbd-bg:       #f4f3ee;
  --shadow-sm:    0 1px 2px rgba(20,18,10,.04);
  --shadow:       0 4px 16px rgba(20,18,10,.06);
  --shadow-lg:    0 12px 48px rgba(20,18,10,.10);
  color-scheme: light;
}

/* ─────────────── reset + base ─────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
img, svg { display: block; max-width: 100%; }
.mono, code, kbd { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace; font-feature-settings: 'zero', 'ss02'; }

/* ─────────────── type scale ─────────────── */
.text-12 { font-size: 12px; line-height: 1.4; }
.text-13 { font-size: 13px; line-height: 1.45; }
.text-14 { font-size: 14px; line-height: 1.5; }
.text-16 { font-size: 16px; line-height: 1.5; }
.text-18 { font-size: 18px; line-height: 1.4; font-weight: 600; }
.text-24 { font-size: 24px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
.text-30 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.text-36 { font-size: 36px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; }
.t-muted { color: var(--text-muted); }
.t-faint { color: var(--text-faint); }
.t-label {
  font-size: 11px; font-weight: 600; line-height: 1.4;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
}

/* ─────────────── app shell ─────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: 64px 1fr; }
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .22s ease; z-index: 50; }
  .app[data-sidebar="open"] .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
  .app[data-sidebar="open"] .sidebar-scrim { display: block; }
}

/* ─────────────── topbar ─────────────── */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand img { height: 32px; width: auto; border-radius: 6px; }
.topbar-brand .name {
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-brand .name small { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: -2px; letter-spacing: 0.04em; }
.topbar-spacer { flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; min-width: 240px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 13px;
}
.topbar-search input {
  flex: 1; background: none; border: 0; outline: 0; color: var(--text); font: inherit;
}
.topbar-search kbd {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--kbd-bg); color: var(--text-muted); border: 1px solid var(--border);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
@media (max-width: 720px) { .topbar-search { display: none; } }

/* icon button (used in topbar + sidebar collapse) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--text-muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* user menu pill */
.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
}
.user-pill .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}

/* ─────────────── sidebar ─────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 100vh;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-head .mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-head .mark img { width: 28px; height: 28px; border-radius: 6px; }
.sidebar-head .mark .label {
  font-size: 13px; font-weight: 700; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app[data-sidebar="collapsed"] .sidebar-head .label,
.app[data-sidebar="collapsed"] .sidebar-section-label,
.app[data-sidebar="collapsed"] .nav-item-label,
.app[data-sidebar="collapsed"] .sidebar-foot { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 10px 12px; }
.app[data-sidebar="collapsed"] .sidebar-head { padding: 0 12px; justify-content: center; }

.sidebar-section { padding: 12px 12px 4px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 8px 8px; margin-top: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 1.75; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--brand-soft); color: var(--brand);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-children { margin: 2px 0 6px 28px; display: flex; flex-direction: column; gap: 1px; }
.nav-children .nav-item { padding: 6px 10px; font-size: 13px; }

.sidebar-foot {
  margin-top: auto; padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-size: 12px; color: var(--text-faint);
}

/* ─────────────── main + page ─────────────── */
main.app-main { grid-area: main; padding: 24px 28px 48px; min-width: 0; }
@media (max-width: 720px) { main.app-main { padding: 16px; } }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-header h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-header .crumb { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.page-header .page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─────────────── grid ─────────────── */
.grid { display: grid; gap: 16px; }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }
@media (max-width: 1100px) { .col-3, .col-4 { grid-column: span 6; } .col-5, .col-7 { grid-column: span 12; } .col-8, .col-9 { grid-column: span 12; } }
@media (max-width: 720px)  { .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { grid-column: span 12; } }

/* ─────────────── card ─────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-head .meta { font-size: 12px; color: var(--text-muted); }

/* KPI tile */
.kpi {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 18px;
  position: relative;
  overflow: hidden;
}
.kpi .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.kpi .value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.15; margin-top: 4px;
}
.kpi .delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi .delta.up   { color: var(--success); }
.kpi .delta.dn   { color: var(--danger); }
.kpi .delta.flat { color: var(--text-muted); }
.kpi .footnote { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.kpi.brand::before, .kpi.accent::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.kpi.brand::before  { background: var(--brand); }
.kpi.accent::before { background: var(--accent); }

/* ─────────────── badges, pills, buttons ─────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.brand   { background: var(--brand-soft);   color: var(--brand);   border-color: transparent; }
.badge.accent  { background: var(--accent-soft);  color: var(--accent);  border-color: transparent; }
.badge.success { background: rgba(74,222,128,.12);  color: var(--success); border-color: transparent; }
.badge.warning { background: rgba(250,204,21,.12);  color: var(--warning); border-color: transparent; }
.badge.danger  { background: rgba(248,113,113,.12); color: var(--danger);  border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn svg { width: 16px; height: 16px; stroke-width: 2; }

/* ─────────────── tables ─────────────── */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-family: 'JetBrains Mono', monospace; text-align: right; font-weight: 500; }

/* ─────────────── status bar (small) ─────────────── */
.status-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.status-bar .item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.status-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-bar .dot.on { background: var(--success); box-shadow: 0 0 0 4px rgba(74,222,128,.18); }
.status-bar .dot.off { background: var(--text-faint); }

/* ─────────────── divider ─────────────── */
.hr { height: 1px; background: var(--border); margin: 18px 0; }

/* ─────────────── theme toggle visual ─────────────── */
.icon-btn[data-theme-toggle] svg.sun { display: none; }
[data-theme="light"] .icon-btn[data-theme-toggle] svg.sun { display: block; }
[data-theme="light"] .icon-btn[data-theme-toggle] svg.moon { display: none; }
