/* Agenda · panel administrativo en neutros
   Tokens en OKLCH; tema claro por defecto, oscuro según el sistema. */

:root {
  color-scheme: light;
  --bg: oklch(0.982 0.002 255);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.968 0.003 255);
  --surface-3: oklch(0.944 0.004 255);
  --border: oklch(0.912 0.004 255);
  --border-strong: oklch(0.85 0.006 255);
  --text: oklch(0.235 0.012 255);
  --text-2: oklch(0.44 0.012 255);
  --text-3: oklch(0.53 0.01 255);
  --ink: oklch(0.255 0.012 255);
  --ink-hover: oklch(0.33 0.014 255);
  --on-ink: oklch(0.99 0 0);
  --accent: oklch(0.49 0.085 255);
  --accent-soft: oklch(0.95 0.02 255);
  --focus: oklch(0.6 0.13 255);

  --ok: oklch(0.47 0.09 155);
  --ok-soft: oklch(0.955 0.03 155);
  --warn: oklch(0.5 0.1 65);
  --warn-soft: oklch(0.96 0.045 85);
  --danger: oklch(0.52 0.16 25);
  --danger-soft: oklch(0.96 0.025 25);
  --muted-soft: oklch(0.95 0.004 255);

  --radius-s: 6px;
  --radius: 8px;
  --radius-l: 12px;
  --shadow-pop: 0 1px 2px oklch(0.2 0.01 255 / 0.06), 0 8px 24px -6px oklch(0.2 0.01 255 / 0.16);
  --shadow-bar: 0 -1px 0 var(--border), 0 -6px 20px -12px oklch(0.2 0.01 255 / 0.2);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.75rem;
  --fs-s: 0.8125rem;
  --fs: 0.9375rem;
  --fs-m: 1.0625rem;
  --fs-l: 1.25rem;
  --fs-xl: 1.5rem;
  --sidebar: 236px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: oklch(0.185 0.006 255);
    --surface: oklch(0.215 0.007 255);
    --surface-2: oklch(0.2 0.006 255);
    --surface-3: oklch(0.26 0.008 255);
    --border: oklch(0.3 0.008 255);
    --border-strong: oklch(0.38 0.01 255);
    --text: oklch(0.94 0.004 255);
    --text-2: oklch(0.76 0.008 255);
    --text-3: oklch(0.68 0.008 255);
    --ink: oklch(0.93 0.004 255);
    --ink-hover: oklch(0.86 0.006 255);
    --on-ink: oklch(0.2 0.006 255);
    --accent: oklch(0.76 0.09 255);
    --accent-soft: oklch(0.28 0.03 255);
    --focus: oklch(0.72 0.12 255);
    --ok: oklch(0.78 0.11 155);
    --ok-soft: oklch(0.27 0.035 155);
    --warn: oklch(0.82 0.11 80);
    --warn-soft: oklch(0.29 0.04 75);
    --danger: oklch(0.74 0.14 25);
    --danger-soft: oklch(0.29 0.045 25);
    --muted-soft: oklch(0.27 0.006 255);
    --shadow-pop: 0 1px 2px oklch(0 0 0 / 0.3), 0 10px 28px -6px oklch(0 0 0 / 0.55);
    --shadow-bar: 0 -1px 0 var(--border);
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
::selection { background: color-mix(in oklch, var(--accent) 22%, transparent); color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-m); }
h3 { font-size: var(--fs); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.i.s { width: 16px; height: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-s); }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

html { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */

.shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); font-weight: 600; font-size: var(--fs-m); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--ink); color: var(--on-ink);
  display: grid; place-items: center;
}
.brand-mark svg.i { width: 16px; height: 16px; }
.nav-group { display: grid; gap: 2px; }
.nav-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; padding: 16px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  color: var(--text-2); font-weight: 500; font-size: var(--fs);
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px oklch(0.2 0.01 255 / 0.05); }
.nav-link[aria-current="page"] svg.i { color: var(--text); }
.nav-foot { margin-top: auto; display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: var(--fs-s); color: var(--text-2); min-width: 0; }
.nav-user strong { color: var(--text); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600; flex: none; }
.nav-new { margin: 0 0 14px; }

