/* ===== Tribastion CART console ===== */
:root {
  --bg: #0b0f17;
  --bg-elev: #121826;
  --bg-elev-2: #1a2234;
  --border: #233047;
  --border-soft: #1b2436;
  --text: #e6ecf5;
  --text-dim: #93a1b8;
  --text-faint: #5f6f88;
  --accent: #4f8cff;
  --accent-2: #38d39f;
  --crit: #ff5470;
  --high: #ff8f4d;
  --med: #ffd23f;
  --low: #59c1ff;
  --info: #7c89a3;
  --ok: #38d39f;
  --warn: #ffd23f;
  --bad: #ff5470;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ---- Layout shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--bg-elev);
  border-right: 1px solid var(--border-soft); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: .6rem; align-items: center; padding: 1.1rem 1.1rem .8rem; }
.brand-mark { font-size: 1.5rem; }
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: .72rem; color: var(--text-faint); letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; padding: .4rem .6rem; gap: 2px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: .9rem;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: rgba(79,140,255,.14); color: #cfe0ff; }
.nav-ico { width: 1.1rem; text-align: center; opacity: .8; }
.sidebar-foot { padding: .8rem; border-top: 1px solid var(--border-soft); }
.org-chip { background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: .55rem .7rem; }
.org-name { font-size: .82rem; font-weight: 600; }
.org-meta { font-size: .7rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.6rem; border-bottom: 1px solid var(--border-soft); background: rgba(11,15,23,.7);
  position: sticky; top: 0; backdrop-filter: blur(8px); z-index: 5;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-badge { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .7rem; color: var(--text-faint); }
.content { padding: 1.6rem; max-width: 1280px; width: 100%; }
.appfoot {
  margin-top: auto; padding: 1rem 1.6rem; border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; color: var(--text-faint); font-size: .75rem;
}

/* ---- Cards & grid ---- */
.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 720px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .sidebar { display:none; } }
.card {
  background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.card-head h3 { margin: 0; }
.card-sub { color: var(--text-faint); font-size: .78rem; }

/* ---- KPI stat ---- */
.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat-label { color: var(--text-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-sub { font-size: .78rem; color: var(--text-faint); }
.stat-value.ok { color: var(--ok); } .stat-value.warn { color: var(--warn); } .stat-value.bad { color: var(--bad); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th {
  text-align: left; padding: .6rem .8rem; color: var(--text-faint); font-weight: 600;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); background: var(--bg-elev);
}
tbody td { padding: .6rem .8rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: none; }
.t-right { text-align: right; } .t-center { text-align: center; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 20px; font-size: .72rem;
  font-weight: 600; text-transform: capitalize; letter-spacing: .01em; border: 1px solid transparent;
}
.sev-critical { background: rgba(255,84,112,.16); color: var(--crit); border-color: rgba(255,84,112,.3); }
.sev-high { background: rgba(255,143,77,.16); color: var(--high); border-color: rgba(255,143,77,.3); }
.sev-medium { background: rgba(255,210,63,.15); color: var(--med); border-color: rgba(255,210,63,.3); }
.sev-low { background: rgba(89,193,255,.15); color: var(--low); border-color: rgba(89,193,255,.3); }
.sev-info { background: rgba(124,137,163,.15); color: var(--info); border-color: rgba(124,137,163,.3); }
.outcome-prevented { background: rgba(56,211,159,.15); color: var(--ok); }
.outcome-detected { background: rgba(89,193,255,.15); color: var(--low); }
.outcome-succeeded { background: rgba(255,84,112,.16); color: var(--crit); }
.outcome-refused { background: rgba(124,137,163,.15); color: var(--info); }
.outcome-error, .outcome-skipped { background: rgba(124,137,163,.12); color: var(--text-faint); }
.status-active, .status-completed, .status-closed, .status-effective, .status-reported { background: rgba(56,211,159,.14); color: var(--ok); }
.status-running, .status-scheduled, .status-in-remediation, .status-partial { background: rgba(79,140,255,.15); color: var(--accent); }
.status-draft, .status-paused, .status-not-tested, .status-queued { background: rgba(124,137,163,.14); color: var(--text-dim); }
.status-blocked, .status-failed, .status-open, .status-ineffective, .status-suspended, .status-revoked, .status-retest-failed { background: rgba(255,84,112,.15); color: var(--crit); }
.status-triaged, .status-awaiting-retest, .status-pending-authorization, .status-risk-accepted { background: rgba(255,210,63,.14); color: var(--med); }
.chip { display:inline-block; padding:.1rem .5rem; background: var(--bg-elev-2); border-radius: 6px; font-size:.74rem; color: var(--text-dim); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elev-2);
  color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f7cf0; }
.btn-danger { background: rgba(255,84,112,.12); border-color: rgba(255,84,112,.4); color: var(--crit); }
.btn-danger:hover { background: rgba(255,84,112,.2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .32rem .65rem; font-size: .78rem; }
.inline { display: inline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---- Forms ---- */
.form { max-width: 760px; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-dim); }
.field .hint { font-size: .74rem; color: var(--text-faint); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: .55rem .7rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: .88rem;
}
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: .82rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field-error { color: var(--crit); font-size: .76rem; margin-top: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }
.row { display: flex; gap: 1rem; } .row > * { flex: 1; }
.checklist { display: grid; grid-template-columns: repeat(2,1fr); gap: .35rem; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: .6rem; }

/* ---- Alerts ---- */
.alert { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .86rem; border: 1px solid; }
.alert-info { background: rgba(79,140,255,.08); border-color: rgba(79,140,255,.3); color: #bcd3ff; }
.alert-warn { background: rgba(255,210,63,.08); border-color: rgba(255,210,63,.3); color: #ffe89a; }
.alert-bad { background: rgba(255,84,112,.08); border-color: rgba(255,84,112,.3); color: #ffb3c0; }
.alert-ok { background: rgba(56,211,159,.08); border-color: rgba(56,211,159,.3); color: #a6f0d6; }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.3rem; gap: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-dim); font-size: .88rem; margin-top: .2rem; }
.section { margin-bottom: 1.6rem; }
.muted { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.empty { padding: 2.5rem; text-align: center; color: var(--text-faint); }

/* ---- Bars / meters ---- */
.mini-bar { height: 6px; background: var(--bg-elev-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.mini-bar span { display: block; height: 100%; border-radius: 4px; }
.mini-bar .ok { background: var(--ok); } .mini-bar .warn { background: var(--warn); } .mini-bar .bad { background: var(--bad); }
.mini-bar .accent { background: var(--accent); }
.meter { display: flex; align-items: center; gap: .6rem; }
.meter-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; text-align: right; }

/* stacked outcome bar */
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg-elev-2); min-width: 120px; }
.stack .s-prevented { background: var(--ok); } .stack .s-detected { background: var(--low); } .stack .s-succeeded { background: var(--crit); }

/* ---- Resilience ring ---- */
.ring-wrap { display: flex; align-items: center; gap: 1.2rem; }
.ring { --p: 0; width: 108px; height: 108px; border-radius: 50%;
  background: conic-gradient(var(--accent-2) calc(var(--p)*1%), var(--bg-elev-2) 0);
  display: grid; place-items: center; position: relative; }
.ring::after { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg-elev); }
.ring-inner { position: relative; z-index: 1; text-align: center; }
.ring-inner .n { font-size: 1.7rem; font-weight: 700; }
.ring-inner .l { font-size: .68rem; color: var(--text-faint); text-transform: uppercase; }

/* ---- Sparkline / trend ---- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; }
.spark .b { flex: 1; background: linear-gradient(180deg, var(--accent), rgba(79,140,255,.25)); border-radius: 2px 2px 0 0; min-height: 3px; }

/* ---- Heatmap ---- */
.heat { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.heat-cell { padding: .55rem .6rem; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); }
.heat-cell .t { font-size: .72rem; color: var(--text-dim); text-transform: capitalize; }
.heat-cell .v { font-size: 1.05rem; font-weight: 700; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 400px; background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .m { font-size: 2.4rem; } .login-brand h1 { font-size: 1.3rem; margin-top: .4rem; }
.login-brand .s { color: var(--text-faint); font-size: .82rem; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: .4rem 1rem; font-size: .86rem; }
.kv dt { color: var(--text-faint); } .kv dd { margin: 0; }
.tag-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border-soft); margin: 1.2rem 0; }
.list-reset { list-style: none; padding: 0; margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { padding: .3rem 0 .7rem 1rem; position: relative; font-size: .84rem; }
.timeline li::before { content:''; position:absolute; left:-5px; top:.6rem; width:8px; height:8px; border-radius:50%; background: var(--accent); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.countdown.overdue { color: var(--crit); }
.countdown.soon { color: var(--warn); }

/* ---- ATT&CK matrix ---- */
.attack { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.attack-col { min-width: 150px; flex: 0 0 150px; }
.attack-col-head { font-size: .72rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .02em; padding: .4rem .3rem; border-bottom: 2px solid var(--border); margin-bottom: 4px;
  position: sticky; top: 0; background: var(--bg); }
.attack-col-head .c { font-weight: 500; color: var(--text-faint); text-transform: none; }
.tcell { display: block; padding: .4rem .5rem; border-radius: 5px; margin-bottom: 4px; border: 1px solid var(--border-soft);
  font-size: .74rem; line-height: 1.25; cursor: default; }
.tcell .tid { font-family: var(--mono); font-size: .68rem; opacity: .75; }
.tcell .tn { display: block; }
.tcell.st-prevented { background: rgba(56,211,159,.16); border-color: rgba(56,211,159,.35); }
.tcell.st-detected { background: rgba(89,193,255,.16); border-color: rgba(89,193,255,.35); }
.tcell.st-succeeded { background: rgba(255,84,112,.18); border-color: rgba(255,84,112,.4); }
.tcell.st-not_tested { background: var(--bg-elev); border-color: var(--border-soft); color: var(--text-faint); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .78rem; align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
