/* ============================================================================
   Minalav Admin · styles
   ----------------------------------------------------------------------------
   Tokens are lifted from the tools' auth.css so the console reads as part of
   the same product rather than a utility bolted on beside it.

   MOTION POLICY
   Only transform and opacity animate — never width, height, margin or a
   position offset, which force layout on every frame. Transitions, not
   keyframes, because a transition retargets from wherever the property
   currently is while a keyframe restarts from zero: the drawer must survive
   being opened, half-closed and reopened.

   ease-out on enter and exit; nothing uses ease-in, which reads as sluggish on
   UI. Durations sit under 250ms. Entrances start at scale(0.97), never
   scale(0) — a panel that grows from nothing reads as a cartoon.

   Reduced motion ships here, not as a follow-up, and is gentler rather than
   absent: the movement is removed, the fade is kept, so state changes are
   still legible.
   ========================================================================= */

:root {
  --ink: #1c1f23;
  --ink-soft: #565c66;
  --ink-faint: #8a9099;
  --line: #e3e5e9;
  --line-strong: #c9ccd2;
  --page: #fbfbfa;
  --card: #ffffff;
  --brand: #0B1F3A;
  --brand-mid: #122A4C;
  --accent: #005EA6;
  --accent-soft: #eaf2fa;
  --red: #a4302a;
  --red-soft: #fdecea;
  --green: #2f6b4f;
  --green-soft: #eaf4ee;
  --amber: #8a6320;
  --amber-soft: #fdf3e3;

  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Strong curves rather than the weak built-ins: the difference between
     "animated" and "designed" is mostly here. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
a { color: var(--accent); }

/* ===== Sign-in gate ====================================================== */
#gate {
  position: fixed; inset: 0; z-index: 200;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#gate .box {
  background: var(--card); border-radius: 10px;
  padding: 34px 32px; width: 100%; max-width: 360px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
#gate h1 { font-size: 17px; margin: 0 0 3px; letter-spacing: -.01em; }
#gate .sub {
  font-family: var(--mono); font-size: 10px; color: var(--ink-faint);
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: 22px;
}
#gate label {
  display: block; font-size: 10px; font-weight: 600; color: var(--ink-soft);
  letter-spacing: .05em; text-transform: uppercase; margin: 0 0 4px;
}
#gate input {
  width: 100%; height: 36px; padding: 0 11px; margin-bottom: 12px;
  border: 1px solid var(--line-strong); border-radius: 5px;
  font-family: var(--mono); font-size: 13px; background: var(--page);
}
#gate input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.gate-step { display: none; }
.gate-step.on { display: block; }