.main { margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs-s); margin-bottom: 8px; }
.back:hover { color: var(--text); }

.tabbar { display: none; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    position: sticky; top: 0; z-index: 15; height: 52px; padding: 0 8px 0 16px;
    padding-top: env(safe-area-inset-top); box-sizing: content-box;
    background: color-mix(in oklch, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs-m); color: var(--text); overflow: hidden; white-space: nowrap; }
  .topbar-title:hover { text-decoration: none; }
  .topbar-title .brand-mark { width: 26px; height: 26px; }
  .page { padding: 18px 16px 40px; }
  .page-head { margin-bottom: 18px; align-items: flex-start; }
  .page-head h1 { font-size: var(--fs-l); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset: auto 0 0 0; z-index: 30;
    background: var(--surface); box-shadow: var(--shadow-bar);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    display: grid; justify-items: center; gap: 2px; padding: 4px 0; border-radius: var(--radius);
    color: var(--text-3); font-size: 0.6875rem; font-weight: 500;
  }
  .tab svg.i { width: 22px; height: 22px; }
  .tab:hover { text-decoration: none; color: var(--text); }
  .tab[aria-current="page"] { color: var(--text); }
  .tab-new span.plus {
    width: 44px; height: 32px; border-radius: 10px; background: var(--ink); color: var(--on-ink);
    display: grid; place-items: center; margin-bottom: 1px;
  }
  .tab-new { color: var(--text); }
}

/* ---------- Botones y formularios ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 var(--fs)/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), box-shadow 150ms var(--ease), transform 100ms var(--ease);
  box-shadow: 0 1px 1px oklch(0.2 0.01 255 / 0.04);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 35%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: oklch(0.99 0 0); }
.btn-danger-solid:hover { background: color-mix(in oklch, var(--danger) 88%, black); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-s { min-height: 32px; padding: 0 10px; font-size: var(--fs-s); border-radius: var(--radius-s); }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn[data-loading="true"] { pointer-events: none; opacity: 0.7; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-s); font-weight: 500; color: var(--text); }
.field .hint { font-size: var(--fs-s); color: var(--text-2); }
.field .error { font-size: var(--fs-s); color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.opt { color: var(--text-3); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: 400 16px/1.4 var(--font);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklch, var(--text-3) 60%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 22%, transparent); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.select {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23778' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.textarea { min-height: 88px; resize: vertical; }
.input-money { position: relative; }
.input-money::before { content: "$"; position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.input-money .input { padding-left: 24px; }
input[type="date"].input, input[type="time"].input { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="time"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-section { display: grid; gap: 16px; padding: 22px 24px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section-head h2 { font-size: var(--fs); }
.form-section-head p { color: var(--text-2); font-size: var(--fs-s); margin-top: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
@media (max-width: 640px) {
  .form-section { padding: 18px 16px; }
  .form-actions { padding: 14px 16px; position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5; }
  .form-actions .btn { flex: 1; }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-check span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; font-size: var(--fs-s); font-weight: 500;
  color: var(--text-2); background: var(--surface); transition: all 150ms var(--ease);
}
.chip-check span svg { display: none; }
.chip-check input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip-check input:checked + span svg { display: block; }
.chip-check input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }

.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: var(--radius); gap: 2px; flex-wrap: wrap; }
.seg a, .seg button {
  padding: 6px 12px; border-radius: var(--radius-s); color: var(--text-2); font: 500 var(--fs-s)/1.2 var(--font);
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
}
.seg a:hover { text-decoration: none; color: var(--text); }
.seg [aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px oklch(0.2 0.01 255 / 0.1), 0 0 0 1px var(--border); }

/* ---------- Paneles ---------- */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: var(--fs); }
.panel-head .meta { color: var(--text-2); font-size: var(--fs-s); }
.panel-body { padding: 16px 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--border); font-size: var(--fs-s); }
@media (max-width: 640px) {
  .panel-head { padding: 14px 16px; }
  .panel-body { padding: 14px 16px; }
  .panel-foot { padding: 12px 16px; }
}
.stack { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .grid-2-even { grid-template-columns: 1fr; } }

