@import url('/vendor/inter/index.css');

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --border: #e6e5e1;
  --border-strong: #d4d3ce;
  --text: #121211;
  --text-2: #52514e;
  --text-3: #85847f;
  --accent: #2a78d6;
  --accent-soft: #e8f1fc;
  --sidebar: #0f1720;
  --sidebar-text: #c9ced6;
  --sidebar-active: #1d2733;
  --grid: #ecebe7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --tag-pos-bg: #eef0f2; --tag-pos: #3b4652;
  --tag-est-bg: #fff4dc; --tag-est: #8a5a00;
  --tag-rec-bg: #e8f1fc; --tag-rec: #1c5cab;
  --tag-time-bg: #efedfb; --tag-time: #4a3aa7;
  --shadow: 0 1px 2px rgba(16, 24, 32, .04), 0 1px 1px rgba(16, 24, 32, .03);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #20201f; --border: #2c2c2a; --border-strong: #3a3a37;
    --text: #f5f5f3; --text-2: #c3c2b7; --text-3: #8f8e86; --accent: #3987e5; --accent-soft: #17283d;
    --sidebar: #0b0f14; --sidebar-text: #b7bdc6; --sidebar-active: #18212b; --grid: #2a2a28;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --tag-pos-bg: #262a2f; --tag-pos: #c9d0d8; --tag-est-bg: #33280f; --tag-est: #f3c463;
    --tag-rec-bg: #17283d; --tag-rec: #8fbcf0; --tag-time-bg: #252142; --tag-time: #b6adf2;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #20201f; --border: #2c2c2a; --border-strong: #3a3a37;
  --text: #f5f5f3; --text-2: #c3c2b7; --text-3: #8f8e86; --accent: #3987e5; --accent-soft: #17283d;
  --sidebar: #0b0f14; --sidebar-text: #b7bdc6; --sidebar-active: #18212b; --grid: #2a2a28;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --tag-pos-bg: #262a2f; --tag-pos: #c9d0d8; --tag-est-bg: #33280f; --tag-est: #f3c463;
  --tag-rec-bg: #17283d; --tag-rec: #8fbcf0; --tag-time-bg: #252142; --tag-time: #b6adf2;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
  font-feature-settings: 'tnum' 1, 'cv11' 1; -webkit-font-smoothing: antialiased;
}
svg.lucide { width: 16px; height: 16px; stroke-width: 1.75; flex: none; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2a78d6, #1c5cab);
  display: grid; place-items: center;
}
.brand-mark svg.lucide { width: 18px; height: 18px; color: #fff; }
.brand b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: #8a94a3; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7685; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #3987e5; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #6b7685; padding: 10px; border-top: 1px solid #1f2933; }
.sidebar-foot button { color: var(--sidebar-text); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 14px 28px; flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: -.015em; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.content { padding: 24px 28px 96px; max-width: 1440px; }

/* Controls */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
.seg button.on { background: var(--text); color: var(--surface); }
.date-inputs { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); }
input[type=date], input[type=time], input[type=number], input[type=text], input[type=password] {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 7px; color: inherit; display: inline-flex; }
.icon-btn:hover { background: var(--border); }

/* Tags: what kind of number this is */
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 8px 2px 6px; border-radius: 999px; white-space: nowrap;
}
.tag svg.lucide { width: 12px; height: 12px; stroke-width: 2; }
.tag.pos { background: var(--tag-pos-bg); color: var(--tag-pos); }
.tag.est { background: var(--tag-est-bg); color: var(--tag-est); }
.tag.rec { background: var(--tag-rec-bg); color: var(--tag-rec); }
.tag.time { background: var(--tag-time-bg); color: var(--tag-time); }
.legend-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Cards */
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-kpi.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.card-h p { margin: 3px 0 0; color: var(--text-3); font-size: 12.5px; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 360px; }
.chart.short { height: 220px; }

.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.delta { font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }

/* Split bar: where gross sales go */
.split { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; margin: 6px 0 14px; }
.split > div { height: 100%; }
.split-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.split-legend .item { display: flex; gap: 10px; align-items: flex-start; }
.swatch { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; flex: none; }
.split-legend b { display: block; font-size: 16px; font-weight: 600; }
.split-legend span { color: var(--text-3); font-size: 12px; }

/* Insights */
.insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: var(--surface-2);
  display: flex; gap: 12px;
}
.insight .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.insight h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.insight p { margin: 0; color: var(--text-2); font-size: 12.5px; }
.insight .big { font-size: 18px; font-weight: 600; color: var(--text); letter-spacing: -.02em; margin: 2px 0 4px; display: block; }

