/* SyncShares — design system + WCAG 2.1 AA styles.
 *
 * Goals:
 * - Modern product look: real type hierarchy, depth via subtle shadows,
 *   proper spacing scale, rounded corners, accent colors that actually
 *   look like 2026, not 1996.
 * - Contrast ≥ 7:1 for body text, ≥ 4.5:1 for UI chrome and borders.
 * - Every interactive element has a visible focus ring.
 * - Respects prefers-reduced-motion and prefers-color-scheme.
 * - Zero external fonts — system-ui stack only. Self-hosted means no
 *   Google Fonts callbacks.
 * - Native form controls only. No <div role="button"> hell.
 * - No JavaScript required for any layout or interaction.
 */

/* ---------- design tokens ---------- */

:root {
  /* neutral palette — cool slate scale */
  --bg:            #f6f8fb;
  --surface:       #ffffff;
  --surface-2:     #f1f4f9;
  --surface-3:     #e7ecf3;
  --fg:            #0f172a;
  --fg-muted:      #475569;
  --fg-subtle:     #64748b;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  /* brand + semantic */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   #dbeafe;
  --accent-fg:     #ffffff;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;
  --success:       #15803d;
  --success-soft:  #dcfce7;
  --warn:          #b45309;
  --warn-soft:     #fef3c7;
  --info:          #0e7490;
  --info-soft:     #cffafe;

  /* per-bit badge colors (permissions) */
  --bit-read:      #0284c7;
  --bit-write:     #15803d;
  --bit-delete:    #b91c1c;
  --bit-share:     #7c3aed;
  --bit-manage:    #c2410c;

  /* focus / shadow */
  --focus-ring:    #2563eb;
  --shadow-sm:     0 1px 2px rgba(15,23,42,0.05);
  --shadow:        0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md:     0 4px 8px -2px rgba(15,23,42,0.10), 0 2px 4px -2px rgba(15,23,42,0.06);
  --shadow-lg:     0 12px 24px -6px rgba(15,23,42,0.14), 0 4px 8px -4px rgba(15,23,42,0.06);

  /* typography */
  --font: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-sans-serif, system-ui, -apple-system, "SF Pro Display",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", "Cascadia Mono",
          Menlo, Consolas, monospace;

  /* spacing scale (4-based) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* radii */
  --rad-sm: 4px;
  --rad:    8px;
  --rad-lg: 12px;
  --rad-xl: 16px;
  --rad-full: 9999px;

  /* legacy aliases (kept so existing class names still resolve) */
  --pad: var(--sp-4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0b1018;
    --surface:       #121925;
    --surface-2:     #1a2332;
    --surface-3:     #232e40;
    --fg:            #f1f5f9;
    --fg-muted:      #a8b3c5;
    --fg-subtle:     #7e8aa0;
    --border:        #27303f;
    --border-strong: #3a4658;

    --accent:        #60a5fa;
    --accent-hover:  #93c5fd;
    --accent-soft:   #1e293b;
    --accent-fg:     #0b1018;
    --danger:        #f87171;
    --danger-soft:   #3b1920;
    --success:       #4ade80;
    --success-soft:  #173324;
    --warn:          #fbbf24;
    --warn-soft:     #3a2a10;
    --info:          #22d3ee;
    --info-soft:     #0c2a30;

    --bit-read:      #38bdf8;
    --bit-write:     #4ade80;
    --bit-delete:    #f87171;
    --bit-share:     #a78bfa;
    --bit-manage:    #fb923c;

    --focus-ring:    #60a5fa;
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.40);
    --shadow:        0 1px 3px rgba(0,0,0,0.50), 0 1px 2px rgba(0,0,0,0.40);
    --shadow-md:     0 6px 12px -3px rgba(0,0,0,0.55), 0 2px 4px -2px rgba(0,0,0,0.40);
    --shadow-lg:     0 16px 32px -8px rgba(0,0,0,0.65), 0 4px 8px -4px rgba(0,0,0,0.40);
  }
}

/* ---------- reset / base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

code, pre, kbd { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: var(--rad-sm); }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-5) 0;
}

/* ---------- focus rings ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--rad-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- skip link ---------- */

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  background: var(--accent);
  color: var(--accent-fg);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--rad);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: top 0.15s;
}
.skip-link:focus { top: var(--sp-4); }

/* ---------- app shell: header / main / footer ---------- */

header[role="banner"] {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-3) var(--sp-6);
  max-width: 1280px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--rad);
}
.brand:hover { text-decoration: none; color: var(--fg); }

.brand-mark {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent), var(--accent-hover) 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), var(--shadow-sm);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
  transform-origin: center;
}
.brand-mark::before { transform: translate(-50%, -50%) translateY(-3px); }
.brand-mark::after  { transform: translate(-50%, -50%) translateY(3px); }

.nav-primary,
.nav-user {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
}
.nav-primary { flex: 1; gap: var(--sp-1); }