/* Franja de cifras */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); margin-bottom: 20px; }
.figure { padding: 16px 20px; display: grid; gap: 2px; color: var(--text); min-width: 0; }
.figure + .figure { border-left: 1px solid var(--border); }
a.figure:hover { background: var(--surface-2); text-decoration: none; }
.figure:first-child { border-radius: var(--radius-l) 0 0 var(--radius-l); }
.figure:last-child { border-radius: 0 var(--radius-l) var(--radius-l) 0; }
.figure .k { font-size: var(--fs-s); color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.figure .v { font-size: var(--fs-l); font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.figure .d { font-size: var(--fs-xs); color: var(--text-3); }
.figure.attn .v { color: var(--warn); }
@media (max-width: 800px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--border); }
  .figure { border-radius: 0 !important; padding: 14px 16px; }
}
.figures-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) {
  .figures-3 { grid-template-columns: 1fr 1fr; }
  .figures-3 .figure:nth-child(3) { grid-column: 1 / -1; }
}

/* ---------- Listas de eventos ---------- */

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px 20px; border-top: 1px solid var(--border); color: inherit; position: relative;
}
.rows > li:first-child > .row, .rows > .row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 640px) { .row { padding: 12px 16px; gap: 12px; grid-template-columns: 46px minmax(0, 1fr) auto; } }
.date-tile {
  display: grid; justify-items: center; align-content: center; gap: 0;
  width: 52px; height: 52px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
  line-height: 1.1;
}
@media (max-width: 640px) { .date-tile { width: 46px; height: 48px; } }
.date-tile .dw { font-size: 0.6875rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.02em; }
.date-tile .dd { font-size: 1.125rem; font-weight: 600; }
.date-tile .dm { font-size: 0.6875rem; color: var(--text-2); }
.date-tile.today { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.date-tile.today .dw, .date-tile.today .dm { color: color-mix(in oklch, var(--on-ink) 75%, transparent); }
.row-main { min-width: 0; display: grid; gap: 2px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: var(--fs-s); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta .sep { color: var(--text-3); padding: 0 4px; }
.row-end { display: grid; justify-items: end; gap: 4px; text-align: right; }
.row-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.row-amount-sub { font-size: var(--fs-xs); color: var(--text-2); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; background: var(--muted-soft); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge-pagado { background: var(--ok-soft); color: var(--ok); }
.badge-parcial { background: var(--accent-soft); color: var(--accent); }
.badge-pendiente, .badge-vencido { background: var(--warn-soft); color: var(--warn); }
.badge-vencido { background: var(--danger-soft); color: var(--danger); }
.badge-sinprecio { background: var(--muted-soft); color: var(--text-2); }
.badge-cancelado { background: var(--muted-soft); color: var(--text-3); }
.badge-plain::before { display: none; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-s); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; }

.contact { display: inline-flex; gap: 6px; }
.contact a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius); border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.contact a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.row .contact { position: relative; z-index: 2; }

/* Vacío */
.empty { padding: 36px 24px; text-align: center; display: grid; gap: 8px; justify-items: center; color: var(--text-2); }
.empty svg.i { width: 28px; height: 28px; color: var(--text-3); stroke-width: 1.5; }
.empty strong { color: var(--text); font-weight: 600; }
.empty p { max-width: 42ch; font-size: var(--fs-s); }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.t th { text-align: left; font-weight: 500; font-size: var(--fs-s); color: var(--text-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.t td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th:first-child, .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.t .r { text-align: right; }
.t tbody tr:hover { background: var(--surface-2); }
.t tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.t .strong { font-weight: 600; }
.t a.cell-link { color: var(--text); font-weight: 500; }

@media (max-width: 640px) {
  .t-stack thead { display: none; }
  .t-stack, .t-stack tbody, .t-stack tr, .t-stack td { display: block; width: 100%; }
  .t-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .t-stack tr:last-child { border-bottom: 0; }
  .t-stack td { padding: 2px 0 !important; border: 0; display: flex; justify-content: space-between; gap: 12px; }
  .t-stack td[data-l]::before { content: attr(data-l); color: var(--text-2); font-size: var(--fs-s); }
  .t-stack td.first { font-weight: 600; }
  .t-stack tfoot tr { background: var(--surface-2); }
}

/* Barras */
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 999px; opacity: 0.82; }
.bar.soft > span { background: var(--text-3); }

/* Gráfica de columnas por mes */
.cols { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 180px; padding: 8px 0 0; }
.col { display: flex; flex-direction: column; height: 100%; gap: 6px; text-align: center; min-width: 0; outline-offset: 2px; }
.col-track { position: relative; flex: 1; min-height: 0; }
.col-fill { position: absolute; bottom: 0; left: 50%; translate: -50% 0; width: min(100%, 34px); background: var(--ink); opacity: 0.82; border-radius: 4px 4px 2px 2px; height: 0; }
.col-fill.zero { background: var(--border); height: 2px !important; opacity: 1; }
.col:hover .col-fill { opacity: 1; }
.col-val { position: absolute; top: -2px; left: 0; right: 0; font-size: 0.6875rem; color: var(--text-2); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 150ms; pointer-events: none; }
.col:hover .col-val, .col:focus-within .col-val { opacity: 1; }
.col-lbl { font-size: var(--fs-xs); color: var(--text-2); }
.col.current .col-lbl { color: var(--text); font-weight: 600; }

/* ---------- Agenda (mes) ---------- */

.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav h1 { min-width: 9.5em; font-size: var(--fs-xl); }
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); overflow: hidden; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 8px 10px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-week + .cal-week .cal-day { border-top: 1px solid var(--border); }
.cal-day { min-height: 118px; padding: 6px 6px 8px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; position: relative; }
.cal-day:first-child { border-left: 0; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--text-3); }
.cal-day.weekend:not(.out) { background: color-mix(in oklch, var(--surface-2) 45%, var(--surface)); }
.cal-num-row { display: flex; align-items: center; justify-content: space-between; }
.cal-num { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: var(--fs-s); font-weight: 500; color: var(--text); }
.cal-day.today .cal-num { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.cal-add { opacity: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--radius-s); color: var(--text-2); transition: opacity 120ms; }
.cal-add:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.cal-day:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
.ev-chip {
  display: block; padding: 3px 7px; border-radius: 5px; font-size: var(--fs-xs); font-weight: 500; line-height: 1.35;
  background: var(--surface-3); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid transparent;
}
.ev-chip:hover { text-decoration: none; border-color: var(--border-strong); }
.ev-chip.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -7px; }
.ev-chip.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -7px; }
.ev-chip.st-pagado { background: var(--ok-soft); }
.ev-chip.st-parcial { background: var(--accent-soft); }
.ev-chip.st-pendiente { background: var(--warn-soft); }
.ev-chip .esp { color: var(--text-2); font-weight: 400; }
.cal-more { font-size: var(--fs-xs); color: var(--text-2); padding: 0 4px; }
.cal-dots { display: none; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); margin-top: 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-legend .l-pagado { background: var(--ok-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ok) 30%, transparent); }
.cal-legend .l-parcial { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent) 30%, transparent); }
.cal-legend .l-pendiente { background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--warn) 30%, transparent); }
.cal-legend .l-sinprecio { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.month-list { display: none; }

@media (max-width: 760px) {
  .cal-nav h1 { font-size: var(--fs-l); min-width: 0; }
  .cal-head div { padding: 6px 0; text-align: center; font-size: 0.6875rem; }
  .cal-day { min-height: 52px; padding: 4px 2px; align-items: center; gap: 2px; border-left: 0; }
  .cal-day .ev-chip, .cal-day .cal-more, .cal-add { display: none; }
  .cal-num-row { justify-content: center; }
  .cal-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; max-width: 30px; }
  .cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); }
  .cal-dots i.st-pagado { background: var(--ok); }
  .cal-dots i.st-parcial { background: var(--accent); }
  .cal-dots i.st-pendiente { background: var(--warn); }
  a.cal-day-link { position: absolute; inset: 0; }
  .cal-day.has-ev .cal-num { font-weight: 700; }
  .month-list { display: block; margin-top: 16px; }
  .cal-legend { display: none; }
}
.day-group { scroll-margin-top: 70px; }
.day-group-head { font-size: var(--fs-s); font-weight: 600; color: var(--text-2); padding: 14px 16px 6px; }

