/* Shared tokens, reset and form controls for every page. */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e7ee;
  --border-strong: #d2d8e2;
  --text: #18233a;
  --text-secondary: #34405a;
  --muted: #5d6b82;
  --muted-light: #8b97a8;
  --hover-bg: #f2f5fa;
  --surface-recessed: #f8fafd;
  --skeleton-a: #eaeef4;
  --skeleton-b: #f3f6fa;

  --accent: #1f6fd1;
  --accent-hover: #1a5fb4;
  --accent-active: #164f97;
  --accent-bg: #eaf2fd;
  --accent-border: #bcd6f5;
  --on-accent: #ffffff;

  --brand-navy: #13203b;
  --brand-navy-2: #182b4f;
  --brand-sky: #6cc7f5;
  --brand-on-navy: #e6edf7;
  --brand-on-navy-muted: #9fb2cd;

  --success: #15803d; --success-bg: #ecfdf3;
  --warning: #b45309; --warning-bg: #fef3c7;
  --danger: #b91c1c; --danger-bg: #fef2f2; --danger-border: #fecaca;
  --info: #1d4ed8; --info-bg: #eff6ff;
  --purple: #6d28d9; --purple-bg: #f3effe;

  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 6px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.20);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1524; --card: #151e31; --border: #243049; --border-strong: #2f3d5a;
    --text: #e6ebf3; --text-secondary: #c4cede; --muted: #93a1b8; --muted-light: #6c7a92;
    --hover-bg: #1b263d; --surface-recessed: #111a2b; --skeleton-a: #1b2538; --skeleton-b: #222e45;
    --accent: #4d93ea; --accent-hover: #6aa6f0; --accent-active: #8bbaf4; --accent-bg: #172a47; --accent-border: #2b4c7a;
    --success: #4ade80; --success-bg: #12301f; --warning: #fbbf24; --warning-bg: #3a2a0c;
    --danger: #f87171; --danger-bg: #3a1618; --danger-border: #5c2226; --info: #7aa7ff; --info-bg: #15264a;
    --purple: #b79cff; --purple-bg: #2a2045;
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35); --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1524; --card: #151e31; --border: #243049; --border-strong: #2f3d5a;
  --text: #e6ebf3; --text-secondary: #c4cede; --muted: #93a1b8; --muted-light: #6c7a92;
  --hover-bg: #1b263d; --surface-recessed: #111a2b; --skeleton-a: #1b2538; --skeleton-b: #222e45;
  --accent: #4d93ea; --accent-hover: #6aa6f0; --accent-active: #8bbaf4; --accent-bg: #172a47; --accent-border: #2b4c7a;
  --success: #4ade80; --success-bg: #12301f; --warning: #fbbf24; --warning-bg: #3a2a0c;
  --danger: #f87171; --danger-bg: #3a1618; --danger-border: #5c2226; --info: #7aa7ff; --info-bg: #15264a;
  --purple: #b79cff; --purple-bg: #2a2045;
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35); --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- controls ------------------------------------------------------------ */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
select, textarea, .cs-trigger {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .cs-trigger:focus-visible, .cs.is-open .cs-trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }
label { font-weight: 600; font-size: 13px; color: var(--text-secondary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--hover-bg); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover-bg); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 36px; }
.btn.icon.sm { width: 30px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13.5px;
}
.form-error:empty { display: none; }
.form-success {
  background: var(--success-bg);
  color: var(--success);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13.5px;
}

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* Same autofill repaint for in-app forms, following the current theme. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--card) inset;
  box-shadow: 0 0 0 1000px var(--card) inset;
  transition: background-color 600000s 0s;
}
