/* ──────────────────────────────────────────────────────────────
   MIND ID PMO — layout + components (v2, light terminal)
   Shell: [ sidebar ] [ main (topbar + view) ] [ copilot ]
   Dense, hairline, panel-based. Tabular mono figures. Metal-tinted signals.
   ────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--copilot-w);
  height: 100vh; width: 100vw; overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 14px 12px; gap: 1px; overflow-y: auto;
}
.brand-row { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; }
.brand-mark {
  width: 25px; height: 25px; border-radius: 6px;
  background: var(--brand-red); flex: none; display: grid; place-items: center;
}
.brand-mark svg { width: 15px; height: 15px; }
.brand-name { font-weight: 700; letter-spacing: 0.01em; font-size: 14px; color: var(--ink); }
.brand-sub { font-family: var(--font-mono); font-size: 9px; color: var(--ink-3); font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; margin-top: 2px; }

.nav-group-label { font-family: var(--font-mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); padding: 15px 9px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 500; font-size: 13px; position: relative;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-item:hover { background: rgba(16,32,60,0.04); color: var(--ink); }
.nav-item.active { background: var(--iris-soft); color: var(--iris-2); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 2.5px;
  background: var(--iris); border-radius: 0 3px 3px 0; }
.nav-item .ic { width: 16px; height: 16px; flex: none; opacity: 0.75; }
.nav-item.active .ic { opacity: 1; color: var(--iris); }
.nav-item .chev { margin-left: auto; width: 19px; height: 19px; display: grid; place-items: center;
  color: var(--ink-3); border-radius: 4px; transition: transform var(--duration) var(--ease); }
.nav-item .chev:hover { background: rgba(16,32,60,0.07); color: var(--ink); }
.nav-item .chev.open { transform: rotate(180deg); }
.nav-history.collapsed { display: none; }
.nav-item .badge { margin-left: auto; background: var(--red-soft); color: var(--red);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; border-radius: var(--r-sm); padding: 1px 6px; }

.nav-history { padding: 2px 4px 4px 28px; display: flex; flex-direction: column; gap: 1px; }
.nav-history a { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); padding: 4px 8px;
  border-radius: var(--r-sm); font-weight: 400; }
.nav-history a:hover { background: rgba(16,32,60,0.04); color: var(--ink); }

.sidebar-foot { margin-top: auto; padding: 12px 9px 4px; border-top: 1px solid var(--line); }
.sov-badge { display:flex; align-items:center; gap:8px; font-family: var(--font-mono); font-size:10.5px; color:var(--ink-2); }
.sov-badge .ping { width:6px;height:6px;border-radius:50%;background:var(--ok); box-shadow:0 0 0 0 rgba(18,146,75,.5); animation: ping 2.4s infinite; }
@keyframes ping { 0%{box-shadow:0 0 0 0 rgba(18,146,75,.45)} 70%{box-shadow:0 0 0 5px rgba(18,146,75,0)} 100%{box-shadow:0 0 0 0 rgba(18,146,75,0)} }

/* ── Collapse states + icon controls ─────────────────────── */
.app { transition: grid-template-columns var(--duration) var(--ease); }
.app.nav-min { grid-template-columns: 0 1fr var(--copilot-w); }
.app.cp-min { grid-template-columns: var(--sidebar-w) 1fr 0; }
.app.nav-min.cp-min { grid-template-columns: 0 1fr 0; }
/* collapse by clipping the track (NOT display:none — that reflows main into col 1) */
.app.nav-min .sidebar { overflow: hidden; padding: 0; border-right: none; }
.app.cp-min .copilot { overflow: hidden; border-left: none; }

.icon-btn { width: 30px; height: 30px; border-radius: var(--r-md); display: grid; place-items: center;
  color: var(--ink-2); flex: none; transition: background var(--duration), color var(--duration); }
.icon-btn:hover { background: rgba(16,32,60,0.06); color: var(--ink); }

