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

:root {
  --ink-900: #111827;
  --ink-800: #1f2937;
  --ink-700: #374151;
  --nav-900: #101522;
  --nav-800: #172033;
  --page: #f4f6f1;
  --surface-0: #ffffff;
  --surface-50: #f7f8f4;
  --surface-100: #edf0e8;
  --line: #dfe4d8;

  --amber: #c9792b;
  --amber-ink: #8a4b18;
  --amber-soft: #fff0dc;
  --copper: #a85f2a;
  --emerald: #168a61;
  --emerald-ink: #0c5f43;
  --emerald-soft: #ddf5ea;
  --azure: #3267a8;
  --azure-ink: #204a7f;
  --azure-soft: #e1ecfb;
  --magenta: #b14f5f;
  --magenta-ink: #8f2f42;
  --magenta-soft: #f9e2e6;
  --violet: #6f5b9a;
  --violet-ink: #4d3c76;
  --violet-soft: #ebe6f6;

  --text-900: #17172b;
  --text-700: #4e5268;
  --text-500: #747990;
  --text-400: #9aa0ae;
  --gradient-brand: linear-gradient(135deg, #c9792b 0%, #e0a348 100%);

  --font-display: "Inter", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--page);
  color: var(--text-900);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalPop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(22,138,97,.25); } 70% { box-shadow: 0 0 0 10px rgba(22,138,97,0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.section.active { animation: fadeInUp .25s ease both; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--nav-900), #0b101c);
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #171006;
  flex-shrink: 0;
  box-shadow: 0 10px 24px -16px rgba(224,163,72,.9);
}
.brand-text { line-height: 1.15; }
.brand-text strong { font-size: 16px; font-weight: 800; display: block; letter-spacing: -.01em; }
.brand-text span { font-size: 10.5px; color: rgba(255,255,255,.52); letter-spacing: .09em; text-transform: uppercase; }
.nav-group { margin-bottom: 22px; }
.sidebar nav { overflow-y: auto; min-height: 0; padding-right: 2px; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 999px; }
.nav-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.38); padding: 0 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.72); font-size: 14px; font-weight: 550;
  margin-bottom: 3px; transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(2px); }
