/* ---------- Design tokens ---------- */
:root {
  color-scheme: light dark;

  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;

  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #55627a;
  --border: #d7dee8;
  --border-strong: #b7c1d1;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 6px rgba(15, 23, 42, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #17213a;
    --text: #e6ebf5;
    --text-muted: #97a3ba;
    --border: #2b3958;
    --border-strong: #3c4d72;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.25);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3 {
  line-height: 1.25;
  margin: 0 0 1rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

p { color: var(--text-muted); }

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

/* ---------- App bar + CSS-only logo ---------- */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text) !important;
  text-decoration: none !important;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: var(--accent-contrast);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow);
}

/* ---------- Nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex: 1 1 auto;
  margin-left: 1.5rem;
}

.topnav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.topnav-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.topnav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.form-narrow {
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.center-page {
  min-height: calc(100vh - 8rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-block {
  width: 100%;
  justify-content: center;
}

.field {
  margin-bottom: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.static-value {
  padding: 0.45rem 0;
  font-weight: 600;
}

/* ---------- Form controls ---------- */
input[type="text"], input[type="password"], input[type="email"],
input:not([type]), select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

textarea { resize: vertical; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, .table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.table th {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }

/* ---------- Buttons ---------- */
.actions-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

button, .button, a.button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

button:hover, .button:hover, a.button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  text-decoration: none;
}

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

.button-secondary, a.button-secondary {
  background: transparent;
  color: var(--accent);
}

.button-secondary:hover, a.button-secondary:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
  font: inherit;
  font-weight: 500;
}

.link-button.danger { color: var(--danger); }

.copy-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-muted);
}

.copy-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.mac-value {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ---------- Flash messages ---------- */
.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.flash-success {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--text);
}

.flash-error {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--text);
}
