/* ==========================================================================
   GRS Munich – design system (ported from the Next.js/Tailwind UI)
   ========================================================================== */

:root {
  --radius: 0.625rem;

  --background: #ffffff;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;

  --primary: #2563eb;
  --primary-foreground: #ffffff;

  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;

  --muted: #f8fafc;
  --muted-foreground: #64748b;

  --accent: #eff6ff;
  --accent-foreground: #1d4ed8;

  --destructive: #dc2626;
  --destructive-foreground: #ffffff;

  --success: #16a34a;
  --success-foreground: #ffffff;

  --warning: #d97706;
  --warning-foreground: #ffffff;

  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #93c5fd;

  --sidebar: #f8fafc;
  --sidebar-foreground: #334155;
  --sidebar-accent: #eef2ff;
  --sidebar-accent-foreground: #1d4ed8;

  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow: 0 1px 3px 0 rgb(15 23 42 / 0.1), 0 1px 2px -1px rgb(15 23 42 / 0.1);

  color-scheme: light;
}

[data-theme="dark"] {
  --background: #0b1120;
  --foreground: #e2e8f0;
  --card: #0f172a;
  --card-foreground: #e2e8f0;

  --primary: #3b82f6;
  --primary-foreground: #f8fafc;

  --secondary: #1e293b;
  --secondary-foreground: #e2e8f0;

  --muted: #1e293b;
  --muted-foreground: #94a3b8;

  --accent: #1e293b;
  --accent-foreground: #bfdbfe;

  --destructive: #f87171;
  --destructive-foreground: #0b1120;

  --success: #34d399;
  --success-foreground: #052e16;

  --warning: #fbbf24;
  --warning-foreground: #451a03;

  --border: #1e293b;
  --input: #1e293b;
  --ring: #3b82f6;

  --sidebar: #0f172a;
  --sidebar-foreground: #cbd5e1;
  --sidebar-accent: #1e293b;
  --sidebar-accent-foreground: #bfdbfe;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in oklab, var(--primary) 25%, white); }

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

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }

svg { display: block; }

/* ---------------------------------------------------------------- layout -- */

.app { display: flex; min-height: 100vh; background: var(--background); }

.main { flex: 1; min-width: 0; overflow-x: hidden; }
.content { width: 100%; max-width: 72rem; margin: 0 auto; padding: 24px 16px; }

/* --------------------------------------------------------------- sidebar -- */