.nav-item.active { background: #ffffff; color: var(--nav-900); font-weight: 750; box-shadow: 0 12px 24px -20px rgba(0,0,0,.5); }
.nav-item .ic { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .badge-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .badge-count { background: var(--surface-100); color: var(--text-700); }
.sidebar-foot { margin-top: 14px; flex-shrink: 0; padding: 14px 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .plan-label { font-size: 10.5px; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .08em; }
.sidebar-foot .plan-name { font-weight: 800; font-size: 16px; margin: 3px 0 9px; }
.sidebar-foot .upgrade-btn { display: block; text-align: center; font-size: 13px; font-weight: 750; background: #e0a348; color: #201305; padding: 9px; border-radius: var(--radius-sm); transition: filter .18s, transform .15s; }
.sidebar-foot .upgrade-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 36px; background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 25px; font-weight: 800; margin: 0; letter-spacing: -.025em; }
.topbar .sub { font-size: 13.5px; color: var(--text-500); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.store-pill { display: flex; align-items: center; gap: 10px; background: var(--surface-0); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 6px; }
.store-pill .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--amber-soft); color: var(--amber-ink); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.store-pill .name { font-size: 13.5px; font-weight: 700; }
.store-pill .loc { font-size: 11px; color: var(--text-500); }
.content { padding: 30px 36px 60px; }
.section { display: none; }
.section.active { display: block; }

.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; border: 1px solid currentColor;
}
.stamp.amber { color: var(--amber-ink); background: var(--amber-soft); }
.stamp.emerald { color: var(--emerald-ink); background: var(--emerald-soft); }
.stamp.magenta { color: var(--magenta-ink); background: var(--magenta-soft); }
.stamp.azure { color: var(--azure-ink); background: var(--azure-soft); }
.stamp.ink { color: var(--text-700); background: var(--surface-50); border-color: var(--line); }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.card {
  background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 22px 24px; box-shadow: 0 18px 50px -44px rgba(17,24,39,.55);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-1px); border-color: #cbd3c3; box-shadow: 0 20px 50px -40px rgba(17,24,39,.72); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.card-head .hint { font-size: 12.5px; color: var(--text-500); }
.kpi { border-left: 4px solid var(--line); position: relative; overflow: hidden; }
.kpi.amber { border-left-color: var(--amber); }
.kpi.magenta { border-left-color: var(--magenta); }
.kpi.emerald { border-left-color: var(--emerald); }
.kpi.azure { border-left-color: var(--azure); }
.kpi .label { font-size: 12px; color: var(--text-500); text-transform: uppercase; letter-spacing: .07em; font-weight: 800; }
.kpi .value { font-family: var(--font-mono); font-size: 29px; font-weight: 650; margin: 7px 0 3px; letter-spacing: -.03em; }
.kpi .delta { font-size: 12.5px; color: var(--text-500); }

.btn {
  border: none; border-radius: var(--radius-sm); padding: 9px 15px;
  font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .14s ease, box-shadow .18s ease, opacity .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink-900); color: #fff; box-shadow: 0 12px 28px -20px rgba(17,24,39,.75); }
.btn-amber { background: #e0a348; color: #201305; }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-magenta { background: var(--magenta); color: #fff; }
.btn-ghost { background: var(--surface-100); color: var(--text-700); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--text-700); }
.btn-outline:hover { border-color: var(--ink-700); color: var(--text-900); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; filter: none !important; }
.btn-block { width: 100%; justify-content: center; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-500); font-weight: 800; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid var(--surface-100); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.row-clickable { transition: background .15s ease; }
tr.row-clickable:hover { background: var(--surface-50); cursor: pointer; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.cell-name { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--text-500); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 750; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.paid, .chip.completed, .chip.confirmed, .chip.delivered, .chip.approved { background: var(--emerald-soft); color: var(--emerald-ink); }
.chip.pending_payment, .chip.pending_review, .chip.pending_collection, .chip.pending, .chip.draft, .chip.pending_approval { background: var(--amber-soft); color: var(--amber-ink); }
.chip.fulfilling, .chip.sent, .chip.assigned, .chip.out_for_delivery, .chip.accepted, .chip.needs_info { background: var(--azure-soft); color: var(--azure-ink); }
.chip.cancelled, .chip.failed, .chip.declined { background: var(--magenta-soft); color: var(--magenta-ink); }
.chip.partially_paid { background: var(--amber-soft); color: var(--amber-ink); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-700); margin-bottom: 6px; }
.field input, .field select, .field textarea, .thread-actions input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  font-family: var(--font-body); font-size: 14px; background: var(--surface-0); color: var(--text-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .field textarea::placeholder, .thread-actions input::placeholder { color: var(--text-400); }
.field input:focus, .field select:focus, .field textarea:focus, .thread-actions input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(201,121,43,.14); }
.field input[disabled] { color: var(--text-500); background: var(--surface-50); }

.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-0); min-height: 560px; }
.thread-list { border-right: 1px solid var(--line); overflow-y: auto; }
.thread-item { padding: 16px 18px; border-bottom: 1px solid var(--surface-100); cursor: pointer; transition: background .15s ease; }
.thread-item:hover, .thread-item.active { background: var(--surface-50); }
.thread-item .top-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.thread-item .t-name { font-weight: 800; font-size: 14px; }
.thread-item .t-time { font-size: 11px; color: var(--text-400); }
.thread-item .t-preview { font-size: 12.5px; color: var(--text-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-pane { display: flex; flex-direction: column; }
.thread-pane-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.thread-messages { flex: 1; padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--surface-50); }
.bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; animation: popIn .2s ease both; }
.bubble.inbound { align-self: flex-start; background: var(--surface-0); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.outbound { align-self: flex-end; background: var(--emerald); color: #fff; border-bottom-right-radius: 4px; }
.bubble .time { display: block; font-size: 10.5px; opacity: .65; margin-top: 4px; }
.thread-actions { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.thread-actions input { flex: 1; }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; }
.kanban-col { background: var(--surface-50); border-radius: var(--radius-md); padding: 14px; min-height: 200px; border: 1px solid var(--line); }
.kanban-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 12px; color: var(--text-500); }
.kanban-card { background: var(--surface-0); border-radius: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); font-size: 13px; transition: transform .15s ease, border-color .15s ease; }
.kanban-card:hover { transform: translateY(-2px); border-color: var(--amber); }
.kanban-card .kc-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-500); }
.kanban-card .kc-driver { font-size: 12px; color: var(--text-500); margin-top: 4px; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; cursor: pointer; inset: 0; background: var(--surface-100); border: 1.5px solid var(--line); border-radius: 30px; transition: background .2s ease; }
.switch-track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 2.5px; background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 4px rgba(0,0,0,.22); }
.switch input:checked + .switch-track { background: var(--emerald); border-color: transparent; }
.switch input:checked + .switch-track::before { transform: translateX(17px); }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--page); }
.login-card { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 40px 36px; width: 380px; max-width: 90vw; animation: modalPop .28s ease both; box-shadow: 0 28px 70px -44px rgba(17,24,39,.75); }
.login-card h1 { font-size: 22px; text-align: center; margin: 0 0 4px; font-weight: 800; }
.empty { text-align: center; padding: 50px 20px; color: var(--text-400); }
.empty .ic-empty { font-size: 32px; margin-bottom: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar-label { width: 110px; font-size: 13px; color: var(--text-700); flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--surface-100); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar-row .bar-val { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-500); width: 30px; text-align: right; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink-900); border: 1px solid rgba(255,255,255,.12); color: #fff; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 650; z-index: 50; opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .25s ease, transform .25s ease; box-shadow: 0 18px 40px -20px rgba(0,0,0,.55); }
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.46); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 40; animation: fadeInUp .18s ease both; }
.modal { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px; width: 440px; max-width: 92vw; max-height: 86vh; overflow-y: auto; animation: modalPop .2s ease both; box-shadow: 0 30px 80px -40px rgba(17,24,39,.8); }
.modal h3 { margin: 0 0 16px; font-weight: 800; }
.modal-close-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .two-col, .inbox { grid-template-columns: 1fr; } .kanban { grid-template-columns: repeat(2,1fr); } }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.tag-collection { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-500); }
.muted { color: var(--text-500); }

