/* ---- Fonts (self-hosted, latin subset) ------------------------------- */
@font-face { font-family: "Geist"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/geist-400.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/geist-500.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/geist-600.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/geist-700.woff2) format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/geist-mono-400.woff2) format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/geist-mono-500.woff2) format("woff2"); }

/* ---- Tokens ---------------------------------------------------------- */
:root {
  color-scheme: light;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e8eaed;
  --border-strong: #d7dbe0;

  --text: #0d1117;
  --text-2: #51596b;
  --muted: #8b93a3;

  --accent: #18181b;
  --accent-hover: #000000;
  --accent-weak: #f0f0f1;
  --ring: 0 0 0 3px rgba(24, 24, 27, 0.14);

  --up: #047a55;
  --up-bg: #e6f6ef;
  --down: #d4332b;
  --down-bg: #fdeceb;
  --running: #b06a00;
  --running-bg: #fdf1dd;
  --new: #5b6472;
  --new-bg: #eef0f3;

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(13, 17, 23, 0.05);
  --shadow: 0 1px 3px rgba(13, 17, 23, 0.06), 0 8px 24px -12px rgba(13, 17, 23, 0.12);
  --maxw: 1120px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---- Top bar --------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 6px -1px rgba(24, 24, 27, 0.4);
}

.nav { display: flex; flex-wrap: wrap; gap: 4px; }

.nav a {
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-2);
  transition: color 0.15s ease, background 0.15s ease;
}

.nav a:hover { color: var(--text); background: var(--surface-2); }

.nav a.active { color: var(--accent); background: var(--accent-weak); }

.session { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.session .user { font-size: 13.5px; color: var(--text-2); font-weight: 500; }

/* ---- Layout ---------------------------------------------------------- */
.page {
  width: min(var(--maxw), calc(100% - 48px));
  margin: 36px auto 80px;
}

.auth-shell {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
  padding: 24px;
}

/* ---- Headings -------------------------------------------------------- */
.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

h2 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p { margin: 6px 0 0; color: var(--text-2); }

.muted { color: var(--muted); }

.subtitle {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-head p { font-size: 14px; color: var(--muted); }

/* ---- Cards / sections ------------------------------------------------ */
.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.panel { padding: 22px; margin-bottom: 18px; }

.form-panel { max-width: 480px; }

.wide-panel { max-width: 720px; }

/* ---- Notices --------------------------------------------------------- */
.notice {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  padding: 13px 16px;
  border: 1px solid #f3c9c6;
  border-radius: var(--r);
  background: var(--down-bg);
  color: #a3231c;
  font-weight: 500;
  font-size: 14px;
}

.notice.success { border-color: #bce5d3; background: var(--up-bg); color: #056043; }

/* ---- Forms ----------------------------------------------------------- */
label { display: grid; gap: 7px; margin-bottom: 18px; }

label > span,
.field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }

.field-block { display: grid; gap: 9px; margin-bottom: 18px; }

.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.field-head.inline-head { justify-content: flex-start; }

.field-hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }

.field-hint code { font-size: 11.5px; padding: 1px 5px; }

input,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input { min-height: 42px; }

input::placeholder,
textarea::placeholder { color: var(--muted); }

input:focus,
textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

textarea {
  min-height: 150px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

input[readonly] {
  color: var(--text-2);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
}

.toggle-field {
  grid-auto-flow: column;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 10px;
}

.toggle-field input { width: auto; min-height: 0; accent-color: var(--accent); }

.toggle-field span { font-size: 14px; font-weight: 400; color: var(--text-2); }

/* ---- Buttons --------------------------------------------------------- */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.04s ease;
}

button:hover,
.button:hover { background: var(--surface-2); border-color: var(--border-strong); }

button:active,
.button:active { transform: translateY(1px); }

button.primary,
.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.3), 0 4px 12px -4px rgba(24, 24, 27, 0.4);
}

button.primary:hover,
.button.primary:hover { background: var(--accent-hover); }

