/* ==========================================================================
   Base común: tipografías, colores, controles. Lo usan la portada, la web y
   el panel de cada empresa y el superadmin. El color de marca de cada
   empresa llega por /<empresa>/tema.css (variables --brand*).
   ========================================================================== */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/assets/vendor/fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/assets/vendor/fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/vendor/fonts/courierprime-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Courier Prime";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/vendor/fonts/courierprime-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-data: "Courier Prime", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --ink: #18181B;
  --ink-2: #3F3F46;
  --muted: #5F5F68;
  --line: #E4E4E7;
  --field: #D4D4D8;
  --hover: #F1F1F2;
  --sunken: #F4F4F5;

  /* Color de la empresa (se sobrescribe en tema.css) */
  --brand: #C21F32;
  --brand-ink: #A3182A;
  --brand-on: #FFFFFF;
  --brand-tint: rgba(194, 31, 50, 0.08);

  --ok: #15803D;
  --ok-tint: #ECFDF3;
  --warn: #B45309;
  --warn-tint: #FFF7E6;
  --danger: #B91C1C;
  --danger-tint: #FEF2F2;

  --radius: 4px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-1: 0 1px 2px rgba(24, 24, 27, 0.06), 0 4px 14px rgba(24, 24, 27, 0.06);
  --shadow-2: 0 12px 32px rgba(24, 24, 27, 0.16);
  --shadow-3: 0 30px 80px rgba(24, 24, 27, 0.24);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--brand);
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; letter-spacing: -0.02em; font-weight: 800; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--brand); color: var(--brand-on); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }
* { scrollbar-width: thin; scrollbar-color: #C4C4CA transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C4C4CA; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
:lang(zh) h1, :lang(zh) h2, :lang(zh) h3, :lang(zh) .tight { letter-spacing: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.data { font-family: var(--font-data); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent; background: none;
  font-weight: 700; font-size: 15px; line-height: 1.1; white-space: nowrap; text-align: center;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn i { font-size: 18px; }
.btn-brand { background: var(--brand); color: var(--brand-on); }
.btn-brand:hover:not(:disabled) { background: var(--brand-ink); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover:not(:disabled) { background: #000; }
.btn-line { border-color: var(--field); background: var(--surface); color: var(--ink); }
.btn-line:hover:not(:disabled) { border-color: var(--ink); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991B1B; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: var(--radius); font-size: 20px; color: var(--ink-2);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-tint); }
.link { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { color: var(--brand); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--brand); }

/* ---------- Campos ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 14px; font-weight: 700; color: var(--ink); }
.field .opt { font-weight: 500; color: var(--muted); }
.field .help { font-size: 13px; color: var(--muted); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--field); border-radius: var(--radius); background: var(--surface);
  font-size: 16px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.input::placeholder, .textarea::placeholder { color: #71717A; }
.input:hover, .select:hover, .textarea:hover { border-color: #A1A1AA; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.10); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.10); }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--field); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.input-group:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.10); }
/* Prefijo largo (p. ej. un dominio de pruebas): se corta por la izquierda con «…» y la casilla siempre tiene sitio */
.input-group .prefix {
  display: block; align-content: center; flex: 0 1 auto; min-width: 0; max-width: 42%; overflow: hidden; text-overflow: ellipsis; direction: rtl;
  padding: 0 10px 0 12px; color: var(--muted); font-size: 15px; white-space: nowrap; background: var(--sunken); border-right: 1px solid var(--line);
}
.input-group .prefix > span { direction: ltr; unicode-bidi: isolate; }
.input-group .input { border: 0; box-shadow: none; flex: 1 1 auto; min-width: 9ch; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Interruptor */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 12px; background: #D4D4D8; position: relative; transition: background .2s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }

/* ---------- Avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; font-weight: 500; line-height: 1.45; }
.alert i { font-size: 18px; margin-top: 1px; flex: none; }
.alert-error { background: var(--danger-tint); color: #991B1B; }
.alert-ok { background: var(--ok-tint); color: #166534; }
.alert-warn { background: var(--warn-tint); color: #92400E; }
.alert-info { background: var(--sunken); color: var(--ink-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center;
  max-width: calc(100% - 32px); box-shadow: var(--shadow-2);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast i { color: #4ADE80; font-size: 18px; flex: none; }
.toast.error i { color: #F87171; }

/* ---------- Capas: panel lateral y diálogo ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(24, 24, 27, 0.45); opacity: 0; pointer-events: none; transition: opacity .25s var(--ease); }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: min(580px, 100%);
  background: var(--surface); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .38s var(--ease); box-shadow: -20px 0 50px rgba(24, 24, 27, 0.12);
  visibility: hidden;
}
.sheet.show { transform: none; visibility: visible; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 21px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 22px 24px 32px; display: grid; gap: 18px; align-content: start; overscroll-behavior: contain; }
.sheet-foot { padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface); }
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn-grow { flex: 2; }
@media (max-width: 560px) { .sheet-body { padding: 18px 16px 28px; } .sheet-head { padding-left: 16px; } .sheet-foot { padding-left: 16px; padding-right: 16px; } }

.dialog {
  position: fixed; z-index: 70; left: 50%; top: 50%; width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-3);
  transform: translate(-50%, -46%); opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity .25s var(--ease), transform .3s var(--ease), visibility 0s linear .3s;
}
.dialog.show { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; visibility: visible; transition: opacity .25s var(--ease), transform .3s var(--ease); }
.dialog h2 { font-size: 23px; padding-right: 36px; }
.dialog .lead { margin-top: 8px; color: var(--muted); font-size: 15px; }
.dialog .close { position: absolute; top: 12px; right: 12px; }
.dialog .actions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
body.lock { overflow: hidden; }

/* ---------- Selector de idioma ---------- */
.langs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.langs button {
  min-width: 38px; height: 30px; padding: 0 8px; border: 0; border-radius: 3px; background: none;
  font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.langs button:hover { color: var(--ink); background: var(--hover); }
.langs button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.langs button:lang(zh) { letter-spacing: 0; }
.langs button { white-space: nowrap; }
.langs-wrap { position: relative; display: inline-flex; }
.langs-toggle {
  display: none; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 13px; font-weight: 800; color: var(--ink); white-space: nowrap;
}
.langs-toggle i { font-size: 17px; }
@media (max-width: 560px) {
  .langs-toggle { display: inline-flex; }
  .langs-wrap .langs { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 45; flex-direction: column; align-items: stretch; box-shadow: var(--shadow-2); padding: 4px; }
  .langs-wrap.open .langs { display: flex; }
  .langs-wrap .langs button { height: 40px; min-width: 76px; }
}

/* ---------- Varios ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.badge i { font-size: 13px; }
.empty { text-align: center; padding: 56px 16px; }
.empty > i { font-size: 38px; color: var(--muted); }
.empty h2, .empty h3 { margin-top: 12px; font-size: 20px; }
.empty p { margin: 6px auto 0; color: var(--muted); max-width: 46ch; }
.empty .btn { margin-top: 18px; }
.skeleton { background: linear-gradient(90deg, #F1F1F2 0%, #F8F8F9 50%, #F1F1F2 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Turnstile en modo "interaction-only": sin altura reservada; solo ocupa sitio cuando enseña la casilla */
.turnstile-box:empty { display: none; }

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