/* WorkerPlan UI — shared design system.
   A vanilla port of shadcn/ui: same token names, component anatomy and sizing
   scale, written as plain CSS so the app keeps working without a build step.
   Pages keep their own <style> block for layout only; everything visual lives here. */

/* ── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  /* Warm stone base, so surfaces read paper-white instead of blue-grey. */
  --background: #f5f5f4;
  --foreground: #1c1917;
  --card: #ffffff;
  --card-foreground: #1c1917;
  --popover: #ffffff;
  --popover-foreground: #1c1917;

  --primary: #17b26a;
  --primary-hover: #12915a;
  --primary-foreground: #ffffff;
  --primary-muted: #ecfdf3;
  --primary-muted-border: #bbf7d0;
  --primary-strong: #0b7a4a;

  --secondary: #f5f5f4;
  --secondary-foreground: #1c1917;

  /* accent is the neutral hover wash, per shadcn — not the brand colour. */
  --accent: #f5f5f4;
  --accent-foreground: #1c1917;

  --muted: #f0efec;
  --muted-foreground: #78716c;
  /* Fails text contrast by design — placeholders, disabled states, hairlines. */
  --subtle-foreground: #a8a29e;

  --destructive: #dc2626;
  --destructive-hover: #b91c1c;
  --destructive-foreground: #ffffff;
  --destructive-muted: #fef2f2;
  --destructive-border: #fecaca;

  --success: #15803d;
  --success-muted: #f0fdf4;
  --success-border: #bbf7d0;

  --warning: #b45309;
  --warning-muted: #fffbeb;
  --warning-border: #fde68a;

  --estimate: #c2410c;
  --estimate-muted: #fff4ed;

  --border: #e2e0dd;
  --border-strong: #ccc9c4;
  --input: #e2e0dd;
  --ring: #17b26a;

  /* Type — seven steps, and nothing between them. */
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Three tracking values: headings, default, micro-caps. */
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.05em;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  /* Space — 4px grid. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* One row height for every table in the app. */
  --row-h: 36px;
  --control-h: 36px;
  --control-h-sm: 32px;
  --header-h: 56px;

  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.08);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 10px 28px rgba(28, 25, 23, 0.14);
  --shadow-xl: 0 20px 50px rgba(28, 25, 23, 0.18);

  --ring-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
  --duration: 150ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  background: var(--background);
  color: var(--foreground);
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tabular figures everywhere numbers are compared down a column. */
input,
td,
th,
.tabular {
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

/* One focus treatment for the whole app. */
:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--ring-shadow);
}

::selection {
  background: var(--primary-muted);
  color: var(--primary-strong);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── SCROLL AREA ────────────────────────────────────────────────────────── */
.scroll-area {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.scroll-area::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.scroll-area::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: var(--radius-full);
  background-clip: content-box;
}
.scroll-area::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ── ICON ───────────────────────────────────────────────────────────────── */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ── BUTTON ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration) var(--ease),
    border-color var(--duration) var(--ease), color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn .icon {
  margin: 0 -2px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  border-color: var(--border);
  color: var(--secondary-foreground);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--card);
  border-color: var(--border-strong);
}

.btn-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--border-strong);
}

.btn-ghost {
  color: var(--muted-foreground);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--accent);
  color: var(--foreground);
}

.btn-destructive {
  background: var(--destructive);
  border-color: var(--destructive);
  color: var(--destructive-foreground);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.btn-destructive:hover:not(:disabled) {
  background: var(--destructive-hover);
  border-color: var(--destructive-hover);
}

.btn-sm {
  height: var(--control-h-sm);
  padding: 0 var(--space-2);
  font-size: var(--text-2xs);
}
.btn-lg {
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-base);
}
.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--control-h);
  padding: 0;
  flex: none;
}
.btn-icon.btn-sm {
  width: var(--control-h-sm);
}

/* ── TABS / SEGMENTED CONTROL ───────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.tab:hover {
  color: var(--foreground);
}
.tab[aria-selected="true"],
.tab.on {
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ── BADGE ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-normal);
  white-space: nowrap;
}
.badge-secondary {
  background: var(--muted);
  border-color: var(--border);
  color: var(--muted-foreground);
}
.badge-success {
  background: var(--success-muted);
  border-color: var(--success-border);
  color: var(--success);
}
.badge-warning {
  background: var(--warning-muted);
  border-color: var(--warning-border);
  color: var(--warning);
}
.badge-destructive {
  background: var(--destructive-muted);
  border-color: var(--destructive-border);
  color: var(--destructive);
}
.badge-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--muted-foreground);
}

/* ── CARD ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.card-description {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  font-weight: 400;
}
.card-content {
  padding: 0 var(--space-4) var(--space-4);
}

/* Sign-in card — office email login and crew SMS login share this. */
.sign-in {
  width: 100%;
  max-width: 380px;
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}
.sign-in .brand {
  margin-bottom: var(--space-6);
}
.sign-in .brand .btn {
  margin-left: auto;
}
.sign-in h1 {
  font-size: var(--text-xl);
}
.sign-in .lede {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}
.sign-in form,
.sign-in .sign-in-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.sign-in .alert {
  margin-top: var(--space-5);
}

