/* 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; }


/* ─────────────── MODERN GUI & GLASSMORPHISM ENHANCEMENTS ─────────────── */
.glass-card {
  background: rgba(21, 24, 28, 0.75) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.glass-card:hover {
  border-color: rgba(52, 211, 168, 0.3) !important;
  box-shadow: 0 12px 40px rgba(52, 211, 168, 0.15) !important;
  transform: translateY(-3px);
}

.kpi {
  background: rgba(25, 29, 35, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--info));
  opacity: 0.8;
}

.kpi.accent::before {
  background: linear-gradient(90deg, var(--accent), var(--danger));
}

.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.ai-insight-card {
  background: linear-gradient(135deg, rgba(52, 211, 168, 0.1), rgba(96, 165, 250, 0.08));
  border: 1px solid rgba(52, 211, 168, 0.25);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.ai-insight-card::after {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(52, 211, 168, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.pulse-dot {
  width: 8px; height: 8px;
  background-color: var(--brand);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(52, 211, 168, 0.7);
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 168, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(52, 211, 168, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 168, 0); }
}

.chart-btn-group {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.chart-btn-group button {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.chart-btn-group button.active {
  background: var(--brand);
  color: #0b0d0f;
  font-weight: 600;
}


/* ═════════════════════════ RESPONSIVE LAYER (2026-10) ═════════════════════════
 * Appended overrides only — nothing above was changed. Remove this block to roll back.
 * Breakpoints: ≤920 drawer menu · ≤720 phone · ≤380 small phone · ≥1900 wide screens
 */

/* 1. Let the content column shrink below the topbar's natural width.
 *    `1fr` = minmax(auto, 1fr), which forced phones to render ~450px wide. */
.app { grid-template-columns: 240px minmax(0, 1fr); overflow-x: clip; }
.app[data-sidebar="collapsed"] { grid-template-columns: 64px minmax(0, 1fr); }
.topbar, main.app-main { min-width: 0; }
.topbar-brand, .topbar-brand > div { min-width: 0; }
.card-head { flex-wrap: wrap; }

/* Desktop: sidebar stays in view while the page scrolls */
@media (min-width: 921px) {
  .sidebar { position: sticky; top: 0; height: 100vh; min-height: 0; overflow-y: auto; }
}

/* Drawer menu (tablet portrait + phone) */
@media (max-width: 920px) {
  .app, .app[data-sidebar] { grid-template-columns: minmax(0, 1fr); }
  .sidebar { width: min(280px, 86vw); overflow-y: auto; overscroll-behavior: contain; }
  .app[data-sidebar="open"] { overflow: hidden; }
}

/* Very wide screens: keep content at a readable width, centred */
@media (min-width: 1900px) {
  main.app-main {
    padding-left:  max(28px, calc((100% - 1680px) / 2));
    padding-right: max(28px, calc((100% - 1680px) / 2));
  }
}

/* 2. Tables scroll inside their card instead of pushing the page sideways
 *    (oneil.js wraps every table in .table-scroll) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-scroll > .table { margin: 0; }

/* 3. Phones */
@media (max-width: 720px) {
  main.app-main { padding: 14px 12px 40px; }

  .topbar { padding: 0 6px; gap: 2px; }
  .topbar-brand .name { font-size: 13px; }
  .topbar-brand .name small { display: none; }
  .topbar-actions { gap: 0; }
  .topbar-actions [aria-label="Notifications"] { display: none; }
  .user-pill { padding: 3px; gap: 0; }
  .user-pill > span:not(.avatar) { display: none; }

  .page-header { margin-bottom: 16px; gap: 10px; align-items: flex-start; }
  .page-header h1 { font-size: 22px; }
  .page-header .page-actions { width: 100%; }
  .page-header .page-actions > * { flex: 1 1 auto; justify-content: center; }
  .page-header .page-actions > form { display: flex !important; }
  .page-header .page-actions > form > * { flex: 1 1 0; min-width: 0; }

  .grid { gap: 12px; }
  .card { padding: 14px; border-radius: 12px; }
  .ai-insight-card { padding: 16px; }

  /* KPI tiles two per row; an odd last tile spans the row */
  .grid-12 > .kpi.col-3, .grid-12 > .kpi.col-4 { grid-column: span 6; }
  .grid-12 > .kpi.col-3:last-child:nth-child(odd),
  .grid-12 > .kpi.col-4:last-child:nth-child(odd) { grid-column: span 12; }
  .kpi { padding: 12px 14px 14px; }
  .kpi .label { font-size: 10px; letter-spacing: 0.05em; }
  .kpi .value { font-size: clamp(17px, 5.2vw, 24px); overflow-wrap: anywhere; }
  .kpi .footnote { font-size: 10.5px; }

  .table { font-size: 12.5px; }
  .table thead th { padding: 8px 10px; white-space: nowrap; }
  .table tbody td { padding: 9px 10px; }

  /* Pop-up forms fit the screen */
  dialog {
    width: calc(100vw - 20px) !important; max-width: 520px !important;
    max-height: calc(100dvh - 20px); overflow-y: auto; padding: 18px !important;
  }

  /* T&A month calendar (7 columns) */
  [style*="repeat(7"] { gap: 4px !important; font-size: 11px; }
  [style*="repeat(7"] > * { padding: 6px 2px !important; min-width: 0; overflow: hidden; }
}

@media (max-width: 380px) {
  .grid-12 > .kpi.col-3, .grid-12 > .kpi.col-4 { grid-column: span 12; }
}

/* 4. Touch screens: bigger targets, no 16px-zoom, no sticky hover effects */
@media (pointer: coarse) {
  .nav-item { padding: 11px 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .btn { min-height: 40px; }
  .chart-btn-group button { padding: 7px 14px; }
}
@media (max-width: 920px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px !important; }
}
@media (hover: none) {
  .kpi:hover, .glass-card:hover { transform: none; }
}
