/* Stintdelta component styles.
   Everything here reads from tokens.css custom properties — no hardcoded
   colors, spacing, or radii. Type styles (.h1, .body, .data-lg, etc.) come
   from tokens.css directly and are applied as classes in markup, not
   redefined here. */

* { box-sizing: border-box; }

/* ---------- Button ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button--sm {
  height: 32px;
  padding: 0 var(--space-3);
}

.button--primary {
  background: var(--brand-600);
  color: var(--on-brand);
}
.button--primary:hover { background: var(--brand-700); }
.button--primary:disabled {
  background: var(--brand-600);
  color: var(--on-brand);
  opacity: var(--opacity-overlay);
  cursor: not-allowed;
}

.button--secondary {
  background: var(--surface-100);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.button--secondary:hover { background: var(--surface-200); }

.button--ghost {
  background: transparent;
  color: var(--text-primary);
}
.button--ghost:hover { background: var(--surface-100); }

.button:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

/* ---------- Field / Input ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 320px;
  font-family: var(--font-sans);
}
.field--full { max-width: none; }

.input {
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
}
textarea.input {
  height: auto;
  padding: var(--space-3) var(--space-4);
  line-height: 1.5;
  resize: vertical;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 1px;
  border-color: var(--brand-text);
}
.input:disabled {
  color: var(--text-disabled);
  background: var(--surface-100);
  cursor: not-allowed;
}

/* ---------- Radio & Checkbox ---------- */

.radio,
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  cursor: pointer;
}

.radio__input,
.checkbox__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.radio__box,
.checkbox__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--space-5);
  height: var(--space-5);
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  transition: background-color 160ms ease, border-color 160ms ease;
}
.radio__box { border-radius: var(--radius-full); }
.checkbox__box { border-radius: var(--radius-sm); }

.radio__box::after {
  content: "";
  width: var(--space-2);
  height: var(--space-2);
  background: transparent;
  border-radius: var(--radius-full);
  transition: background-color 160ms ease;
}
.radio__input:checked + .radio__box {
  border-color: var(--brand-600);
}
.radio__input:checked + .radio__box::after {
  background: var(--brand-600);
}

.checkbox__box .icon {
  width: var(--space-4);
  height: var(--space-4);
  color: var(--on-brand);
  opacity: 0;
  transition: opacity 120ms ease;
}
.checkbox__input:checked + .checkbox__box {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.checkbox__input:checked + .checkbox__box .icon {
  opacity: 1;
}

.radio__input:focus-visible + .radio__box,
.checkbox__input:focus-visible + .checkbox__box {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

.radio__input:disabled + .radio__box,
.checkbox__input:disabled + .checkbox__box {
  opacity: var(--opacity-overlay);
  cursor: not-allowed;
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  white-space: nowrap;
}
.badge--brand { background: var(--brand-100); color: var(--brand-tint-text); }
.badge--success { background: var(--success-100); color: var(--success-text); }
.badge--warning { background: var(--warning-100); color: var(--warning-text); }
.badge--info { background: var(--info-100); color: var(--info-text); }
.badge--neutral { background: var(--surface-200); color: var(--text-secondary); }

/* ---------- Card ---------- */

.card {
  background: var(--surface-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  font-family: var(--font-sans);
}
:root[data-theme="dark"] .card { box-shadow: none; }
.card--danger { border-color: var(--brand-600); }

/* ---------- Stat tile ---------- */

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  min-width: 168px;
  font-family: var(--font-sans);
}
:root[data-theme="dark"] .stat-tile { box-shadow: none; }

.stat-tile__value { font-variant-numeric: tabular-nums; }

.stat-tile__delta { font-variant-numeric: tabular-nums; }
.stat-tile__delta--improved { color: var(--success-text); }
.stat-tile__delta--regressed { color: var(--chart-focus); }

.stat-tile--hero {
  position: relative;
  overflow: hidden;
  gap: var(--space-3);
  padding: var(--space-7);
}

.stat-tile__content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: inherit;
}

.stat-tile__outline {
  position: absolute;
  top: 50%;
  right: var(--space-6);
  transform: translateY(-50%);
  width: 40%;
  max-width: 200px;
  aspect-ratio: 1;
  opacity: 0.3;
  pointer-events: none;
}
.stat-tile__outline path {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* ---------- Insights preview ---------- */

.insights-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  overflow: hidden;
}

.insights-preview__trace {
  position: absolute;
  inset: var(--space-6);
  width: calc(100% - 2 * var(--space-6));
  height: calc(100% - 2 * var(--space-6));
  filter: blur(4px);
  opacity: 0.4;
  pointer-events: none;
}
.insights-preview__trace path {
  fill: none;
  stroke: var(--chart-focus);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.insights-preview__overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  max-width: 360px;
}
.insights-preview__overlay .button { margin-top: var(--space-2); }

/* ---------- Stat group ---------- */

.stat-group {
  display: flex;
  flex-direction: column;
}

.stat-group__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}
.stat-group__item:first-child { padding-top: 0; }
.stat-group__item:last-child { padding-bottom: 0; }
.stat-group__item + .stat-group__item { border-top: 1px solid var(--border-subtle); }

