:root {
  --bg: #FAFAF8;
  --ink: #1A1A1A;
  --muted: #8A8A85;
  --border: #E4E4E0;
  --accent: #2B5CE6;
  --accent-soft: #EDF1FD;
  --danger: #C0392B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

nav.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

nav.topbar .brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}

nav.topbar .links { display: flex; gap: 20px; align-items: center; font-size: 14px; }
nav.topbar .links a.button { color: var(--ink); }

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 28px; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
  margin-bottom: 8px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }

.btn {
  display: inline-block;
  border: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--border); }

form .field { margin-bottom: 18px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
form input[type="text"], form input[type="email"], form input[type="url"],
form input[type="number"], form input[type="date"], form input[type="password"],
form textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}
form select {
  width: 100%;
  border: 1px solid var(--border);
  /* Solid, not transparent: a <select>'s open option-list popup is drawn
     by the browser/OS, not the page, and doesn't reliably inherit a
     transparent background -- it tends to fall back to a system default
     (often white), which combined with var(--ink) text color can render
     as invisible white-on-white in dark mode. option { } below applies
     the same treatment to the popup's individual rows. */
  background: var(--bg);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14.5px;
  color: var(--ink);
  font-family: inherit;
}
form select option {
  background: var(--bg);
  color: var(--ink);
}
form input:focus, form textarea:focus, form select:focus { outline: none; border-color: var(--accent); }
form .helptext { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
form ul.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.muted { background: var(--border); color: var(--muted); }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 1px; /* avoids a layout jump when the first chip appears */
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.chip button {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
}
.chip button:hover { background: rgba(0, 0, 0, 0.08); }

.progress-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; width: 100px; }
.progress-fill { height: 100%; background: var(--accent); }

.empty { color: var(--muted); font-size: 14px; padding: 32px 0; text-align: center; }

.alert-warning {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 20px;
}

.actions-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

.key-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171A; --ink: #F0F0EE; --muted: #86868C;
    --border: #2B2B30; --accent: #6E93F7; --accent-soft: #202638;
  }
}
