/* ============================================================
   GRC-verktyg — Design System
   Bricolage Grotesque (headings) + Figtree (body)
   OKLCH color system, 4pt spacing grid, light/dark theme
   ============================================================ */

/* --- Fonts (self-hosted for airgap) --- */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/static/fonts/bricolage-latin-ext.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/static/fonts/bricolage-latin.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Figtree';
  src: url('/static/fonts/figtree-latin-ext.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF;
}
@font-face {
  font-family: 'Figtree';
  src: url('/static/fonts/figtree-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Spacing scale (4pt grid) --- */
:root {
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;
  --space-5xl: 96px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Light theme (default) --- */
:root, [data-theme="light"] {
  --color-bg: oklch(0.97 0.006 260);
  --color-surface: oklch(1.0 0 0);
  --color-surface-raised: oklch(0.99 0.003 260);
  --color-border: oklch(0.88 0.01 260);
  --color-border-subtle: oklch(0.93 0.006 260);
  --color-text: oklch(0.22 0.02 260);
  --color-text-secondary: oklch(0.48 0.015 260);
  --color-text-muted: oklch(0.6 0.01 260);
  --color-primary: oklch(0.55 0.18 255);
  --color-primary-hover: oklch(0.48 0.19 255);
  --color-primary-subtle: oklch(0.93 0.04 255);
  --color-primary-text: oklch(1.0 0 0);
  --color-success: oklch(0.55 0.15 155);
  --color-success-subtle: oklch(0.93 0.04 155);
  --color-success-text: oklch(0.3 0.08 155);
  --color-warning: oklch(0.7 0.15 75);
  --color-warning-subtle: oklch(0.94 0.04 75);
  --color-warning-text: oklch(0.4 0.1 75);
  --color-danger: oklch(0.55 0.2 25);
  --color-danger-subtle: oklch(0.93 0.04 25);
  --color-danger-text: oklch(0.35 0.12 25);
  --color-info: oklch(0.55 0.12 230);
  --color-info-subtle: oklch(0.93 0.03 230);
  --color-info-text: oklch(0.35 0.08 230);
  --color-sidebar: oklch(0.18 0.025 260);
  --color-sidebar-text: oklch(0.9 0.005 260);
  --color-sidebar-muted: oklch(0.6 0.01 260);
  --color-sidebar-active: oklch(0.25 0.04 255);
  --color-sidebar-hover: oklch(0.22 0.03 260);
  --shadow-sm: 0 1px 2px oklch(0.2 0 0 / 0.04);
  --shadow-md: 0 2px 8px oklch(0.2 0 0 / 0.06);
  color-scheme: light;
}

/* --- Dark theme --- */
[data-theme="dark"] {
  --color-bg: oklch(0.16 0.015 260);
  --color-surface: oklch(0.2 0.015 260);
  --color-surface-raised: oklch(0.24 0.015 260);
  --color-border: oklch(0.3 0.015 260);
  --color-border-subtle: oklch(0.26 0.012 260);
  --color-text: oklch(0.92 0.005 260);
  --color-text-secondary: oklch(0.7 0.01 260);
  --color-text-muted: oklch(0.55 0.01 260);
  --color-primary: oklch(0.68 0.15 255);
  --color-primary-hover: oklch(0.73 0.14 255);
  --color-primary-subtle: oklch(0.25 0.05 255);
  --color-primary-text: oklch(0.15 0.02 260);
  --color-success: oklch(0.68 0.12 155);
  --color-success-subtle: oklch(0.22 0.04 155);
  --color-success-text: oklch(0.8 0.06 155);
  --color-warning: oklch(0.75 0.12 75);
  --color-warning-subtle: oklch(0.25 0.04 75);
  --color-warning-text: oklch(0.85 0.06 75);
  --color-danger: oklch(0.65 0.16 25);
  --color-danger-subtle: oklch(0.22 0.05 25);
  --color-danger-text: oklch(0.85 0.06 25);
  --color-info: oklch(0.65 0.1 230);
  --color-info-subtle: oklch(0.22 0.03 230);
  --color-info-text: oklch(0.85 0.05 230);
  --color-sidebar: oklch(0.13 0.02 260);
  --color-sidebar-text: oklch(0.85 0.005 260);
  --color-sidebar-muted: oklch(0.55 0.01 260);
  --color-sidebar-active: oklch(0.2 0.04 255);
  --color-sidebar-hover: oklch(0.18 0.025 260);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-md: 0 2px 8px oklch(0 0 0 / 0.3);
  color-scheme: dark;
}

/* --- Base --- */
html { font-size: 100%; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- App Shell: sidebar + main --- */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: var(--space-xl) 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: block;
  padding: 0 var(--space-xl);
  margin-bottom: var(--space-3xl);
  text-decoration: none;
}
.sidebar__logo {
  height: 48px;
  width: auto;
  transition: opacity 0.12s ease-out;
}
.sidebar__brand:hover .sidebar__logo { opacity: 0.8; }
.sidebar__app-title {
  padding: 0 var(--space-xl);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-sidebar-text);
  margin-bottom: var(--space-xl);
}
.sidebar__section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-sidebar-muted);
  padding: var(--space-lg) var(--space-xl) var(--space-sm);
}
.sidebar__nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-xl);
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.12s ease-out;
  min-height: 40px;
}
.sidebar__link:hover {
  background: var(--color-sidebar-hover);
}
.sidebar__link.is-active {
  background: var(--color-sidebar-active);
  color: var(--color-primary);
  font-weight: 600;
}
.sidebar__link .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-muted);
  flex-shrink: 0;
}
.sidebar__link.is-active .step-num {
  background: var(--color-primary);
  color: var(--color-primary-text);
}
.sidebar__link.is-done .step-num {
  background: var(--color-success);
  color: oklch(1.0 0 0);
}
.sidebar__link.is-done .step-num::after {
  content: '✓';
  font-size: 0.7rem;
}
.sidebar__link.is-done .step-num span { display: none; }
.sidebar__spacer { flex: 1; }
.sidebar__footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-sidebar-hover);
  margin-top: var(--space-lg);
}

