:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e6eb;
  --border-strong: #d0d3d9;
  --text: #111318;
  --text-muted: #5b616e;
  --text-subtle: #8a909c;
  --brand: #2f5bea;
  --brand-hover: #2449c4;
  --brand-soft: #eef2ff;
  --success: #1a7f37;
  --success-soft: #e6f4ea;
  --danger: #cf222e;
  --danger-soft: #fde7e9;
  --warn-soft: #fff8c5;
  --warn-border: #e6c85c;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 2px 6px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ---------- header ---------- */

header.app {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header.app .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

header.app .brand::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), #7b8cff);
}

header.app .user {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

header.app .user button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
header.app .user button:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

/* ---------- nav ---------- */

nav.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

nav.tabs a {
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color .12s, border-color .12s;
}
nav.tabs a:hover { color: var(--text); text-decoration: none; }
nav.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}

/* ---------- main ---------- */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}

.page-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
}

/* ---------- buttons and inputs ---------- */

input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47,91,234,0.15);
}

button.primary {
  padding: 9px 16px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
button.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
button.primary:disabled { opacity: 0.55; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
button.ghost:hover { background: var(--bg); }

button.danger {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
button.danger:hover { background: var(--danger-soft); }

/* ---------- auth card ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(47,91,234,0.10), transparent 50%),
    radial-gradient(900px 500px at 100% 110%, rgba(123,140,255,0.10), transparent 50%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.auth-card .logo::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #7b8cff);
}

.auth-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.auth-card p.lead {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-card .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-card .field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-card button.primary {
  margin-top: 4px;
  padding: 10px 16px;
}

.auth-card .alt {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- error banner ---------- */

.error-banner {
  background: var(--danger-soft);
  border: 1px solid #f5b5bb;
  color: #a5121e;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

/* ---------- keys panel ---------- */

.create-row {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.create-row input { flex: 1; }

.reveal {
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.reveal .headline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 10px;
  color: #6b5200;
}
.reveal .headline::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e6c85c;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.reveal .key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.reveal code {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  background: #fff;
  border: 1px solid #e6d994;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  word-break: break-all;
}
.reveal .dismiss {
  display: inline-block;
  margin-top: 8px;
  color: #7a5f00;
  font-size: 12px;
}

/* ---------- data table ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-top: 16px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  background: #fafbfc;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-subtle);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f2f4;
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfd; }

table.data code.key {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  background: #f3f4f6;
  border-radius: 4px;
  padding: 2px 6px;
}
table.data .muted { color: var(--text-subtle); }
table.data .right { text-align: right; }

/* ---------- empty state ---------- */

.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty .icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 10px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 700;
  font-size: 18px;
}
.empty h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.empty p { margin: 0; font-size: 13px; }

/* ---------- status pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}
.pill.green { background: var(--success-soft); color: var(--success); }
.pill.red   { background: var(--danger-soft);  color: var(--danger); }
.pill.gray  { background: #eef0f3; color: var(--text-muted); }

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.stat .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}
.stat .sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ---------- loading ---------- */

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
}
.loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
