/* ===========================
   Lucis Ops Dashboard
   Design tokens (design.md)
   =========================== */
:root {
  /* surfaces */
  --bg:           #F7F3EA;
  --bg-alt:       #FBF8F1;
  --surface:      #FFFFFF;
  --surface-2:    #F2EBDD;

  /* ink */
  --ink:          #151515;
  --ink-2:        #4A4A45;
  --ink-3:        #8A8278;

  /* lines */
  --line:         rgba(21, 21, 21, 0.06);
  --line-strong:  rgba(21, 21, 21, 0.10);

  /* accents */
  --olive:        #394437;
  --sage:         #8B9A7A;
  --moss:         #C9D3B7;
  --mint:         #E7EFE0;

  /* status */
  --ok:           #6D8B5F;
  --warn:         #D9A441;
  --crit:         #C85C4A;
  --neutral:      #B8B3A7;
  --info:         #6E8FA3;

  --radius:       24px;
  --radius-sm:    14px;
  --radius-xs:    10px;
  --shadow:       0 1px 0 rgba(21,21,21,0.02), 0 8px 24px rgba(21,21,21,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

a { color: inherit; }
button, input { font-family: inherit; }

/* =========== Layout =========== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo-img { height: 52px; width: auto; display: block; }
.brand .sep { color: var(--ink-3); font-weight: 300; }
.brand .page { color: var(--ink-2); font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.brand .badge {
  margin-left: 4px;
  font-size: 11px;
  padding: 3px 10px;
  background: var(--mint);
  color: var(--olive);
  border-radius: 99px;
  font-weight: 500;
  letter-spacing: 0;
}
.meta { color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 14px; }
.meta .live-wrap { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(109,139,95,0.15); }
.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 99px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 500;
}
.btn-ghost:hover { border-color: var(--olive); color: var(--olive); }

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px);
}
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.sidebar {
  padding: 28px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.side-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  padding: 0 12px 8px;
  font-weight: 500;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
  font-weight: 500;
}
.side-item:hover { background: var(--surface); color: var(--ink); }
.side-item.active { background: var(--surface); color: var(--olive); box-shadow: var(--shadow); }
.side-item .ico { width: 14px; height: 14px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.side-item .ico svg { width: 14px; height: 14px; }

.mobile-tabs { display: none; gap: 6px; padding: 12px 24px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; }
@media (max-width: 880px) {
  .mobile-tabs { display: flex; }
}
.mobile-tabs button {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-3);
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
}
.mobile-tabs button.active { background: var(--surface); color: var(--olive); border: 1px solid var(--line); }

main {
  padding: 32px 36px 48px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 640px) { main { padding: 20px 18px 32px; } }

.panel { display: none; }
.panel.active { display: block; }

/* =========== Section title =========== */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 16px;
}
.section-title h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.section-title .muted { color: var(--ink-3); font-size: 12px; }
.section-title + .section-title { margin-top: 32px; }

/* =========== KPI cards =========== */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpis { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi-label {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 14px;
  letter-spacing: 0;
}
.kpi-value {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.kpi-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.trend { font-weight: 500; }
.trend.up   { color: var(--ok); }
.trend.down { color: var(--crit); }
.trend.flat { color: var(--ink-3); }

/* =========== Pills =========== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0;
  background: var(--surface-2);
  color: var(--ink-2);
}
.pill .pip { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill.ok       { background: var(--mint);                 color: #3F5934; }
.pill.warn     { background: rgba(217,164,65,0.16);       color: #8C6614; }
.pill.crit     { background: rgba(200,92,74,0.14);        color: #8C3A2C; }
.pill.neutral  { background: var(--surface-2);            color: var(--ink-2); }
.pill.info     { background: rgba(110,143,163,0.14);      color: #3F5C6E; }

/* =========== Cards & grid =========== */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.grid.two { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, 1fr); } .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 720px)  { .grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .card.span-2 { grid-column: span 1; } }
.card-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.card-h h3 {
  font-size: 14px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.muted { color: var(--ink-3); font-size: 12px; }

/* =========== Live Incident =========== */
.incident {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 28px;
  position: relative;
}
.incident::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--crit);
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.incident-h { display: flex; justify-content: space-between; align-items: flex-start; }
.incident-h h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.incident-h .sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.incident-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 24px;
}
.incident-grid.simple { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 880px) { .incident-grid, .incident-grid.simple { grid-template-columns: repeat(2, 1fr); } }
.incident-field .lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.incident-field .val { font-size: 13px; color: var(--ink); font-weight: 500; }

