/* ============================================================
   Falcon Shield OS — shared design system
   Fire & safety / trading operating-system demo
   ============================================================ */

:root {
  /* -- neutrals (cool navy-grey, not pure grey) -- */
  --ink-950: #0a1626;
  --ink-900: #0e1e33;
  --ink-800: #16293f;
  --ink-700: #223752;
  --ink-500: #4d6079;
  --ink-300: #8496ac;
  --ink-200: #b8c4d3;
  --line: #e1e7f0;
  --line-soft: #edf1f6;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --canvas-alt: #eaeff6;

  /* -- brand -- */
  --brand-800: #0d3a7a;
  --brand-700: #144d9e;
  --brand-600: #1c5fc4;
  --brand-500: #2f74e0;
  --brand-100: #e4edfc;
  --brand-50: #f1f6fd;

  /* -- AI accent (warm, distinct from brand blue) -- */
  --ai-600: #b8791f;
  --ai-500: #d4941f;
  --ai-100: #fbeed6;
  --ai-50: #fdf6ea;

  /* -- status -- */
  --good-600: #157347;
  --good-100: #dff3e7;
  --warn-600: #a45a05;
  --warn-100: #faecd2;
  --crit-600: #b3261e;
  --crit-100: #fbe1df;
  --info-600: #1c5fc4;
  --info-100: #e4edfc;
  --hold-600: #6b4fa0;
  --hold-100: #ece5f7;

  /* -- categorical (fixed order: divisions) -- */
  --cat-trading: #1c5fc4;
  --cat-fire: #158a72;
  --cat-cleaning: #8452c9;
  --cat-amc: #d4941f;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(14, 30, 51, 0.06);
  --shadow: 0 4px 16px rgba(14, 30, 51, 0.08);
  --shadow-lg: 0 12px 32px rgba(14, 30, 51, 0.14);

  --sidebar-w: 248px;
  --topbar-h: 64px;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: "Sora", "Inter", sans-serif;
  color: var(--ink-950);
  margin: 0 0 4px;
  text-wrap: balance;
  font-weight: 600;
}
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; color: var(--ink-500); }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
[hidden] { display: none !important; }
button { font-family: inherit; }
::selection { background: var(--brand-100); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------- layout shell ---------------- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--ink-950), var(--ink-900) 60%);
  color: #cfdcee;
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-800));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: "Sora", sans-serif; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(28,95,196,0.4);
}
.brand-text { line-height: 1.2; min-width: 0; }
.brand-text strong { display: block; color: #fff; font-family: "Sora", sans-serif; font-size: 13.5px; font-weight: 600; }
.brand-text span { font-size: 10.5px; color: #8fa3c0; text-transform: uppercase; letter-spacing: .06em; }

.nav-scroll { flex: 1; padding: 10px 10px 14px; }
.nav-group { margin-bottom: 4px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: #61789e; padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: #c2d1e6; font-size: 13.2px; font-weight: 500;
  cursor: pointer;
}
.nav-item .ic { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(47,116,224,0.22); color: #fff; box-shadow: inset 2px 0 0 var(--brand-500); }
.nav-item .badge-dot {
  margin-left: auto; font-size: 10.5px; font-weight: 700;
  background: var(--crit-600); color: #fff; border-radius: 20px;
  padding: 1px 6px; line-height: 1.4;
}
.nav-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px; color: #6f86a9;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  gap: 16px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { flex-shrink: 0; }
.topbar-sub { font-size: 12px; color: var(--ink-300); margin-top: -2px; }
.topbar-spacer { flex: 1; }
.top-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--canvas-alt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; width: 240px; color: var(--ink-300);
  font-size: 12.5px;
}
.top-search svg { flex-shrink: 0; }
.top-icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-500); position: relative;
}
.top-icon-btn:hover { background: var(--canvas-alt); }
.top-icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--crit-600); border: 1.5px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); cursor: pointer; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; font-family: "Sora", sans-serif;
  flex-shrink: 0;
}
.user-chip .who { line-height: 1.25; }
.user-chip .who strong { display: block; font-size: 12.5px; color: var(--ink-900); }
.user-chip .who span { font-size: 11px; color: var(--ink-300); }