/* ---------- Detalle de evento ---------- */

.dl { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.dl dt { color: var(--text-2); font-size: var(--fs-s); padding-top: 1px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; } }
.money-box { display: grid; gap: 10px; }
.money-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.money-line .lbl { color: var(--text-2); }
.money-line.total { padding-top: 10px; border-top: 1px solid var(--border); font-size: var(--fs-m); font-weight: 600; }
.money-line.total .lbl { color: var(--text); }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 999px; }
.notes { white-space: pre-wrap; color: var(--text); font-size: var(--fs); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: auto 1fr; gap: 10px; font-size: var(--fs-s); }
.timeline li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); margin-top: 6px; }
.timeline .when { color: var(--text-3); }

details.disclosure > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .chev { transition: transform 200ms var(--ease); }
details.disclosure[open] > summary .chev { transform: rotate(180deg); }

/* ---------- Avisos ---------- */

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: var(--fs); border: 1px solid; }
.alert svg.i { margin-top: 2px; }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in oklch, var(--ok) 25%, transparent); color: var(--text); }
.alert-ok svg.i { color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 30%, transparent); color: var(--text); }
.alert-error svg.i { color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, transparent); color: var(--text); }
.alert-warn svg.i { color: var(--warn); }
.alert-info { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.alert-info svg.i { color: var(--text-2); }
.alert .alert-body { display: grid; gap: 4px; min-width: 0; }
.alert ul { margin: 0; padding-left: 18px; }
.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { animation: flash-in 300ms var(--ease) both; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Filtros ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 240px; max-width: 380px; }
.search svg.i { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 36px; }
.toolbar .select { width: auto; }
@media (max-width: 640px) { .search { max-width: none; flex-basis: 100%; } .toolbar .select { flex: 1; } }

/* ---------- Acceso ---------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 24px; }
.auth-head { display: grid; gap: 14px; justify-items: start; }
.auth-head .brand-mark { width: 36px; height: 36px; border-radius: 9px; }
.auth-head .brand-mark svg.i { width: 20px; height: 20px; }
.auth-head p { color: var(--text-2); }
.auth-form { display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 24px; box-shadow: 0 1px 2px oklch(0.2 0.01 255 / 0.04), 0 12px 32px -16px oklch(0.2 0.01 255 / 0.18); }
.auth-foot { font-size: var(--fs-s); color: var(--text-3); text-align: center; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 44px; }
.pass-toggle { position: absolute; right: 4px; top: 50%; translate: 0 -50%; }

/* ---------- Diálogos ---------- */

dialog.dlg {
  border: 1px solid var(--border); border-radius: var(--radius-l); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog.dlg::backdrop { background: oklch(0.2 0.01 255 / 0.35); backdrop-filter: blur(2px); }
dialog.dlg[open] { animation: dlg-in 220ms var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dlg-body { padding: 20px 22px; display: grid; gap: 12px; }
.dlg-body h2 { font-size: var(--fs-m); }
.dlg-body p { color: var(--text-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }

/* Hoja de pago (en línea) */
.pay-form { display: grid; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.pay-form[hidden] { display: none; }
.pay-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .pay-grid { grid-template-columns: 1fr 1fr; } .pay-form { padding: 14px 16px; } }

/* Disponibilidad */
.avail { list-style: none; margin: 0; padding: 0; }
.avail li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.avail li:first-child { border-top: 0; }
.avail .name { font-weight: 600; }
.avail .who { font-size: var(--fs-s); color: var(--text-2); }
@media (max-width: 640px) { .avail li { padding: 12px 16px; } }

/* Lista de configuración */
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text); }
.menu-list li:first-child a { border-top: 0; }
.menu-list a:hover { background: var(--surface-2); text-decoration: none; }
.menu-list .grow { flex: 1; min-width: 0; }
.menu-list .count { color: var(--text-2); font-size: var(--fs-s); }
.menu-list .chev { color: var(--text-3); }
@media (max-width: 640px) { .menu-list a { padding: 14px 16px; } }
.only-mobile { display: none; }
@media (max-width: 960px) { .only-mobile { display: block; } .only-desktop { display: none !important; } }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 180px; }

@media print {
  .sidebar, .tabbar, .topbar, .actions, .toolbar, .no-print, .flashes { display: none !important; }
  .main { margin: 0; }
  .page { padding: 0; max-width: none; }
  body { background: white; }
  .panel, .figures { border-color: #ccc; break-inside: avoid; }
}

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

button.nav-link { width: 100%; border: 0; background: transparent; font: 500 var(--fs) var(--font); cursor: pointer; text-align: left; }
.nav-user-name { min-width: 0; }

/* Filas con enlace de cobertura (permite botones de contacto dentro) */
.row-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.row-link:focus-visible { outline-offset: -2px; }
li.row:hover { background: var(--surface-2); }
.rows > li.row:first-child { border-top: 0; }
.row-end-line { display: flex; align-items: center; gap: 8px; }
.row .contact { position: relative; z-index: 2; }
.row .contact a { width: 30px; height: 30px; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.row.is-cancelled .row-title { text-decoration: line-through; text-decoration-color: var(--text-3); color: var(--text-2); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 640px) {
  .row-end-line:has(.contact) .badge { display: none; }
}
.mt { margin-top: 20px; }
.mt-s { margin-top: 12px; }
.cal-toolbar .toolbar { margin-bottom: 0; }
.day-anchor { display: block; scroll-margin-top: 70px; }
.mb { margin-bottom: 16px; }
.pt-field { padding-top: 8px; }
.form-grid-2c { display: grid; grid-template-columns: minmax(0, 1fr) 7.5em; gap: 8px; }
.avail-box { display: grid; gap: 6px; }
.avail-box .alert { font-size: var(--fs-s); }
[data-anticipo-extra][hidden], [data-responsable-tel][hidden] { display: none; }
.stack-s { display: grid; gap: 10px; }
.contact-line { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.inline-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
details.disclosure > summary.panel-head { border-bottom: 0; }
details.disclosure[open] > summary.panel-head { border-bottom: 1px solid var(--border); }
.page-head .sub .badge { vertical-align: 1px; }
.field-s { flex: 0 1 140px !important; }
.form-narrow { max-width: 760px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list > li { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; border-top: 1px solid var(--border); }
.cat-list > li:first-child { border-top: 0; }
.cat-list > li.is-archived .cat-name { color: var(--text-2); }
.cat-main { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; }
.cat-actions { display: flex; align-items: center; gap: 2px; }
.cat-edit { flex: 1; padding: 4px 8px 4px 0; }
@media (max-width: 640px) { .cat-list > li { padding: 12px 8px 12px 16px; } }

/* Menú desplegable (details) */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 270px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 4px; display: grid;
}
.menu-pop a, .menu-pop button {
  display: flex; justify-content: space-between; gap: 16px; padding: 9px 12px; border-radius: var(--radius-s);
  color: var(--text); font: 400 var(--fs) var(--font); background: none; border: 0; text-align: left; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop span { color: var(--text-3); font-size: var(--fs-xs); }
details.menu[open] > summary { background: var(--surface-2); }
@media (max-width: 640px) { .menu-pop { right: auto; left: 0; } }

.filters { justify-content: space-between; }
.filters .inline-form { align-items: center; }
.field-date { flex: 0 1 160px !important; }
.w-bar { width: 32%; }
@media (max-width: 640px) {
  .hide-s { display: none; }
  .filters .inline-form .select { flex: 1 1 100%; }
  .field-date { flex: 1 1 0 !important; }
}
.form-wide { max-width: 880px; }