/* Theme toggle in sidebar */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  color: var(--color-sidebar-muted);
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: color 0.12s;
}
.theme-toggle:hover { color: var(--color-sidebar-text); }
.theme-toggle__icon { font-size: 1rem; }

/* --- Main content --- */
.main-content {
  padding: var(--space-3xl) var(--space-4xl);
  max-width: 960px;
}

/* --- Typography --- */
.page-eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}
h1, .h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}
h2, .h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}
h3, .h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text);
}
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.85rem; }

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; }
.card--compact { padding: var(--space-lg); }
.card__header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border-subtle);
}
.card__body { padding: var(--space-xl); }

/* --- Stats row --- */
.stats-row {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
.stat-card {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: var(--shadow-sm);
}
.stat-card__value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.stat-card__label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* --- Forms --- */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.form-field label, .form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}
.form-field .help-text {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  padding: var(--space-sm) 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--color-primary);
}

input[type="text"],
input[type="password"],
input[type="number"],
input:not([type]),
select,
textarea {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  transition: border-color 0.12s ease-out, box-shadow 0.12s ease-out;
  line-height: 1.5;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}
textarea {
  min-height: 80px;
  resize: vertical;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: var(--space-2xl);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease-out, transform 0.08s ease-out;
  min-height: 40px;
  line-height: 1;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-border-subtle); }
.btn-success {
  background: var(--color-success);
  color: oklch(1.0 0 0);
}
.btn-success:hover { background: oklch(0.5 0.14 155); }
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}
.btn-ghost:hover { background: var(--color-primary-subtle); }
.btn-danger {
  background: var(--color-danger);
  color: oklch(1.0 0 0);
}

.btn-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-ok {
  background: var(--color-success-subtle);
  color: var(--color-success-text);
}
.badge-warn {
  background: var(--color-warning-subtle);
  color: var(--color-warning-text);
}
.badge-info {
  background: var(--color-info-subtle);
  color: var(--color-info-text);
}
.badge-danger {
  background: var(--color-danger-subtle);
  color: var(--color-danger-text);
}

/* --- Case list --- */
.case-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.case-item {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  transition: box-shadow 0.12s ease-out;
}
.case-item:hover { box-shadow: var(--shadow-md); }
.case-item__info { flex: 1; min-width: 0; }
.case-item__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}
.case-item__meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}
.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: top;
}
.data-table tr:hover td { background: var(--color-primary-subtle); }

/* --- Risk colors --- */
.risk-low { color: var(--color-success); }
.risk-medium { color: var(--color-warning); }
.risk-high { color: oklch(0.6 0.18 40); }
.risk-critical { color: var(--color-danger); }

