:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2330;
  --text: #e6e8eb;
  --muted: #9ba3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #232732;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #10b981;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar .user { color: var(--muted); }

.container {
  max-width: 1080px;
  margin: 32px auto;
  padding: 0 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 4px 0; font-size: 1.6rem; }
.page-header-title { min-width: 0; }
.page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

h1 { font-size: 1.6rem; margin: 0 0 16px 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px 0; display: flex; align-items: baseline; gap: 10px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 0 0 20px 0;
}
.panel-narrow { max-width: 500px; margin: 32px auto; }

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table th.num, .data-table td.num { text-align: right; }

/* ---------- Definition lists ---------- */

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin: 0;
}
.kv-cols { grid-template-columns: 180px 80px 180px 80px; }
.kv dt { color: var(--muted); font-size: 0.9rem; }
.kv dd { margin: 0; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: #2d3340;
  color: #cbd5e1;
  border: 1px solid transparent;
}
.badge-grey   { background: #2d3340; color: #cbd5e1; }
.badge-blue   { background: #1e3a8a33; color: #93c5fd; border-color: #1e3a8a; }
.badge-orange { background: #78350f33; color: #fcd34d; border-color: #78350f; }
.badge-green  { background: #064e3b33; color: #6ee7b7; border-color: #064e3b; }
.badge-red    { background: #7f1d1d33; color: #fecaca; border-color: #7f1d1d; }

/* ---------- Buttons ---------- */

.btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary[disabled], .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-disabled {
  background: var(--panel-2);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
  position: relative;
}
.btn-disabled:hover { background: var(--panel-2); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.btn-link:hover { text-decoration: underline; }

.tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 10px;
  background: #1f2937;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  z-index: 10;
}

/* ---------- Forms ---------- */

.store-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 720px;
}
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field .help { margin: 4px 0 0 0; color: var(--muted); font-size: 0.8rem; }

.field-input,
input[type=text],
input[type=url],
input[type=number],
input[type=password],
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b0d12;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.field-input:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.errors,
.field-errors {
  background: #3b1d1d;
  border: 1px solid #7f1d1d;
  color: #fecaca;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 6px;
  font-size: 0.88rem;
}
.errors p, .field-errors p { margin: 0; }
.field-errors.client-errors { background: #3b1d1d88; border-style: dashed; }

/* ---------- Flash messages ---------- */

.flash-area { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.flash-success { border-color: #064e3b; background: #064e3b33; color: #6ee7b7; }
.flash-error   { border-color: #7f1d1d; background: #7f1d1d33; color: #fecaca; }
.flash-warning { border-color: #78350f; background: #78350f33; color: #fcd34d; }
.flash-info    { border-color: var(--border); background: var(--panel-2); color: var(--text); }
.flash-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 4px;
}
.flash-close:hover { opacity: 1; }

/* ---------- Misc ---------- */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
}
.empty-state p { margin: 0 0 12px 0; }

.prompt-list { list-style: none; padding: 0; margin: 0; }
.prompt-list li {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.prompt-list li:last-child { border-bottom: none; }
.prompt-list li > div { display: flex; gap: 8px; align-items: center; }
.prompt-list p { margin: 4px 0; }

.notes {
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0 0 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  max-height: 400px;
  overflow: auto;
}