.sign-in .picks {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.pick {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}
.pick:hover {
  background: var(--accent);
  border-color: var(--border-strong);
}
.pick-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-foreground);
}
.pick-mark .icon {
  width: 18px;
  height: 18px;
}
.pick-copy {
  flex: 1;
  min-width: 0;
}
.pick-copy strong {
  display: block;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.pick-lede {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  font-weight: 400;
}
.pick > .icon {
  flex: none;
  color: var(--subtle-foreground);
}

/* Metric card — the "$4.20m WON" tiles. */
.metric {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-xs);
}
.metric-label {
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--muted-foreground);
  letter-spacing: var(--tracking-normal);
}
.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.metric-value {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.metric-value.neg {
  color: var(--destructive);
}

/* ── LABEL / FIELD / INPUT ──────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--foreground);
}
.field-hint {
  font-size: var(--text-2xs);
  color: var(--muted-foreground);
}

.input {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  font: inherit;
  font-size: var(--text-base);
  color: var(--foreground);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.input::placeholder {
  color: var(--subtle-foreground);
}
.input:hover:not(:focus) {
  border-color: var(--border-strong);
}
.input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--ring-shadow);
}

/* Native select, with the caret drawn in so it matches .input across browsers. */
.select {
  width: 100%;
  height: var(--control-h-sm);
  padding: 0 28px 0 var(--space-3);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--foreground);
  cursor: pointer;
  appearance: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
/* Compact size, for sitting inside a panel header next to a title. */
.select-xs {
  height: 26px;
  padding: 0 22px 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  background-position: right 6px center;
  background-size: 12px;
}
.select:hover {
  border-color: var(--border-strong);
}
.select:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--ring-shadow);
}

/* ── SWITCH ─────────────────────────────────────────────────────────────── */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  display: inline-block;
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.switch-thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease);
}
.switch input:checked + .switch-track {
  background: var(--primary);
}
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
}
.switch input:focus-visible + .switch-track {
  box-shadow: var(--ring-shadow);
}
.switch-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--foreground);
}

/* ── TABLE ──────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  padding: 0 var(--space-2);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--muted-foreground);
  text-align: center;
  letter-spacing: var(--tracking-normal);
  white-space: nowrap;
}
.table td {
  height: var(--row-h);
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  vertical-align: middle;
}
.table td.num {
  text-align: right;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover td {
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}

/* Editable table cell — reads as a field on hover and focus, flat at rest, so
   a dense grid stays quiet without hiding which columns accept input. */
.cell-input {
  width: 100%;
  height: calc(var(--row-h) - 6px);
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--foreground);
  transition: background var(--duration) var(--ease),
    border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.cell-input::placeholder {
  color: var(--subtle-foreground);
}
.cell-input:hover:not(:focus) {
  background: var(--card);
  border-color: var(--border);
}
.cell-input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--ring);
  box-shadow: var(--ring-shadow);
}
.cell-input.num {
  text-align: right;
}
.cell-input.strong {
  font-weight: 500;
}

/* Derived cell — visibly not a field. */
.cell-derived {
  padding-right: var(--space-3);
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--muted) 60%, transparent);
  font-variant-numeric: tabular-nums;
}

/* ── POPOVER ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 98;
}
.popover {
  position: fixed;
  z-index: 99;
  min-width: 200px;
  max-height: calc(100vh - 16px);
  padding: var(--space-1);
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  animation: pop-in 120ms var(--ease);
}
.popover-padded {
  padding: var(--space-4);
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}
.popover-label {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--space-2) var(--space-2) var(--space-1);
  background: var(--popover);
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--muted-foreground);
}
.popover-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 7px var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--foreground);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.popover-item:hover:not(:disabled) {
  background: var(--accent);
}
.popover-item:disabled {
  color: var(--subtle-foreground);
  cursor: default;
}
.popover-item.destructive {
  color: var(--destructive);
}
.popover-item.destructive:hover {
  background: var(--destructive-muted);
}
.popover-separator {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border);
}
.popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ── DIALOG / ALERT DIALOG ──────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: color-mix(in srgb, var(--foreground) 45%, transparent);
  animation: fade-in var(--duration) var(--ease);
}
@keyframes fade-in {
  from { opacity: 0; }
}
.dialog {
  width: 100%;
  max-width: 420px;
  padding: var(--space-6);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: dialog-in 180ms var(--ease);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}
.dialog-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.dialog-description {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  line-height: var(--leading-relaxed);
}
.dialog-body {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

/* Recipient list inside the publish confirmation. */
.dialog-list {
  max-height: 200px;
  margin-top: var(--space-3);
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--muted) 50%, transparent);
  overflow: auto;
}
.dialog-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 5px var(--space-2);
  font-size: var(--text-xs);
}
.dialog-list-row + .dialog-list-row {
  border-top: 1px solid var(--border);
}