.cp-reopen { display: none; position: fixed; right: 20px; bottom: 20px; z-index: 50;
  align-items: center; gap: 8px; padding: 10px 15px; border-radius: var(--r-pill);
  background: var(--iris); color: #fff; font-weight: 600; font-size: 12.5px; box-shadow: var(--shadow-pop); }
.cp-reopen:hover { background: var(--iris-2); }
.app.cp-min ~ .cp-reopen { display: inline-flex; }

/* ── Ticker (running price strip) ────────────────────────── */
.ticker { height: 30px; flex: none; background: var(--panel); border-bottom: 1px solid var(--line);
  overflow: hidden; display: flex; align-items: center; position: relative; }
.ticker::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 40px;
  background: linear-gradient(90deg, transparent, var(--panel)); pointer-events: none; }
.ticker-track { display: inline-flex; white-space: nowrap; animation: tick 64s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tk { display: inline-flex; align-items: baseline; gap: 7px; padding: 0 16px; border-right: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11.5px; }
.tk .tk-name { color: var(--ink-3); font-weight: 500; letter-spacing: 0.03em; }
.tk .tk-px { color: var(--ink); font-weight: 600; }
.tk .tk-chg { font-size: 10.5px; font-weight: 500; }
.tk .tk-chg.up { color: var(--ok); }
.tk .tk-chg.down { color: var(--red); }

/* ── Main column ─────────────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--canvas); }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { font-size: 13.5px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .crumb { color: var(--ink-3); font-weight: 500; font-size: 12px; font-family: var(--font-mono); }
.topbar .spacer { flex: 1; }
.topbar .meta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); display:flex; gap:12px; align-items:center; }
.topbar .flagchip { display:inline-flex; align-items:center; gap:6px; background:var(--red-soft);
  color:var(--bad); font-weight:600; font-family: var(--font-mono); font-size:11px; padding:4px 10px; border-radius:var(--r-sm); }

.view { padding: 14px 22px 16px; overflow-y: auto; flex: 1; }
.view-head { margin-bottom: 12px; }
.hero-art { flex: none; opacity: 0.95; margin-top: 2px; }
.hero-art img { display: block; width: 300px; height: auto; object-fit: contain; mix-blend-mode: multiply; }
@media (max-width: 1300px) { .hero-art { display: none; } }
.view-head h2 { font-size: 21px; font-weight: 700; margin: 5px 0 5px; letter-spacing: -0.02em; line-height:1.22; max-width: 60ch; }
.view-head p { color: var(--ink-2); margin: 0; max-width: 78ch; font-size: 12.5px; }

/* ── Panels / grid ───────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); }
.card-pad { padding: 14px 16px; }
.card-title { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); }
.grid { display: grid; gap: 12px; }

/* Widget header bar (from .section-label) */
.section-label { display:flex; align-items:center; gap:10px; margin: 14px 0 8px; }
.link-sm { font-size: 12px; font-weight: 600; color: var(--iris); cursor: pointer; white-space: nowrap; }
.link-sm:hover { color: var(--iris-2); }
.sim-hint { font-size: 11px; font-weight: 500; color: var(--ink-faint); white-space: nowrap; }

/* Flags strip — "what needs attention this week" (the first read) */
.flags-strip { display:flex; align-items:stretch; gap:9px; margin-top:12px;
  background:var(--panel); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-card); padding:8px 10px; }
.flags-lead { display:flex; flex-direction:column; justify-content:center; padding:0 8px 0 4px; flex:none;
  font-weight:700; font-size:12.5px; color:var(--ink); }
.flags-lead span { font-weight:600; font-size:9.5px; color:var(--ink-3); text-transform:uppercase; letter-spacing:.07em; }
.flag-chip { display:flex; align-items:baseline; gap:8px; flex:1; min-width:0; text-align:left; padding:8px 12px;
  border-radius:var(--r-md); background:var(--panel-3); border:1px solid var(--line);
  border-left:3px solid var(--warn); transition:box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease); }
