/* CAF · diseño base (celular primero, estilo Apple, tonos cálidos) */
:root {
  --brand: #B01E2E;
  --brand-2: color-mix(in srgb, var(--brand) 62%, #1a0508);
  --brand-soft: color-mix(in srgb, var(--brand) 9%, transparent);
  --gold: #C79B3B;
  --gold-soft: #F3E6C6;
  --bg: #FBF6EF;
  --bg-2: #F4ECE1;
  --card: #FFFFFF;
  --ink: #261C1B;
  --ink-2: #5E504C;
  --muted: #8C7C76;
  --line: rgba(60, 40, 30, .11);
  --line-2: rgba(60, 40, 30, .06);
  --good: #2F7D56;
  --warn: #B7791F;
  --bad: #B3261E;
  --a-general: #B01E2E;
  --a-alabanza: #B8892E;
  --a-lideres: #2F6B4F;
  --a-finanzas: #40608A;
  --r: 20px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(60, 30, 20, .05), 0 10px 30px -12px rgba(60, 30, 20, .16);
  --shadow-lg: 0 24px 60px -20px rgba(60, 25, 15, .35);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --nav-h: 56px;
  --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #161011; --bg-2: #1E1516; --card: #231A1B; --ink: #F6EEE8; --ink-2: #CDBFB8; --muted: #9A8A84;
    --line: rgba(255, 235, 225, .13); --line-2: rgba(255, 235, 225, .07); --gold-soft: #3a2f17;
    --brand: #D5465A; --good: #5CC08E; --warn: #E0B35A; --bad: #FF8A80;
    --a-general: #E0586B; --a-alabanza: #D9AE55; --a-lideres: #5FB58C; --a-finanzas: #7FA3D4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
img, svg { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; letter-spacing: -.022em; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; background: var(--brand); color: #fff; transition: transform .15s, filter .15s, background .2s; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.gold { background: linear-gradient(180deg, #E1BC62, #C79B3B); color: #3a2a06; }
.btn.danger { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 19px; height: 19px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* formularios */
.field { display: grid; gap: 6px; }
.field > label, .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); font-size: 16px; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238c7c76' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.hint { font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .span2 { grid-column: 1 / -1; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; z-index: 1; cursor: pointer; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 40%, transparent); transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(20px); }

/* superficies */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.card.flat { box-shadow: none; border-color: var(--line); }
.stack { display: grid; gap: 14px; }
.stack.lg { gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serif { font-family: var(--serif); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.gold { background: var(--gold-soft); color: #7a5a10; }
.badge.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--a-general); flex: none; display: inline-block; }
.dot.alabanza, .a-alabanza { --c: var(--a-alabanza); } .dot.lideres, .a-lideres { --c: var(--a-lideres); } .dot.finanzas, .a-finanzas { --c: var(--a-finanzas); } .a-general { --c: var(--a-general); }
.dot.alabanza { background: var(--a-alabanza); } .dot.lideres { background: var(--a-lideres); } .dot.finanzas { background: var(--a-finanzas); }

/* segmentado estilo iOS */
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--line-2); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-height: 36px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14.5px; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* lista agrupada estilo iOS */
.list { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--line-2); }
.item { display: flex; align-items: center; gap: 13px; padding: 13px 16px; min-height: 58px; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; }
button.item:active, a.item:active { background: var(--line-2); }
.item .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.item .ico svg { width: 21px; height: 21px; }
.item .t { font-weight: 600; }
.item .s { font-size: 13.5px; color: var(--muted); }
.item .chev { width: 18px; height: 18px; color: var(--muted); flex: none; }

/* hoja (modal) */
.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(20, 8, 6, .5); backdrop-filter: blur(3px); opacity: 0; transition: opacity .25s; display: flex; align-items: flex-end; justify-content: center; }
.scrim.in { opacity: 1; }
.sheet { width: 100%; max-height: 92dvh; background: var(--bg); border-radius: 26px 26px 0 0; display: flex; flex-direction: column; transform: translateY(40px); transition: transform .3s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg); }
.scrim.in .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px 22px; flex: none; }
.sheet-head::before { content: ""; position: absolute; left: 50%; top: 8px; width: 38px; height: 5px; border-radius: 3px; background: var(--line); transform: translateX(-50%); }
.sheet-head h3 { flex: 1; font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 8px 22px 22px; overscroll-behavior: contain; }
.sheet-foot { padding: 12px 22px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; border-top: 1px solid var(--line-2); flex: none; }
.sheet-foot .btn { flex: 1; }
.sheet { position: relative; }
@media (min-width: 720px) {
  .scrim { align-items: center; }
  .sheet { width: min(640px, 92vw); border-radius: 26px; max-height: 88dvh; }
  .sheet.wide { width: min(940px, 94vw); }
  .sheet-head::before { display: none; }
}

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom)); z-index: 120; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toast-wrap { bottom: 26px; } }
.toast { background: #251a19; color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toast .35s cubic-bezier(.2, .8, .2, 1); max-width: 92vw; text-align: center; }
.toast.err { background: #8d1b14; }
@keyframes toast { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; margin: 0 auto 10px; opacity: .55; }
.skeleton { border-radius: 14px; background: linear-gradient(100deg, var(--line-2) 30%, var(--line) 50%, var(--line-2) 70%); background-size: 200% 100%; animation: sk 1.3s infinite; min-height: 70px; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.logo img, .logo svg.mark { height: 38px; width: auto; }
.logo .word { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: .02em; color: #5a4c49; line-height: 1; }
.logo .sub { display: block; font-family: var(--serif); font-size: 9.5px; color: var(--muted); letter-spacing: .03em; margin-top: 3px; font-weight: 400; }
@media (prefers-color-scheme: dark) { :root:not([data-tema="claro"]) .logo .word { color: #e9ddd6; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media print { .no-print { display: none !important; } body { background: #fff; } }
