:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191f;
  --muted: #5d6573;
  --line: #dfe3e8;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok-bg: #e8f5ec;
  --ok: #1d6b3a;
  --warn-bg: #fff6e0;
  --warn: #7a5200;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --text: #e7eaee;
    --muted: #9aa3af;
    --line: #2c323b;
    --accent: #5b9bf0;
    --accent-text: #0b1220;
    --danger: #f08b80;
    --danger-bg: #3a1d1b;
    --ok-bg: #16301f;
    --ok: #8fd6a6;
    --warn-bg: #352a12;
    --warn: #f0cd7c;
    color-scheme: dark;
  }
}

* { 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;
}

a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 20px; }
.top nav a { text-decoration: none; }
.top nav form { margin: 0; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-top: 16px;
}
.card.narrow { max-width: 380px; margin: 10vh auto 0; }
.card.narrow-left { max-width: 440px; }
.card.empty p { margin: 0 0 4px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
input, textarea, select {
  font: inherit; font-weight: 400; padding: 8px 10px; height: 38px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.error { font-weight: 400; color: var(--danger); font-size: 13px; }
.error:empty { display: none; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer; display: inline-block; text-decoration: none;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; }

.alert, .notice, .warning { padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; }
.alert { background: var(--danger-bg); color: var(--danger); }
.alert ul { margin: 0; padding-left: 18px; }
.alert.validation-summary-valid { display: none; }
.notice { background: var(--ok-bg); color: var(--ok); }
.warning { background: var(--warn-bg); color: var(--warn); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.app-name { font-weight: 600; display: block; text-decoration: none; }

@media (max-width: 600px) {
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top nav { gap: 14px; }
}

/* Secrets page */
textarea { height: auto; min-height: 90px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.45; }
select { height: 38px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.crumb { display: inline-block; margin-bottom: 6px; text-decoration: none; font-size: 13px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
code.slug { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
form.inline { display: inline; margin: 0; }
form.split { display: inline-flex; }
form.split button:first-child { border-radius: 6px 0 0 6px; }
form.split button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
button.small, .button.small { padding: 4px 9px; font-size: 13px; font-weight: 500; }
button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; overflow-y: hidden; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* The side panel is a drawer over the right edge, so the table keeps its full width. */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 10; width: min(420px, 100vw);
  margin: 0; border-radius: 0; border-width: 0 0 0 1px; overflow-y: auto;
  box-shadow: -12px 0 32px rgba(0, 0, 0, .25);
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: 13px; text-decoration: none; }

table.secrets td { vertical-align: top; }
code.key { font-weight: 600; overflow-wrap: anywhere; }
table.secrets td:first-child { min-width: 200px; }
.value-cell { min-width: 160px; max-width: 320px; }
.secret { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; color: var(--muted); letter-spacing: 1px; }
.secret.revealed { color: var(--text); letter-spacing: 0; white-space: pre-wrap; word-break: break-all; background: var(--warn-bg); padding: 2px 4px; border-radius: 4px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 2px; }
tr.selected td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.versions { list-style: none; margin: 0 0 12px; padding: 0; }
.versions li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.versions li:last-child { border-bottom: 0; }
.versions .muted { font-size: 13px; }

details.deleted { margin-top: 16px; }
details.deleted summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.deleted ul { list-style: none; padding: 0; margin: 8px 0 0; }
details.deleted li { display: flex; gap: 12px; align-items: baseline; padding: 4px 0; }

.status { font-weight: 600; }
.status-new { color: var(--ok); }
.status-changed { color: var(--accent); }
.status-same { color: var(--muted); font-weight: 400; }
.status-invalid { color: var(--danger); }
.problems { color: var(--warn); margin: 12px 0 0; padding-left: 18px; }
.env-name { color: var(--accent); }

/* Tokens page */
.lead { margin: -6px 0 16px; max-width: 70ch; }
.copy-row { display: flex; gap: 8px; margin: 8px 0 12px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.created-token { border-color: var(--accent); }
.token-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.token-form label { min-width: 180px; }
.tokens { margin-top: 16px; }
tr.revoked td { color: var(--muted); }
