/* SCAD Suite Admin (admin.scad.events): the staff cockpit for SCAD Maps, SCAD Share and licences.
   Same brand DNA as the hub (projects.css): Manrope, warm paper light theme, deep slate-emerald dark theme. */
@font-face { font-family: Manrope; src: url('/assets/manrope-latin.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

:root {
  --bg: #f4f3ec; --side: #eceee4; --panel: #fffef9; --panel-2: #f0f1e8; --sunk: #f7f6f0; --line: #dcdfd2; --line-strong: #c7ccbc;
  --text: #1f3a30; --muted: #5f6d60; --faint: #8a968a;
  --accent: #204e3d; --accent-hover: #2f644d; --on-accent: #fff; --accent-soft: rgba(32, 78, 61, .09); --dot: #81994a;
  --ok: #1f6b35; --ok-bg: #e4f0e2; --warn: #8a5a14; --warn-bg: #f6ecd7; --bad: #b42318; --bad-bg: #fbe6e3;
  --info: #1f5f86; --info-bg: #e3eef5; --sleep: #5b3fa0; --sleep-bg: #ece7f7;
  --shadow: rgba(30, 72, 55, .28); --hover: rgba(32, 78, 61, .055); --scrim: rgba(20, 32, 27, .38);
  --radius: 14px; --side-w: 248px;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0d1714; --side: #0f1c18; --panel: #13221e; --panel-2: #192b25; --sunk: #102019; --line: #243830; --line-strong: #31493f;
  --text: #e6ecdf; --muted: #97a898; --faint: #6f8273;
  --accent: #dbea9b; --accent-hover: #e8f2bd; --on-accent: #16301f; --accent-soft: rgba(219, 234, 155, .1); --dot: #dbea9b;
  --ok: #9fd9a0; --ok-bg: #17321f; --warn: #f2c078; --warn-bg: #2d2615; --bad: #f97066; --bad-bg: #351a18;
  --info: #9ccbea; --info-bg: #142a37; --sleep: #c4b1f5; --sleep-bg: #251f39;
  --shadow: rgba(0, 0, 0, .6); --hover: rgba(219, 234, 155, .055); --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-rail='1'] { --side-w: 72px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 Manrope, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; caret-color: var(--accent); scrollbar-color: var(--line-strong) transparent;
}
::selection { background: var(--dot); color: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--dot); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.ico { flex: 0 0 auto; }

/* ---------------------------------------------------------------- boot + gate screens */
.boot { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 100vh; color: var(--muted); font-weight: 600; }
.boot img { border-radius: 10px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(400px, 100%); padding: 34px 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 70px -45px var(--shadow); text-align: center;
}
.gate-card img { display: block; margin: 0 auto 16px; border-radius: 11px; }
.gate-card h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
.gate-card p { margin: 8px 0 22px; color: var(--muted); }
.gate-card form { display: grid; gap: 10px; text-align: left; }
.gate-card .err { min-height: 18px; color: var(--bad); font-size: 13px; text-align: center; }
.gate-card .linkbtn { margin-top: 14px; }
.gate-eyebrow { display: inline-block; margin-bottom: 10px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s cubic-bezier(.16, 1, .3, 1);
  background: linear-gradient(90deg, var(--side) 0 var(--side-w), var(--bg) var(--side-w)); }
.app.is-booting, .app.is-gate { display: block; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px;
  background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; z-index: 30;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; text-decoration: none; white-space: nowrap; }
.side-brand img { border-radius: 9px; flex: 0 0 auto; }
.side-brand b { font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.side-brand span { color: var(--muted); font-weight: 600; }
.nav-group { display: grid; gap: 2px; margin-top: 8px; }
.nav-label { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 7px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 650; white-space: nowrap; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.is-active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .05), inset 0 0 0 1px var(--line); }
.nav-item.is-active::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .ico { width: 18px; height: 18px; }
.nav-item.is-active .ico { color: var(--accent); }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; text-align: center; line-height: 18px; }
.nav-count.soft { background: var(--panel-2); color: var(--muted); }
.side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
:root[data-rail='1'] .side .nav-label, :root[data-rail='1'] .side .nav-text, :root[data-rail='1'] .side-brand .brand-text, :root[data-rail='1'] .nav-count { display: none; }
:root[data-rail='1'] .nav-item { justify-content: center; padding: 7px; }
:root[data-rail='1'] .side-brand { justify-content: center; padding-inline: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 62px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.top-title h1 { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; }
.top-title .crumb { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: min(300px, 32vw); height: 38px; padding: 0 10px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
kbd { font: 700 11px/1 ui-monospace, Consolas, monospace; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); }
.who-badge { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); max-width: 240px; }
.who-badge .avatar { width: 28px; height: 28px; font-size: 11px; }
.who-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 12px; letter-spacing: .02em; }
.menu-btn { display: none; }
.view { padding: 24px; width: 100%; max-width: 1360px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head h2 { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 650; letter-spacing: -.035em; line-height: 1.15; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stamp { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { border-color: var(--line-strong); background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ico { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--accent); cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.ghost:hover { background: var(--hover); color: var(--text); }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn.is-spinning .ico { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--text); }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--sunk); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type='checkbox'] { width: 17px; height: 17px; min-height: 0; padding: 0; accent-color: var(--accent); }
label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.input-search { position: relative; min-width: 220px; }
.input-search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; width: 16px; height: 16px; }
.input-search input { padding-left: 34px; background: var(--panel); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.err-line { color: var(--bad); font-size: 13px; min-height: 18px; }

/* chips, tabs, badges */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.chip-btn:hover { color: var(--text); border-color: var(--line-strong); }
.chip-btn[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-btn .n { font-variant-numeric: tabular-nums; opacity: .75; }
.chip-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; padding: 10px 14px; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13.5px; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); }
.tab[aria-selected='true']::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  letter-spacing: .01em; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.sleep { background: var(--sleep-bg); color: var(--sleep); }
.badge.outline { background: transparent; border-color: var(--line); }
.default-badge { padding: 1px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 700; }