.stat-group__value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
:root[data-theme="dark"] .table-wrap { box-shadow: none; }
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--surface-100);
  border-radius: var(--radius-full);
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  white-space: nowrap;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 160ms ease; }
.table tbody tr:hover { background: var(--surface-200); }

.table tbody tr.table__row--best,
.table tbody tr.table__row--best:hover { background: var(--brand-100); }

.table th.table__num,
.table td.table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Wide tables: the first two columns stay put while the rest scrolls. */
.table--sticky th:nth-child(-n+2),
.table--sticky td:nth-child(-n+2) {
  position: sticky;
  z-index: 1;
  min-width: 128px;
  background: var(--surface-100);
}
.table--sticky th:nth-child(1),
.table--sticky td:nth-child(1) { left: 0; }
.table--sticky th:nth-child(2),
.table--sticky td:nth-child(2) {
  left: 128px;
  box-shadow: 1px 0 0 var(--border-subtle);
}
.table--sticky tbody tr:hover td:nth-child(-n+2) { background: var(--surface-200); }
.table--sticky tbody tr.table__row--best td:nth-child(-n+2),
.table--sticky tbody tr.table__row--best:hover td:nth-child(-n+2) { background: var(--brand-100); }

.table__empty {
  color: var(--text-tertiary);
}

.table__delta--improved { color: var(--success-text); }
.table__delta--regressed { color: var(--chart-focus); }

/* ---------- Sidebar nav ---------- */

.sidebar-shell {
  z-index: 70;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 240px;
  padding: var(--space-6);
  background: var(--surface-100);
  border-right: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) 0;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: auto;
}

.sidebar__pro {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  background: var(--success-100);
  color: var(--success-text);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}
.nav__item:hover { background: var(--surface-200); color: var(--text-primary); }
.nav__item:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

.nav__item--active,
.nav__item--active:hover {
  background: var(--brand-100);
  color: var(--brand-tint-text);
}

.sidebar__collapse-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.sidebar__collapse-toggle:hover { background: var(--surface-200); color: var(--text-primary); }
.sidebar__collapse-toggle:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

/* ---------- Tooltip ---------- */

.tooltip {
  position: absolute;
  left: calc(100% + var(--space-2));
  top: 50%;
  z-index: 70;
  padding: var(--space-1) var(--space-3);
  background: var(--surface-200);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
}
:root[data-theme="dark"] .tooltip { box-shadow: none; }

:root[data-sidebar-collapsed] .sidebar-shell .nav__item:hover .tooltip,
:root[data-sidebar-collapsed] .sidebar-shell .nav__item:focus-visible .tooltip,
:root[data-sidebar-collapsed] .sidebar-shell .sidebar__pro:hover .tooltip {
  opacity: 1;
}

/* ---------- Sidebar collapsed state ---------- */

:root[data-sidebar-collapsed] .sidebar-shell .sidebar {
  width: 72px;
  align-items: center;
  padding: var(--space-4);
}

:root[data-sidebar-collapsed] .sidebar-shell .sidebar__brand {
  justify-content: center;
  padding: 0;
}

:root[data-sidebar-collapsed] .sidebar-shell .nav__item,
:root[data-sidebar-collapsed] .sidebar-shell .sidebar__pro,
:root[data-sidebar-collapsed] .sidebar-shell .sidebar__collapse-toggle {
  justify-content: center;
  width: 40px;
  padding: 0;
}

:root[data-sidebar-collapsed] .sidebar-shell .nav__item-label {
  display: none;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--scrim);
}

.modal {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  padding: var(--space-7);
  background: var(--surface-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  color: var(--text-primary);
}
:root[data-theme="dark"] .modal { box-shadow: none; }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ---------- Toast ---------- */

.toast-region {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  padding: var(--space-4) var(--space-5);
  background: var(--surface-100);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-family: var(--font-sans);
  color: var(--text-primary);
}
:root[data-theme="dark"] .toast { box-shadow: none; }

.toast--success { border-left-color: var(--success-text); }
.toast--error { border-left-color: var(--brand-text); }

/* ---------- Popover ---------- */

.popover { position: relative; }

.popover__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  background: var(--surface-100);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.popover__trigger:hover { background: var(--surface-200); }
.popover__trigger:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

.popover__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-6);
  height: var(--space-6);
  background: var(--surface-200);
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.popover__panel {
  position: absolute;
  left: 0;
  top: calc(100% + var(--space-2));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 240px;
  padding: var(--space-3);
  background: var(--surface-200);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-family: var(--font-sans);
  color: var(--text-primary);
}
:root[data-theme="dark"] .popover__panel { box-shadow: none; }

