/* Reset, typography and form controls. */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

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

code, .mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

svg { display: block; fill: currentColor; }

/* ── Focus: always visible, never removed ─────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

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

.skip-link {
  position: absolute;
  top: -48px;
  left: var(--sp-2);
  z-index: 100;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: top 0.12s ease;
}
.skip-link:focus { top: var(--sp-2); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--text-inverse); }

.btn--icon { width: 32px; padding: 0; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.segmented__btn {
  height: 30px;
  padding: 0 var(--sp-3);
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.segmented__btn:first-child { border-left: 0; }
.segmented__btn:hover { background: var(--surface-hover); }
.segmented__btn[aria-pressed="true"] {
  background: var(--surface-active);
  color: var(--text-accent);
}

/* ── Form fields ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field__label {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-secondary);
}
.field__hint { font-size: var(--fs-12); color: var(--text-muted); }

input[type="text"],
input[type="date"],
select {
  height: 32px;
  min-width: 0;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-13);
}
input[type="text"]:hover,
input[type="date"]:hover,
select:hover { border-color: var(--border-strong); }
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.input-group { display: flex; gap: var(--sp-2); }
.input-group input { flex: 1 1 auto; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-5);
}

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