/* =========================================================================
   BASE - reset, typography, form elements, utilities
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-body);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, h5 {
  margin: 0;
  color: var(--text);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p  { margin: 0; }

a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); text-decoration: underline; }

img, svg { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }

code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--blue-150); color: var(--ink); }

/* --- Scrollbars ------------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--gray-250);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gray-300); background-clip: content-box; }

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }

.label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--gray-700);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.label .req { color: var(--blue-600); font-weight: var(--fw-bold); }
.label .hint { font-weight: var(--fw-regular); color: var(--text-subtle); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 0 var(--sp-3);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-inset);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-300); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: var(--sh-focus);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}
.textarea { min-height: 76px; padding: var(--sp-3); resize: vertical; line-height: var(--lh-normal); }

.select {
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.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 var(--sp-3) center;
  cursor: pointer;
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
  border-color: var(--danger-fg);
  background: var(--danger-bg);
}
.input.is-invalid:focus, .select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(180, 35, 31, 0.15); }

.error-text {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--danger-fg);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
}
.error-text::before { content: "!"; font-weight: var(--fw-bold); }

.help-text { font-size: var(--fs-xs); color: var(--text-muted); }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-md);
  color: var(--text-body);
  cursor: pointer;
  user-select: none;
}
.checkbox input, .radio input {
  width: 17px; height: 17px;
  accent-color: var(--blue-600);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 34px; }
.input-group .input-icon {
  position: absolute; left: 10px;
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
}
.input-prefix {
  position: absolute; left: var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  pointer-events: none;
}
.input-group.has-prefix .input { padding-left: 40px; }

/* =========================================================================
   UTILITIES
   ========================================================================= */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.nowrap       { white-space: nowrap; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide         { display: none !important; }
.mono         { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular      { font-variant-numeric: tabular-nums; }
.bold         { font-weight: var(--fw-semibold); }
.muted        { color: var(--text-muted); }
.subtle       { color: var(--text-subtle); }
.text-danger  { color: var(--danger-fg); }
.text-success { color: var(--success-fg); }
.text-warning { color: var(--warning-fg); }
.text-primary { color: var(--blue-600); }
.fw-600       { font-weight: var(--fw-semibold); }
.fw-700       { font-weight: var(--fw-bold); }
.text-xs      { font-size: var(--fs-xs); }
.text-sm      { font-size: var(--fs-sm); }
.text-lg      { font-size: var(--fs-lg); }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.justify-center { justify-content: center; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1 1 0%; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.w-full { width: 100%; }
.full-height { min-height: 100vh; }