.content {
  padding: 22px 26px 60px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head .eyebrow {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--brand-600); margin-bottom: 4px;
}
.page-head p { max-width: 62ch; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.demo-banner {
  background: var(--ai-50); border: 1px solid var(--ai-100);
  color: #7a5313; border-radius: var(--radius); padding: 10px 14px;
  font-size: 12.3px; display: flex; gap: 9px; align-items: flex-start;
  margin-bottom: 18px;
}
.demo-banner svg { flex-shrink: 0; margin-top: 1px; color: var(--ai-600); }
.demo-banner strong { color: #5f4110; }

/* ---------------- primitives ---------------- */
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-12 { grid-template-columns: repeat(12, 1fr); }
@media (max-width: 1080px) { .g-4 { grid-template-columns: repeat(2,1fr); } .g-3 { grid-template-columns: repeat(2,1fr);} .g-12 > * { grid-column: 1 / -1 !important; } }
@media (max-width: 640px) { .g-4, .g-3, .g-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.card-head .hint { font-size: 12px; color: var(--ink-300); }

.stat-tile { display: flex; flex-direction: column; gap: 6px; }
.stat-tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-300); font-weight: 600; }
.stat-tile .value { font-family: "Sora", sans-serif; font-size: 26px; font-weight: 700; color: var(--ink-950); }
.stat-tile .delta { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.stat-tile .delta.up { color: var(--good-600); }
.stat-tile .delta.down { color: var(--crit-600); }
.stat-tile .delta.flat { color: var(--ink-300); }
.stat-tile .sub { font-size: 11.5px; color: var(--ink-300); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-700);
  font-size: 12.8px; font-weight: 600; padding: 8px 14px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--canvas-alt); text-decoration: none; }
.btn.primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn.primary:hover { background: var(--brand-700); }
.btn.ai { background: var(--ai-500); border-color: var(--ai-500); color: #fff; }
.btn.ai:hover { background: var(--ai-600); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--canvas-alt); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: var(--crit-600); border-color: var(--crit-100); }
.btn.danger:hover { background: var(--crit-100); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.3px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-100); color: var(--good-600); }
.pill.warn { background: var(--warn-100); color: var(--warn-600); }
.pill.crit { background: var(--crit-100); color: var(--crit-600); }
.pill.info { background: var(--info-100); color: var(--info-600); }
.pill.hold { background: var(--hold-100); color: var(--hold-600); }
.pill.neutral { background: var(--canvas-alt); color: var(--ink-500); }

.tag {
  display: inline-flex; padding: 2px 8px; border-radius: 5px;
  font-size: 10.8px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.tag.trading { background: #e4edfc; color: var(--cat-trading); }
.tag.fire { background: #dff4ef; color: var(--cat-fire); }
.tag.cleaning { background: #efe7fa; color: var(--cat-cleaning); }
.tag.amc { background: #faecd2; color: var(--cat-amc); }

table { border-collapse: collapse; width: 100%; font-size: 12.8px; }
.table-wrap { overflow-x: auto; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-300); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-700); vertical-align: middle; }
tbody tr:hover { background: var(--canvas-alt); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-title { font-weight: 600; color: var(--ink-950); }
.row-sub { font-size: 11.5px; color: var(--ink-300); }

.progress { height: 6px; border-radius: 20px; background: var(--canvas-alt); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 20px; background: var(--brand-600); }
.progress.warn > span { background: var(--warn-600); }
.progress.crit > span { background: var(--crit-600); }
.progress.good > span { background: var(--good-600); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 10px 4px; margin-right: 18px; font-size: 13px; font-weight: 600;
  color: var(--ink-300); border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--brand-600); border-color: var(--brand-600); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--ink-500); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink-900);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-100); border-color: var(--brand-500); }
.field .help { font-size: 11px; color: var(--ink-300); }

