/* =====================================================================
   Nuestro Calendario · Estilos (CSS propio, sin dependencias)
   ===================================================================== */
:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f1effa;
  --line: #e7e4f3;
  --text: #1f1d36;
  --muted: #6e6a8a;
  --primary: #6d5dfc;
  --primary-2: #8b7dff;
  --primary-soft: #ece9ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(31, 29, 54, .04), 0 6px 20px rgba(31, 29, 54, .06);
  --shadow-lg: 0 20px 50px rgba(31, 29, 54, .18);
  --sidebar: 248px;
  --bottom: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14131f; --surface: #1d1c2b; --surface-2: #262538; --line: #312f47;
    --text: #ecebf7; --muted: #a29fbd; --primary-soft: #2d2852;
    --ok-soft: #12351f; --warn-soft: #3b2c0a; --danger-soft: #3d1717; --info-soft: #172a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.ic-xs { width: 13px; height: 13px; vertical-align: -2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.spacer { flex: 1; }
.txt-danger { color: var(--danger); }
.txt-ok { color: var(--ok); }
.txt-info { color: var(--info); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text); transition: transform .08s, background .15s, box-shadow .15s; min-height: 42px; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 4px 14px rgba(109, 93, 252, .3); }
.btn-success { background: var(--ok); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; position: relative; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-ok { color: var(--ok); }
.icon-danger { color: var(--danger); }
.link { font-size: 14px; font-weight: 600; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 42px; outline: none; transition: border .15s, box-shadow .15s; font-size: 16px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=color] { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; flex: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.err { color: var(--danger); font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.stack > * + * { margin-top: 2px; }
.inline-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.w-num { width: 84px !important; }
.inline-field select { width: auto; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 2px 0 14px; font-weight: 500; user-select: none; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }
.switch-sm { margin: 0; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; cursor: pointer; background: var(--surface); }
.chip-check input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.row-end { display: flex; justify-content: flex-end; }
.audit { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.alert { padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; font-size: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #e5e0ff, transparent), radial-gradient(900px 500px at 110% 110%, #ffe1ef, transparent), var(--bg); }
@media (prefers-color-scheme: dark) { .auth-body { background: var(--bg); } }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 22px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 24px; margin: 18px 0 6px; }
.auth-card .muted { margin: 0 0 18px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary); }
.auth-foot { text-align: center; margin: 18px 0 0; font-size: 14px; }
.brand-logo { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #f472b6); color: #fff; flex: none; }
.brand-logo .ic { width: 19px; height: 19px; fill: rgba(255,255,255,.25); }

/* ---------- Layout ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); padding: 4px 8px 18px; font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 500; position: relative; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.badge-count { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }
.side-user { border-top: 1px solid var(--line); padding-top: 14px; }
.side-couple { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.side-couple > div { margin-left: 6px; min-width: 0; }
.side-couple small { display: block; color: var(--muted); font-size: 12px; }
.side-couple .who + .who { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.topbar { display: none; }
.main { margin-left: var(--sidebar); padding: 28px 32px 100px; max-width: calc(1280px + var(--sidebar)); }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; border-bottom: 1px solid var(--line); }
  .brand-sm { padding: 0; }
  .topbar-title { font-size: 17px; flex: 1; margin-left: 4px; }
  .badge-dot { position: absolute; top: 3px; right: 2px; background: var(--danger); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; }
  .main { margin: 0; padding: 16px 14px calc(var(--bottom) + 90px + var(--safe-b)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); height: calc(var(--bottom) + var(--safe-b)); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); background: none; border: 0; cursor: pointer; }
  .bottom-nav .active { color: var(--primary); font-weight: 650; }
  .bottom-nav .ic { width: 22px; height: 22px; }
}

/* Hoja "Más" */
.sheet { position: fixed; inset: 0; background: rgba(20, 18, 40, .4); z-index: 60; display: flex; align-items: flex-end; }
.sheet-panel { background: var(--surface); width: 100%; border-radius: 22px 22px 0 0; padding: 14px 14px calc(18px + var(--safe-b)); animation: up .2s ease; }
.sheet-panel a, .sheet-panel button { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: 12px; color: var(--text); font-weight: 500; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; font-size: 16px; }
.sheet-panel a:hover, .sheet-panel button:hover { background: var(--surface-2); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* FAB */
.fab-wrap { position: fixed; right: 22px; bottom: 26px; z-index: 50; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fab { width: 58px; height: 58px; border-radius: 20px; border: 0; background: linear-gradient(135deg, var(--primary), #f472b6); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 26px rgba(109, 93, 252, .45); cursor: pointer; transition: transform .2s; }
.fab .ic { width: 28px; height: 28px; transition: transform .2s; }
.fab[aria-expanded=true] .ic { transform: rotate(45deg); }
.fab-menu { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; animation: up .15s ease; }
.fab-menu button { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
.fab-menu .ic { color: var(--primary); }
@media (max-width: 860px) { .fab-wrap { right: 16px; bottom: calc(var(--bottom) + 16px + var(--safe-b)); } .fab { width: 54px; height: 54px; } }

/* ---------- Componentes ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 24px; letter-spacing: -.02em; }
@media (max-width: 860px) { .page-title { font-size: 20px; } .page-head .btn-primary { display: none; } }
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { color: var(--primary); }
.card-foot { margin: 12px 0 0; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }
.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 10px; }
.big-money { font-size: 30px; font-weight: 800; margin: 4px 0; letter-spacing: -.02em; }

.hero { background: linear-gradient(135deg, var(--primary), #a78bfa 60%, #f9a8d4); color: #fff; border-radius: 22px; padding: 24px; margin-bottom: 18px; box-shadow: 0 12px 30px rgba(109, 93, 252, .25); }
.hero h2 { font-size: 26px; margin: 4px 0 6px; letter-spacing: -.02em; }
.hero .muted { color: rgba(255,255,255,.88); margin: 0; }
.hero-date { margin: 0; opacity: .85; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); color: var(--text); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat b { font-size: 24px; letter-spacing: -.02em; }
.stat .stat-money { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat-alert { box-shadow: inset 0 0 0 2px var(--danger-soft), var(--shadow); }
.stat-alert b { color: var(--danger); }
.stat-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 8px; }
.stat-ic .ic { width: 18px; height: 18px; }
.st-violet { background: var(--primary-soft); color: var(--primary); }
.st-blue { background: var(--info-soft); color: var(--info); }
.st-red { background: var(--danger-soft); color: var(--danger); }
.st-amber { background: var(--warn-soft); color: var(--warn); }
.st-green { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; } .stats-3 { grid-template-columns: repeat(3, 1fr); } .stats-3 .stat b { font-size: 18px; } .stats-3 .stat .stat-money { font-size: 14px; } .stat { padding: 12px; } .hero { padding: 20px; } .hero h2 { font-size: 22px; } }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.dash-grid .card-wide { grid-column: 1 / -1; }
@media (max-width: 960px) { .dash-grid { grid-template-columns: 1fr; } }

/* Listas de ítems */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 0; border-radius: 12px; position: relative; background: var(--surface); min-width: 0; }
.list-rows .item { border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 4px 12px 0; }
.list-rows .item:last-child { border-bottom: 0; }
.item-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c, var(--primary)); flex: none; }
.item-main { flex: 1; min-width: 0; cursor: pointer; color: var(--text); display: block; }
.item-main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main small { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.item-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.item-event { cursor: pointer; }
.item-event:hover, .item .item-main:hover b { color: var(--primary); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.type-ic { color: var(--muted); display: grid; place-items: center; flex: none; }
@media (max-width: 640px) {
  .item-bill { flex-wrap: wrap; }
  .item-bill .item-main { flex-basis: calc(100% - 140px); }
  .item-bill > .who { order: 5; margin-left: 14px; }
  .item-bill .item-actions { order: 6; flex: 1; justify-content: flex-end; }
  .item-bill .item-actions .btn { flex: 1; }
}

.pill { font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; flex: none; }
.pill-pagado, .pill-completada { background: var(--ok-soft); color: var(--ok); }
.pill-vencido { background: var(--danger-soft); color: var(--danger); }
.pill-parcial, .pill-en_curso { background: var(--warn-soft); color: var(--warn); }
.pill-pendiente { background: var(--info-soft); color: var(--info); }
.pill-prio-urgente { background: var(--danger); color: #fff; }
.pill-prio-alta { background: var(--danger-soft); color: var(--danger); }
.pill-prio-media { background: var(--warn-soft); color: var(--warn); }
.pill-prio-baja { background: var(--surface-2); color: var(--muted); }
.st-vencido .item-main small { color: var(--danger); }
.st-pagado .item-main b { color: var(--muted); }

.who { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--uc, var(--primary)); flex: none; }
.who-both { background: linear-gradient(135deg, var(--primary), #f472b6); font-size: 13px; }
.who-name { font-size: 13px; }

/* Tareas */
.check { width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: transparent; flex: none; margin-left: 4px; transition: all .15s; }
.check .ic { width: 16px; height: 16px; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.is-done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.is-done .item-main b { text-decoration: line-through; color: var(--muted); }
.is-overdue .check { border-color: var(--danger); }
.prio-urgente:not(.is-done) { box-shadow: inset 3px 0 0 var(--danger); }

/* Actividad */
.acts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.act { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.act .who { width: 26px; height: 26px; font-size: 11px; }
.act small { display: block; color: var(--muted); font-size: 12px; }
.acts-full .act { padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty .ic { width: 34px; height: 34px; color: var(--primary); opacity: .45; }
.empty p { margin: 8px 0 0; font-size: 14px; }

/* Tabs y filtros */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; border-radius: 99px; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow); }
.tabs a.active { background: var(--primary); color: #fff; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: var(--surface); padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.filters-plain { background: none; box-shadow: none; padding: 0; margin: 12px 0 0; }
.field-inline { margin: 0; min-width: 130px; }
.field-inline input, .field-inline select { min-height: 38px; padding: 7px 10px; font-size: 14px; }
.grow { flex: 1; min-width: 180px; }
@media (max-width: 640px) { .filters .field-inline { flex: 1 1 calc(50% - 10px); min-width: 0; } }
.period { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; font-size: 17px; }

/* Barras de estadísticas */
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 14px; }
.bar-row > span { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-row .who { width: 22px; height: 22px; font-size: 10px; }
.bar { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.evo { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 170px; align-items: end; }
.evo-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; color: var(--muted); font-size: 11px; }
.evo-bar { width: 100%; max-width: 34px; background: var(--primary-soft); border-radius: 8px 8px 3px 3px; transition: background .15s; }
.evo-col:hover .evo-bar, .evo-col.current .evo-bar { background: linear-gradient(180deg, var(--primary-2), var(--primary)); }
.evo-col.current { color: var(--primary); font-weight: 700; }
.evo-val { font-size: 10px; white-space: nowrap; }

/* Buscador */
.search-hero { margin-bottom: 16px; }
.search-box { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 16px; padding: 4px 16px; box-shadow: var(--shadow); }
.search-box .ic { color: var(--muted); }
.search-box input { border: 0 !important; box-shadow: none !important; font-size: 17px !important; padding-left: 0 !important; background: transparent !important; }

/* Ajustes */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.settings-grid .card-wide { grid-column: 1 / -1; }
@media (max-width: 960px) { .settings-grid { grid-template-columns: 1fr; } }
.kv { list-style: none; padding: 0; margin: 0 0 14px; }
.kv li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--muted); }
.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.cat-row input[name=name] { min-height: 38px !important; padding: 7px 10px !important; font-size: 14px !important; }
.cat-row input[type=color] { width: 38px; height: 38px; }
.cat-new { opacity: .85; }
.install-help p { font-size: 14px; margin: 8px 0; }
.pager { display: flex; justify-content: space-between; margin-top: 14px; }
.notif.is-unread .item-main b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 8px; vertical-align: 2px; }
.notif.is-read { opacity: .7; }

/* ---------- Modales ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal-sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(20, 18, 40, .45); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .18s ease; display: flex; }
dialog.modal > form, dialog.modal > .modal-inner { display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 40px); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 8px 18px 12px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.pay-what { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-weight: 600; margin: 0 0 14px; }
@media (max-width: 640px) {
  dialog.modal, dialog.modal-sm { width: 100vw; max-width: 100vw; max-height: 94vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  dialog.modal > form, dialog.modal > .modal-inner { max-height: 94vh; }
  dialog.modal[open] { animation: up .2s ease; }
  .grid-2 { gap: 0 10px; }
}
.hist-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.hist-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.hist-table td:last-child { text-align: right; }

/* Toasts */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { background: #1f1d36; color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; display: flex; align-items: center; gap: 10px; animation: pop .2s ease; }
.toast-error { background: var(--danger); }
.toast-ok { background: #1f1d36; }
.toast button { margin-left: auto; background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 9px; padding: 6px 10px; cursor: pointer; font-weight: 600; }

/* ---------- Calendario ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-title { font-size: 21px; margin-left: 8px; letter-spacing: -.01em; }
.seg { display: inline-flex; background: var(--surface); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button.active { background: var(--primary); color: #fff; }
.cal-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.cal-filters select { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.cal-search { position: relative; flex: 1; min-width: 180px; display: flex; align-items: center; }
.cal-search > .ic { position: absolute; left: 10px; color: var(--muted); width: 17px; }
.cal-search input { padding-left: 34px !important; min-height: 36px !important; font-size: 14px !important; }
.cal-search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); list-style: none; margin: 0; padding: 6px; z-index: 25; max-height: 320px; overflow-y: auto; }
.cal-search-results li { padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.cal-search-results li:hover { background: var(--surface-2); }
.cal-search-results small { display: block; color: var(--muted); }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .who { width: 20px; height: 20px; font-size: 10px; }
.cal-body { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.m-head, .m-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-head div { padding: 10px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; letter-spacing: .04em; }
.m-cell { min-height: 112px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px; cursor: pointer; position: relative; min-width: 0; transition: background .12s; }
.m-cell:nth-child(7n+1) { border-left: 0; }
.m-cell:hover { background: var(--surface-2); }
.m-cell.other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.m-cell.other .m-num { opacity: .45; }
.m-cell.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.m-num { font-size: 13px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 2px; }
.m-cell.today .m-num { background: var(--primary); color: #fff; }
.chip { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 1.2; padding: 3px 6px; border-radius: 7px; margin-bottom: 2px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: var(--text); border-left: 3px solid var(--c); overflow: hidden; white-space: nowrap; cursor: pointer; }
.chip:hover { background: color-mix(in srgb, var(--c) 30%, var(--surface)); }
.chip .t { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chip .tm { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .u { width: 8px; height: 8px; border-radius: 50%; background: var(--uc); flex: none; }
.chip.k-bill, .chip.k-task { border-left-style: dashed; }
.chip.done { opacity: .55; text-decoration: line-through; }
.chip.danger { border-left-color: var(--danger); }
.more { font-size: 11.5px; color: var(--primary); font-weight: 600; padding: 1px 6px; }
.dots { display: none; }
@media (max-width: 640px) {
  .m-cell { min-height: 58px; padding: 3px 2px; text-align: center; }
  .m-num { margin: 0 auto 2px; }
  .m-cell .chip, .m-cell .more { display: none; }
  .dots { display: flex; justify-content: center; gap: 3px; flex-wrap: wrap; }
  .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
  .cal-title { font-size: 18px; }
  .cal-filters select { flex: 1; }
}
.cal-agenda:empty { display: none; }
.cal-agenda { margin-top: 14px; background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cal-agenda h3 { font-size: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.cal-agenda h3 span::first-letter { text-transform: uppercase; }

/* Semana / día */
.w-wrap { display: flex; flex-direction: column; max-height: calc(100vh - 250px); min-height: 420px; }
.w-head, .w-allday { display: grid; grid-template-columns: 52px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.w-head div { padding: 8px 4px; text-align: center; font-size: 12px; color: var(--muted); cursor: pointer; }
.w-head b { display: block; font-size: 19px; color: var(--text); }
.w-head .today b { color: var(--primary); }
.w-allday > div { border-left: 1px solid var(--line); padding: 3px; min-height: 30px; min-width: 0; }
.w-allday > div:first-child { border-left: 0; font-size: 10.5px; color: var(--muted); display: grid; place-items: center; }
.w-scroll { overflow-y: auto; flex: 1; position: relative; }
.w-grid { display: grid; grid-template-columns: 52px repeat(var(--days), minmax(0, 1fr)); position: relative; }
.w-hours div { height: 48px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.w-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 48px); cursor: pointer; }
.w-col.today { background-color: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
.w-ev { position: absolute; left: 2px; right: 2px; border-radius: 8px; padding: 3px 6px; font-size: 12px; overflow: hidden; background: color-mix(in srgb, var(--c) 22%, var(--surface)); border-left: 3px solid var(--c); cursor: pointer; line-height: 1.25; z-index: 2; }
.w-ev:hover { z-index: 3; box-shadow: var(--shadow); }
.w-ev b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.w-ev small { color: var(--muted); }
.w-ev .u { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--uc); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.cal-title::first-letter { text-transform: uppercase; }

/* Filtros plegables en celulares */
.filters-toggle { display: none; }
@media (max-width: 640px) {
  .filters-toggle { display: inline-flex; margin-bottom: 10px; }
  .filters.collapsed { display: none; }
}