button.danger { border-color: #f0c4c1; background: var(--surface); color: var(--down); }

button.danger:hover { background: var(--down-bg); border-color: #e8a9a4; }

.small-button { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }

.icon-button { width: 40px; min-width: 40px; padding: 0; font-size: 15px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }

/* ---- Help tooltip ---------------------------------------------------- */
.help-icon {
  position: relative;
  width: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--muted);
  font-size: 11px;
  box-shadow: none;
}

.help-icon::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 40;
  width: min(460px, 80vw);
  padding: 12px 14px;
  border-radius: var(--r);
  background: #0d1117;
  color: #e6e9ee;
  content: attr(data-tooltip);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  text-align: left;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: var(--shadow);
}

.help-icon:hover, .help-icon:focus-visible { border-color: var(--accent); color: var(--accent); }
.help-icon:hover::after, .help-icon:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Grids ----------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.copy-row input { min-width: 0; }

.header-list { display: grid; gap: 8px; }

.header-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }

.header-row input { min-width: 0; }

/* ---- Disclosure ------------------------------------------------------ */
.usage-details { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }

.usage-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  list-style: none;
}

.usage-details summary::-webkit-details-marker { display: none; }
.usage-details summary::before { content: "＋ "; font-weight: 600; }
.usage-details[open] summary::before { content: "－ "; }

.usage-body { display: grid; gap: 7px; margin-top: 12px; }
.usage-body p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* ---- Endpoint -------------------------------------------------------- */
.endpoint .elabel { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.endpoint .elabel b { font-size: 13px; font-weight: 600; color: var(--text); }
.endpoint .elabel .path { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ---- Stat cards ------------------------------------------------------ */
.statboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-tile { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }

.stat-tile .k {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

.stat-tile .k::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--muted); }

.stat-tile .n { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.stat-tile.acc-up .k::before { background: var(--up); }
.stat-tile.acc-down .k::before { background: var(--down); }
.stat-tile.acc-running .k::before { background: var(--running); }

/* ---- Tables ---------------------------------------------------------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }

.table-wrap { overflow-x: auto; }

table { width: 100%; min-width: 720px; border-collapse: collapse; }

thead th {
  padding: 13px 18px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

tbody td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }

td.num, th.num { font-family: var(--mono); font-size: 12.5px; }

.row-link { font-weight: 600; font-size: 14px; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent); }

code {
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}

/* ---- Status badges --------------------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: none; }

.status.large { padding: 6px 14px 6px 11px; font-size: 14px; }
.status.large::before { width: 8px; height: 8px; }

.status-up { color: var(--up); background: var(--up-bg); }
.status-down { color: var(--down); background: var(--down-bg); }
.status-running { color: var(--running); background: var(--running-bg); }
.status-new { color: var(--new); background: var(--new-bg); }

/* ---- Detail ---------------------------------------------------------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
}

.back-link:hover { color: var(--accent); }

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.readout div { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }

.readout span { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }

.readout strong { display: block; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); overflow-wrap: anywhere; }

.readout small { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---- Empty / login --------------------------------------------------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 64px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.empty h2 { margin: 0; }
.empty p { margin: 0 0 14px; }

.login-panel { width: min(400px, 100%); padding: 30px; }

.login-head { display: grid; justify-items: center; gap: 14px; margin-bottom: 26px; text-align: center; }

.login-head .mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 14px -2px rgba(24, 24, 27, 0.4);
}

.login-head h1 { font-size: 22px; }
.login-head p { margin: 0; font-size: 13.5px; color: var(--muted); }

.token-reveal input { border-color: var(--accent); box-shadow: var(--ring); }

/* ---- Danger zone ----------------------------------------------------- */
.danger-zone { border-color: #f0c4c1; }
.danger-zone h2 { color: var(--down); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-row strong { font-size: 14px; font-weight: 600; }
.danger-row p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.danger-row form { flex: none; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 880px) {
  .statboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; gap: 10px 18px; padding: 12px 18px; }
  .session { width: 100%; margin-left: 0; }
  .page { width: calc(100% - 32px); margin-top: 26px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .detail-head { flex-direction: column; }
  .statboard, .form-grid, .header-row, .readout { grid-template-columns: 1fr; }
  .danger-row { flex-direction: column; align-items: stretch; }
  .icon-button { width: 100%; }
}
