/* Karbar Pulse component styles (hand-authored; production also builds Tailwind via the Dockerfile). */

/* ===================== App shell (matches design/) ===================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 13.5px; background: var(--bg); color: var(--text); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
.mono { font-family: "JetBrains Mono", monospace; }

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 12px; gap: 12px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.side-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; }
.side-brand .nm { font-weight: 600; font-size: 14px; line-height: 1.1; }
.side-brand .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.side-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface2); border-radius: 9px; padding: 7px 10px; color: var(--muted); font-size: 13px; cursor: text; }
.side-search .kbd { margin-left: auto; font-family: "JetBrains Mono", monospace; font-size: 10.5px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text2); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.nav-item svg { width: 18px; height: 18px; flex: none; stroke: currentColor; opacity: .85; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); }
.nav-item.active svg { color: var(--ai); opacity: 1; }
.nav-badge { margin-left: auto; background: var(--crit-soft); color: var(--crit); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 0 7px; line-height: 18px; }
.side-spacer { flex: 1; }
.fresh { border: 1px solid var(--border); background: var(--surface2); border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.fresh .hd { display: flex; align-items: center; gap: 7px; color: var(--text2); }
.fresh b { color: var(--text); }
.fresh .mut { color: var(--muted); margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ok); flex: none; }
.dot.warn { background: var(--watch); }
.user { display: flex; align-items: center; gap: 10px; padding-top: 2px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--surface3); color: var(--text2); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.user .nm { font-size: 13px; font-weight: 500; }
.user .ro { font-size: 11px; color: var(--muted); }
.user .so { margin-left: auto; font-size: 12px; color: var(--muted); background: none; border: 0; cursor: pointer; }
.user .so:hover { color: var(--text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 53px; display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.top-title { font-size: 13px; color: var(--muted); }
.top-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface2); border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--text2); }
.top-date { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.spring { flex: 1; }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); }
.assistant-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--ai-border); background: var(--ai-soft); color: var(--ai-ink); border-radius: 9px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.content { padding: 22px 24px 48px; max-width: 1240px; width: 100%; }

@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .side { display: none; } }


.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-h1 { font-size: 26px; font-weight: 600; margin: 0 0 3px; letter-spacing: -.025em; }
.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }

/* Segmented filter pills */
.segs { display: flex; gap: 10px; }
.seg { border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 6px 12px; font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.seg b { color: var(--text); font-weight: 600; }

/* AI briefing */
.briefing { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
.briefing-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ai-label { display: inline-flex; align-items: center; gap: 8px; color: var(--ai-ink); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.ai-label .dot { background: var(--ai); }
.briefing-meta { font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--muted); }
.briefing-text { font-size: 16px; line-height: 1.62; color: var(--text2); margin: 0; }
.briefing-text b { color: var(--text); font-weight: 600; }
.briefing-text a { color: var(--ai-ink); }
.briefing-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* KPI cards with sparkline */
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; min-height: 26px; line-height: 1.25; }
/* Reserve room so the sparkline never overlaps the label (truncate like the design). */
.kpi:has(.spark) .k { padding-right: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 27px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi .spark { position: absolute; top: 15px; right: 16px; width: 56px; height: 18px; }
.kpi.crit .v { color: var(--crit); }
a.kpi { text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--faint); }

/* PO detail */
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; display: inline-block; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.po-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .po-grid { grid-template-columns: 1fr; } }
.po-id { font-size: 26px; font-weight: 600; letter-spacing: -.02em; display: inline-flex; align-items: center; gap: 12px; }
.sketch { height: 150px; border: 1px dashed var(--border); border-radius: 12px; background: repeating-linear-gradient(135deg, var(--surface2) 0 10px, transparent 10px 20px); display: grid; place-items: center; color: var(--faint); font-size: 12px; margin-bottom: 16px; }
.field { margin-top: 14px; }
.field .lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field .val { font-size: 15px; font-weight: 500; margin-top: 2px; }
.rec-card { border: 1px solid var(--ai-border); background: var(--ai-soft); border-radius: 14px; padding: 18px 20px; }
.rec-text { font-size: 15px; line-height: 1.6; color: var(--text); margin: 8px 0 14px; }
.rec-text b { font-weight: 600; }
.opt { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 13px 15px; margin-top: 10px; }
.opt-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.opt-title { font-weight: 600; font-size: 13.5px; }
.opt-chip { font-family: "JetBrains Mono", monospace; font-size: 12px; font-weight: 600; }
.opt-chip.good { color: var(--ok); }
.opt-chip.bad { color: var(--risk); }
.opt-body { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.opt-foot { font-size: 12px; color: var(--text2); margin-top: 6px; }

/* Prediction metric row */
.pred-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 2px 0 6px; }
.pred-cell .lab { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pred-cell .val { font-size: 18px; font-weight: 600; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.section-title { font-size: 13px; font-weight: 600; color: var(--text2); margin: 0 0 8px; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--hair); }
.tbl tr:hover td { background: var(--surface2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
a.row-link { color: var(--text); font-weight: 500; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-soft); }
.b-watch { color: var(--watch); background: var(--watch-soft); }
.b-risk { color: var(--risk); background: var(--risk-soft); }
.b-crit { color: var(--crit); background: var(--crit-soft); }
.b-late { color: var(--late); background: var(--late-soft); }
.b-ship { color: var(--ship); background: var(--ship-soft); }
.b-noupd { color: var(--noupd); background: var(--noupd-soft); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface2); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text2); cursor: pointer; text-decoration: none; }
.chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Charts */
.chart { width: 100%; height: 280px; }
.chart-sm { width: 100%; height: 200px; }

/* Heatmap */
.heat { display: grid; gap: 3px; }
.heat-row { display: grid; grid-template-columns: 150px repeat(8, 1fr); gap: 3px; align-items: center; }
.heat-cell { height: 22px; border-radius: 4px; }
.h0 { background: var(--surface3); }
.h1 { background: var(--ok-soft); }
.h2 { background: var(--watch-soft); }
.h3 { background: var(--risk-soft); }
.h4 { background: var(--crit-soft); }
.h-1 { background: var(--noupd-soft); }
.heat-label { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* AI briefing */
.ai-box { border: 1px solid var(--ai-border); background: var(--ai-soft); border-radius: 12px; padding: 14px 16px; }
.ai-box .ai-tag { color: var(--ai-ink); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* Source tooltip */
.src { color: var(--faint); font-size: 11px; cursor: help; border-bottom: 1px dotted var(--faint); }

/* Drivers */
.driver { font-size: 12.5px; color: var(--text2); padding: 4px 0; border-bottom: 1px solid var(--hair); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 8px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Chat */
.chat-thread { display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble { max-width: 86%; border-radius: 14px; padding: 10px 13px; font-size: 13.5px; line-height: 1.5; }
.chat-msg.user .chat-bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.chat-msg.ai .chat-bubble { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-bubble p { margin: 0 0 6px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-steps { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.chat-steps .done::before { content: "✓ "; color: var(--ok); }
.chat-sources { font-size: 11px; color: var(--faint); margin-top: 8px; }
.typing { display: inline-flex; gap: 3px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.btn { border: 1px solid var(--border); background: var(--surface2); color: var(--text2); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text); font-size: 13px; }