/* ---------------------------------------------------------------- cards + KPIs */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .03), 0 22px 44px -40px var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 750; letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-head .mark { width: 30px; height: 30px; border-radius: 8px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card + .card { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  position: relative; display: grid; gap: 4px; padding: 16px 18px; text-decoration: none; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, transform .15s;
}
a.kpi:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .02em; }
.kpi-label img { width: 20px; height: 20px; border-radius: 5px; }
.kpi-value { font-size: 30px; font-weight: 650; letter-spacing: -.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; color: var(--muted); font-weight: 650; letter-spacing: 0; }
.kpi-sub { display: flex; gap: 6px 12px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.kpi-sub b { color: var(--text); font-weight: 750; }
.kpi.is-alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.kpi.is-alert .kpi-value { color: var(--bad); }
.kpi.is-calm .kpi-value { color: var(--ok); }
.kpi.is-off .kpi-value { font-size: 16px; color: var(--muted); font-weight: 700; letter-spacing: -.01em; padding: 7px 0; }
.alerts { display: grid; gap: 8px; margin-bottom: 18px; }
.alert {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel); text-decoration: none;
}
.alert .ico { width: 18px; height: 18px; }
.alert.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: color-mix(in srgb, var(--bad-bg) 60%, var(--panel)); }
.alert.bad .ico { color: var(--bad); }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: color-mix(in srgb, var(--warn-bg) 60%, var(--panel)); }
.alert.warn .ico { color: var(--warn); }
.alert b { font-weight: 750; }
.alert .go { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
a.alert:hover .go { color: var(--text); }
.calm { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 11px; background: var(--ok-bg); color: var(--ok); font-weight: 700; margin-bottom: 18px; }
.jumps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.jump {
  display: grid; gap: 4px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); text-decoration: none;
  transition: border-color .15s, background .15s;
}
.jump:hover { border-color: var(--accent); background: var(--panel); }
.jump .ico { width: 20px; height: 20px; color: var(--accent); }
.jump b { font-size: 13.5px; }
.jump span { color: var(--muted); font-size: 12px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 18px; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed .avatar { width: 28px; height: 28px; font-size: 10px; background: var(--panel-2); color: var(--muted); }
.feed-what { min-width: 0; font-size: 13px; }
.feed-what code { font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--panel-2); }
.feed-when { color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data th {
  position: sticky; top: 0; text-align: left; padding: 10px 14px; background: var(--panel); color: var(--faint); font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background .12s; }
.data tbody tr:hover { background: var(--hover); }
.data tr.is-click { cursor: pointer; }
.data .cell-main { display: grid; min-width: 0; }
.data .cell-main b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data .cell-main span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data .actions-cell { text-align: right; white-space: nowrap; }
.data .actions-cell .btn + .btn { margin-left: 4px; }
.data td.num, .data th.num { text-align: right; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .ico { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }
.empty h4 { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.empty p { margin: 0 auto; max-width: 52ch; font-size: 13px; }
.empty .btn { margin-top: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.notice.info { background: var(--info-bg); color: var(--info); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice .ico { width: 18px; height: 18px; margin-top: 1px; }
.notice p { margin: 0; }

/* usage bar */
.usage { display: grid; gap: 4px; min-width: 140px; }
.usage-bar { position: relative; height: 7px; border-radius: 99px; background: var(--panel-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.usage-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); transition: width .4s cubic-bezier(.16, 1, .3, 1); }
.usage-bar.warn i { background: var(--warn); }
.usage-bar.bad i { background: var(--bad); }
.usage-text { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Maps cards */
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.inst {
  display: grid; gap: 12px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.inst:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: 0 16px 36px -30px var(--shadow); }
.inst-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.inst-name { display: grid; min-width: 0; }
.inst-name b { font-size: 15px; font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-name span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: grid; gap: 1px; padding: 8px 10px; border-radius: 9px; background: var(--sunk); }
.stat span { color: var(--faint); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.inst-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.inst.is-down { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.spark { display: block; width: 100%; height: 56px; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.spark path.area { fill: var(--accent-soft); }
.spark rect.down { fill: var(--bad); opacity: .35; }

/* ---------------------------------------------------------------- limits */
.limit-list { display: grid; }
.limit {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(180px, 1fr) auto; align-items: center; gap: 16px; padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.limit:first-child { border-top: 0; }
.limit.is-dirty { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.limit-id b { display: block; font-weight: 700; font-size: 13.5px; }
.limit-id span { color: var(--muted); font-size: 12px; }
.limit-input { display: flex; align-items: center; gap: 8px; }
.limit-input input { max-width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
.limit-input .unit { color: var(--muted); font-size: 12px; font-weight: 700; min-width: 34px; }
.limit-input.wide input { max-width: none; text-align: left; }
.limit-meta { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.limit.is-readonly .limit-input input { background: transparent; border-style: dashed; }
.savebar {
  position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 14px 12px 18px; border-radius: 13px; background: var(--text); color: var(--bg);
  box-shadow: 0 20px 44px -18px var(--shadow); animation: rise .28s cubic-bezier(.16, 1, .3, 1) both;
}
.savebar .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.savebar .btn.primary { background: var(--bg); color: var(--text); border-color: var(--bg); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.limits-row-state { color: var(--muted); font-size: 12.5px; }
.limits-summary { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.limits-summary b { color: var(--text); font-weight: 700; }

/* ---------------------------------------------------------------- drawer, modal, palette, toasts */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(620px, 100vw); display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -30px 0 60px -40px var(--shadow);
  animation: slide .26s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.drawer-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.drawer-body .tabs { margin: -6px -20px 18px; padding: 0 12px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunk); }
.section { margin-top: 22px; }
.section:first-child { margin-top: 0; }
.section h4 { margin: 0 0 10px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.kv { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; display: grid; }
.list .grow b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .grow span { color: var(--muted); font-size: 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 10px; }
.inline-form > * { flex: 1 1 160px; }
.inline-form > .btn { flex: 0 0 auto; }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 40px 90px -40px var(--shadow); animation: pop .22s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal h3 { margin: 0 0 4px; font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.modal > p { margin: 0 0 18px; color: var(--muted); }
.keybox { display: grid; gap: 10px; padding: 16px; border-radius: 13px; background: var(--ok-bg); color: var(--ok); }
.keybox .key { display: flex; gap: 8px; align-items: center; }
.keybox code { flex: 1; padding: 10px 12px; border-radius: 9px; background: var(--panel); color: var(--text); font: 700 15px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
.keybox p { margin: 0; font-size: 13px; }

.palette-wrap { position: fixed; inset: 0; z-index: 80; display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px; }
.palette {
  position: relative; width: min(620px, 100%); border-radius: 16px; background: var(--panel); border: 1px solid var(--line); overflow: hidden;
  box-shadow: 0 40px 90px -30px var(--shadow); animation: pop .18s cubic-bezier(.16, 1, .3, 1) both;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input .ico { width: 18px; height: 18px; color: var(--faint); }
.palette-input input { border: 0; background: transparent; min-height: 54px; padding: 0; font-size: 16px; box-shadow: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.palette-group { padding: 10px 10px 4px; color: var(--faint); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.palette-item .ico { width: 17px; height: 17px; color: var(--muted); }
.palette-item .grow { flex: 1; min-width: 0; display: grid; }
.palette-item .grow b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .grow span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item[aria-selected='true'] { background: var(--accent-soft); }
.palette-item[aria-selected='true'] .ico { color: var(--accent); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; background: var(--sunk); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 36px)); padding: 11px 14px; border-radius: 11px; pointer-events: auto;
  background: var(--text); color: var(--bg); font-weight: 650; font-size: 13px; box-shadow: 0 18px 40px -18px var(--shadow); animation: rise .24s cubic-bezier(.16, 1, .3, 1) both;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast .ico { width: 17px; height: 17px; }

/* skeleton */
.skel { border-radius: 10px; background: linear-gradient(90deg, var(--panel-2), var(--sunk), var(--panel-2)); background-size: 300% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }
.skel-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.skel-kpis div { height: 108px; }
.skel-block { height: 260px; }

/* feedback + errors */
.items { display: grid; gap: 10px; }
.item { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }
.item-head b { color: var(--text); }
.item-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.item pre { margin: 8px 0 0; padding: 10px; max-height: 180px; overflow: auto; border-radius: 9px; background: var(--sunk); font-size: 11.5px; white-space: pre-wrap; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs img { width: 92px; height: 92px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) { .kpis, .skel-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  :root, :root[data-rail='1'] { --side-w: 264px; }
  .app { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; z-index: 25; background: var(--scrim); animation: fade .18s ease both; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); transform: translateX(-102%); transition: transform .24s cubic-bezier(.16, 1, .3, 1); box-shadow: 30px 0 60px -40px var(--shadow); }
  .app.nav-open .side { transform: none; }
  :root[data-rail='1'] .side .nav-label, :root[data-rail='1'] .side .nav-text, :root[data-rail='1'] .side-brand .brand-text, :root[data-rail='1'] .nav-count { display: revert; }
  :root[data-rail='1'] .nav-item { justify-content: flex-start; padding: 7px 10px; }
  .rail-btn { display: none; }
  .menu-btn { display: inline-grid; }
  .top { padding: 0 14px; }
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .who-badge > span:not(.avatar) { display: none; }
  .who-badge { padding: 4px; }
  .view { padding: 18px 14px 40px; }
  .limit { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .limit-meta { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .kpis, .skel-kpis { grid-template-columns: minmax(0, 1fr); }
  .top-title .crumb { display: none; }
  .inst-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .drawer { width: 100vw; }
  .data .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.nav-btn { width: 100%; border: 0; background: none; cursor: pointer; font: inherit; text-align: left; }
.savebar-actions { display: flex; gap: 8px; }