.signal-fab {
  position: fixed; bottom: 26px; right: 26px; z-index: 70;
  width: 58px; height: 58px; border-radius: 16px;
  background: var(--ink-900);
  border: 1px solid rgba(255,255,255,.12); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 18px 40px -24px rgba(17,24,39,.9);
  transition: transform .18s ease, background .18s ease;
}
.signal-fab:hover { transform: translateY(-2px); background: var(--ink-800); }
.signal-fab svg { width: 28px; height: 28px; }
.signal-badge {
  position: absolute; top: -6px; right: -6px; min-width: 21px; height: 21px; border-radius: 50%;
  background: var(--emerald); color: #fff; font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  box-shadow: 0 0 0 3px var(--page);
}
.signal-badge.urgent { animation: pulseGlow 1.8s infinite; }
.signal-panel {
  position: fixed; bottom: 98px; right: 26px; z-index: 70;
  width: 360px; max-height: 70vh; display: flex; flex-direction: column;
  background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -42px rgba(17,24,39,.85);
  transform-origin: bottom right; animation: modalPop .2s ease both; overflow: hidden;
  color: var(--text-900);
}
.signal-panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--ink-900); color: #fff; }
.signal-panel-head .signal-avatar { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; background: rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center; }
.signal-panel-head .signal-avatar svg { width: 22px; height: 22px; }
.signal-panel-head strong { font-size: 15px; display: block; font-weight: 800; }
.signal-panel-head span { font-size: 11.5px; opacity: .72; }
.signal-panel-close { margin-left: auto; background: rgba(255,255,255,.09); border: none; color: #fff; width: 28px; height: 28px; border-radius: 8px; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.signal-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; color: var(--text-900); }
.signal-insight { display: flex; gap: 10px; padding: 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; background: #fbfbf7; border: 1px solid var(--line); color: var(--text-900); cursor: pointer; transition: transform .15s ease, border-color .15s ease; animation: popIn .2s ease both; }
.signal-insight:hover { transform: translateX(2px); border-color: var(--amber); }
.signal-insight .mi-icon { width: 9px; height: 9px; border-radius: 50%; background: var(--azure); margin-top: 5px; flex-shrink: 0; }
.signal-insight.urgent .mi-icon { background: var(--magenta); }
.signal-insight.warning .mi-icon { background: var(--amber); }
.signal-insight.positive .mi-icon { background: var(--emerald); }
.signal-panel-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.signal-panel-foot input { flex: 1; background: var(--surface-0); border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text-900); font-size: 13px; font-family: var(--font-body); }
.signal-panel-foot input:focus { outline: none; border-color: var(--amber); }
.signal-panel-foot button { background: var(--ink-900); color: #fff; border: none; border-radius: var(--radius-sm); width: 38px; flex-shrink: 0; font-weight: 800; }
.signal-loading { text-align: center; padding: 30px 0; color: var(--text-500); font-size: 13px; }