/* --- Progress bar --- */
.progress-bar {
  background: var(--color-border-subtle);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar__fill {
  background: var(--color-primary);
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Flash messages --- */
.flash {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-lg);
  font-size: 0.88rem;
}
.flash-success {
  background: var(--color-success-subtle);
  color: var(--color-success-text);
}
.flash-error {
  background: var(--color-danger-subtle);
  color: var(--color-danger-text);
}
.flash-warn {
  background: var(--color-warn-subtle, #fef3cd);
  color: var(--color-warn-text, #856404);
}

/* --- Template helper (LLM-assisted fill) --- */
.template-helper {
  margin-bottom: var(--space-lg);
}
.template-helper > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  cursor: pointer;
  list-style: none;
}
.template-helper > summary::-webkit-details-marker,
.template-helper > summary::marker { display: none; content: ""; }
.template-helper > summary::before {
  content: '\25B8';
  font-size: 0.7rem;
  transition: transform 0.15s;
}
.template-helper[open] > summary::before {
  transform: rotate(90deg);
}

/* --- Grid layouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

/* --- Form row (inline) --- */
.form-row {
  display: flex;
  gap: var(--space-md);
  align-items: end;
  flex-wrap: wrap;
}
.form-row .form-field { flex: 1; min-width: 160px; }

/* --- Section spacing --- */
.section { margin-bottom: var(--space-2xl); }
.section-header { margin-bottom: var(--space-lg); }
.section-header p {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  max-width: 65ch;
}

/* --- Action item row --- */
.action-item {
  padding: var(--space-md);
  background: var(--color-surface-raised);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
}
.action-item__status {
  font-size: 0.78rem;
  font-weight: 600;
}

/* --- Comment thread --- */
.comment {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border-subtle);
}
.comment:last-child { border-bottom: none; }
.comment__body { font-size: 0.9rem; }
.comment__meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
  color: var(--color-text-muted);
}
.empty-state__heading {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}
.empty-state__text {
  font-size: 0.88rem;
  max-width: 40ch;
  margin: 0 auto;
}

/* --- Saved feedback --- */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.78rem;
  color: var(--color-success);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
.save-indicator.is-visible { opacity: 1; }

/* --- Hover and transition utilities --- */
.fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive (sidebar collapses on mobile) --- */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    z-index: 200;
    transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.is-open { left: 0; }
  .mobile-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .mobile-header__toggle {
    background: none;
    border: none;
    color: var(--color-sidebar-text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: var(--space-sm);
  }
  .mobile-header__brand {
    font-family: var(--font-display);
    font-weight: 700;
  }
  .main-content {
    padding: var(--space-xl) var(--space-lg);
  }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-row { flex-direction: column; }
}
@media (min-width: 769px) {
  .mobile-header { display: none; }
}

/* --- prefers-reduced-motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Collapsible requirement categories --- */
.req-category {
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.req-category > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  cursor: pointer;
  user-select: none;
  list-style: none;
  border-radius: var(--radius-lg);
  transition: background 0.12s ease-out;
}
.req-category > summary::-webkit-details-marker,
.req-category > summary::marker { display: none; content: ""; }
.req-category > summary:hover { background: var(--color-bg); }
.req-category > summary h2 { margin: 0; }
.req-category__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease-out;
  opacity: 0.5;
}
.req-category[open] > .req-category__header .req-category__chevron {
  transform: rotate(180deg);
}
.req-category > :not(summary) {
  padding: 0 var(--space-xl) var(--space-lg);
}

/* --- Classification options --- */
.classify-options {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.classify-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex: 1;
  min-width: 180px;
  transition: border-color 0.12s ease-out, background 0.12s ease-out;
}
.classify-option:hover {
  background: var(--color-surface-raised);
}
.classify-option input[type="radio"] {
  width: auto;
  accent-color: var(--color-primary);
}
.classify-option input[type="radio"]:checked ~ .classify-option__label {
  font-weight: 700;
}
.classify-option:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}
.classify-option--green:has(input:checked) { border-color: var(--color-success); background: var(--color-success-subtle); }
.classify-option--yellow:has(input:checked) { border-color: var(--color-warning); background: var(--color-warning-subtle); }
.classify-option--red:has(input:checked) { border-color: var(--color-danger); background: var(--color-danger-subtle); }
.classify-option__label {
  font-weight: 600;
  font-size: 0.95rem;
}
.classify-option__desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ---------- Autosave toast ---------- */
.autosave-toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9000;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  opacity: 0;
  transform: translateY(8px);
  box-shadow: var(--shadow-md);
}
.autosave-toast--busy {
  background: var(--color-warning-subtle);
  color: var(--color-warning);
}
.autosave-toast--ok {
  background: var(--color-success-subtle);
  color: var(--color-success);
}
.autosave-toast--err {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

/* Hide per-field save buttons when autosave is active */
form[data-autosave] button[type="submit"].autosave-hide {
  display: none;
}

/* ---------- Review step accordion ---------- */
.review-step {
  border-top: 1px solid var(--color-border);
}
.review-step__summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background .15s;
}
.review-step__summary:hover {
  background: var(--color-surface-raised);
}
.review-step__summary::-webkit-details-marker { display: none; }
.review-step__arrow {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}
.review-step[open] .review-step__arrow {
  transform: rotate(90deg);
}
.review-step__label {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.review-step__meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}
.review-step__bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.review-step__bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--color-primary);
  transition: width .3s;
}
.review-step__body {
  padding: 0 var(--space-lg) var(--space-lg) calc(var(--space-lg) + 0.65rem + var(--space-md));
}
.btn-xs {
  padding: 2px var(--space-sm) !important;
  font-size: 0.72rem !important;
  min-width: auto !important;
}
.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.review-table th,
.review-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.review-table th {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.review-table__key {
  font-weight: 600;
  white-space: nowrap;
  width: 40%;
  color: var(--color-text-secondary);
}

/* ---------- Branch / diff styles ---------- */
.branch-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}
.branch-banner__icon {
  font-size: 1.8rem;
  color: var(--color-primary);
  line-height: 1;
}
.branch-banner h1 { margin-bottom: 0; }

