/* ITAM-agent UI. Plain CSS, no build step. Tokens first, then layout, then components. */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-700.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); }

:root {
  --ground: #F4F5F2;
  --surface: #FFFFFF;
  --ink: #15212B;
  --ink-2: #33414C;
  --muted: #55626C;
  --line: #DCE1DE;
  --line-soft: #E6EAE8;
  --field: #C5CDC9;
  --teal: #0B6B65;
  --teal-dark: #074A46;
  --teal-soft: #DCEEEB;
  --teal-mid: #9ACFC8;
  --teal-ink: #0B5550;
  --amber: #E8A33D;
  --amber-soft: #FBEBD5;
  --amber-ink: #7A4100;
  --red: #A8321F;
  --red-soft: #F6E0DC;
  --red-ink: #8A2516;
  --side: #15212B;
  --side-2: #22313D;
  --side-3: #1C2A35;
  --side-text: #C9D3DA;
  --side-muted: #9FB0BC;
  --r: 8px;
  --r-lg: 12px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* --- layout ---------------------------------------------------------------------------------- */

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 232px; max-width: 100%; background: var(--side); color: var(--side-text); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.content { flex: 999 1 560px; min-width: 0; }
.page { max-width: 1280px; padding: 32px clamp(16px, 3vw, 40px) 64px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: #FFFFFF; text-decoration: none; }
.brand:hover { color: #FFFFFF; }
.brand b { font-weight: 600; font-size: 16px; display: block; line-height: 1.2; }
.brand small { font-size: 12px; color: var(--side-muted); display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border-radius: var(--r); color: var(--side-text); text-decoration: none; }
.nav a:hover { background: var(--side-3); color: #FFFFFF; }
.nav a[aria-current="page"] { background: var(--side-2); color: #FFFFFF; font-weight: 500; }
.nav svg { flex: 0 0 auto; }
.nav .count { margin-left: auto; background: var(--amber); color: var(--ink); font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--r); background: var(--side-3); font-size: 13px; }
.side-foot .who { display: flex; flex-direction: column; }
.side-foot .who b { color: #FFFFFF; font-weight: 500; }
.side-foot span { color: var(--side-muted); }
.side-foot button { align-self: flex-start; background: transparent; border: 1px solid #3A4B58; color: var(--side-text); border-radius: var(--r); padding: 4px 10px; font: inherit; cursor: pointer; }
.side-foot button:hover { color: #FFFFFF; border-color: var(--side-muted); }
@media (max-width: 820px) {
  .side { gap: 16px; padding: 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
}

.killbanner { background: var(--red); color: #FFFFFF; padding: 10px clamp(16px, 3vw, 40px); font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.killbanner a { color: #FFFFFF; }
.demobanner { background: var(--amber-soft); color: var(--amber-ink); padding: 8px clamp(16px, 3vw, 40px); font-size: 14px; }

.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.page-head .lead { display: flex; flex-direction: column; gap: 4px; }
.page-head .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--muted); font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--teal); }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #1E8A5A; }
.status-dot.off { color: var(--red); }
.status-dot.off::before { background: var(--red); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.grid.hero { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }

/* --- components ------------------------------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head a { font-size: 14px; }

.money { border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 6px; }
.money .label { font-size: 14px; font-weight: 500; }
.money .big { font-size: clamp(32px, 4vw, 44px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.money .big small { font-size: 18px; font-weight: 500; }
.money.realized { background: var(--teal); color: #FFFFFF; }
.money.realized .label { color: #CDE7E3; }
.money.realized p { color: #E3F2F0; }
.money.pending { background: var(--surface); border: 1px solid var(--line); }
.money.pending .label, .money.pending small, .money.pending p { color: var(--muted); }
.money .btn { align-self: flex-start; margin-top: 8px; }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--teal-mid); color: inherit; }
.kpi .n { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { font-weight: 500; }
.kpi .s { font-size: 13px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--teal); }
.legend i.pend { background: var(--teal-mid); }
.bars { display: flex; flex-direction: column; gap: 18px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.bar-row .top b { font-weight: 500; }
.bar { display: flex; height: 12px; border-radius: 6px; background: #EEF1EF; overflow: hidden; }
.bar .real { background: var(--teal); }
.bar .pend { background: var(--teal-mid); }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.feed li { display: flex; gap: 12px; align-items: flex-start; }
.feed time { flex: 0 0 44px; font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 2px; }
.feed .dot { flex: 0 0 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--muted); }
.feed .dot.ok { background: var(--teal); }
.feed .dot.wait { background: var(--amber); }
.feed .dot.bad { background: var(--red); }
.feed b { font-weight: 500; display: block; }
.feed span { font-size: 13px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--teal-mid); color: inherit; }
.tile .n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .n.bad { color: var(--red); }
.tile .n.warn { color: var(--amber-ink); }
.tile b { font-size: 14px; font-weight: 500; }
.tile span { font-size: 13px; color: var(--muted); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.rows li:first-child { border-top: 0; }

.callout { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--ground); border-radius: 10px; }
.callout div { display: flex; flex-direction: column; }
.callout b { font-weight: 500; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; padding: 8px 10px; }
td { padding: 12px 10px; border-top: 1px solid var(--line-soft); vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 13px; color: var(--muted); }
tr.detail td { border-top: 0; padding-top: 0; }

/* pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; background: #E8ECEA; color: var(--muted); }
.pill.ok, .pill.L2, .pill.executed, .pill.verified, .pill.succeeded, .pill.resolved, .pill.high-conf { background: var(--teal-soft); color: var(--teal-ink); }
.pill.wait, .pill.L1, .pill.proposed, .pill.open, .pill.running, .pill.mid-conf, .pill.approved { background: var(--amber-soft); color: var(--amber-ink); }
.pill.bad, .pill.failed, .pill.rejected, .pill.dismissed, .pill.low-conf, .pill.rolled_back { background: var(--red-soft); color: var(--red-ink); }
.pill.actioned { background: var(--teal-soft); color: var(--teal-ink); }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #FFFFFF; font-weight: 600; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #FFFFFF; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #FFFFFF; font-weight: 600; }
.btn.dark:hover { background: #000000; color: #FFFFFF; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.danger.solid { background: var(--red); color: #FFFFFF; }
.btn.small { min-height: 36px; padding: 0 12px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
label.field span { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea { min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: var(--r); font: inherit; background: var(--surface); color: var(--ink); }
textarea { padding: 10px 12px; min-height: 80px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; }
.chip:hover { border-color: var(--muted); color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.chip .c { opacity: 0.75; }

.notice { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--teal-mid); background: var(--teal-soft); color: var(--teal-dark); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.notice.bad { border-color: #E2B4AB; background: var(--red-soft); color: var(--red-ink); }
.notice.wait { border-color: #EBC892; background: var(--amber-soft); color: var(--amber-ink); }
#flash:empty { display: none; }

.empty { padding: 32px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.empty b { color: var(--ink); font-weight: 500; }

/* inbox */
.inbox { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.inbox-list { flex: 1 1 380px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.inbox-list ul { list-style: none; margin: 0; padding: 0; }
.inbox-list li { display: flex; align-items: stretch; border-bottom: 1px solid var(--line-soft); }
.inbox-list li:last-child { border-bottom: 0; }
.inbox-list li.on { background: #F0F7F6; box-shadow: inset 3px 0 0 var(--teal); }
.inbox-list li.done { background: #FAFBFA; }
.inbox-list .check { flex: 0 0 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.inbox-list .item { flex: 1 1 auto; min-width: 0; display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 14px 16px 14px 0; color: inherit; text-decoration: none; }
.inbox-list .item:hover { color: inherit; }
.inbox-list .item .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inbox-list .item b { font-weight: 600; }
.inbox-list .item .r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.inbox-list .more { padding: 12px 16px; font-size: 14px; color: var(--muted); }
.inbox-detail { flex: 1.4 1 480px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: 0.06em; }
.stat { border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 400; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: #EEF1EF; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--teal); }
.meter i.mid { background: #C27A12; }
.meter i.low { background: var(--red); }
.facts { margin: 0; display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 6px 16px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.explain { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.explain div { background: var(--ground); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.explain b { font-size: 13px; font-weight: 600; }
.explain span { font-size: 14px; color: var(--ink-2); }
.decide { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.decide .buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--ink); color: #FFFFFF; border-radius: 10px; }
.bulkbar[hidden] { display: none; }
.bulkbar .btn { min-height: 40px; }
.bulkbar .btn.ghost { background: transparent; border-color: var(--muted); color: #FFFFFF; }
.bulkbar .btn.go { background: #2BA58F; border-color: #2BA58F; color: #08211E; font-weight: 600; }

details.why summary { cursor: pointer; color: var(--teal); font-size: 14px; }
details.why[open] summary { margin-bottom: 8px; }
pre { background: var(--ground); padding: 10px; border-radius: var(--r); overflow-x: auto; font-size: 12px; margin: 6px 0 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .box { width: min(100%, 400px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; display: flex; flex-direction: column; gap: 20px; }
.login .brand { color: var(--ink); padding: 0; }
.login .brand small { color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 14px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