.popover__panel--end {
  left: auto;
  right: 0;
}

.popover__panel--up {
  top: auto;
  bottom: calc(100% + var(--space-2));
}

.popover__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.popover__item:hover { background: var(--surface-100); }
.popover__item:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: -2px;
}

.popover__divider {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border-subtle);
}

/* ---------- Page header (top bar) ---------- */

.page-header {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}
.page-header__title,
.page-header__description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-header__description { color: var(--text-secondary); }

/* ---------- Select ---------- */

.select { position: relative; }

.select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  height: 40px;
  padding: 0 var(--space-3) 0 var(--space-4);
  background: var(--surface-100);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.select__trigger:hover { background: var(--surface-200); }
.select__trigger:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

.select__chevron { display: inline-flex; color: var(--text-secondary); }

.select__panel {
  position: absolute;
  left: 0;
  top: calc(100% + var(--space-2));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 100%;
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface-200);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  list-style: none;
  font-family: var(--font-sans);
}
:root[data-theme="dark"] .select__panel { box-shadow: none; }

.select__option {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.select__option:hover { background: var(--surface-100); }
.select__option[aria-selected="true"] { color: var(--brand-text); font-weight: 500; }
.select__option:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: -2px;
}

.select--up .select__panel {
  top: auto;
  bottom: calc(100% + var(--space-2));
}

/* ---------- Icon ---------- */

.icon {
  flex-shrink: 0;
  width: var(--space-5);
  height: var(--space-5);
}

.link-external {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.link-external .icon { width: var(--space-4); height: var(--space-4); }

.label-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.label-icon .icon { width: var(--space-4); height: var(--space-4); }

.badge .icon { width: var(--space-3); height: var(--space-3); }

/* ---------- File picker ---------- */

.file-picker { position: relative; }

.file-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.file-picker__control {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-2);
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.file-picker__control:hover { background: var(--surface-100); }
.file-picker__input:focus-visible + .file-picker__control {
  outline: 2px solid var(--brand-text);
  outline-offset: 1px;
  border-color: var(--brand-text);
}

.file-picker__button {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--surface-200);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}

.file-picker__name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-picker__name--chosen { color: var(--text-primary); }

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  background: var(--surface-100);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
}

.empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-10);
  height: var(--space-10);
  margin-bottom: var(--space-2);
  background: var(--surface-200);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
}
.empty-state__icon .icon {
  width: var(--space-7);
  height: var(--space-7);
}

.empty-state__hint {
  max-width: 360px;
  color: var(--text-secondary);
}

/* ---------- Dropzone ---------- */

.dropzone { display: block; cursor: pointer; }

.dropzone__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  background: var(--surface-100);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.dropzone__label:hover { background: var(--surface-200); }

.dropzone--active .dropzone__label {
  background: var(--brand-100);
  border-color: var(--brand-text);
}

.dropzone--submitting .dropzone__label {
  cursor: default;
  opacity: 0.7;
  pointer-events: none;
}


/* ---------- Number input ---------- */

.input[type="number"],
.number-input__field {
  -moz-appearance: textfield;
  appearance: textfield;
}
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button,
.number-input__field::-webkit-inner-spin-button,
.number-input__field::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-input {
  display: flex;
  align-items: center;
  height: 40px;
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
}
.number-input:focus-within {
  outline: 2px solid var(--brand-text);
  outline-offset: 1px;
  border-color: var(--brand-text);
}

.number-input__field {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 var(--space-4);
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
}

.number-input__suffix {
  padding-right: var(--space-3);
  color: var(--text-secondary);
}

.number-input__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 40px;
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  border-left: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.number-input__step:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.number-input__step:hover { background: var(--surface-200); color: var(--text-primary); }

/* ---------- Date picker ---------- */

.date-picker { position: relative; }

.date-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.date-picker__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3) 0 var(--space-4);
  background: var(--surface-0);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.date-picker__trigger:hover { background: var(--surface-100); }
.date-picker__trigger:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 1px;
  border-color: var(--brand-text);
}
.date-picker__trigger .icon { color: var(--text-secondary); }

