/* ==========================================================================
   JFM Ventas · Sistema de diseño de la aplicación
   Derivado de "JFM Design System v20 · Commerce" (Web JFM/design.md).
   Tokens copiados tal cual del sistema; nunca improvisar valores.
   Claro, cálido, naranja como único acento. Sin gradientes, sin modo oscuro,
   sin emojis: los iconos son SVG (includes/ui.php → icono()).
   ========================================================================== */

:root {
  /* Superficies */
  --bg: #FCFBF7;
  --surface: #FFFFFF;
  --panel: #F5F4F1;
  --panel-2: #FBFAF8;
  /* Tinta */
  --ink: #1A1714;
  --ink-2: #57524B;
  --muted: #948E84;
  --line: #EAE7E1;
  --line-2: #F1EEE8;
  /* Marca */
  --brand: #F6921E;
  --brand-press: #DE7C0A;
  --brand-deep: #B4610A;
  --brand-tint: #FDF2E4;
  /* Semánticos */
  --ok: #1C9B57;
  --ok-tint: #E6F5EC;
  --warn: #C7780A;
  --warn-tint: #FDF2E4;
  --danger: #D63A2C;
  --danger-tint: #FBE9E7;
  --info: #2F6DB5;
  --info-tint: #E8F0FA;
  /* Geometría y movimiento */
  --r: 14px;
  --r-sm: 10px;
  --r-pill: 999px;
  --maxw: 1200px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --sh-2: 0 6px 16px rgba(26, 23, 20, .07), 0 1px 3px rgba(26, 23, 20, .05);
  --sh-3: 0 20px 50px rgba(26, 23, 20, .13);
  /* Tipografía */
  --fh: 'Rubik', system-ui, sans-serif;
  --fb: 'Nunito Sans', system-ui, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--fb); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden; min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--fh); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; color: var(--ink); }
h1 { font-size: clamp(22px, 2.4vw, 30px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0 0 12px; }
a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 700; }
small { font-size: 12.5px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--panel); padding: 1px 6px; border-radius: 6px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.eyebrow { font-family: var(--fh); font-size: 11.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.brand { color: var(--brand-deep); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; } .between { justify-content: space-between; } .gap-1 { gap: 8px; } .gap-2 { gap: 14px; } .gap-3 { gap: 22px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .hide-mobile { display: none !important; } }

/* ---------- Iconos ---------- */
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex-shrink: 0; }
.icon--sm { width: .95em; height: .95em; }
.icon--lg { width: 1.6em; height: 1.6em; }
.icon--xl { width: 2.4em; height: 2.4em; }

/* ---------- Barra superior ---------- */
.app-topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.app-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; }
.brand-logo { display: flex; align-items: center; }
.brand-logo img { height: 34px; width: auto; display: block; }
.app-topbar__right { display: flex; align-items: center; gap: 12px; }
.userchip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); }
.userchip__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-deep); font-family: var(--fh); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.userchip__name { font-weight: 700; font-size: 13.5px; line-height: 1.1; }
.userchip__role { color: var(--muted); font-size: 11.5px; line-height: 1.1; margin-top: 2px; }