/* ── TOOLTIP ────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  z-index: 300;
  max-width: 280px;
  padding: 6px var(--space-2);
  background: var(--foreground);
  color: var(--card);
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: 500;
  line-height: var(--leading-normal);
  white-space: pre-line;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.tooltip b {
  font-weight: 600;
  font-size: var(--text-xs);
}
.tooltip .mut {
  color: var(--subtle-foreground);
  font-variant-numeric: tabular-nums;
}
.tooltip.on {
  opacity: 1;
}

/* ── TOAST ──────────────────────────────────────────────────────────────── */
.toaster {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: min(460px, calc(100vw - 40px));
  padding: 10px var(--space-4);
  background: var(--foreground);
  color: var(--card);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms var(--ease);
}
.toast.out {
  animation: toast-out 160ms var(--ease) forwards;
}
.toast .icon {
  color: var(--primary);
}
.toast.destructive {
  background: var(--destructive);
}
.toast.destructive .icon {
  color: var(--destructive-foreground);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
}

/* ── ALERT ──────────────────────────────────────────────────────────────── */
.alert {
  display: none;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  border: 1px solid var(--destructive-border);
  border-radius: var(--radius-md);
  background: var(--destructive-muted);
  color: var(--destructive);
  font-size: var(--text-xs);
  font-weight: 500;
}
.alert.on {
  display: flex;
}
.alert .icon {
  margin-top: 1px;
}

/* ── SKELETON ───────────────────────────────────────────────────────────── */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--muted) 25%,
    color-mix(in srgb, var(--muted) 40%, var(--card)) 50%,
    var(--muted) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ── EMPTY ──────────────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-5);
  text-align: center;
}
.empty-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
}
.empty-title {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.empty-description {
  max-width: 380px;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  line-height: var(--leading-relaxed);
}

/* ── GRIP ───────────────────────────────────────────────────────────────── */
/* Drag handle for resizing a panel. Quiet until you go looking for it, so it
   doesn't compete with the content it's there to make more of. */
.grip {
  position: relative;
  flex: none;
  height: 11px;
  cursor: ns-resize;
  transition: background var(--duration) var(--ease);
}
.grip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: var(--border-strong);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.grip:hover::after,
.grip:focus-visible::after,
.grip.on::after {
  opacity: 1;
}
.grip:focus-visible {
  outline: none;
  background: var(--primary-muted);
}
.grip.on {
  background: var(--muted);
}
/* There's no hover on touch, so the handle has to be visible and thumb-sized. */
@media (pointer: coarse) {
  .grip {
    height: 22px;
  }
  .grip::after {
    opacity: 1;
    width: 40px;
  }
}

/* ── SEPARATOR / KBD / SPINNER ──────────────────────────────────────────── */
.separator {
  flex: none;
  background: var(--border);
}
.separator-h {
  width: 100%;
  height: 1px;
}
.separator-v {
  width: 1px;
  height: 16px;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  font-family: inherit;
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--muted-foreground);
}

.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── APP CHROME ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-h);
  padding: 0 var(--space-6);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--foreground);
  text-decoration: none;
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
}
.brand-mark .icon {
  width: 17px;
  height: 17px;
}
.app-header-end {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.user-email {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted-foreground);
}

/* Secondary toolbar under the header. */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 52px;
  padding: var(--space-2) var(--space-6);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── UTILITIES ──────────────────────────────────────────────────────────── */
.muted { color: var(--muted-foreground); }
.subtle { color: var(--subtle-foreground); }
.text-2xs { font-size: var(--text-2xs); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.medium { font-weight: 500; }
.semibold { font-weight: 600; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.row-flex {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.grow { flex: 1; min-width: 0; }

.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--subtle-foreground);
}
.status-dot.ok { background: var(--primary); }
.status-dot.warn { background: var(--warning); }
.status-dot.bad { background: var(--destructive); }

/* ── MOTION / TOUCH ─────────────────────────────────────────────────────── */
@media (pointer: coarse) {
  :root {
    --control-h: 44px;
    --control-h-sm: 40px;
  }
  .tab {
    height: 34px;
  }
  /* Under 16px, iOS Safari zooms the page on focus. */
  .input,
  .select {
    font-size: var(--text-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton {
    animation: none;
    background: var(--muted);
  }
  .spinner {
    animation-duration: 900ms !important;
    animation-iteration-count: infinite !important;
  }
}