.date-picker__panel {
  position: absolute;
  left: 0;
  top: calc(100% + var(--space-2));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 320px;
  max-width: calc(100vw - var(--space-8));
  padding: var(--space-4);
  background: var(--surface-200);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-family: var(--font-sans);
  color: var(--text-primary);
}
:root[data-theme="dark"] .date-picker__panel { box-shadow: none; }

.date-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.date-picker__title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  color: var(--text-primary);
  border: 0;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.date-picker__title:hover { background: var(--surface-100); }
.date-picker__title:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: -2px;
}
.date-picker__title .icon { width: var(--space-4); height: var(--space-4); }

.date-picker__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.date-picker__nav:hover { background: var(--surface-100); color: var(--text-primary); }

.date-picker__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-1);
}

.date-picker__years {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.date-picker__year {
  height: 48px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.date-picker__year:hover { background: var(--surface-100); }
.date-picker__year:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: -2px;
}
.date-picker__year--today { border-color: var(--border-strong); }
.date-picker__year--selected,
.date-picker__year--selected:hover {
  background: var(--brand-600);
  color: var(--on-brand);
}

.date-picker__weekday {
  padding-bottom: var(--space-1);
  color: var(--text-secondary);
  text-align: center;
  text-transform: capitalize;
}

.date-picker__day {
  height: 36px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color 160ms ease;
}
.date-picker__day:hover { background: var(--surface-100); }
.date-picker__day:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: -2px;
}
.date-picker__day--outside { color: var(--text-tertiary); }
.date-picker__day--today { border-color: var(--border-strong); }
.date-picker__day--selected,
.date-picker__day--selected:hover {
  background: var(--brand-600);
  color: var(--on-brand);
}

.date-picker__time {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.date-picker__time .label { margin-right: auto; }
.date-picker__time-field {
  width: 64px;
  text-align: center;
}

.date-picker__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ---------- Geometry ---------- */

.geometry {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-6);
  align-items: center;
}

.geometry__center {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 220px;
}

.geometry__diagram {
  width: 100%;
  height: auto;
}

.geometry__summary {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
}

.geometry__axle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  text-align: center;
  overflow-wrap: anywhere;
}

.geometry__corner {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.geometry__corner--fr,
.geometry__corner--rr { text-align: right; }

.geometry__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.geometry__corner--fr .geometry__row,
.geometry__corner--rr .geometry__row { flex-direction: row-reverse; }

.geometry__value { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .geometry { grid-template-columns: 1fr 1fr; gap: var(--space-5); }
  .geometry__center { display: contents; }
  .geometry__diagram { display: none; }
  .geometry__axle { grid-column: 1 / -1; align-items: flex-start; text-align: left; }
  .geometry__axle--front { order: -1; }
  .geometry__axle--rear { order: 1; }
  .geometry__corner--fr,
  .geometry__corner--rr { text-align: left; }
  .geometry__corner--fr .geometry__row,
  .geometry__corner--rr .geometry__row { flex-direction: row; }
}

/* ---------- Drivetrain ---------- */

.drivetrain__body {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.drivetrain__wheel {
  fill: var(--surface-200);
  stroke: var(--chart-compare-2);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.drivetrain__rim {
  fill: var(--surface-0);
  stroke: var(--chart-compare-2);
  stroke-width: 2;
}

.drivetrain__axle,
.drivetrain__shaft {
  stroke: var(--chart-compare-1);
  stroke-linecap: round;
}

.drivetrain__axle { stroke-width: 5; }
.drivetrain__shaft { stroke-width: 3; }

.drivetrain__diff {
  fill: var(--surface-0);
  stroke: var(--chart-compare-1);
  stroke-width: 3;
}

.account-island {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2);
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  text-decoration: none;
  transition: border-color 0.16s ease;
}

.account-island:hover { border-color: var(--border-strong); }

.account-island__cta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--brand-text);
  font-weight: 500;
}

@media (max-width: 640px) {
  .account-island__name { display: none; }
}

.pricing-toggle {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}

.pricing-toggle__option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: background 0.16s ease, color 0.16s ease;
}

.pricing-toggle__option--active {
  background: var(--brand-600);
  color: var(--on-brand);
}

.pricing-card { padding: var(--space-7); }

.pricing-card--pro {
  border: 2px solid var(--brand-600);
  box-shadow: var(--shadow-lg);
}

.pricing-price {
  font-size: 44px;
  line-height: 1.1;
  font-weight: 600;
  font-style: italic;
}

.pricing-check {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: var(--space-6);
  height: var(--space-6);
  border-radius: var(--radius-full);
  background: var(--brand-100);
  color: var(--brand-tint-text);
}

.pricing-check .icon { width: var(--space-4); height: var(--space-4); }