/* ---------- Navegación ---------- */
.app-nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.app-nav__list { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.app-nav__list::-webkit-scrollbar { display: none; }
.app-nav__item a { display: inline-flex; align-items: center; gap: 8px; padding: 14px 14px; font-family: var(--fh); font-weight: 600; font-size: 13.5px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; transition: color .16s var(--ease), border-color .16s var(--ease); }
.app-nav__item a:hover { color: var(--ink); text-decoration: none; }
.app-nav__item.is-active a { color: var(--brand-deep); border-bottom-color: var(--brand); }
.nav-badge { background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: var(--r-pill); padding: 1px 7px; line-height: 1.5; }

/* ---------- Contenido ---------- */
.app-main { padding: 26px 0 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head__title h1 { display: flex; align-items: center; gap: 10px; }
.page-head__sub { color: var(--muted); margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sec { margin-bottom: 26px; }
.sec__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.sec__more { font-family: var(--fh); font-weight: 600; color: var(--brand-deep); font-size: 13.5px; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 20px; }
.card--panel { background: var(--panel-2); }
.card--tint { background: var(--brand-tint); border-color: #F7D9B5; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.card__title .icon { color: var(--brand); }
.card__body > :last-child { margin-bottom: 0; }

/* ---------- Estadísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat__label { font-family: var(--fh); font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat__value { font-family: var(--fh); font-weight: 700; font-size: 26px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat__meta { font-size: 12.5px; color: var(--ink-2); }
.stat--brand .stat__value { color: var(--brand-deep); }
.stat--ok .stat__value { color: var(--ok); }
.stat--warn .stat__value { color: var(--warn); }
.stat--danger .stat__value { color: var(--danger); }
.stat--info .stat__value { color: var(--info); }
.stat--compact { padding: 12px 14px; } .stat--compact .stat__value { font-size: 20px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--fh); font-weight: 600; font-size: 14px; padding: 11px 18px; border-radius: 12px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.2; transition: transform .16s var(--ease), box-shadow .2s var(--ease), background .16s var(--ease), border-color .16s var(--ease); }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--brand { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(180, 97, 10, .28); }
.btn--brand:hover { background: var(--brand-press); color: #fff; }
.btn--out { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--out:hover { border-color: var(--ink-2); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--panel); color: var(--ink); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--danger { background: var(--danger-tint); color: var(--danger); border-color: #F3C2BC; }
.btn--danger:hover { background: #F6D5D1; }
.btn--ok { background: var(--ok-tint); color: var(--ok); border-color: #BFE3CD; }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn--lg { padding: 14px 24px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; width: 36px; height: 36px; border-radius: 10px; }
.btn .icon { width: 1.05em; height: 1.05em; }

/* ---------- Tablas ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { font-family: var(--fh); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 12px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--panel-2); }
.table tfoot td { font-family: var(--fh); font-weight: 700; background: var(--panel-2); border-top: 1px solid var(--line); }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact th, .table--compact td { padding: 8px 10px; font-size: 13px; }
.table .row-muted td { color: var(--muted); }
.table .row-hl td { background: var(--brand-tint); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table a { font-weight: 600; }

/* ---------- Badges y píldoras ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--fh); font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-pill); background: var(--panel); color: var(--ink-2); white-space: nowrap; line-height: 1.3; }
.badge--ok { background: var(--ok-tint); color: var(--ok); }
.badge--warn { background: var(--warn-tint); color: var(--warn); }
.badge--danger { background: var(--danger-tint); color: var(--danger); }
.badge--info { background: var(--info-tint); color: var(--info); }
.badge--brand { background: var(--brand-tint); color: var(--brand-deep); }
.badge--dark { background: var(--ink); color: #fff; }
.badge .icon { width: .95em; height: .95em; }
/* Selector de etapa de venta en línea (mismo tamaño que un badge) */
.sel-etapa { appearance: none; font-family: var(--fh); font-size: 11.5px; font-weight: 600; line-height: 1.3; padding: 4px 26px 4px 10px; border-radius: var(--r-pill); border: 1px solid transparent; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center; color: var(--ink-2); cursor: pointer; max-width: 100%; }
.sel-etapa:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.sel-etapa--ok { background-color: var(--ok-tint); color: var(--ok); }
.sel-etapa--warn { background-color: var(--warn-tint); color: var(--warn); }
.sel-etapa--info { background-color: var(--info-tint); color: var(--info); }
.sel-etapa--brand { background-color: var(--brand-tint); color: var(--brand-deep); }
.sel-etapa.is-saving, .sel-etapa:disabled { opacity: .6; cursor: progress; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot--ok { background: var(--ok); } .dot--warn { background: var(--brand); } .dot--danger { background: var(--danger); }

/* ---------- Alertas y avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); margin-bottom: 16px; font-size: 14px; }
.alert .icon { margin-top: 2px; flex-shrink: 0; }
.alert--ok, .alert.success, .alert-success { background: var(--ok-tint); border-color: #BFE3CD; color: #14663A; }
.alert--warn, .alert.warning, .alert-warning { background: var(--warn-tint); border-color: #F7D9B5; color: #8A5306; }
.alert--danger, .alert.error, .alert-error, .alert-danger { background: var(--danger-tint); border-color: #F3C2BC; color: #9E2A1F; }
.alert--info, .alert.info, .alert-info { background: var(--info-tint); border-color: #C6D9F0; color: #234F84; }
.flash-message { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel-2); margin-bottom: 16px; font-size: 14px; }
.flash-message.success { background: var(--ok-tint); border-color: #BFE3CD; color: #14663A; }
.flash-message.error { background: var(--danger-tint); border-color: #F3C2BC; color: #9E2A1F; }
.flash-message.warning { background: var(--warn-tint); border-color: #F7D9B5; color: #8A5306; }
.flash-message.info { background: var(--info-tint); border-color: #C6D9F0; color: #234F84; }
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 9500; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 92vw); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--r-sm); padding: 12px 14px; box-shadow: var(--sh-2); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.toast--ok { border-left-color: var(--ok); } .toast--danger { border-left-color: var(--danger); } .toast--warn { border-left-color: var(--warn); } .toast--info { border-left-color: var(--info); }
.toast__close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field__label, .field label { display: block; font-family: var(--fh); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea,
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font-family: var(--fb); font-size: 14.5px; padding: 11px 13px; min-height: 44px; transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus, .select:focus, .textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.input.is-invalid, .field input.error, .field .is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-tint); }
.textarea, .field textarea { min-height: 96px; resize: vertical; }
.select, .field select { appearance: none; 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='%2357524B' stroke-width='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 12px center; padding-right: 36px; }
.field__hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field__error { font-size: 12.5px; color: var(--danger); margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span-2 { grid-column: 1 / -1; }
/* Medios de pago de una venta */
.pagos { margin-bottom: 14px; }
.pagos__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.pagos__head label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.pagos__fila { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.pagos__fila .select, .pagos__fila .input { margin: 0; }
.pagos__costo { font-size: 12px; white-space: nowrap; min-width: 64px; text-align: right; color: var(--warn); }
.pagos__pie { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.pagos__resumen { font-size: 12.5px; }
.pagos__resumen strong { color: var(--ink); }
.pagos__resumen.danger, .pagos__resumen.danger strong { color: var(--danger); }
.pagos__resumen.ok strong.pagos__suma { color: var(--ok); }
@media (max-width: 640px) { .pagos__fila { grid-template-columns: 1fr 1fr; } .pagos__costo { text-align: left; } }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group__addon { display: flex; align-items: center; padding: 0 12px; border: 1.5px solid var(--line); border-left: none; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--panel); color: var(--ink-2); font-weight: 600; }
.password-toggle { position: relative; }
.password-toggle .input, .password-toggle input { padding-right: 44px; }
.password-toggle__btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); padding: 6px; display: grid; place-items: center; }
.password-toggle__btn:hover { color: var(--ink); }

/* ---------- Filtros y selector de período ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 18px; }
.filters .field { margin-bottom: 0; min-width: 160px; }
.filters .field__label { margin-bottom: 4px; }
.period { display: inline-flex; align-items: center; gap: 6px; }
.period .select { min-width: 190px; min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-family: var(--fh); font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 7px 14px; cursor: pointer; transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease); text-decoration: none; }
.chip:hover { border-color: var(--ink-2); text-decoration: none; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Progreso ---------- */
.progress { width: 100%; height: 10px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; }
.progress--lg { height: 18px; }
.progress__bar { height: 100%; background: var(--brand); border-radius: var(--r-pill); transition: width .5s var(--ease); display: flex; align-items: center; justify-content: flex-end; }
.progress__bar--ok { background: var(--ok); } .progress__bar--warn { background: var(--warn); } .progress__bar--danger { background: var(--danger); } .progress__bar--info { background: var(--info); }
.progress__label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.progress-inline { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-inline .progress { flex: 1; }
.progress-inline span { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); min-width: 42px; text-align: right; }

/* ---------- Estados vacíos ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 44px; height: 44px; color: var(--line); margin-bottom: 10px; }
.empty__title { font-family: var(--fh); font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------- Modales (compatible con el JS existente: .modal + .active) ---------- */
.modal, .modal-overlay { position: fixed; inset: 0; background: rgba(26, 23, 20, .55); z-index: 9100; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 14px; }
.modal.active, .modal.is-open, .modal-overlay.active, .modal-overlay.is-open { display: flex; }
.modal-content, .modal__dialog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); width: 100%; max-width: 560px; padding: 24px; box-shadow: var(--sh-3); color: var(--ink); animation: modal-in .2s var(--ease); }
.modal-content--lg, .modal__dialog--lg { max-width: 820px; }
@keyframes modal-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header, .modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-header h2, .modal-header h3, .modal-title, .modal__title { font-family: var(--fh); font-size: 18px; font-weight: 700; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 8px; }
.modal-close, .btn-close, .modal__close { background: var(--panel); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--ink-2); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.modal-close:hover, .btn-close:hover, .modal__close:hover { background: var(--line); color: var(--ink); }
.modal-actions, .modal-footer, .modal__foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Detalles / plegables ---------- */
details.fold { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); margin-bottom: 12px; }
details.fold > summary { cursor: pointer; padding: 12px 14px; font-family: var(--fh); font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { border-bottom: 1px solid var(--line-2); color: var(--ink); }
details.fold > .fold__body { padding: 12px 14px; }

/* ---------- Listas de definición ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }

/* ---------- Ranking / listas ---------- */
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank__item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.rank__pos { font-family: var(--fh); font-weight: 700; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); color: var(--ink-2); font-size: 13px; flex-shrink: 0; }
.rank__pos--1 { background: var(--brand); color: #fff; } .rank__pos--2 { background: #DDD9D0; color: var(--ink); } .rank__pos--3 { background: #E8C9A8; color: var(--ink); }
.rank__name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__value { font-family: var(--fh); font-weight: 700; font-variant-numeric: tabular-nums; }
.rank__item.is-me { background: var(--brand-tint); border-color: #F7D9B5; }

/* ---------- Gamificación (sobrio, sin emojis) ---------- */
.level { display: flex; align-items: center; gap: 14px; }
.level__ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-family: var(--fh); font-weight: 700; font-size: 18px; background: var(--brand-tint); color: var(--brand-deep); border: 2px solid #F7D9B5; }
.level__name { font-family: var(--fh); font-weight: 700; font-size: 18px; }
.level__tier { color: var(--muted); font-size: 12.5px; }
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.achievement { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 13px; }
.achievement .icon { width: 22px; height: 22px; color: var(--brand); }
.achievement.is-locked { opacity: .5; filter: grayscale(1); }
.achievement__name { font-weight: 700; display: block; }
.achievement__xp { color: var(--muted); font-size: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { font-family: var(--fh); font-weight: 600; font-size: 13.5px; color: var(--ink-2); padding: 10px 14px; border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.is-active { color: var(--brand-deep); border-bottom-color: var(--brand); }
.tab-panel { display: none; } .tab-panel.is-active { display: block; }

/* ---------- Gráficas ---------- */
.chart-box { position: relative; width: 100%; height: 280px; }
.chart-box--sm { height: 200px; }
.chart-box canvas { max-width: 100%; }

/* ---------- Pie ---------- */
.app-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.app-footer strong { color: var(--ink-2); }

/* ---------- Pantallas de acceso ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth__card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 34px 30px; box-shadow: var(--sh-2); }
.auth__logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth__logo img { height: 40px; width: auto; }
.auth__title { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth__sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.auth__foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 22px; }
.auth__welcome { background: var(--brand-tint); border: 1px solid #F7D9B5; border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 18px; }
.auth__welcome strong { font-family: var(--fh); }
.reqs { list-style: none; margin: 0 0 18px; padding: 12px 14px; background: var(--panel-2); border-radius: var(--r-sm); font-size: 13px; color: var(--ink-2); }
.reqs li { display: flex; gap: 8px; align-items: center; margin: 3px 0; }
.reqs .icon { color: var(--ok); }

/* ---------- Utilidades de impresión ---------- */
@media print {
  .app-topbar, .app-nav, .app-footer, .btn, .filters, .sop-boton, .page-head__actions { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap, .stat { border-color: #ccc; break-inside: avoid; }
}
