/* Reset + base typography + generic form/table/status styling.
   Loaded after tokens.css, before layout.css/components.css. */
*, *::before, *::after { box-sizing: border-box; }
/* overflow-x: hidden (not clip) here would force overflow-y to compute as
   `auto` too, per the CSS Overflow spec's "one axis non-visible forces the
   other to auto" rule — that silently turns <body> into its own internal
   scroll container instead of the viewport/<html> scrolling normally,
   which breaks window.scrollTo()/window.scrollY (they operate on
   document.scrollingElement, i.e. <html>, not on whichever element actually
   ends up holding the real scrollbar). overflow-x: clip clips the same way
   without tripping that pairing rule. Confirmed live: with `hidden`,
   document.documentElement.scrollHeight stayed pinned to the viewport
   height and window.scrollTo() was a no-op; with `clip`, both track the
   page's real content height and window.scrollTo() works. */
html, body { height: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--charcoal);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 0.6rem; letter-spacing: -0.01em; color: var(--charcoal); }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
h4 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--steel); }
a:hover { color: var(--accent); }

/* ---------- forms ---------- */
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem 1.2rem;
}
legend {
  padding: 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}
label {
  display: block;
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
label:first-child { margin-top: 0; }

input, select, textarea {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin-top: 0.3rem;
  padding: 0.5rem 0.65rem;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  color: var(--charcoal);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { max-width: 30rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(26, 58, 82, 0.1);
}
input[type="file"] {
  padding: 0.4rem 0.5rem;
  background: var(--bg);
}
input:disabled, input[readonly] { color: var(--faint); background: var(--bg); }

.hint {
  font-size: 0.83rem;
  color: var(--faint);
  margin: 0.3rem 0 0.75rem;
}

/* ---------- buttons ---------- */
button, .btn {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--steel);
  color: #fff;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s, background 0.15s;
}
button:hover { filter: brightness(1.08); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { color: var(--accent); filter: none; }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; }
th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fbfcfd;
}
td:last-child, th:last-child { text-align: left; }
tbody tr:hover { background: #fafbfc; }

/* ---------- status banners ---------- */
.error {
  color: #a5321f;
  background: var(--red-soft);
  border: 1px solid #f3c3c3;
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-weight: 600;
}
.warning {
  color: var(--amber);
  background: #fff8e6;
  border: 1px solid #f0d28a;
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-weight: 600;
}
.warning a { color: inherit; text-decoration: underline; }
.ok {
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid #b7e6cb;
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-weight: 600;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  right: max(1.5rem, env(safe-area-inset-right));
  background: var(--charcoal);
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(26, 58, 82, 0.25);
}
.toast-show { animation: toast-pop 2.2s ease forwards; }
@keyframes toast-pop {
  0% { opacity: 0; transform: translateY(6px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
