/* One stylesheet, no framework, no external font. Every asset must be same-origin
   so the CSP in phase 05 can stay at default-src 'none'. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1b1f24;
  --muted: #62707f;
  --accent: #1f6feb;
  --danger: #c0362c;
  --ok: #1a7f4b;
  --warn: #a86a00;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --surface: #1c2126; --border: #2d343b; --text: #e6edf3;
    --muted: #8b98a5; --accent: #4c8dff; --danger: #f0796b; --ok: #4cc38a; --warn: #d9a441;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

/* --- gate ---------------------------------------------------------------- */
#gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

#gate-form {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#gate-form h1 { margin: 0; font-size: 20px; }
#gate-form label { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* --- shell --------------------------------------------------------------- */
header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 600; }
#nav { display: flex; gap: 4px; margin-right: auto; }

#nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
}
#nav a:hover { background: var(--bg); color: var(--text); }
#nav a.active { background: var(--accent); color: #fff; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 20px; margin: 0; }

/* --- controls ------------------------------------------------------------ */
button, input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
}

button { cursor: pointer; background: var(--accent); color: #fff; border-color: transparent; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); }

input:focus-visible, button:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.error { color: var(--danger); margin: 4px 0 0; font-size: 14px; }

.error-box {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 12px 16px;
}
.error-box p { margin: 4px 0 0; }
.empty { padding: 28px; text-align: center; }

/* --- table --------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Long, client-controlled values (user agents, gateway ids) must not stretch the
   table; the row stays readable and the full value goes in a title attribute. */
td.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- dialog + toast ------------------------------------------------------ */
dialog.confirm {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  max-width: 440px;
}
dialog.confirm h2 { margin: 0 0 10px; font-size: 17px; }
dialog.confirm .row { margin-top: 16px; justify-content: flex-end; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; }

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: 380px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--danger); border-color: var(--danger); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