.kanban { display: grid; grid-template-columns: repeat(8, minmax(210px,1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kanban-col { background: var(--canvas-alt); border-radius: var(--radius); padding: 10px; min-width: 210px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; }
.kanban-col-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }
.kanban-count { font-size: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1px 7px; color: var(--ink-500); font-weight: 700; }
.k-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 9px; box-shadow: var(--shadow-sm); cursor: pointer; }
.k-card:hover { border-color: var(--brand-500); }
.k-card .k-cust { font-weight: 700; font-size: 12.6px; color: var(--ink-950); margin-bottom: 3px; }
.k-card .k-meta { font-size: 11px; color: var(--ink-300); display: flex; justify-content: space-between; margin-top: 8px; }
.k-card .k-val { font-weight: 700; color: var(--brand-700); font-size: 12.5px; }

.timeline { display: flex; flex-direction: column; }
.t-step { display: flex; gap: 12px; position: relative; padding-bottom: 20px; }
.t-step:last-child { padding-bottom: 0; }
.t-step .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--good-100); color: var(--good-600); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 11px; font-weight: 800; z-index: 1; }
.t-step.pending .dot { background: var(--canvas-alt); color: var(--ink-300); }
.t-step.active .dot { background: var(--brand-100); color: var(--brand-600); }
.t-step:not(:last-child)::before { content:""; position: absolute; left: 9px; top: 22px; bottom: -2px; width: 2px; background: var(--line); }
.t-body strong { display: block; font-size: 12.8px; color: var(--ink-950); }
.t-body span { font-size: 11.5px; color: var(--ink-300); }

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,22,38,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 620px; max-width: 100%;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-close { border: none; background: var(--canvas-alt); width: 28px; height: 28px; border-radius: 7px; cursor: pointer; color: var(--ink-500); font-size: 15px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-300); }

.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--ink-500); cursor: pointer; background: var(--surface); }
.chip.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.source-note {
  border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px;
  font-size: 11px; color: var(--ink-300); display: flex; gap: 6px; align-items: center;
}

/* legend / chart bits */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-500); }
.legend .li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 9px; height: 9px; border-radius: 2px; }
.axis-label { font-size: 10px; fill: var(--ink-300); }

.mobile-frame {
  width: 340px; max-width: 100%; background: var(--ink-950); border-radius: 34px; padding: 12px;
  box-shadow: var(--shadow-lg); margin: 0 auto;
}
.mobile-screen { background: var(--canvas); border-radius: 24px; overflow: hidden; min-height: 640px; display: flex; flex-direction: column; }
.mobile-status { display:flex; justify-content: space-between; padding: 10px 18px 2px; font-size: 11px; font-weight: 700; color: var(--ink-900); }
.mobile-topbar { padding: 6px 16px 14px; }
.mobile-topbar h2 { color: #fff; }
.mobile-topbar.dark { background: linear-gradient(135deg, var(--brand-700), var(--ink-900)); padding-top: 14px; padding-bottom: 18px; border-radius: 0 0 20px 20px; margin-bottom: -8px; }
.mobile-topbar.dark p { color: #c9dbfa; margin: 0; font-size: 12px; }
.mobile-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.mobile-card { background: var(--surface); border-radius: 14px; padding: 13px; border: 1px solid var(--line); }
.mobile-tabbar { display: flex; border-top: 1px solid var(--line); background: var(--surface); padding: 8px 6px; }
.mobile-tabbar .mt-item { flex: 1; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--ink-300); display:flex; flex-direction:column; align-items:center; gap:3px; }
.mobile-tabbar .mt-item.active { color: var(--brand-600); }

.ai-chat { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 84%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .m-avatar { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.msg.ai .m-avatar { background: var(--ai-100); color: var(--ai-600); }
.msg.user .m-avatar { background: var(--brand-100); color: var(--brand-700); }
.m-bubble { background: var(--canvas-alt); border-radius: 12px; padding: 11px 13px; font-size: 13px; color: var(--ink-800); }
.msg.user .m-bubble { background: var(--brand-600); color: #fff; }
.msg.ai .m-bubble { background: var(--surface); border: 1px solid var(--line); }

.scrollx { overflow-x: auto; }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); width: 248px; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .top-search { display: none; }
}