.flag-chip.bad { border-left-color:var(--bad); }
.flag-chip.warn { border-left-color:var(--warn); }
.flag-chip:hover { box-shadow:0 3px 12px rgba(16,32,60,0.09); transform:translateY(-1px); }
.flag-chip .fc-ent { font-weight:700; font-size:12.5px; white-space:nowrap; flex:none; }
.flag-chip .fc-txt { color:var(--ink-3); font-size:11.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.section-label h3 { font-family: var(--font-mono); font-size: 11px; font-weight: 600; margin: 0;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
  padding-left: 10px; position: relative; }
.section-label h3::before { content:""; position:absolute; left:0; top:1px; bottom:1px; width:3px;
  background: var(--brand-red); border-radius: 2px; }
.section-label .rule { flex:1; height:1px; background: var(--line); }

/* KPI stat rail */
.stat-rail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 15px 12px; box-shadow: var(--shadow-card); transition: box-shadow var(--duration) var(--ease); }
.stat:hover { box-shadow: 0 4px 16px rgba(16,32,60,0.09); }
.stat .k-top { display: flex; align-items: center; justify-content: space-between; }
.stat .k-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.055em;
  text-transform: uppercase; color: var(--ink-3); }
.stat .k-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-faint); }
.stat .k-dot.ok { background: var(--ok); } .stat .k-dot.warn { background: var(--warn); } .stat .k-dot.bad { background: var(--bad); }
.stat .k-mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 9px 0 5px; }
.stat .k-val { font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: -0.025em;
  font-feature-settings: "tnum" 1; color: var(--ink); transition: color var(--duration) var(--ease); }
.stat .k-spark { flex: none; opacity: 0.9; margin-bottom: 4px; }
.stat .k-sub { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.stat.flash .k-val { animation: flash 0.55s var(--ease); }
@keyframes flash { 0%{ color: var(--brand-red) } 100%{} }

/* Tables — dense terminal */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl thead th { text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); padding: 8px 12px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl thead th:first-child { border-top-left-radius: var(--r-lg); }
table.tbl thead th:last-child { border-top-right-radius: var(--r-lg); }
table.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background var(--duration) var(--ease); cursor: default; }
table.tbl tbody tr:hover { background: var(--panel-3); }
table.tbl tbody tr.hot { background: var(--iris-soft); box-shadow: inset 3px 0 0 var(--iris); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--font-mono); font-feature-settings:"tnum" 1; }
.ent-name { font-weight: 600; }
.ent-sub { color: var(--ink-3); font-family: var(--font-mono); font-size: 10.5px; }

/* Shock sliders — metal-tinted top edge (the signature) */
.shock-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.shock { border: 1px solid var(--line); border-top: 2px solid var(--mc, var(--line-2)); border-radius: var(--r-md);
  padding: 11px 12px; background: var(--panel); box-shadow: var(--shadow-card); }
.shock .sh-top { display:flex; justify-content:space-between; align-items:baseline; margin-bottom: 8px; }
.shock .sh-name { font-weight: 600; font-size: 12px; }
.shock .sh-val { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--mc, var(--ink)); }
.shock input[type=range] { width: 100%; accent-color: var(--mc, var(--iris)); height: 4px; }
.shock .sh-impact { font-family: var(--font-mono); font-size: 11px; margin-top: 7px; color: var(--ink-3); }
.net-swing { display:flex; align-items:center; gap:14px; padding: 12px 16px; background: #F7F8FE;
  border-radius: var(--r-md); border:1px solid var(--line); box-shadow: var(--shadow-card); }
.net-swing .ns-val { font-size: 26px; font-weight: 700; letter-spacing:-0.025em;
  font-feature-settings: "tnum" 1; transition: color var(--duration) var(--ease); }

.btn { display:inline-flex; align-items:center; gap:8px; padding: 8px 14px; border-radius: var(--r-md);
  font-weight: 600; font-size: 12.5px; transition: transform var(--duration), background var(--duration), box-shadow var(--duration); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-red); color: #fff; box-shadow: 0 1px 2px rgba(218,0,39,0.3); }
.btn-primary:hover { background: var(--red); }
.btn-ghost { background: var(--panel); color: var(--ink); border:1px solid var(--line-2); }
.btn-ghost:hover { background: var(--panel-3); }

