/* ==========================================================================
   Sistema de diseño — variables, reinicio, tipografía, botones y formularios
   ========================================================================== */
:root {
  --brand-50: #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-200: #99f6e4;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-800: #115e59;
  --brand-900: #134e4a;

  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;

  --green: #16a34a;
  --green-bg: #dcfce7;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --slate: #334155;
  --slate-bg: #e2e8f0;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.25);
  --ring: 0 0 0 3px rgba(20, 184, 166, 0.35);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 268px;
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.75em; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

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

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand-700); color: #fff;
  font-weight: 600; font-size: 0.95rem; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--brand-800); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); outline: none; }
.btn[disabled], .btn.is-loading { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.btn svg { flex: none; }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--slate-bg); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-outline { background: var(--surface); color: var(--red); border-color: #fca5a5; }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-success { background: var(--green); }
.btn-success:hover { background: #15803d; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.85rem; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }
.btn-block { width: 100%; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--red); margin-left: 2px; }
.hint { font-size: 0.8rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: #94a3b8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--ring); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red); }
.select { appearance: none; padding-right: 36px; 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.5' 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 12px center; }
input[type="date"], input[type="time"], input[type="datetime-local"] { min-height: 42px; }
input[type="file"] { display: none; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.form-grid > .col-12 { grid-column: span 12; }
.form-grid > .col-8 { grid-column: span 8; }
.form-grid > .col-6 { grid-column: span 6; }
.form-grid > .col-4 { grid-column: span 4; }
.form-grid > .col-3 { grid-column: span 3; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-error { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--red-bg); color: #991b1b; font-size: 0.9rem; }
.form-error:empty { display: none; }

.radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio { position: relative; }
.radio input { position: absolute; opacity: 0; pointer-events: none; }
.radio span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; font-weight: 500; user-select: none; transition: all 0.15s;
}
.radio span:hover { border-color: var(--muted); }
.radio input:checked + span { background: var(--brand-50); border-color: var(--brand-600); color: var(--brand-800); font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand-600); }
.radio input:focus-visible + span { box-shadow: var(--ring); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.92rem; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand-700); flex: none; cursor: pointer; }

@media (max-width: 720px) {
  .form-grid > .col-8, .form-grid > .col-6, .form-grid > .col-4, .form-grid > .col-3 { grid-column: span 12; }
  .form-grid > .col-4.keep, .form-grid > .col-3.keep, .form-grid > .col-6.keep { grid-column: span 6; }
  .form-actions .btn { flex: 1 1 auto; }
  body { font-size: 16px; }
  .input, .select, .textarea { font-size: 16px; } /* evita el zoom automático en iOS */
}

/* ---------- Carga ---------- */
.splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand-600); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