/* =========== Table =========== */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); }
.tbl th {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
}
.tbl tbody tr { transition: background 120ms ease; }
.tbl tbody tr:hover { background: var(--bg-alt); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.lab { font-weight: 500; color: var(--ink); }
.tbl td .lab-note { color: var(--ink-3); font-size: 11px; font-weight: 400; margin-top: 2px; }
.spark { display: inline-block; vertical-align: middle; }

/* =========== Alerts =========== */
.alerts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; }
.alerts li {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
}
.alerts li.crit  { border-color: rgba(200,92,74,0.25); background: rgba(200,92,74,0.05); }
.alerts li.warn  { border-color: rgba(217,164,65,0.25); background: rgba(217,164,65,0.06); }
.alerts .a-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.alerts .a-msg { font-size: 13px; color: var(--ink); line-height: 1.45; }

/* =========== IDF Centres =========== */
.centres { display: flex; flex-direction: column; gap: 12px; }
.centre {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.centre:last-child { border-bottom: none; padding-bottom: 0; }
.centre .nm { font-size: 13px; font-weight: 500; }
.centre .mini { color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.centre .bar { width: 100%; height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.centre .bar > div { height: 100%; border-radius: 99px; }
.centre .cnt { font-weight: 500; font-size: 18px; letter-spacing: -0.02em; }

/* =========== Bars chart =========== */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; }
.bars .col .seg { width: 100%; border-radius: 2px 2px 0 0; }
.bars .col .seg:not(:last-of-type) { border-radius: 0; }
.bars .col .seg.delay   { background: var(--warn); }
.bars .col .seg.missing { background: #B8865C; }
.bars .col .seg.range   { background: var(--crit); }
.bars .col .seg.booking { background: var(--neutral); }
.bars .col .lbl { font-size: 10px; color: var(--ink-3); margin-top: 6px; text-align: center; }
.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 11px; color: var(--ink-3); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* =========== Flow =========== */
.flow-grid { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.flow-step {
  flex: 1;
  min-width: 150px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.flow-step.strong { background: var(--mint); border-color: var(--moss); }
.flow-src { display: block; font-weight: 600; font-size: 13px; color: var(--ink); }
.flow-how { display: block; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.flow-arrow { display: flex; align-items: center; color: var(--ink-3); font-size: 16px; font-weight: 300; }

/* =========== Priority Queue =========== */
.queue { list-style: none; padding: 0; margin: 0; counter-reset: q; }
.queue li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.queue li:last-child { border-bottom: none; }
.queue li::before {
  counter-increment: q;
  content: counter(q);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}
.queue li .q-lbl { font-size: 13px; color: var(--ink); font-weight: 500; }
.queue li .q-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* =========== Hypotheses page =========== */
#hypotheses .hyp-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
#hypotheses h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 6px; }
#hypotheses .hyp-tag { display: inline-block; font-size: 11px; color: var(--olive); background: var(--mint); padding: 3px 10px; border-radius: 99px; font-weight: 500; margin-bottom: 12px; }
#hypotheses p { font-size: 14px; line-height: 1.65; color: var(--ink-2); margin: 8px 0; }
#hypotheses .confirm { background: var(--bg-alt); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
#hypotheses .confirm strong { color: var(--olive); }

/* =========== Playbook =========== */
.playbook {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 48px;
  box-shadow: var(--shadow);
  max-width: 780px;
}
.playbook .pb-meta { color: var(--ink-3); font-size: 12px; margin-bottom: 24px; }
.playbook h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.playbook h3 {
  margin: 28px 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--olive);
  font-weight: 600;
}
.playbook p, .playbook li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}
.playbook ul, .playbook ol { padding-left: 22px; }
.playbook code {
  background: var(--mint);
  color: var(--olive);
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* =========== Side badge =========== */
.side-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 99px;
  font-weight: 500;
}
.side-item.active .side-badge { background: var(--mint); color: var(--olive); }

/* =========== Buttons =========== */
.btn-primary {
  background: var(--olive);
  color: var(--bg-alt);
  border: none;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0;
  transition: opacity 120ms ease;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-mini {
  background: var(--surface);
  color: var(--olive);
  border: 1px solid var(--line-strong);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.btn-mini:hover { border-color: var(--olive); background: var(--mint); }
.btn-mini:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========== AI Signal · Pattern Detector =========== */
.signal-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--mint) 380%);
  border: 1px solid var(--moss);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.signal-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sage), var(--olive), var(--sage));
  background-size: 200% 100%;
  animation: shimmer 6s ease infinite;
}
@keyframes shimmer { 0%,100% { background-position: 0% 0%; } 50% { background-position: 100% 0%; } }

.signal-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.signal-meta { flex: 1; min-width: 280px; }
.signal-lbl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--olive);
  font-weight: 600;
}
.signal-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 4px rgba(139,154,122,0.2);
  animation: pulse 2.4s ease infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(139,154,122,0.2); }
  50%     { box-shadow: 0 0 0 8px rgba(139,154,122,0.06); }
}
.signal-title { margin: 8px 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.signal-sub { margin: 0; font-size: 13px; color: var(--ink-2); }

.signal-actions { display: flex; gap: 8px; flex-shrink: 0; }

.auto-feed {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 160px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auto-feed:empty { display: none; }
.feed-line { display: flex; align-items: center; gap: 10px; color: var(--ink-2); line-height: 1.6; }
.feed-line .ts { color: var(--ink-3); font-size: 11px; min-width: 60px; }
.feed-line .tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 8px;
  border-radius: 99px;
  min-width: 70px;
  text-align: center;
}
.feed-line .tag.triage  { background: var(--mint);                color: var(--olive); }
.feed-line .tag.signal  { background: rgba(110,143,163,0.16);     color: #3F5C6E; }
.feed-line .tag.webhook { background: rgba(217,164,65,0.14);      color: #8C6614; }
.feed-line .tag.error   { background: rgba(200,92,74,0.14);       color: var(--crit); }
.feed-line .txt { color: var(--ink); font-size: 12px; }
.feed-line.new { animation: fadeIn 220ms ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}

.signal-body { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.signal-body:empty { display: none; }

.pattern {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  border-left: 3px solid var(--sage);
}
.pattern.high { border-left-color: var(--crit); }
.pattern.medium { border-left-color: var(--warn); }
.pattern-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pattern-name { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; letter-spacing: -0.005em; }
.pattern-meta { font-size: 11px; color: var(--ink-3); }
.pattern-desc { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.pattern-action {
  background: var(--bg-alt);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  margin-top: 4px;
}
.pattern-action-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--olive); font-weight: 600; margin-bottom: 6px; }
.pattern-action-title { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.pattern-action-draft { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; white-space: pre-wrap; background: var(--surface); padding: 12px 14px; border-radius: var(--radius-xs); border: 1px solid var(--line); }

.signal-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  color: var(--ink-2);
  font-size: 13px;
}

/* =========== Mini-stats + toolbar =========== */
.ticket-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.mini-stats {
  display: flex;
  gap: 22px;
  align-items: center;
}
.mini-stat { display: flex; flex-direction: column; gap: 2px; }
.ms-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 500; }
.ms-val { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.ms-val.ms-crit { color: var(--crit); }
.tb-right { display: flex; align-items: center; gap: 12px; }

/* =========== Kanban =========== */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kanban { grid-template-columns: 1fr; } }

.k-col {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px 12px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}
.k-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}
.k-name { font-size: 12px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
.k-count {
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 99px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 600;
}
.k-sub { font-size: 10px; color: var(--ink-3); padding: 4px 4px 0; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.k-cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; }

.k-col.k-p0 .k-name { color: var(--crit); }
.k-col.k-p0 .k-count { background: rgba(200,92,74,0.12); color: var(--crit); }
.k-col.k-p1 .k-name { color: var(--warn); }
.k-col.k-p1 .k-count { background: rgba(217,164,65,0.16); color: #8C6614; }

/* Kanban card */
.k-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  overflow: hidden;
}
.k-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(21,21,21,0.05); }
.k-card .strip { height: 3px; width: 100%; }
.k-card.sla-ok       .strip { background: var(--ok); }
.k-card.sla-warn     .strip { background: var(--warn); }
.k-card.sla-crit     .strip { background: var(--crit); }
.k-card.sla-breached .strip { background: var(--crit); animation: pulseStrip 1.6s ease infinite; }
.k-card.sla-neutral  .strip { background: var(--neutral); }
@keyframes pulseStrip {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.k-card .inner { padding: 12px 14px; }
.k-card .row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.k-card .elapsed {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.k-card .elapsed.b { color: var(--crit); }
.k-card .lang {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 600;
}
.k-card .subj { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.35; letter-spacing: -0.005em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; }
.k-card .from { font-size: 11px; color: var(--ink-3); }
.k-card .cat {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.k-card .cat.medical { background: rgba(200,92,74,0.12); color: var(--crit); }

/* =========== Modal =========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21,21,21,0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 24px;
  z-index: 100;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal-shell {
  background: var(--surface);
  border-radius: var(--radius);
  width: 720px;
  max-width: 100%;
  position: relative;
  box-shadow: 0 24px 64px rgba(21,21,21,0.18);
  border: 1px solid var(--line);
}
.modal-close {
  position: absolute;
  top: 14px; right: 18px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 36px 40px 32px; }

.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-from { font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.modal-email { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.modal-info { font-size: 11px; color: var(--ink-3); display: flex; gap: 10px; align-items: center; }
.modal-info .lang-tag { background: var(--surface-2); color: var(--ink-2); padding: 2px 8px; border-radius: 99px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }

.modal-subject { font-size: 18px; font-weight: 600; color: var(--ink); margin: 6px 0 12px; letter-spacing: -0.015em; }
.modal-body-text { font-size: 14px; color: var(--ink-2); line-height: 1.65; white-space: pre-wrap; background: var(--bg-alt); padding: 16px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.modal-pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 6px; }

.modal-ai {
  margin-top: 18px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  border: 1px solid var(--line);
}
.modal-ai .ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.modal-ai .ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.modal-ai .ai-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--olive); font-weight: 600; }
.modal-ai .reasoning { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.modal-ai .actions-list { margin-top: 10px; font-size: 13px; color: var(--ink-2); padding-left: 20px; }
.modal-ai .actions-list li { line-height: 1.55; }
.modal-ai .draft {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 16px 18px;
}
.modal-ai .draft-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; margin-bottom: 8px; }
.modal-ai .draft-text { font-size: 13.5px; color: var(--ink); line-height: 1.7; white-space: pre-wrap; }
.modal-ai .draft-actions { display: flex; gap: 8px; margin-top: 14px; }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.modal-loading { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; }

/* =========== Workflow spec card =========== */
.spec-card {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow);
}
.spec-card .spec-h { margin-bottom: 22px; }
.spec-card .spec-h h3 { margin: 8px 0 0; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px 32px;
}
@media (max-width: 880px) { .spec-grid { grid-template-columns: 1fr; gap: 18px; } }
.spec-field {}
.spec-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--olive);
  font-weight: 600;
  margin-bottom: 6px;
}
.spec-val {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
}
.spec-val code {
  background: var(--mint);
  color: var(--olive);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.spec-val em { font-style: normal; color: var(--olive); font-weight: 500; }
.spec-val strong { color: var(--ink); font-weight: 600; }

footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--ink-3);
  font-size: 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