/* ===== Shell ============================================================= */
.topbar {
  background: var(--brand); color: #fff;
  height: 52px; padding: 0 20px;
  display: flex; align-items: center; gap: 18px;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 40;
}
.brand { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.brand small {
  display: block; font-family: var(--mono); font-size: 9px;
  color: rgba(255, 255, 255, .45); letter-spacing: .12em; text-transform: uppercase;
  font-weight: 400;
}
.nav { display: flex; gap: 2px; margin-left: 8px; flex: 1; overflow-x: auto; }
.nav button {
  background: none; border: 0; color: rgba(255, 255, 255, .6);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 6px 11px; border-radius: 5px; cursor: pointer; white-space: nowrap;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
}
.nav button:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav button.on { color: #fff; background: rgba(255, 255, 255, .14); }
.topbar .who { font-family: var(--mono); font-size: 10px; color: rgba(255, 255, 255, .55); }

.wrap { max-width: 1400px; margin: 0 auto; padding: 22px 20px 80px; }
.view { display: none; }
.view.on { display: block; }

/* ===== Type ============================================================== */
h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; letter-spacing: -.01em; }
.lede { font-size: 12px; color: var(--ink-soft); margin: 0 0 16px; max-width: 68ch; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }

/* ===== Panels & tables =================================================== */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; overflow: hidden; }
.panel-h {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-b { padding: 14px; }
.panel-b.flush { padding: 0; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th {
  font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--page); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background 100ms var(--ease-out); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.empty { padding: 30px 14px; text-align: center; color: var(--ink-faint); font-size: 12px; }

/* ===== Stat tiles ======================================================== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px; }
.tile .k { font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 5px; }
.tile .v { font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .n { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.tile.warn { border-color: #e8cfa0; background: var(--amber-soft); }
.tile.warn .v { color: var(--amber); }

/* ===== Controls ========================================================== */
.btn {
  height: 30px; padding: 0 13px; border-radius: 5px; border: 1px solid transparent;
  background: var(--accent); color: #fff; cursor: pointer;
  font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .03em;
  transition: background 120ms var(--ease-out), opacity 120ms var(--ease-out);
}
.btn:hover { background: #0070c4; }
.btn:disabled { background: var(--line-strong); cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--accent); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.danger { background: var(--card); color: var(--red); border-color: #e0bdba; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 25px; padding: 0 9px; font-size: 10px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 9px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  height: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 5px;
  background: var(--card); font-family: var(--mono); font-size: 12px; color: var(--ink); min-width: 0;
}
.field textarea { height: auto; padding: 7px 9px; font-family: var(--sans); resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.search { height: 30px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; min-width: 220px; background: var(--card); }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ===== Chips ============================================================= */
.chip {
  display: inline-block; font-size: 10px; font-weight: 600; line-height: 1.7;
  padding: 1px 8px; border-radius: 20px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink-soft); margin: 1px 3px 1px 0; white-space: nowrap;
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: #b9d6ef; }
.chip.good { background: var(--green-soft); color: var(--green); border-color: #b9dcc8; }
.chip.warnc { background: var(--amber-soft); color: var(--amber); border-color: #e8cfa0; }
.chip.bad { background: var(--red-soft); color: var(--red); border-color: #e6bdba; }
.chip.tog { cursor: pointer; user-select: none; transition: background 110ms var(--ease-out), border-color 110ms var(--ease-out); }
.chip.tog:hover { border-color: var(--accent); }

/* ===== Status line ======================================================= */
.status { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); min-height: 16px; }
.status.err { color: var(--red); }
.status.ok { color: var(--green); }
.hint { font-size: 11px; color: var(--ink-faint); }
.banner {
  border: 1px solid #e8cfa0; background: var(--amber-soft); color: var(--amber);
  border-radius: 7px; padding: 10px 13px; font-size: 12px; margin-bottom: 16px;
}
.banner.bad { border-color: #e6bdba; background: var(--red-soft); color: var(--red); }
.banner strong { font-weight: 600; }

/* ===== Drawer ============================================================
   Slides on transform, not on `right`, so the compositor owns every frame.
   ========================================================================= */
.scrim {
  position: fixed; inset: 0; background: rgba(11, 31, 58, .38); z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease-out);
}
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--card); z-index: 110; overflow-y: auto;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 44px rgba(0, 0, 0, .13);
  transform: translateX(100%);
  transition: transform 220ms var(--ease-out);
}
.drawer.on { transform: translateX(0); }
.drawer-h {
  position: sticky; top: 0; background: var(--brand); color: #fff;
  padding: 14px 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.drawer-h .t { font-size: 13px; font-weight: 600; word-break: break-all; }
.drawer-h .s { font-family: var(--mono); font-size: 10px; color: rgba(255, 255, 255, .5); margin-top: 2px; }
.drawer-b { padding: 16px 18px 60px; }
.x {
  background: rgba(255, 255, 255, .12); border: 0; color: #fff; cursor: pointer;
  width: 26px; height: 26px; border-radius: 5px; font-size: 15px; line-height: 1; flex: 0 0 auto;
  transition: background 120ms var(--ease-out);
}
.x:hover { background: rgba(255, 255, 255, .25); }

.dsec { margin-bottom: 20px; }
.dsec h3 {
  font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 12px; font-size: 12px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 11px; word-break: break-word; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ===== Modal =============================================================
   Centered, so no transform-origin at a trigger — a modal is not spatially
   anchored to the button that opened it.
   ========================================================================= */
.modal {
  position: fixed; inset: 0; z-index: 120; display: flex;
  align-items: flex-start; justify-content: center; padding: 6vh 16px 16px;
  overflow-y: auto;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease-out);
}
.modal.on { opacity: 1; pointer-events: auto; }
.modal .card {
  background: var(--card); border-radius: 10px; width: 100%; max-width: 520px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, .26);
  transform: scale(.97);
  transition: transform 180ms var(--ease-out);
}
.modal.on .card { transform: scale(1); }
.modal .card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-h { padding: 16px 18px 0; }
.modal-b { padding: 14px 18px; display: flex; flex-direction: column; gap: 11px; }
.modal-f { padding: 12px 18px 16px; display: flex; gap: 8px; align-items: center; justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-f .status { margin-right: auto; }

.picker { display: flex; flex-wrap: wrap; gap: 5px; }
.linkout {
  font-family: var(--mono); font-size: 11px; word-break: break-all;
  background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px;
}

/* ===== Matrix ============================================================ */
.matrix th.tool { text-align: center; font-size: 9px; }
.matrix td.cell { text-align: center; }
.matrix input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
.matrix tr.sel { background: var(--accent-soft); }

/* ===== Bars ==============================================================
   A plain flex bar rather than a chart library: three numbers do not justify
   a dependency, and the console's CSP lists no chart CDN.
   ========================================================================= */
.bar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: transform 260ms var(--ease-out); transform-origin: left center; }

/* ===== Reduced motion ====================================================
   Gentler, not absent: movement goes, the fade stays, so a drawer opening is
   still perceptible as a change of state.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
  .drawer { transition: opacity 140ms linear; transform: none; opacity: 0; }
  .drawer.on { opacity: 1; }
  .modal .card { transform: none; }
  .modal.on .card { transform: none; }
}

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 14px; gap: 8px; }
  .wrap { padding: 16px 14px 60px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { font-size: 11px; margin-top: 6px; }
}