.nav-primary a,
.nav-user a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--rad);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.12s, color 0.12s;
}
.nav-primary a:hover,
.nav-user a:hover {
  background: var(--surface-2);
  color: var(--fg);
  text-decoration: none;
}
.nav-primary a[aria-current="page"],
.nav-primary a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-user {
  gap: var(--sp-2);
}
.nav-user a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.nav-user .avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--rad-full);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.inline-form { display: inline; margin: 0; }
.inline-form button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--rad);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.inline-form button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--fg);
}

main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
}

footer[role="contentinfo"] {
  color: var(--fg-subtle);
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  text-align: center;
  background: var(--surface);
}
footer[role="contentinfo"] p { margin: 0; }

/* ---------- typography ---------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--sp-3) 0;
  letter-spacing: -0.015em;
  color: var(--fg);
}
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem;  }
h4 { font-size: 0.98rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }

p { margin: 0 0 var(--sp-4) 0; }
p:last-child { margin-bottom: 0; }

.subtle, .muted { color: var(--fg-muted); }
.small { font-size: 0.88rem; }

/* page header: title + optional right-side action */
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: var(--sp-1); }
.page-header p { color: var(--fg-muted); font-size: 0.92rem; margin: 0; }
.page-header > div:first-child { min-width: 0; }
.page-header > :last-child:not(:first-child) { flex-shrink: 0; }

/* ---------- flash messages ---------- */

.messages { margin-bottom: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.message {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--rad);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  box-shadow: var(--shadow-sm);
  margin: 0;
}
.message::before {
  content: "";
  display: inline-block;
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.message-error, .message-danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  color: var(--danger);
}
.message-error::before, .message-danger::before { background: var(--danger); }
.message-success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
  color: var(--success);
}
.message-success::before { background: var(--success); }
.message-warning {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, var(--border));
  color: var(--warn);
}
.message-warning::before { background: var(--warn); }
.message-info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 30%, var(--border));
  color: var(--info);
}
.message-info::before { background: var(--info); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-5);
}
.card h2, .card h3 { margin-top: 0; }
.card > h2:first-child,
.card > h3:first-child { margin-bottom: var(--sp-4); }
.card + .card { margin-top: var(--sp-5); }

.card-compact { padding: var(--sp-4) var(--sp-5); }

/* a grid of side-by-side cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}
.card-grid .card { margin-bottom: 0; }

/* stat card — big number + small label */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-sub { font-size: 0.85rem; color: var(--fg-muted); }

/* ---------- forms ---------- */

form.stacked > * + * { margin-top: var(--sp-4); }

form label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--fg);
  margin-bottom: var(--sp-2);
}
form .help,
form small.help {
  display: block;
  color: var(--fg-muted);
  font-size: 0.84rem;
  margin-top: var(--sp-1);
}

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="number"],
form input[type="url"],
form input[type="search"],
form textarea,
form select {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--rad);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
form input::placeholder,
form textarea::placeholder { color: var(--fg-subtle); }

form input:hover,
form textarea:hover,
form select:hover { border-color: var(--fg-subtle); }

form input:focus-visible,
form textarea:focus-visible,
form select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

form textarea { min-height: 100px; resize: vertical; }

form input[type="checkbox"],
form input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin-right: var(--sp-2);
  vertical-align: middle;
}

form input[type="checkbox"] + *,
form input[type="radio"] + * { vertical-align: middle; }

/* when a label wraps a checkbox, inline it */
form label:has(> input[type="checkbox"]),
form label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  font-size: 0.93rem;
  margin-bottom: 0;
  cursor: pointer;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}

form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: var(--sp-4) var(--sp-5);
  margin: 0;
  background: var(--surface-2);
}
form fieldset + fieldset { margin-top: var(--sp-4); }
form legend {
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0 var(--sp-2);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

form .errorlist,
ul.errorlist {
  color: var(--danger);
  list-style: none;
  padding: 0;
  margin: var(--sp-2) 0 0 0;
  font-size: 0.85rem;
  font-weight: 500;
}

/* form row: label + value side-by-side (optional, templates can opt-in) */
.form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- buttons ---------- */

.btn,
button[type="submit"],
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--rad);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.08s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.btn:active,
button[type="submit"]:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--fg-muted);
  color: var(--fg);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 80%, #000);
  border-color: color-mix(in srgb, var(--danger) 80%, #000);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.82rem;
}

.btn-group {
  display: inline-flex;
  gap: var(--sp-2);
  align-items: center;
}

/* ---------- tables ---------- */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
}
table caption {
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
  caption-side: top;
  background: transparent;
}
table thead tr { background: var(--surface-2); }
table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--fg);
}
table tbody tr:last-child td { border-bottom: 0; }
table tbody tr { transition: background 0.1s; }
table tbody tr:hover td {
  background: var(--surface-2);
}

/* empty-state row */
table td.empty,
table tbody tr td[colspan]:only-child {
  text-align: center;
  color: var(--fg-subtle);
  font-style: italic;
  padding: var(--sp-8);
}