/* Tables */
.table-wrap { overflow: auto; max-height: 440px; overscroll-behavior: contain; border-radius: 8px; }
.table-wrap thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
.table-wrap tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 1px 0 var(--border-strong); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); }
tbody tr:hover { background: var(--surface-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.muted { color: var(--text-3); }
.scroll-y { max-height: 440px; overflow: auto; }

/* Notes and status */
.note {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--text-2); font-size: 12.5px;
}
.note svg.lucide { margin-top: 1px; color: var(--text-3); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.status.good svg { color: var(--good); }
.status.warning svg { color: #b57f00; }
.status.critical svg { color: var(--critical); }
.status.critical { color: var(--text-2); }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }
.section-title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.section-title span { color: var(--text-3); font-size: 12.5px; }

/* Settings */
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 10px 16px; align-items: center; }
.form-grid label { color: var(--text-2); font-size: 13px; }
.form-grid input { width: 100%; }
.saved { color: var(--good); font-size: 12.5px; display: none; align-items: center; gap: 6px; }
.saved.show { display: inline-flex; }

.loading { padding: 80px 0; text-align: center; color: var(--text-3); }
.error { color: var(--critical); }

/* Chat */
.chat {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 20;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(16, 24, 32, .12);
  display: flex; flex-direction: column;
}
.chat[hidden] { display: none; }
.chat-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; }
.chat-resize::after { content: ''; position: absolute; left: 3px; top: 50%; width: 2px; height: 40px; margin-top: -20px; border-radius: 2px; background: var(--border-strong); opacity: 0; transition: opacity .15s; }
.chat-resize:hover::after, .chat-resize:focus-visible::after, .chat.resizing .chat-resize::after { opacity: 1; background: var(--accent); }
.chat.resizing { user-select: none; }
.chat-table { overflow-x: auto; margin: 6px 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.chat-table table { font-size: 12.5px; }
.chat-table th { background: var(--surface-2); font-size: 11.5px; padding: 7px 10px; }
.chat-table td { padding: 7px 10px; }
.chat-table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 860px) { .chat { width: 100vw !important; } .chat-resize { display: none; } }
.chat-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-title { display: flex; gap: 10px; align-items: center; }
.chat-title b { display: block; font-size: 14px; }
.chat-title span { color: var(--text-3); font-size: 12px; }
.chat-title .kpi-icon { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 94%; font-size: 13.5px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); padding: 11px 14px; border-radius: 14px 14px 14px 4px; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 18px; } .msg.bot li { margin: 2px 0; }
.msg.bot.err { color: var(--critical); }
.msg-src { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 11.5px; }
.msg-src svg.lucide { width: 13px; height: 13px; }
.msg-check { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; font-size: 11.5px; }
.msg-check svg.lucide { width: 13px; height: 13px; margin-top: 1px; }
.msg-check.ok { color: var(--text-3); } .msg-check.ok svg { color: var(--good); }
.msg-check.warn { color: #9a6700; } .msg-check.warn svg { color: #b57f00; }
.typing { display: inline-flex; gap: 4px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.suggest { display: flex; flex-direction: column; gap: 8px; }
.suggest p { color: var(--text-3); font-size: 12.5px; margin: 0 0 2px; }
.suggest button { text-align: left; font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.suggest button:hover { border-color: var(--accent); }
.suggest svg.lucide { color: var(--accent); }
.chat-input { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; outline: none; max-height: 140px; }
.chat-input textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input .btn { padding: 9px 11px; }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

/* Floating chat button: on every page */
.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 15; display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 12px 18px 12px 16px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px rgba(42, 120, 214, .35);
}
.fab:hover { filter: brightness(1.06); }
.fab[hidden] { display: none; }
.fab svg.lucide { width: 18px; height: 18px; }
.threads { display: flex; flex-direction: column; gap: 6px; }
.thread { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 2px 4px 2px 2px; background: var(--surface); }
.thread.on { border-color: var(--accent); }
.thread-open { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: 9px 10px; cursor: pointer; }
.thread-open svg.lucide { color: var(--text-3); margin-top: 2px; }
.thread-open span { min-width: 0; }
.thread-open b { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-open small { color: var(--text-3); font-size: 11.5px; }
.thread .icon-btn { color: var(--text-3); }
.thread .icon-btn:hover { color: var(--critical); }
.danger-link { margin-top: 14px; align-self: flex-start; color: var(--critical); border-color: transparent; background: transparent; padding-left: 4px; }
.danger-link:hover { border-color: var(--border); }
.chat-input[hidden] { display: none; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(16, 24, 32, .08); }
.login-card h1 { font-size: 20px; margin: 18px 0 4px; letter-spacing: -.02em; }
.login-card p { color: var(--text-3); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; font-size: 12.5px; color: var(--text-2); margin: 12px 0 6px; font-weight: 500; }
.login-card input { width: 100%; padding: 10px 12px; font-size: 14px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; font-size: 14px; }

@media (max-width: 1100px) {
  .g-3, .g-21 { grid-template-columns: 1fr; }
  .g-kpi, .g-kpi.six, .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px 16px; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .nav-label, .sidebar-foot { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .g-2, .g-kpi, .g-kpi.six, .insights { grid-template-columns: 1fr; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}