.diff-legend {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.diff-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.diff-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}
.diff-row {
  background: var(--color-primary-subtle);
}
tr.diff-row td {
  background: var(--color-primary-subtle);
}
p.diff-row {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

/* Branch list */
.branch-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.branch-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  transition: box-shadow 0.12s ease-out;
}
.branch-item:hover { box-shadow: var(--shadow-md); }
.branch-item__icon {
  font-size: 1.2rem;
  color: var(--color-primary);
  flex-shrink: 0;
}
.branch-item__info { flex: 1; min-width: 0; }
.branch-item__name {
  font-weight: 600;
  font-size: 0.95rem;
}
.branch-item__meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Branch dialog */
.branch-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90vw;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 8px 32px oklch(0.1 0 0 / 0.3);
}
.branch-dialog::backdrop {
  background: oklch(0.1 0 0 / 0.5);
}
.branch-dialog h2 {
  margin-bottom: var(--space-sm);
}
.branch-dialog .form-field {
  margin-top: var(--space-lg);
}
.branch-dialog .btn-row {
  margin-top: var(--space-lg);
}

/* ---------- Login / Change-password page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-lg);
  /* Subtle radial glow behind card */
  background-image: radial-gradient(ellipse 60% 50% at 50% 40%, oklch(0.55 0.08 255 / 0.06) 0%, transparent 70%);
}
[data-theme="dark"] .login-page {
  background-image: radial-gradient(ellipse 60% 50% at 50% 40%, oklch(0.5 0.1 255 / 0.08) 0%, transparent 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3xl) var(--space-2xl) var(--space-xl);
  box-shadow: var(--shadow-md), 0 0 0 1px oklch(0 0 0 / 0.02);
}
[data-theme="dark"] .login-card {
  box-shadow: var(--shadow-md), 0 0 0 1px oklch(1 0 0 / 0.04);
}

/* Brand cluster */
.login-card__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}
.login-card__logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}
.login-card__wordmark {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-md);
}

/* Heading */
.login-card__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: var(--space-xs);
}
.login-card__subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-bottom: var(--space-xl);
}

/* Alert */
.login-alert {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-lg);
  background: var(--color-danger-subtle);
  color: var(--color-danger-text);
  border: 1px solid oklch(0.85 0.05 25);
}
[data-theme="dark"] .login-alert {
  background: oklch(0.22 0.04 25);
  border-color: oklch(0.32 0.06 25);
}
.login-alert__icon {
  flex-shrink: 0;
  opacity: 0.8;
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.login-field__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.login-field__input {
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--color-surface-raised);
  color: var(--color-text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}
.login-field__input:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px oklch(0.55 0.18 255 / 0.12);
}
[data-theme="dark"] .login-field__input:focus-visible {
  box-shadow: 0 0 0 3px oklch(0.68 0.15 255 / 0.18);
}
.login-field__hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Submit button */
.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--color-primary);
  color: var(--color-primary-text);
  transition: background 0.15s, transform 0.08s;
  min-height: 44px;
}
.login-btn:hover {
  background: var(--color-primary-hover);
}
.login-btn:active {
  transform: scale(0.98);
}
.login-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.login-btn svg {
  transition: transform 0.15s;
}
.login-btn:hover svg {
  transform: translateX(2px);
}

/* Footer with theme toggle */
.login-card__footer {
  display: flex;
  justify-content: center;
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border-subtle);
}
.login-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.login-theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-border);
  background: var(--color-surface-raised);
}
/* Show sun in dark mode, moon in light mode */
[data-theme="light"] .login-theme-toggle__sun { display: none; }
[data-theme="dark"] .login-theme-toggle__moon { display: none; }

/* Legacy alert (keep for backwards compat) */
.alert {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: var(--space-lg);
}
.alert-danger {
  background: oklch(0.95 0.03 25);
  color: var(--color-danger);
  border: 1px solid oklch(0.85 0.05 25);
}
[data-theme="dark"] .alert-danger {
  background: oklch(0.25 0.03 25);
  border-color: oklch(0.35 0.05 25);
}

/* Sidebar user footer */
.sidebar__user {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-size: 0.82rem;
}
.sidebar__user-info {
  min-width: 0;
}
.sidebar__user-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-role {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
}
