/* ATLAS Control Admin. Tokens are copied from ATLAS's own dark theme (packages/designer/src/themes/atlas.css):
   Ink and Graphite surfaces, Paper legends, Geist + Geist Mono, Signal amber on exactly one action per screen.
   Green / blue / red are state colours only. No inline styles anywhere (the CSP forbids them). */
@font-face { font-family: 'Geist Atlas'; font-display: block; font-weight: 100 900; src: url('/fonts/geist-latin-wght-normal.woff2') format('woff2-variations'); }
@font-face { font-family: 'Geist Mono Atlas'; font-display: block; font-weight: 100 900; src: url('/fonts/geist-mono-latin-wght-normal.woff2') format('woff2-variations'); }

:root {
  color-scheme: dark;
  --font: 'Geist Atlas', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Geist Mono Atlas', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ink: #0d0e10; --graphite: #16181b; --slate: #5d636b; --mist: #a6abb1; --paper: #f4f4f1; --amber: #f5a524;
  --key: #24272c; --key-hover: #2c3036; --well: #0d0e10;
  --line: rgba(244, 244, 241, 0.09); --field-edge: rgba(166, 171, 177, 0.6); --faint: #878d94;
  --green: #4cc38a; --red: #ff6369; --red-text: #ff8b8f; --notice: #6cb6ff; --notice-tint: #121c28;
  --edge-top: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --lift: 0 1px 0 rgba(0, 0, 0, 0.7), 0 3px 6px rgba(0, 0, 0, 0.32);
  --sink: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  --float: 0 28px 70px rgba(0, 0, 0, 0.62), 0 2px 6px rgba(0, 0, 0, 0.5);
  --scrim: rgba(5, 6, 7, 0.76);
  --r2: 8px; --r3: 12px; --r4: 16px;
}
* { box-sizing: border-box; scrollbar-color: var(--slate) transparent; }
html, body { margin: 0; background: var(--ink); color: var(--paper); }
body { font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; min-height: 100vh; }
::selection { background: var(--paper); color: var(--ink); }
h1 { font-size: 24px; line-height: 1.2; font-weight: 500; margin: 0; }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; }
h3 { font: 400 12px/1.3 var(--mono); color: var(--mist); margin: 0 0 8px; letter-spacing: .01em; }
a { color: var(--paper); }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--mist); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--graphite); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 4px 10px 18px; }
.brand b { font-weight: 500; letter-spacing: .08em; font-size: 15px; }
.brand span { font: 400 12px var(--mono); color: var(--mist); }
.nav a { display: block; padding: 9px 12px; border-radius: var(--r2); text-decoration: none; color: var(--mist); min-height: 40px; line-height: 22px; }
.nav a:hover { background: var(--key); color: var(--paper); }
.nav a[aria-current='page'] { background: var(--key); color: var(--paper); box-shadow: var(--edge-top); }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.side .who .mono { color: var(--mist); display: block; margin-bottom: 8px; overflow-wrap: anywhere; }
.side .who button { margin: 0 6px 6px 0; }
.card .kv + .actions, .card .kv + p { margin-top: 18px; }
.main { padding: 28px 32px 64px; max-width: 1200px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--mist); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
button, .btn { font: 500 14px var(--font); color: var(--paper); background: var(--key); border: 1px solid var(--line); border-radius: var(--r2); padding: 0 16px; min-height: 40px; cursor: pointer; box-shadow: var(--edge-top), var(--lift); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover { background: var(--key-hover); }
button:active { box-shadow: var(--sink); transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
button.primary { background: var(--amber); color: var(--ink); border-color: transparent; }
button.primary:hover { background: #ffb740; }
button.danger { color: var(--red-text); border-color: rgba(255, 99, 105, .45); }
button.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
button.link { background: none; border: 0; box-shadow: none; padding: 0; min-height: 0; color: var(--paper); text-decoration: underline; text-underline-offset: 3px; font-weight: 400; display: inline; }
label { display: block; font: 400 12px var(--mono); color: var(--mist); margin-bottom: 6px; }
input, select, textarea { width: 100%; font: 400 15px var(--font); color: var(--paper); background: var(--well); border: 1px solid var(--field-edge); border-radius: var(--r2); padding: 9px 12px; min-height: 40px; box-shadow: var(--sink); }
textarea { min-height: 84px; resize: vertical; }
input[disabled], textarea[disabled], select[disabled] { color: var(--mist); border-color: var(--line); }
input[type='checkbox'] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--paper); }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.check label { margin: 0; font: 400 14px var(--font); color: var(--paper); }

/* ---------- cards, tables, pills ---------- */
.card { background: var(--graphite); border: 1px solid var(--line); border-radius: var(--r3); padding: 18px; box-shadow: var(--edge-top); margin-bottom: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--graphite); border: 1px solid var(--line); border-radius: var(--r3); padding: 14px 16px; box-shadow: var(--edge-top); }
.tile .n { font: 500 28px/1.1 var(--mono); }
.tile .l { font: 400 12px var(--mono); color: var(--mist); margin-top: 6px; }
.tile.ok .n { color: var(--green); } .tile.warn .n { color: var(--notice); } .tile.down .n { color: var(--red-text); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r3); background: var(--graphite); margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th { font: 400 12px var(--mono); color: var(--mist); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; min-width: 96px; }
tr:last-child td { border-bottom: 0; }
tbody tr.row { cursor: pointer; } tbody tr.row:hover { background: var(--key); }
td.num, th.num { text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 400 12px var(--mono); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--slate); }
.pill.ok { color: var(--green); } .pill.ok::before { background: var(--green); }
.pill.warn, .pill.expiring { color: var(--notice); } .pill.warn::before, .pill.expiring::before { background: var(--notice); }
.pill.down, .pill.lapsed, .pill.revoked { color: var(--red-text); } .pill.down::before, .pill.lapsed::before, .pill.revoked::before { background: var(--red); }
.pill.active { color: var(--green); } .pill.active::before { background: var(--green); }
.pill.unknown, .pill.none, .pill.superseded { color: var(--mist); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--mist); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; min-height: 40px; }
.tabs a[aria-current='page'] { color: var(--paper); border-bottom-color: var(--paper); }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { font: 400 12px var(--mono); color: var(--mist); padding-top: 3px; } .kv dd { margin: 0; overflow-wrap: anywhere; }
pre.log { background: var(--well); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px; font: 400 13px/1.5 var(--mono); overflow: auto; max-height: 60vh; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; box-shadow: var(--sink); }
.notice { background: var(--notice-tint); border: 1px solid rgba(108, 182, 255, .35); border-radius: var(--r2); padding: 12px 14px; margin-bottom: 16px; }
.notice.bad { background: #2a1214; border-color: rgba(255, 99, 105, .4); }
.secret { font: 500 16px var(--mono); letter-spacing: .06em; background: var(--well); border: 1px dashed var(--slate); border-radius: var(--r2); padding: 12px; overflow-wrap: anywhere; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; font: 500 15px var(--mono); background: var(--well); border-radius: var(--r2); padding: 14px; user-select: all; }
.empty { color: var(--mist); padding: 26px; text-align: center; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { max-width: 320px; } .toolbar select { max-width: 200px; }
.ent { display: flex; flex-wrap: wrap; gap: 6px; } .ent span { font: 400 12px var(--mono); background: var(--key); padding: 2px 8px; border-radius: var(--r2); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tier-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tier-row:last-child { border-bottom: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font: 400 13px var(--font); color: var(--paper); margin: 0; min-height: 32px; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 420px; padding: 26px; margin: 0; }
.auth h1 { margin-bottom: 4px; } .auth p { color: var(--mist); margin: 0 0 20px; }
.auth .brand { padding: 0 0 18px; }

/* ---------- modal + toast ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; z-index: 20; overflow-y: auto; }
.dialog { background: var(--graphite); border: 1px solid var(--slate); border-radius: var(--r4); box-shadow: var(--float); padding: 22px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog.wide { max-width: 860px; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--key); border: 1px solid var(--slate); border-radius: var(--r2); padding: 12px 14px; box-shadow: var(--float); }
.toast.bad { border-color: var(--red); color: var(--red-text); }

/* ---------- responsive ---------- */
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar { display: block; background: var(--graphite); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .topbar .row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; }
  .topbar nav { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px 8px; }
  .topbar nav a { padding: 8px 12px; color: var(--mist); text-decoration: none; border-radius: var(--r2); white-space: nowrap; min-height: 40px; line-height: 24px; }
  .topbar nav a[aria-current='page'] { background: var(--key); color: var(--paper); }
  .main { padding: 20px 16px 56px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: 10px; }
  h1 { font-size: 21px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar input, .toolbar select { max-width: none; }
  .page-head .actions button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