/* ---------- badges / pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  border-radius: var(--rad-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.4;
}
.badge-accent  { background: var(--accent-soft);  color: var(--accent);  border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warn    { background: var(--warn-soft);    color: var(--warn);    border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: transparent; }

/* permission bit badges — per-bit colored pill */
.bit-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  list-style: none;
  padding: 0;
  margin: 0;
}
.bit {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--rad-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.bit-read     { background: color-mix(in srgb, var(--bit-read)   14%, transparent); color: var(--bit-read); }
.bit-write    { background: color-mix(in srgb, var(--bit-write)  14%, transparent); color: var(--bit-write); }
.bit-delete   { background: color-mix(in srgb, var(--bit-delete) 14%, transparent); color: var(--bit-delete); }
.bit-share-p  { background: color-mix(in srgb, var(--bit-share)  14%, transparent); color: var(--bit-share); }
.bit-manage   { background: color-mix(in srgb, var(--bit-manage) 14%, transparent); color: var(--bit-manage); }
.bit-off      { background: transparent; color: var(--fg-subtle); border-color: var(--border); }

/* ---------- ACL editor ---------- */

.acl-editor fieldset + fieldset { margin-top: var(--sp-4); }
.acl-editor .bit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-2);
}

/* ---------- installer ---------- */

.installer {
  max-width: 620px;
  margin: var(--sp-12) auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-xl);
  padding: var(--sp-8) var(--sp-8);
  box-shadow: var(--shadow-lg);
}
.installer h1 {
  font-size: 1.5rem;
  margin-bottom: var(--sp-6);
  text-align: center;
}
.installer h2 {
  font-size: 1.15rem;
  margin-bottom: var(--sp-3);
}

.installer .progress {
  display: flex;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-6) 0;
  padding: 0;
  list-style: none;
}
.installer .progress .step {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--rad);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--fg-subtle);
  position: relative;
}
.installer .progress .step.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.installer .progress .step.done {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* sign-in page uses .installer for the card wrapper */
.installer.auth-card { max-width: 420px; }
.installer.auth-card form { margin-top: var(--sp-3); }

/* ---------- file browser ---------- */

.file-browser tbody td:first-child {
  font-family: var(--font);
  font-weight: 500;
}
.file-browser .dir-icon,
.file-browser .file-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.file-browser .dir-icon::before,
.dir-icon::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background: var(--accent);
  clip-path: path("M1 3 a1 1 0 0 1 1 -1 h5 l2 2 h6 a1 1 0 0 1 1 1 v8 a1 1 0 0 1 -1 1 h-13 a1 1 0 0 1 -1 -1 z");
  flex-shrink: 0;
}
.file-browser .file-icon::before,
.file-icon::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background: var(--fg-subtle);
  clip-path: path("M3 2 a1 1 0 0 1 1 -1 h7 l3 3 v10 a1 1 0 0 1 -1 1 h-9 a1 1 0 0 1 -1 -1 z");
  flex-shrink: 0;
}

/* ---------- breadcrumbs ---------- */

.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  padding: 0;
  margin: 0 0 var(--sp-5) 0;
  font-size: 0.92rem;
  color: var(--fg-muted);
}
.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.breadcrumb li + li::before {
  content: "/";
  color: var(--fg-subtle);
  margin: 0 var(--sp-1);
}
.breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: 2px var(--sp-2);
  border-radius: var(--rad-sm);
}
.breadcrumb a:hover {
  background: var(--surface-2);
  color: var(--fg);
  text-decoration: none;
}
.breadcrumb [aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  padding: 2px var(--sp-2);
}

/* ---------- lists (inherited rules, etc.) ---------- */

.card ul, .card ol {
  margin: var(--sp-3) 0;
  padding-left: var(--sp-5);
}
.card ul li + li,
.card ol li + li { margin-top: var(--sp-1); }

/* ---------- utility ---------- */

.row        { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.row-tight  { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.stack      { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm   { display: flex; flex-direction: column; gap: var(--sp-2); }
.spacer     { flex: 1; }
.right      { text-align: right; }
.hidden     { display: none !important; }
.mt-4       { margin-top: var(--sp-4); }
.mt-6       { margin-top: var(--sp-6); }
.mb-0       { margin-bottom: 0 !important; }
.text-muted { color: var(--fg-muted); }
.text-small { font-size: 0.85rem; }

/* visually-hidden (accessible label only) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  header nav {
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }
  .nav-primary {
    order: 2;
    flex-basis: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .nav-primary a { white-space: nowrap; }
  main { padding: var(--sp-5) var(--sp-4); }
  .installer { margin: var(--sp-5) var(--sp-4); padding: var(--sp-6); }
  h1 { font-size: 1.45rem; }
  .page-header { flex-direction: column; align-items: stretch; }
  table { font-size: 0.85rem; }
  table th, table td { padding: var(--sp-2) var(--sp-3); }
}