.sidebar {
  width: 16rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 4rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-logo { height: 2rem; width: 2rem; flex-shrink: 0; object-fit: contain; border-radius: 0.5rem; }
.brand-mark {
  height: 2rem; width: 2rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  background: var(--primary); color: var(--primary-foreground);
}
.brand-mark svg { width: 1rem; height: 1rem; }
.brand-name { font-size: 0.9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle {
  display: none;
  margin-left: auto;
  align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--background);
  color: var(--foreground);
  cursor: pointer;
}
.nav-toggle svg { width: 1.125rem; height: 1.125rem; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 0.75rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--sidebar-foreground);
  transition: background-color .15s, color .15s;
}
.nav-link:hover { background: var(--muted); text-decoration: none; }
.nav-link.active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.nav-link svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.nav-primary { margin-top: 0.5rem; border: 1px solid var(--border); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.user { display: flex; align-items: center; gap: 0.75rem; }
.avatar {
  height: 2.25rem; width: 2.25rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 0.875rem; font-weight: 600;
}
.user-meta { min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 500; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-company { font-size: 0.75rem; color: var(--muted-foreground); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.foot-label { font-size: 0.75rem; color: var(--muted-foreground); }
.copyright { margin: 0.25rem 0 0; text-align: center; font-size: 0.625rem; color: var(--muted-foreground); }

.segmented {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 0.375rem;
  padding: 0.125rem;
}
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.375rem 0.5rem;
  border: none; background: transparent; cursor: pointer;
  border-radius: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.75rem; font-weight: 500; text-transform: uppercase;
  transition: background-color .15s, color .15s;
}
.seg-btn svg { width: 0.875rem; height: 0.875rem; }
.seg-btn:hover { background: var(--muted); }
.seg-btn.active { background: var(--primary); color: var(--primary-foreground); }
.seg-btn:disabled { opacity: 0.6; cursor: default; }

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

.page-header {
  display: flex; flex-direction: column; gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-header p { margin: 0.25rem 0 0; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.muted { color: var(--muted-foreground); }
.right { text-align: right; }
.spacer { flex: 1; }
.hidden { display: none; }
.danger { color: var(--destructive); }
.success { color: var(--success); }
.warning-text { color: var(--warning); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.25rem; padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--background);
  color: var(--foreground);
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  line-height: 1; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: var(--muted); text-decoration: none; }
.btn svg { width: 1rem; height: 1rem; }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 90%, black); }
.btn-danger { background: var(--destructive); color: var(--destructive-foreground); border-color: var(--destructive); }
.btn-danger:hover { opacity: 0.92; background: var(--destructive); }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.75rem; border-radius: 0.375rem; }

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

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card:last-child { margin-bottom: 0; }
.card-head { margin-bottom: 1rem; }
.card-head h2 { font-size: 1rem; font-weight: 600; }
.card-head p { margin: 0.25rem 0 0; font-size: 0.875rem; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

details.card { padding: 1.25rem; }
details.card > summary { cursor: pointer; font-weight: 600; font-size: 1rem; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 1rem; }

/* --------------------------------------------------------------- metrics - */

.metrics {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
}
.metric-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.metric-label { color: var(--muted-foreground); font-size: 0.875rem; }
.metric-value { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.metric-sub { color: var(--muted-foreground); font-size: 0.75rem; }
.metric-icon {
  height: 2.5rem; width: 2.5rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
}
.metric-icon svg { width: 1.25rem; height: 1.25rem; }
.icon-default { background: color-mix(in oklab, var(--primary) 12%, transparent); color: var(--primary); }
.icon-success { background: #ecfdf5; color: #059669; }
.icon-warning { background: #fffbeb; color: #d97706; }
.icon-destructive { background: #fef2f2; color: #dc2626; }
[data-theme="dark"] .icon-success { background: rgb(16 185 129 / 0.15); color: #6ee7b7; }
[data-theme="dark"] .icon-warning { background: rgb(245 158 11 / 0.15); color: #fcd34d; }
[data-theme="dark"] .icon-destructive { background: rgb(239 68 68 / 0.15); color: #fca5a5; }

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

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  height: 2.75rem; padding: 0 0.75rem;
  text-align: left; vertical-align: middle;
  font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 0.75rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: color-mix(in oklab, var(--muted) 60%, transparent); }
.table a { font-weight: 500; }

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

.badge {
  display: inline-flex; align-items: center;
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem; font-weight: 500; line-height: 1.4;
}
.badge-DRAFT { background: #f1f5f9; color: #475569; }
.badge-SENT { background: color-mix(in oklab, var(--primary) 12%, transparent); color: var(--primary); }
.badge-PAID { background: #ecfdf5; color: #047857; }
.badge-OVERDUE { background: #fef2f2; color: #b91c1c; }
.badge-CANCELLED { background: #fffbeb; color: #b45309; }
[data-theme="dark"] .badge-DRAFT { background: rgb(100 116 139 / 0.2); color: #cbd5e1; }
[data-theme="dark"] .badge-PAID { background: rgb(16 185 129 / 0.15); color: #6ee7b7; }
[data-theme="dark"] .badge-OVERDUE { background: rgb(239 68 68 / 0.15); color: #fca5a5; }
[data-theme="dark"] .badge-CANCELLED { background: rgb(245 158 11 / 0.15); color: #fcd34d; }

/* ---------------------------------------------------------------- alerts - */

.flash, .alert {
  padding: 0.625rem 0.875rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
}
.alert.info { background: var(--accent); color: var(--accent-foreground); border-color: var(--border); }
[data-theme="dark"] .flash, [data-theme="dark"] .alert { background: rgb(245 158 11 / 0.12); color: #fcd34d; border-color: rgb(245 158 11 / 0.3); }
[data-theme="dark"] .alert.info { background: rgb(59 130 246 / 0.12); color: #bfdbfe; border-color: rgb(59 130 246 / 0.3); }

/* ------------------------------------------------------------ filters/chip */

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.chip {
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 0.8125rem;
}
.chip:hover { background: var(--muted); text-decoration: none; }
.chip.active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.625rem; margin-bottom: 1.25rem; }

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

.field { display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.8125rem; }
.field > span { color: var(--muted-foreground); }
.field.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.field.inline > span { white-space: nowrap; }

input, select, textarea {
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--foreground);
  font-size: 0.875rem;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 0.5rem 0.75rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 70%, transparent);
}
input:disabled { opacity: 0.6; cursor: not-allowed; }
input[type="checkbox"] { width: auto; height: auto; box-shadow: none; accent-color: var(--primary); }
input[type="file"] { height: auto; padding: 0.4rem 0.6rem; font-size: 0.8125rem; }

/* Native dropdown popups follow the theme (otherwise they stay white). */
select option,
select optgroup {
  background-color: var(--card);
  color: var(--card-foreground);
}
[data-theme="dark"] select { background-color: var(--card); color: var(--card-foreground); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.875rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem; }
.form-actions small { font-size: 0.75rem; }

.check { display: flex; align-items: flex-start; gap: 0.625rem; margin: 0.75rem 0; font-size: 0.875rem; }
.check input { margin-top: 0.2rem; flex-shrink: 0; }
.check span { display: block; }
.check small { color: var(--muted-foreground); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
.grid-form { display: flex; flex-direction: column; gap: 1.25rem; }
.grid-2 > .card, .grid-3 > .card, .grid-form > .card { margin-bottom: 0; }

/* Invoice builder: form + live PDF preview */
.invoice-layout { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
.invoice-preview { display: flex; flex-direction: column; gap: 1rem; }
.invoice-preview > .card { margin-bottom: 0; }
.recipient-row { display: flex; gap: 0.5rem; align-items: stretch; }
.recipient-row select { flex: 1; min-width: 0; }
.recipient-row .btn { flex-shrink: 0; }
.new-customer-panel {
  margin-top: 0.75rem; padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--muted);
}
.preview-frame {
  height: 560px;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #ffffff;
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-summary { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.875rem; }
.preview-summary .preview-total {
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  font-size: 1rem; font-weight: 600;
}

@media (min-width: 1024px) {
  .invoice-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .invoice-preview { position: sticky; top: 1.5rem; }
}

.card.flush { padding: 0; }
.card.flush .card-head { padding: 1.25rem 1.25rem 0; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 1.25rem; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 1.25rem; }
.card.flush .table td { border-bottom: 1px solid var(--border); }
.card.flush .table tbody tr:last-child td { border-bottom: none; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 8rem; }

.edit-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.625rem;
  margin-top: 0.5rem; padding: 0.875rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  width: 100%;
}

/* --------------------------------------------------------------- totals -- */

.totals { margin-left: auto; width: min(360px, 100%); display: flex; flex-direction: column; gap: 0.375rem; margin-top: 1rem; }
.totals-row { display: flex; justify-content: space-between; padding: 0.1875rem 0; font-size: 0.875rem; }
.totals-row.grand { border-top: 2px solid var(--foreground); margin-top: 0.375rem; padding-top: 0.5rem; font-weight: 700; font-size: 1.0625rem; }
.totals-card { display: flex; flex-direction: column; }

.items-table input, .items-table select { width: 100%; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }

.inline-edit { position: relative; display: inline-block; }
.inline-edit > summary { list-style: none; cursor: pointer; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] { z-index: 5; }

/* --------------------------------------------------------------- charts -- */

.chart-wrap { width: 100%; overflow: hidden; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 1rem; font-size: 0.8125rem; color: var(--muted-foreground); margin-bottom: 0.5rem; }
.legend { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 2px; margin-right: 0.375rem; }
.legend-revenue { background: var(--primary); }
.legend-expense { background: #f59e0b; }

/* grid fallback bars (kept for very small screens) */
.chart { display: flex; gap: 0.375rem; align-items: flex-end; height: 180px; padding-top: 0.625rem; overflow-x: auto; }
.chart-col { flex: 1; min-width: 24px; display: flex; flex-direction: column; align-items: center; gap: 0.375rem; height: 100%; }
.chart-col .bars { flex: 1; display: flex; gap: 2px; align-items: flex-end; width: 100%; }
.bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-revenue { background: var(--primary); }
.bar-expense { background: #f59e0b; }
.chart-label { font-size: 0.6875rem; color: var(--muted-foreground); }

/* ------------------------------------------------- chart legend swatches - */
.legend-swatch { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 9999px; margin-right: 0.375rem; }

/* ------------------------------------------------------- status / lists -- */

.status-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 1rem; }
.status-item { display: flex; flex-direction: column; gap: 0.5rem; }
.status-item-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.875rem; }
.status-item-head .count { font-weight: 600; }
.status-track { height: 0.5rem; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.status-fill { height: 100%; border-radius: 9999px; background: var(--primary); }

.card-total { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-start; margin-top: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.875rem; color: var(--muted-foreground); }
.card-total strong { color: var(--foreground); }

.meta-dl { margin: 0; }
.meta-dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; font-size: 0.875rem; }
.meta-dl dt { color: var(--muted-foreground); margin: 0; }
.meta-dl dd { margin: 0; font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 0.625rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.timeline li:last-child { border-bottom: none; }

.category-list { list-style: none; padding: 0; margin: 0; }
.category-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.category-list li:last-child { border-bottom: none; }
.category-list li.child { padding-left: 1.125rem; color: var(--muted-foreground); }

.logo-preview { max-width: 160px; max-height: 80px; object-fit: contain; margin-bottom: 0.75rem; display: block; border-radius: 0.375rem; }

/* -------------------------------------------------------------- settings - */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: stretch;
}
.settings-grid > * { margin: 0; }
.settings-grid .card { padding: 1rem 1.125rem; }
.settings-grid .card-head { margin-bottom: 0.75rem; }
.settings-grid .form-grid { gap: 0.75rem; }
.settings-wide { grid-column: 1 / -1; }
.settings-save { grid-column: 1 / -1; margin: 0; }
@media (min-width: 900px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------- switch -- */

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.switch-text strong { display: block; font-size: 0.875rem; }
.switch-text small { color: var(--muted-foreground); font-size: 0.75rem; }
.switch { position: relative; display: inline-flex; width: 2.5rem; height: 1.5rem; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--input);
  border-radius: 9999px;
  transition: background-color .15s;
}
.switch .track::after {
  content: "";
  position: absolute; top: 0.2rem; left: 0.2rem;
  width: 1.1rem; height: 1.1rem;
  background: #ffffff; border-radius: 9999px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(1rem); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 2px var(--ring); }

/* ---------------------------------------------------------------- legal -- */

.legal-page { max-width: 52rem; margin: 0 auto; padding: 24px 16px 64px; }
.legal-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem; margin-bottom: 1.5rem;
}
.legal-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.legal h1 { font-size: 1.875rem; font-weight: 600; margin-bottom: 0.25rem; }
.legal h2 { font-size: 1.125rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
.legal h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.375rem; }
.legal p, .legal li { font-size: 0.9375rem; line-height: 1.65; color: var(--foreground); }
.legal ul { margin: 0.5rem 0; padding-left: 1.25rem; }
.legal li { margin-bottom: 0.25rem; }
.legal .muted { color: var(--muted-foreground); }
.legal .legal-toc { font-size: 0.9375rem; }
.legal .legal-toc ol { padding-left: 1.25rem; }
.legal hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.legal-lang-tag {
  display: inline-block; font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: 9999px;
  padding: 0.1rem 0.5rem; margin-bottom: 0.5rem;
}

/* ---------------------------------------------------------------- login -- */

.login-body { background: var(--background); color: var(--foreground); }
.login-wrap { display: grid; grid-template-columns: 1fr; min-height: 100vh; }

.login-hero {
  display: none;
  flex-direction: column; justify-content: space-between;
  background: #0f172a; color: #ffffff; padding: 3rem;
}
.login-hero .hero-brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.125rem; font-weight: 600; }
.login-hero .hero-brand img { height: 2.5rem; max-width: 160px; object-fit: contain; }
.login-hero h1 { font-size: 1.875rem; font-weight: 600; line-height: 1.2; }
.hero-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; font-size: 0.875rem; color: #cbd5e1; }
.hero-list li { display: flex; align-items: center; gap: 0.75rem; }
.hero-list svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.hero-foot { font-size: 0.75rem; color: #94a3b8; margin: 0; }
.hero-foot a { color: inherit; }

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; }
.login-panel-inner { width: 100%; max-width: 24rem; }
.login-topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 1.5rem; }
.login-brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.125rem; font-weight: 600; min-width: 0; }
.login-brand img { height: 2rem; max-width: 120px; object-fit: contain; }
.login-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-brand .brand-mark { width: 2rem; height: 2rem; }
.login-head { text-align: center; margin-bottom: 2rem; }
.login-head h2 { font-size: 1.5rem; font-weight: 600; }
.login-head p { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--muted-foreground); }

.login-card { background: transparent; padding: 0; }
.demo-box {
  margin-top: 1.25rem; padding: 0.75rem;
  border-radius: 0.5rem;
  background: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--muted-foreground);
}
.demo-box strong { color: var(--foreground); display: block; margin-bottom: 0.25rem; }

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

@media (min-width: 640px) {
  .content { padding: 32px 24px; }
  .page-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-head { text-align: left; }
}

@media (min-width: 1024px) {
  .login-wrap { grid-template-columns: 1fr 1fr; }
  .login-hero { display: flex; }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 .col-span-2 { grid-column: span 2; }
}

@media (min-width: 1280px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .brand { height: 3.75rem; }
  .nav-toggle { display: inline-flex; }
  .sidebar:not(.open) .nav, .sidebar:not(.open) .sidebar-foot { display: none; }
  .sidebar.open .nav { display: flex; flex-direction: column; }
  .sidebar.open .sidebar-foot { display: flex; flex-direction: column; }
  .nav { flex-direction: column; }
  .nav-link { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .hide-sm { display: none; }
  .table th, .table td { padding-left: 0.5rem; padding-right: 0.5rem; }
}