/* ── Copilot ─────────────────────────────────────────────── */
.copilot { background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; }
.cp-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display:flex; align-items:center; gap:9px; }
.cp-avatar { width: 27px; height: 27px; border-radius: 7px; background: var(--iris); color:#fff;
  display:grid; place-items:center; font-size: 13px; box-shadow: 0 0 0 3px var(--iris-soft); }
.cp-title { font-weight: 700; font-size: 13px; }
.cp-model { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); font-weight:500; margin-top: 1px; }
.cp-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 11px; background: var(--panel-3); }
.msg { max-width: 100%; font-size: 12.5px; line-height: 1.5; }
.msg.bot { align-self: flex-start; width: 100%; }
.msg.user { align-self: flex-end; background: var(--iris); color: #fff; padding: 8px 12px;
  border-radius: 10px 10px 3px 10px; max-width: 82%; box-shadow: var(--shadow-card); }
.msg.bot .bubble { background: var(--panel); border:1px solid var(--line);
  padding: 10px 12px; border-radius: 10px 10px 10px 3px; box-shadow: var(--shadow-card); }
.msg.bot .bubble strong { color: var(--ink); font-weight: 600; }
.msg .cite { display:inline-flex; align-items:center; gap:5px; margin-top:8px; font-family: var(--font-mono);
  font-size:10.5px; font-weight:500; color: var(--iris); background: var(--iris-soft); padding: 3px 8px; border-radius: var(--r-sm); cursor:pointer; }
.msg .cite:hover { background: rgba(63,99,224,0.18); }
.brief-item { display:flex; align-items:flex-start; gap:10px; width:100%; text-align:left;
  padding:9px 10px; border-radius:9px; margin-top:7px; background:var(--panel); border:1px solid var(--line);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease); }
.brief-item:hover { border-color: var(--iris); box-shadow: 0 2px 10px rgba(63,99,224,0.12); }
.brief-num { flex:none; width:19px; height:19px; border-radius:50%; background:var(--iris); color:#fff;
  font-size:11px; font-weight:700; display:grid; place-items:center; margin-top:1px; }
.brief-h { display:block; font-weight:700; font-size:12.5px; color: var(--ink); }
.brief-s { display:block; color:var(--ink-3); font-size:11.5px; margin-top:1px; }

.cp-typing { display:flex; gap:4px; padding: 4px 2px; }
.cp-typing span { width:6px;height:6px;border-radius:50%;background:var(--ink-faint); animation: bob 1s infinite; }
.cp-typing span:nth-child(2){animation-delay:.15s} .cp-typing span:nth-child(3){animation-delay:.3s}
@keyframes bob { 0%,60%,100%{transform:translateY(0);opacity:.5} 30%{transform:translateY(-4px);opacity:1} }
.cp-chips { display:flex; flex-wrap:wrap; gap:6px; padding: 8px 14px; border-top: 1px solid var(--line); }
.cp-chip { font-family: var(--font-mono); font-size: 11px; font-weight:500; color: var(--iris-2); background: var(--iris-soft);
  border-radius: var(--r-sm); padding: 6px 10px; transition: background var(--duration); }
.cp-chip:hover { background: rgba(63,99,224,0.18); }
.cp-input { border-top: 1px solid var(--line); padding: 10px 12px; display:flex; gap:8px; align-items:center; }
.cp-input input { flex:1; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  padding: 9px 14px; outline: none; background: var(--panel-3); }
.cp-input input:focus { border-color: var(--iris); background: var(--panel); }
.cp-send { width: 33px; height: 33px; border-radius: 50%; background: var(--iris); color:#fff;
  display:grid; place-items:center; flex:none; }
.cp-send:hover { background: var(--iris-2); }

/* stub view */
.stub { display:grid; place-items:center; height: 60vh; text-align:center; color: var(--ink-3); }
.stub .big { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: calc(50% + (var(--sidebar-w) - var(--copilot-w)) / 2);
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); font-weight: 500; font-size: 12.5px; opacity: 0; z-index: 60;
  transition: all 300ms var(--ease); display:flex; align-items:center; gap:10px; max-width: 620px; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast .t-ok { color: var(--ok); }
