/* Venia · estándar del sector (listón: Holded y el panel de Stripe).
   Tema claro: se usa en despachos y juzgados con luz de día y delante del cliente. */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #55657a;

  --nav: #0f172a;
  --nav-2: #1e293b;
  --nav-text: #cbd5e1;
  --nav-muted: #8090a8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-text: #1d4ed8;
  --focus: rgba(37, 99, 235, .35);

  --danger: #dc2626;
  --danger-text: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-text: #b45309;
  --warn-soft: #fffbeb;
  --ok: #16a34a;
  --ok-text: #15803d;
  --ok-soft: #f0fdf4;

  --c-cita: #2563eb;
  --c-juicio: #dc2626;
  --c-plazo: #d97706;
  --cita-soft: #e3ecfd;
  --juicio-soft: #fde8e8;
  --plazo-soft: #fdf0d9;
  --festivo-text: #be185d;
  --sel-dia: #e2e8f0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .06);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --sidebar: 248px;
  --barra-alto: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  scrollbar-color: var(--border-strong) transparent;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  caret-color: var(--primary);
}
::selection { background: #dbeafe; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--primary-text); text-decoration: none; text-underline-offset: 3px; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; margin: 0; text-wrap: balance; }
h2 { font-size: 1rem; line-height: 1.4; font-weight: 600; margin: 0; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88em; background: var(--surface-3); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: var(--text-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 22px; height: 22px; }

/* Controles: feedback al pulsar, sin destello de toque ni selección accidental */
button, a, [role="button"], label.btn, summary { touch-action: manipulation; }
button, [role="button"], .btn, .chip, .nav-link, summary { user-select: none; -webkit-user-select: none; }

/* ---------------- Estructura ---------------- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  align-items: center; gap: .25rem;
  padding: calc(.5rem + env(safe-area-inset-top, 0px)) .75rem .5rem;
  background: var(--nav); color: #fff;
}
.topbar .brand { display: flex; align-items: center; min-height: 40px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: none; border: 0; color: inherit; border-radius: var(--radius-sm); cursor: pointer;
  transition: background-color 160ms var(--ease-out), transform 100ms var(--ease-out);
}
.icon-btn:active { transform: scale(.94); background: rgba(255, 255, 255, .12); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--nav); color: var(--nav-text);
  overflow-y: auto; overscroll-behavior: contain;
  padding: env(safe-area-inset-top, 0px) .75rem calc(1rem + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-color: var(--nav-2) transparent;
}
.sidebar a.side-brand { display: flex; align-items: center; flex: none; height: var(--barra-alto); padding: 0 .75rem; margin-bottom: .35rem; border-radius: 0; background: none; }
.sidebar a.side-brand:hover, .sidebar a.side-brand:active { background: none; text-decoration: none; }
.sidebar a, .sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: var(--nav-text); padding: .5rem .75rem; border-radius: var(--radius-sm);
  font: 500 .92rem/1.3 var(--font); background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.sidebar a .ico, .sidebar .nav-link .ico { color: var(--nav-muted); transition: color 160ms var(--ease-out); }
.sidebar a.activo { background: var(--nav-2); color: #fff; }
.sidebar a.activo .ico { color: #60a5fa; }
.sidebar a:active, .sidebar .nav-link:active { background: var(--nav-2); }
.nav-sep { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--nav-muted); padding: 1.1rem .75rem .35rem; }
#backdrop { display: none; }

main {
  margin-left: var(--sidebar);
  padding: .5rem 2.25rem 4rem;
  max-width: calc(1240px + var(--sidebar));
}

@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform 240ms var(--ease-out), visibility 0s linear 240ms; }
  body.menu-abierto .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform 240ms var(--ease-out), visibility 0s; }
  #backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity 240ms var(--ease-out); }
  body.menu-abierto #backdrop { opacity: 1; pointer-events: auto; }
  main { margin-left: 0; padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------- Cabeceras y botones ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; }
.page-head h1 .ico { width: 24px; height: 24px; color: var(--muted); }
.page-head .sub { color: var(--muted); margin-top: .25rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 38px; padding: .45rem .9rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 .9rem/1.2 var(--font);
  cursor: pointer; white-space: nowrap; box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 100ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.btn .ico { width: 16px; height: 16px; }
.btn:active { transform: scale(.97); background: var(--surface-3); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .25); }
.btn.primary:active { background: var(--primary-hover); }
.btn.danger { color: var(--danger-text); }
.btn.danger:active { background: var(--danger-soft); }
.btn.small { min-height: 32px; padding: .3rem .65rem; font-size: .85rem; }
.btn.icono { width: 34px; min-height: 34px; padding: 0; }
.btn.big { flex: 1; min-height: 52px; font-size: 1rem; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; }
  .sidebar a:hover, .sidebar .nav-link:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
  .sidebar a:hover .ico { color: #93c5fd; }
  .btn:hover { background: var(--surface-2); border-color: #94a3b8; text-decoration: none; }
  .btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
  .btn.danger:hover { background: var(--danger-soft); border-color: #fca5a5; }
  .item:hover, .tl-item:hover { background: var(--surface-2); text-decoration: none; }
  .tabla tbody tr:hover { background: var(--surface-2); }
  .doc-card:hover { border-color: #93c5fd; box-shadow: var(--shadow); text-decoration: none; }
  .cal-dia:hover { border-color: #93c5fd; text-decoration: none; }
  .icon-btn:hover { background: rgba(255, 255, 255, .1); }
  .stat-link:hover { border-color: #93c5fd; text-decoration: none; }
}

/* ---------------- Superficies ---------------- */
.seccion, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.25rem;
}
.seccion + .seccion, .card + .card, .seccion + .card { margin-top: 1rem; }
.seccion-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; min-height: 32px; }
.seccion-head h2 { display: flex; align-items: center; gap: .5rem; }
.seccion-head h2 .ico { color: var(--muted); }
.seccion-head > a { font-size: .85rem; font-weight: 500; }
.cuenta { color: var(--muted); font-weight: 500; }

/* Panel: dos columnas independientes, cada una apila sus secciones sin huecos */
.panel-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.panel-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.panel-col > .seccion { margin: 0; }
@media (max-width: 1100px) { .panel-cols { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); color: var(--text); }
.stat .valor { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .etiqueta { color: var(--text-2); font-size: .85rem; font-weight: 500; margin-top: .2rem; }
.stat .contexto { color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.stat .valor.danger { color: var(--danger-text); }
/* Cifras dentro de una sección: fila plana, sin tarjetas anidadas */
.seccion .stats { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 -.25rem; }
.seccion .stat { flex: 1 1 150px; border: 0; border-radius: 0; background: none; box-shadow: none; padding: .5rem 1.25rem .75rem 0; }
.seccion .stat .valor { font-size: 1.3rem; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .8rem .9rem; }
  .stat .valor { font-size: 1.25rem; }
}

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-3); color: #475569; white-space: nowrap; line-height: 1.5; font-variant-numeric: tabular-nums; }
.badge.ok { background: var(--ok-soft); color: var(--ok-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge.info { background: var(--primary-soft); color: var(--primary-text); }

/* Listas de elementos (panel, fichas, agenda) */
.items { display: flex; flex-direction: column; margin: 0 -.5rem; }
.item {
  display: grid; grid-template-columns: 7.75rem minmax(0, 1fr) auto; gap: .2rem .9rem; align-items: center;
  padding: .65rem .5rem; border-top: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  transition: background-color 160ms var(--ease-out);
}
.item:first-child { border-top-color: transparent; }
.item-fecha { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.item-texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.item-sub { color: var(--muted); font-size: .84rem; font-weight: 400; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.vencido .item-fecha { color: var(--danger-text); font-weight: 600; }
.item.hoy .item-fecha, .item.pronto .item-fecha { color: var(--warn-text); font-weight: 600; }
.item.hecho .item-texto { text-decoration: line-through; color: var(--muted); }
.item.saliendo { overflow: hidden; opacity: 0; transform: translateX(12px); padding-block: 0; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), height 220ms var(--ease-out), padding 220ms var(--ease-out); }
.vacio { color: var(--muted); padding: .6rem 0; font-size: .92rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: .45rem; vertical-align: 1px; flex: none; }
.dot.cita { background: var(--c-cita); } .dot.juicio { background: var(--c-juicio); } .dot.plazo { background: var(--c-plazo); }
@media (max-width: 600px) {
  .item { grid-template-columns: minmax(0, 1fr) auto; }
  .item-fecha { grid-column: 1 / -1; }
}

/* Tablas de listados */
.toolbar { display: flex; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.buscador { position: relative; flex: 1; min-width: 220px; }
.buscador .ico { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.buscador input { padding-left: 2.4rem; }
.toolbar select { width: auto; min-width: 180px; }
.tabla-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabla td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr { cursor: pointer; transition: background-color 120ms var(--ease-out); }
.tabla tbody tr:active { background: var(--surface-3); }
.tabla td:first-child { font-weight: 500; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recorte { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 40ch; }
@media (max-width: 720px) {
  .tabla-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tabla thead { display: none; }
  .tabla, .tabla tbody, .tabla tr, .tabla td { display: block; width: 100%; }
  .tabla tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding: .7rem 1rem; box-shadow: var(--shadow); }
  .tabla td { border: 0; padding: .12rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; font-size: .9rem; }
  .tabla td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  .tabla td:first-child { font-weight: 600; font-size: 1rem; text-align: left; padding-bottom: .3rem; }
  .tabla td:first-child::before, .tabla td[data-label=""]::before { display: none; }
  .tabla td:empty { display: none; }
}

/* Formularios */
form.formulario { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.campo { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.campo.full { grid-column: 1 / -1; }
.campo label { font-weight: 600; font-size: .86rem; color: var(--text-2); }
.campo small { font-size: .8rem; color: var(--muted); }
.form-acciones { grid-column: 1 / -1; display: flex; gap: .5rem; justify-content: flex-end; padding-top: .5rem; flex-wrap: wrap; }
input, select, textarea {
  font: 15px/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .55rem .75rem; width: 100%; min-height: 40px;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
input::placeholder, textarea::placeholder { color: #64748b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
textarea { resize: vertical; min-height: 88px; }
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='%2355657a' 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 .65rem center; padding-right: 2.2rem; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); margin: 0; flex: none; }
input[type=date], input[type=datetime-local], input[type=time] { font-variant-numeric: tabular-nums; }
.con-unidad { position: relative; }
.con-unidad input { padding-right: 2rem; }
.con-unidad span { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; font-size: .92rem; color: var(--text); cursor: pointer; min-height: 40px; }
.solo-lectura { padding: .55rem 0; }
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }
@media (max-width: 640px) {
  form.formulario { grid-template-columns: 1fr; }
  .form-acciones {
    position: sticky; bottom: 0; z-index: 5; margin: 0 -1.25rem -1.1rem;
    padding: .75rem 1.25rem calc(.75rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  }
  .form-acciones .btn { flex: 1; min-height: 46px; }
}

/* Ficha */
.ficha { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.ficha div { min-width: 0; }
.ficha dt { color: var(--muted); font-size: .8rem; font-weight: 500; margin-bottom: .1rem; }
.ficha dd { margin: 0; overflow-wrap: anywhere; }
.ficha .full { grid-column: 1 / -1; }

/* Conceptos de factura */
.lineas { display: flex; flex-direction: column; gap: .4rem; }
.linea, .linea-head { display: grid; grid-template-columns: minmax(0, 1fr) 6rem 8rem 5.5rem 2.5rem; gap: .5rem; align-items: center; }
.linea-head { font-size: .78rem; color: var(--muted); font-weight: 600; padding: 0 .1rem; }
.linea { border-radius: var(--radius-sm); transition: background-color 160ms var(--ease-out); }
.linea.es-suplido { background: var(--warn-soft); box-shadow: 0 0 0 4px var(--warn-soft); }
.l-sup { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; font-size: .85rem; font-weight: 500; cursor: pointer; }
.solo-movil { display: none; }
.lineas-acciones { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
@media (max-width: 640px) {
  .linea-head { display: none; }
  .linea { grid-template-columns: 1fr 1fr; padding: .7rem; border: 1px solid var(--border); }
  .linea.es-suplido { box-shadow: none; }
  .linea .l-concepto { grid-column: 1 / -1; }
  .solo-movil { display: inline; }
}
.totales { margin-left: auto; width: min(100%, 340px); margin-top: 1rem; font-variant-numeric: tabular-nums; }
.totales div { display: flex; justify-content: space-between; padding: .25rem 0; color: var(--text-2); }
.totales .fuerte { font-weight: 650; color: var(--text); border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .25rem; font-size: 1.02rem; }

/* Documentos */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.doc-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); background: var(--surface); display: flex; flex-direction: column; transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 100ms var(--ease-out); }
.doc-card:active { transform: scale(.98); }
.doc-thumb { aspect-ratio: 4 / 3; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-ext { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-weight: 700; color: var(--muted); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.doc-ext .ico { width: 28px; height: 28px; stroke-width: 1.5; }
.doc-info { padding: .55rem .7rem .65rem; }
.doc-nombre { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .2rem; align-items: center; }
.subida { display: flex; gap: .75rem; flex-wrap: wrap; grid-column: 1 / -1; }
.subida .btn { cursor: pointer; }
.preview { grid-column: 1 / -1; display: flex; flex-direction: column; gap: .5rem; }
.preview img { max-width: 100%; max-height: 50vh; border-radius: var(--radius-sm); border: 1px solid var(--border); align-self: flex-start; }
.visor { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.visor-img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.generar { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.generar summary { cursor: pointer; font-weight: 600; padding: .7rem .9rem; display: flex; align-items: center; gap: .5rem; list-style: none; }
.generar summary::-webkit-details-marker { display: none; }
.generar summary .ico:last-child { margin-left: auto; color: var(--muted); transition: transform 200ms var(--ease-out); }
.generar[open] summary .ico:last-child { transform: rotate(90deg); }
.generar .cuerpo { padding: 0 .9rem .9rem; }
.generar .fila { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.generar .fila select { flex: 1; min-width: 180px; }

/* Historial de contactos */
.timeline { display: flex; flex-direction: column; margin: 0 -.5rem; }
.tl-item { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: .75rem; padding: .7rem .5rem; border-top: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); }
.tl-item:first-child { border-top-color: transparent; }
.tl-icon { width: 2.25rem; height: 2.25rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; }
.tl-icon .ico { width: 16px; height: 16px; }
.tl-meta { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-texto { white-space: pre-line; overflow-wrap: anywhere; }

/* Agenda */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.cal-head h2 { font-size: 1.15rem; min-width: 10.5rem; text-align: center; }
.calendario { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding-bottom: .2rem; }
.cal-dia { min-height: 104px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .35rem; color: var(--text); display: flex; flex-direction: column; gap: 3px; overflow: hidden; user-select: none; -webkit-user-select: none; transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out); }
.cal-dia.fuera { background: transparent; border-style: dashed; }
/* Día seleccionado: toda la celda sombreada (gris neutro para no confundirse con el azul de las citas) */
.cal-dia.sel { background: var(--sel-dia); border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.cal-top { display: flex; align-items: center; gap: .3rem; min-width: 0; }
.cal-num { font-size: .82rem; font-weight: 600; width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 999px; font-variant-numeric: tabular-nums; flex: none; }
.cal-dia.hoy .cal-num { background: var(--primary); color: #fff; }
.cal-dia.es-festivo .cal-num { color: var(--festivo-text); }
.cal-dia.hoy.es-festivo .cal-num { color: #fff; }
.cal-festivo { font-size: .66rem; font-weight: 500; color: var(--festivo-text); line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Cada tipo con su color: barra a la izquierda + fondo suave */
.chip { font-size: .72rem; font-weight: 600; padding: 2px 6px 2px 5px; border-radius: 4px; border-left: 3px solid; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.chip.cita { background: var(--cita-soft); color: var(--primary-text); border-left-color: var(--c-cita); }
.chip.juicio { background: var(--juicio-soft); color: var(--danger-text); border-left-color: var(--c-juicio); }
.chip.plazo { background: var(--plazo-soft); color: var(--warn-text); border-left-color: var(--c-plazo); }
.chip.hecho { opacity: .55; text-decoration: line-through; }
.mas { font-size: .72rem; color: var(--muted); padding-left: 6px; }
.puntos { display: none; gap: 3px; justify-content: center; flex-wrap: wrap; }
.punto { width: 6px; height: 6px; border-radius: 999px; }
.punto.cita { background: var(--c-cita); } .punto.juicio { background: var(--c-juicio); } .punto.plazo { background: var(--c-plazo); }
.leyenda { display: flex; gap: .5rem 1.1rem; font-size: .82rem; color: var(--muted); margin: 0 0 .75rem; flex-wrap: wrap; align-items: center; }
.leyenda span { display: inline-flex; align-items: center; }
.marca-festivo { width: 10px; height: 3px; border-radius: 2px; background: var(--festivo-text); margin-right: .45rem; }
.leyenda-pista { margin-left: auto; }
.item.tipo-cita { box-shadow: inset 3px 0 0 var(--c-cita); }
.item.tipo-juicio { box-shadow: inset 3px 0 0 var(--c-juicio); }
.item.tipo-plazo { box-shadow: inset 3px 0 0 var(--c-plazo); }
.item.tipo-externo { box-shadow: inset 3px 0 0 var(--c-externo); }
.item[class*="tipo-"] { padding-left: .8rem; }
@media (max-width: 640px) {
  .calendario { gap: 4px; }
  .cal-dia { min-height: 50px; align-items: center; padding: .3rem .1rem; }
  .chip, .mas, .cal-festivo, .leyenda .leyenda-pista { display: none; }
  .puntos { display: flex; }
}

/* Acceso */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; padding-top: calc(1.25rem + env(safe-area-inset-top, 0px)); }
.auth-card { width: min(100%, 400px); display: flex; flex-direction: column; gap: 1rem; padding: 2rem 1.75rem; }
.auth-card h1 { text-align: center; font-size: 1.35rem; }
.auth-card .intro { text-align: center; color: var(--muted); margin: -.5rem 0 .25rem; }
.auth-card .btn { width: 100%; min-height: 44px; }
.auth-logo { display: flex; justify-content: center; padding-bottom: .25rem; }
.auth-logo .logo-venia { gap: 12px; }
.auth-logo .logo-venia-simbolo { width: 44px; height: 44px; }
.auth-logo .logo-venia-nombre { height: 28px; }
.auth { position: relative; }
.auth-empresa { position: absolute; top: calc(1rem + env(safe-area-inset-top, 0px)); right: max(1.25rem, env(safe-area-inset-right, 0px)); }

/* Avisos y estados */
.cargando { padding: 3rem 1rem; color: var(--muted); text-align: center; }
.error { background: var(--danger-soft); color: var(--danger-text); padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid #fecaca; }
.aviso { background: var(--warn-soft); color: var(--warn-text); padding: .65rem .9rem; border-radius: var(--radius-sm); font-size: .9rem; border: 1px solid #fde68a; display: flex; gap: .5rem; align-items: flex-start; }
.nota { background: var(--primary-soft); color: #1e3a8a; padding: .65rem .9rem; border-radius: var(--radius-sm); font-size: .9rem; border: 1px solid #bfdbfe; margin: 0 0 1rem; display: flex; gap: .5rem; align-items: flex-start; }
.aviso .ico, .nota .ico { margin-top: 2px; }
#toasts { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--nav); color: #fff; padding: .75rem 1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .92rem; animation: entrar 220ms var(--ease-out); }
.toast.error { background: var(--danger-text); }
@keyframes entrar { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.fab { display: none; }
@media (max-width: 900px) {
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 20;
    right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    width: 56px; height: 56px; border: 0; border-radius: 16px; background: var(--primary); color: #fff; cursor: pointer;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .35), 0 2px 4px rgba(15, 23, 42, .12);
    transition: transform 100ms var(--ease-out);
  }
  .fab .ico { width: 24px; height: 24px; transition: transform 200ms var(--ease-out); }
  .fab:active { transform: scale(.94); }
  .fab[aria-expanded="true"] .ico { transform: rotate(45deg); }
  .page-head .ocultar-movil { display: none; }
  /* Menú de creación del botón flotante (panel) */
  .crear-menu {
    position: fixed; z-index: 21; right: 1rem; bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: .35rem; min-width: 200px; display: flex; flex-direction: column;
    transform-origin: bottom right; transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
  }
  .crear-menu[hidden] { display: flex; opacity: 0; transform: scale(.94) translateY(6px); pointer-events: none; visibility: hidden; }
  .crear-menu a { display: flex; align-items: center; gap: .7rem; padding: .75rem .8rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
  .crear-menu a .ico { color: var(--primary); }
  .crear-menu a:active { background: var(--surface-3); }
}
@media (min-width: 901px) { .crear-menu { display: none !important; } }

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

/* ---------------- Factura imprimible ---------------- */
.barra-imp { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.factura-doc {
  position: relative; background: #fff; color: #0f172a; max-width: 820px;
  padding: 2.75rem; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 14px; overflow: hidden; font-variant-numeric: tabular-nums;
}
.factura-doc table { width: 100%; border-collapse: collapse; }
.fd-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; flex-wrap: wrap; }
.fd-emisor { line-height: 1.6; color: #334155; }
.fd-emisor strong { font-size: 1.15rem; color: #0f172a; }
.fd-titulo h1 { font-size: 1.5rem; letter-spacing: .12em; color: #0f172a; margin-bottom: .5rem; text-align: right; font-weight: 700; }
.fd-titulo td { padding: 2px 0 2px 1rem; text-align: right; }
.fd-titulo td:first-child { color: #55657a; }
.fd-cliente { background: #f8fafc; border: 1px solid #e2e8f0; padding: .9rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; line-height: 1.6; }
.fd-cliente h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #55657a; margin-bottom: .2rem; }
.fd-lineas th { text-align: left; border-bottom: 2px solid #0f172a; padding: .45rem .3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #334155; }
.fd-lineas td { padding: .5rem .3rem; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.fd-lineas .num { text-align: right; white-space: nowrap; }
.fd-sub { font-size: .88rem; color: #334155; margin: 1.4rem 0 .3rem; font-weight: 600; }
.fd-totales { width: min(100%, 330px) !important; margin: 1.25rem 0 0 auto; }
.fd-totales td { padding: .28rem .3rem; }
.fd-totales td:last-child { text-align: right; white-space: nowrap; }
.fd-totales .fuerte td { font-weight: 700; border-top: 2px solid #0f172a; padding-top: .5rem; }
.fd-pie { margin-top: 2rem; font-size: .88rem; color: #334155; }
.marca-agua { position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 6rem; font-weight: 800; color: rgba(185, 28, 28, .1); pointer-events: none; white-space: nowrap; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .topbar, .sidebar, #backdrop, .no-print, .fab, #toasts { display: none !important; }
  main { margin: 0; padding: 0; max-width: none; }
  .factura-doc { border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
}

/* ---------------- Ficha del cliente: DNI, pestañas y vista por asuntos ---------------- */
.dni { color: var(--text-2); font-variant-numeric: tabular-nums; }
.dni strong { font-weight: 600; letter-spacing: .02em; }
.aviso-dni { flex-wrap: wrap; align-items: center; margin: 0 0 1rem; }
.aviso-dni label { flex: 1 1 260px; }
.aviso-dni .fila { display: flex; gap: .5rem; flex: 1 1 260px; }
.aviso-dni input { min-height: 34px; padding: .35rem .6rem; text-transform: uppercase; background: var(--surface); }

.pestanas { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: -.25rem 0 1rem; overflow-x: auto; scrollbar-width: none; }
.pestanas a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .9rem; margin-bottom: -1px;
  color: var(--muted); font-weight: 600; font-size: .92rem; white-space: nowrap;
  border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.pestanas a[aria-selected="true"] { color: var(--text); background: var(--surface); border-color: var(--border); }
.pestanas a[aria-selected="true"] .ico { color: var(--primary); }
.pestanas .cuenta { font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .pestanas a:hover { color: var(--text); text-decoration: none; } }

.asuntos-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.asunto { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.asunto + .asunto { margin-top: .75rem; }
.asunto > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem;
  padding: .9rem 1.25rem; flex-wrap: wrap; border-radius: var(--radius);
  transition: background-color 160ms var(--ease-out);
}
.asunto > summary::-webkit-details-marker { display: none; }
.asunto-titulo { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1 1 280px; }
.asunto-titulo > .ico { color: var(--muted); }
.asunto-titulo strong { font-weight: 650; margin-right: .35rem; font-variant-numeric: tabular-nums; }
.asunto-meta { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.asunto-meta > .ico { transition: transform 200ms var(--ease-out); }
.asunto[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.asunto[open] > summary .asunto-meta > .ico { transform: rotate(90deg); }
.sin-asunto .asunto-titulo span span, .sin-asunto .asunto-titulo > span { color: var(--text-2); }
.asunto-cuerpo { padding: .25rem 1.25rem 1.1rem; }
.asunto-cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .9rem 0; flex-wrap: wrap; }
.asunto-cabecera .ficha { flex: 1 1 420px; }
/* Dentro de un asunto, las secciones son bloques planos separados por una línea (sin tarjetas anidadas) */
.asunto .seccion { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: .9rem 0 .5rem; margin: 0; }
.anadir-rapido { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: .9rem; }
@media (hover: hover) and (pointer: fine) { .asunto > summary:hover { background: var(--surface-2); } }
@media (max-width: 640px) {
  .asunto > summary, .asunto-cuerpo { padding-left: 1rem; padding-right: 1rem; }
  .asunto-meta { width: 100%; justify-content: flex-start; padding-left: 1.75rem; }
  .asunto-meta > .ico { margin-left: auto; }
}

/* Diálogo de confirmación (borrar cliente) */
.dialogo {
  width: min(92vw, 460px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface);
}
.dialogo::backdrop { background: rgba(15, 23, 42, .45); }
.dialogo[open] { animation: entrar 200ms var(--ease-out); }
.dialogo form { padding: 1.4rem 1.5rem 1.25rem; display: flex; flex-direction: column; gap: .85rem; }
.dialogo h2 { display: flex; align-items: center; gap: .55rem; font-size: 1.1rem; }
.dialogo h2 .ico { color: var(--danger-text); }
.dialogo p { margin: 0; }
.lista-borrado { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lista-borrado li { display: flex; justify-content: space-between; padding: .45rem .8rem; font-size: .92rem; }
.lista-borrado li + li { border-top: 1px solid var(--border); }
.lista-borrado strong { font-variant-numeric: tabular-nums; }
.dialogo-acciones { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .25rem; flex-wrap: wrap; }
.btn.peligro { background: var(--danger-text); border-color: var(--danger-text); color: #fff; }
.btn.peligro:active { background: #991b1b; }
@media (hover: hover) and (pointer: fine) { .btn.peligro:hover { background: #991b1b; border-color: #991b1b; } }

/* ---------------- Calendario externo: Outlook o Google (citas importadas, solo lectura) ---------------- */
:root { --c-externo: #0f766e; --externo-soft: #f0fdfa; --externo-text: #115e59; }
.chip.externo, .badge.externo { background: var(--externo-soft); color: var(--externo-text); }
.chip.externo { border-left-color: var(--c-externo); }
.dot.externo, .punto.externo { background: var(--c-externo); }
.nota.ok { background: var(--ok-soft); color: var(--ok-text); border-color: #bbf7d0; }
.ayuda ol { margin: 0 0 .6rem; padding-left: 1.2rem; line-height: 1.6; }
.ayuda summary .ico:first-child { color: var(--muted); }
.cal-sync { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .85rem; flex-wrap: wrap; justify-content: flex-end; }
.cal-sync-error { color: var(--danger-text); font-weight: 500; }
.girando .ico { animation: girar 900ms linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .cal-sync { margin-left: 0; width: 100%; justify-content: space-between; flex-wrap: nowrap; }
  .cal-sync .solo-ancho { display: none; }
}

/* Selector «Conectar tu calendario» (agenda y perfil) */
.panel-conectar { margin-bottom: 1rem; }
.panel-conectar:not([hidden]) { animation: entrar 200ms var(--ease-out); }
.conector { display: flex; flex-direction: column; gap: .9rem; }
.proveedores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.proveedor {
  display: flex; align-items: center; gap: .8rem; min-height: 64px; padding: .8rem 1rem; text-align: left;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 100ms var(--ease-out);
}
.proveedor:active { transform: scale(.98); }
.proveedor[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--primary-soft); }
.prov-icono { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out); }
.proveedor[aria-checked="true"] .prov-icono { background: var(--primary); color: #fff; }
.prov-texto { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.prov-texto small { color: var(--muted); font-size: .82rem; }
.prov-marca { color: var(--primary); opacity: 0; transition: opacity 160ms var(--ease-out); }
.proveedor[aria-checked="true"] .prov-marca { opacity: 1; }
.prov-pasos { border-top: 1px solid var(--border); padding-top: .9rem; }
.prov-pasos ol { margin: 0 0 .6rem; padding-left: 1.25rem; line-height: 1.65; }
.prov-pasos li + li { margin-top: .15rem; }
.cal-acciones { margin-bottom: .75rem; }
@media (hover: hover) and (pointer: fine) { .proveedor:hover { border-color: #93c5fd; } }
@media (max-width: 640px) { .proveedores { grid-template-columns: 1fr; } }
/* «Conectar tu calendario»: en el violeta de los calendarios externos para que destaque */
.btn.btn-calendario { background: var(--c-externo); border-color: var(--c-externo); color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.btn.btn-calendario:active, .btn.btn-calendario[aria-expanded="true"] { background: var(--externo-text); border-color: var(--externo-text); }
@media (hover: hover) and (pointer: fine) { .btn.btn-calendario:hover { background: var(--externo-text); border-color: var(--externo-text); } }

/* Cifras del panel como enlaces a su información */
a.stat-link { display: block; position: relative; color: var(--text); text-decoration: none; transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 100ms var(--ease-out); }
a.stat-link:active { transform: scale(.98); }
.stat-ir { position: absolute; top: .8rem; right: .8rem; color: var(--muted); opacity: .55; transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out), color 160ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  a.stat-link:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); text-decoration: none; }
  a.stat-link:hover .stat-ir { opacity: 1; color: var(--primary); transform: translateX(2px); }
}

/* ---------------- Marca: Venia (programa) y PRISM4 (empresa) ---------------- */
.logo-venia { display: inline-flex; align-items: center; gap: 10px; }
.logo-venia-simbolo { width: 30px; height: 30px; flex: none; }
.logo-venia-nombre { height: 19px; width: auto; flex: none; }
.topbar .logo-venia-simbolo { width: 28px; height: 28px; }
.topbar .logo-venia-nombre { height: 17px; }
.logo-prism4 { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.logo-prism4 img:first-child { height: 30px; width: auto; }
.logo-prism4 img:last-child { height: 11.5px; width: auto; }
.topbar .logo-prism4 { margin-left: auto; gap: 6px; opacity: .92; }
.topbar .logo-prism4 img:first-child { height: 24px; }
.topbar .logo-prism4 img:last-child { height: 9.5px; }
/* Escritorio: barra fija arriba con PRISM4 y el usuario, a la misma altura que el logo de Venia */
.barra-superior {
  position: sticky; top: 0; z-index: 25;
  margin-left: var(--sidebar); height: var(--barra-alto);
  padding: 0 2.25rem; display: flex; justify-content: flex-end; align-items: center; gap: 1.1rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
@media (max-width: 900px) { .barra-superior { display: none; } }
@media print { .barra-superior { display: none !important; } }
.solo-lector { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav-links { display: contents; }
.panel-cols.una { grid-template-columns: 1fr; }

/* Configuración: apartados visibles */
.apartados { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 2rem; }
.grupo-apartados h3 { font-size: .95rem; margin: 0 0 .15rem; }
.grupo-apartados > p { margin: 0 0 .5rem; font-size: .82rem; color: var(--muted); }
.interruptor { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--border); cursor: pointer; }
.interruptor .ico { color: var(--muted); }
.interruptor .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.interruptor .txt small { font-size: .78rem; color: var(--muted); }
.interruptor input {
  appearance: none; -webkit-appearance: none; width: 40px; height: 24px; min-height: 0; padding: 0; margin: 0; border: 0;
  border-radius: 999px; background: var(--border-strong); position: relative; flex: none; cursor: pointer;
  transition: background-color 160ms var(--ease-out);
}
.interruptor input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .25); transition: transform 160ms var(--ease-out); }
.interruptor input:checked { background: var(--primary); }
.interruptor input:checked::after { transform: translateX(16px); }
.interruptor input:disabled { opacity: .45; cursor: default; }
.interruptor.bloqueado { cursor: default; }
.fijos { font-size: .82rem; color: var(--muted); margin: .5rem 0 0; }
@media (max-width: 760px) { .apartados { grid-template-columns: 1fr; } }

/* ---------------- Ventana del día (doble clic en la agenda) ---------------- */
.dia-modal {
  width: min(70vw, 1100px); height: 70vh; max-width: none; max-height: none; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 4px 12px rgba(15, 23, 42, .08);
  overscroll-behavior: contain;
}
.dia-modal[open] { display: flex; flex-direction: column; animation: entrar 200ms var(--ease-out); }
/* Lo de fuera queda difuminado */
.dia-modal::backdrop { background: rgba(15, 23, 42, .28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dia-cab { display: flex; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.4rem .9rem; border-bottom: 1px solid var(--border); }
.dia-titulo { flex: 1; min-width: 0; }
.dia-titulo h2 { font-size: 1.2rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.dia-titulo p { margin: .15rem 0 0; font-size: .88rem; }
.dia-nav { display: flex; gap: .35rem; flex: none; }
.dia-festivos { display: flex; flex-wrap: wrap; gap: .4rem; padding: .75rem 1.4rem 0; }
#agendaDia .dia-festivos { padding: 0 0 .6rem; }
.festivo-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--festivo-text); background: #fdf2f8; border: 1px solid #fbcfe8; border-radius: 999px; padding: .15rem .65rem .15rem .5rem; }
.festivo-badge small { font-weight: 500; color: var(--muted); }
.dia-cuerpo { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1.4rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem 1.25rem; align-content: start; }
.dia-cuerpo > .vacio { grid-column: 1 / -1; text-align: center; padding: 3rem 0; }
.dia-grupo h3 { display: flex; align-items: center; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 0 0 .5rem; }
.dia-grupo h3 .cuenta { margin-left: .4rem; color: var(--muted); font-weight: 500; }
.dia-items { display: flex; flex-direction: column; gap: .45rem; }
.dia-item { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: .75rem; align-items: baseline; padding: .6rem .8rem .6rem .7rem; border-radius: var(--radius-sm); border-left: 4px solid; color: var(--text); transition: filter 140ms var(--ease-out); }
.dia-item.cita { background: var(--cita-soft); border-left-color: var(--c-cita); }
.dia-item.juicio { background: var(--juicio-soft); border-left-color: var(--c-juicio); }
.dia-item.plazo { background: var(--plazo-soft); border-left-color: var(--c-plazo); }
.dia-item.externo { background: var(--externo-soft); border-left-color: var(--c-externo); }
.dia-item.hecho { opacity: .6; }
.dia-item.hecho strong { text-decoration: line-through; }
.dia-item:active { filter: brightness(.96); }
.dia-hora { font-size: .85rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.dia-texto { min-width: 0; }
.dia-texto strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.dia-texto small { display: block; color: var(--muted); font-size: .84rem; margin-top: .1rem; overflow-wrap: anywhere; }
.dia-pie { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding: .85rem 1.4rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
@media (hover: hover) and (pointer: fine) {
  .dia-item:hover { filter: brightness(.97); text-decoration: none; }
}
@media (max-width: 900px) {
  .dia-modal { width: calc(100vw - 24px); height: 85dvh; }
  .dia-cab, .dia-cuerpo, .dia-pie { padding-left: 1rem; padding-right: 1rem; }
  .dia-festivos { padding-left: 1rem; padding-right: 1rem; }
  .dia-pie { padding-bottom: calc(.85rem + env(safe-area-inset-bottom, 0px)); }
}

/* Configuración → festivos locales */
.festivos-locales { display: flex; flex-direction: column; gap: .5rem; }
.festivos-locales:empty { display: none; }
.fila-local { display: grid; grid-template-columns: 11rem minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
@media (max-width: 600px) { .fila-local { grid-template-columns: minmax(0, 1fr) auto; } .fila-local input[type="text"] { grid-column: 1; grid-row: 2; } .fila-local [data-quitar] { grid-row: 1 / 3; grid-column: 2; } }

/* ---------------- Configuración: apartados plegables ---------------- */
.config-lista { display: flex; flex-direction: column; gap: .6rem; }
.plegable { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: 1rem; }
.plegable > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1.25rem; border-radius: var(--radius); transition: background-color 160ms var(--ease-out);
}
.plegable > summary::-webkit-details-marker { display: none; }
.plegable > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.plegable-icono { width: 2.1rem; height: 2.1rem; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--text-2); }
.plegable-titulo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plegable-titulo strong { font-weight: 600; font-size: 1rem; }
.plegable-titulo small { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plegable-flecha { color: var(--muted); transition: transform 200ms var(--ease-out); }
.plegable[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.plegable[open] > summary .plegable-flecha { transform: rotate(90deg); }
.plegable-cuerpo { padding: 1rem 1.25rem 1.2rem; }
.plegable-cuerpo > :first-child { margin-top: 0; }
.plegable[open] .plegable-cuerpo { animation: desplegar 180ms var(--ease-out); }
@keyframes desplegar { from { opacity: 0; transform: translateY(-4px); } }
@media (hover: hover) and (pointer: fine) { .plegable > summary:hover { background: var(--surface-2); } }
@media (max-width: 640px) { .plegable > summary, .plegable-cuerpo { padding-left: 1rem; padding-right: 1rem; } }

/* ---------------- Usuario (arriba a la derecha) ---------------- */
.tema-oscuro-solo { display: none; }
:root[data-theme="dark"] .tema-oscuro-solo { display: contents; }
:root[data-theme="dark"] .tema-claro-solo { display: none; }
.tema-claro-solo { display: contents; }
.avatar { width: 32px; height: 32px; border-radius: 999px; flex: none; object-fit: cover; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 600; font-size: .8rem; letter-spacing: .02em; }
.avatar.grande { width: 44px; height: 44px; font-size: 1rem; }
.avatar.enorme { width: 96px; height: 96px; font-size: 2rem; }
.zona-usuario { display: contents; }
.usuario-btn {
  display: inline-flex; align-items: center; gap: .55rem; height: 42px; padding: 0 .55rem 0 .3rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: 600 .9rem/1 var(--font); cursor: pointer; max-width: 260px;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 100ms var(--ease-out);
}
.usuario-btn:active { transform: scale(.97); }
.usuario-btn[aria-expanded="true"] { border-color: var(--primary); }
.usuario-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-flecha { color: var(--muted); transition: transform 200ms var(--ease-out); }
.usuario-btn[aria-expanded="true"] .usuario-flecha { transform: rotate(180deg); }
.topbar .usuario-btn { background: transparent; border-color: transparent; color: #fff; height: 40px; padding: 0 .2rem; margin-left: .35rem; }
.topbar .usuario-nombre, .topbar .usuario-flecha { display: none; }
@media (hover: hover) and (pointer: fine) {
  .usuario-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
  .topbar .usuario-btn:hover { background: rgba(255, 255, 255, .1); }
  .usuario-item:hover { background: var(--surface-3); text-decoration: none; }
  .seg-opcion:hover { color: var(--text); }
}

.usuario-menu {
  position: fixed; z-index: 60; width: min(340px, calc(100vw - 16px));
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .4rem; transform-origin: top right;
  max-height: calc(100dvh - 90px); overflow-y: auto; overscroll-behavior: contain;
}
.usuario-menu:not([hidden]) { animation: menu-entra 160ms var(--ease-out); }
@keyframes menu-entra { from { opacity: 0; transform: scale(.97) translateY(-4px); } }
.usuario-cab { display: flex; align-items: center; gap: .75rem; padding: .65rem .65rem .8rem; }
.usuario-cab div { min-width: 0; display: flex; flex-direction: column; }
.usuario-cab strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-cab small { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-grupo { border-top: 1px solid var(--border); padding: .35rem 0; display: flex; flex-direction: column; gap: 1px; }
.usuario-grupo:last-child { padding-bottom: 0; }
.usuario-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem .65rem; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: 500 .92rem/1.3 var(--font); text-align: left; cursor: pointer;
  transition: background-color 140ms var(--ease-out);
}
.usuario-item .ico { color: var(--muted); }
.usuario-item:active { background: var(--surface-3); }
.usuario-item.peligro, .usuario-item.peligro .ico { color: var(--danger-text); }
.usuario-fila { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem .65rem; font-size: .92rem; font-weight: 500; }
.usuario-fila > span { display: inline-flex; align-items: center; gap: .65rem; }
.usuario-fila > span .ico { color: var(--muted); }
.segmentado { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border); }
.seg-opcion {
  border: 0; background: none; color: var(--muted); font: 600 .8rem/1 var(--font); padding: .42rem .6rem; border-radius: 7px; cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.seg-opcion[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

/* Diálogo «Foto y nombre» */
.dialogo h2.dlg-neutro .ico { color: var(--muted); }
.foto-perfil { display: flex; align-items: center; gap: 1.1rem; }
.foto-acciones { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.foto-acciones small { font-size: .8rem; }

/* ---------------- Tema oscuro (Configuración del usuario: claro, oscuro o el del sistema) ---------------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #121a2c;
  --surface-2: #172238;
  --surface-3: #1d2a44;
  --border: #26344f;
  --border-strong: #3a4b6e;
  --text: #e6ebf4;
  --text-2: #c2ccdc;
  --muted: #95a3b9;

  --nav: #080d19;
  --nav-2: #1a2540;

  --primary-soft: rgba(59, 130, 246, .15);
  --primary-text: #93c5fd;
  --focus: rgba(96, 165, 250, .45);
  --danger-text: #fca5a5;
  --danger-soft: rgba(239, 68, 68, .14);
  --warn-text: #fcd34d;
  --warn-soft: rgba(245, 158, 11, .13);
  --ok-text: #86efac;
  --ok-soft: rgba(34, 197, 94, .13);

  --c-cita: #60a5fa;
  --c-juicio: #f87171;
  --c-plazo: #fbbf24;
  --c-externo: #2dd4bf;
  --cita-soft: rgba(96, 165, 250, .15);
  --juicio-soft: rgba(248, 113, 113, .14);
  --plazo-soft: rgba(251, 191, 36, .13);
  --externo-soft: rgba(45, 212, 191, .14);
  --externo-text: #5eead4;
  --festivo-text: #f9a8d4;
  --sel-dia: #22304f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
}
:root[data-theme="dark"] ::selection { background: rgba(59, 130, 246, .4); }
:root[data-theme="dark"] .badge { color: var(--text-2); }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: #7686a0; }
:root[data-theme="dark"] .error { border-color: rgba(248, 113, 113, .35); }
:root[data-theme="dark"] .aviso { border-color: rgba(251, 191, 36, .3); }
:root[data-theme="dark"] .nota { color: var(--primary-text); border-color: rgba(96, 165, 250, .3); }
:root[data-theme="dark"] .nota.ok { color: var(--ok-text); border-color: rgba(74, 222, 128, .3); }
:root[data-theme="dark"] .festivo-badge { background: rgba(244, 114, 182, .12); border-color: rgba(244, 114, 182, .3); }
:root[data-theme="dark"] .seg-opcion[aria-pressed="true"] { background: var(--border-strong); box-shadow: none; }
:root[data-theme="dark"] .btn { box-shadow: none; }
:root[data-theme="dark"] .toast { background: #26344f; }
:root[data-theme="dark"] .dia-modal::backdrop, :root[data-theme="dark"] .dialogo::backdrop { background: rgba(2, 6, 16, .55); }
:root[data-theme="dark"] select { 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='%2395a3b9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
/* La factura es papel: se queda blanca también en oscuro */
:root[data-theme="dark"] .factura-doc { box-shadow: 0 0 0 1px var(--border); }
:root[data-theme="dark"] .btn.btn-calendario { background: #0f766e; border-color: #0f766e; color: #fff; }
@media (hover: hover) and (pointer: fine) { :root[data-theme="dark"] .btn.btn-calendario:hover { background: #115e59; border-color: #115e59; } }

/* ---------------- Crear en la agenda: cada tipo con su color (el mismo que en el calendario) ---------------- */
.btn.tipo-plazo, .btn.tipo-juicio, .btn.tipo-cita { color: #fff; border-color: transparent; }
.btn.tipo-plazo { background: #b45309; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.btn.tipo-juicio { background: #dc2626; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.btn.tipo-cita { background: #2563eb; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.btn.tipo-plazo:active { background: #92400e; }
.btn.tipo-juicio:active { background: #b91c1c; }
.btn.tipo-cita:active { background: #1d4ed8; }
@media (hover: hover) and (pointer: fine) {
  .btn.tipo-plazo:hover { background: #92400e; border-color: transparent; }
  .btn.tipo-juicio:hover { background: #b91c1c; border-color: transparent; }
  .btn.tipo-cita:hover { background: #1d4ed8; border-color: transparent; }
}

/* ---------------- Selector de archivo ---------------- */
.etiqueta-campo { font-weight: 600; font-size: .86rem; color: var(--text-2); }
.subida {
  position: relative; display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  cursor: pointer; transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.subida-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.subida:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.subida.arrastrando { border-color: var(--primary); background: var(--primary-soft); }
.subida-icono { width: 2.5rem; height: 2.5rem; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-text); }
.subida-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.subida-texto strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subida-texto small { font-size: .82rem; }
.subida-cambiar { font-size: .85rem; font-weight: 600; color: var(--primary-text); }
.subida.con-archivo { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.subida.con-archivo .subida-icono { background: var(--ok); color: #fff; }
@media (hover: hover) and (pointer: fine) { .subida:hover { border-color: var(--primary); } }

/* Calendario: cada registro con fondo de su color y letra blanca (los mismos colores que los botones de crear) */
.chip { border-left: 0; padding: 2px 6px; color: #fff; }
.chip.plazo { background: #b45309; color: #fff; }
.chip.juicio { background: #dc2626; color: #fff; }
.chip.cita { background: #2563eb; color: #fff; }
.chip.externo { background: #0f766e; color: #fff; }
.chip.hecho { opacity: .5; }
:root[data-theme="dark"] .fab { box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }

/* ---------------- Listados: filtros por columna ---------------- */
.tabla th:has(.th-btn) { padding: 0; }
.th-btn {
  display: inline-flex; align-items: center; gap: .35rem; width: 100%; padding: .7rem 1rem;
  border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-align: left; cursor: pointer;
  transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.tabla th.num .th-btn { justify-content: flex-end; }
.th-icono { color: var(--border-strong); transition: color 140ms var(--ease-out); }
.th-orden { color: var(--primary-text); }
.th-btn.activo, .th-btn[aria-expanded="true"] { color: var(--primary-text); }
.th-btn.activo .th-icono { color: var(--primary-text); }
.th-btn:active { background: var(--surface-3); }
@media (hover: hover) and (pointer: fine) {
  .th-btn:hover { color: var(--text); background: var(--surface-3); }
  .th-btn:hover .th-icono { color: var(--muted); }
  .chip-filtro:hover { border-color: var(--border-strong); }
  .fc-opcion:hover { background: var(--surface-3); }
  .fc-orden-btn:hover { background: var(--surface-3); }
}
.tabla tr.sin-filas { cursor: default; }
.tabla tr.sin-filas td { color: var(--muted); text-align: center; padding: 1.5rem 1rem; font-weight: 400; }

/* En el móvil (tarjetas, sin cabecera) los filtros son una fila de botones */
.filtros-movil { display: none; }
.chip-filtro {
  display: inline-flex; align-items: center; gap: .3rem; flex: none; height: 34px; padding: 0 .75rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font: 600 .84rem/1 var(--font); cursor: pointer;
}
.chip-filtro .th-icono { color: var(--muted); }
.chip-filtro.activo { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.chip-filtro.activo .th-icono { color: var(--primary-text); }
@media (max-width: 720px) {
  .filtros-movil { display: flex; gap: .4rem; overflow-x: auto; margin: -.25rem -1rem .8rem; padding: .25rem 1rem; scrollbar-width: none; overscroll-behavior-x: contain; }
  .filtros-movil::-webkit-scrollbar { display: none; }
  .tabla tr.sin-filas { background: none; border: 0; box-shadow: none; }
}

.filtro-col {
  position: fixed; z-index: 55; width: 280px; max-width: calc(100vw - 16px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .55rem; display: flex; flex-direction: column; gap: .45rem;
  font-size: .9rem; text-transform: none; letter-spacing: normal;
}
.filtro-col:not([hidden]) { animation: menu-entra 140ms var(--ease-out); }
.filtro-col[hidden] { display: none; }
.fc-cab { padding: .2rem .35rem 0; }
.fc-cab strong { font-weight: 600; }
.fc-orden { display: flex; flex-direction: column; gap: 1px; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.fc-orden-btn {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .45rem; border: 0; border-radius: 7px;
  background: none; color: var(--text); font: 500 .88rem/1.2 var(--font); text-align: left; cursor: pointer;
}
.fc-orden-btn .ico { color: var(--muted); }
.fc-orden-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-text); }
.fc-orden-btn[aria-pressed="true"] .ico { color: var(--primary-text); }
.fc-cuerpo { display: flex; flex-direction: column; gap: .45rem; }
.fc-cuerpo input[type=search], .fc-cuerpo input[type=date], .fc-cuerpo input[type=number] { min-height: 36px; padding-top: .4rem; padding-bottom: .4rem; }
.fc-buscar { min-width: 0; }
.fc-botones { display: flex; gap: .4rem; }
.fc-botones .btn { flex: 1; }
.fc-lista { max-height: 260px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1px; }
.fc-opcion { display: flex; align-items: center; gap: .55rem; padding: .4rem .45rem; border-radius: 7px; cursor: pointer; }
.fc-opcion span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-opcion small { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.fc-opcion[hidden] { display: none; }
.fc-rango { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.fc-rango label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.fc-pie { border-top: 1px solid var(--border); padding-top: .45rem; display: flex; justify-content: flex-end; }

/* Un botón con el atributo hidden no se ve (la clase .btn le daba display propio) */
.btn[hidden] { display: none; }
.fc-rango label { min-width: 0; }
.fc-rango input { min-width: 0; width: 100%; padding-left: .5rem; padding-right: .35rem; font-size: .85rem; }
.filtro-col:has(.fc-rango) { width: 300px; }

/* Cabecera: nombre (abre el filtro) + flechas arriba/abajo para ordenar */
.th-celda { display: flex; align-items: center; gap: .15rem; padding-right: .5rem; }
.th-celda .th-btn { width: auto; flex: 1; min-width: 0; padding-right: .25rem; }
.tabla th.num .th-celda .th-btn { justify-content: flex-end; }
.th-flechas { display: flex; flex-direction: column; flex: none; }
.th-flecha {
  display: grid; place-items: center; width: 20px; height: 15px; padding: 0; border: 0; border-radius: 4px;
  background: none; color: var(--border-strong); cursor: pointer; transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.th-flecha .ico { width: 14px; height: 14px; stroke-width: 2.5; }
.th-flecha[aria-pressed="true"] { color: var(--primary); }
.th-flecha:active { background: var(--surface-3); }
@media (hover: hover) and (pointer: fine) { .th-flecha:hover { color: var(--text); background: var(--surface-3); } }

/* Flechas pegadas al nombre de la columna */
.th-celda .th-btn { flex: 0 1 auto; }
.th-celda { padding-right: .9rem; }
.tabla th.num .th-celda { justify-content: flex-end; }

/* Separador entre columnas para cambiar el ancho */
.tabla th { position: relative; }
.th-resize { position: absolute; top: 0; right: -5px; z-index: 2; width: 10px; height: 100%; cursor: col-resize; touch-action: none; }
.th-resize::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; left: 4px; width: 2px; border-radius: 2px;
  background: var(--border); transition: background-color 140ms var(--ease-out), top 140ms var(--ease-out), bottom 140ms var(--ease-out);
}
.tabla th:last-child .th-resize { display: none; }
.th-resize:focus-visible { outline: none; }
.th-resize:focus-visible::after, .th-resize:active::after { background: var(--primary); top: 0; bottom: 0; }
@media (hover: hover) and (pointer: fine) { .th-resize:hover::after { background: var(--primary); top: 0; bottom: 0; } }
body.redimensionando, body.redimensionando * { cursor: col-resize !important; user-select: none; }
.tabla-wrap:has(.tabla.ajustada) { overflow-x: auto; }
.tabla.ajustada { table-layout: fixed; }
.tabla.ajustada td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla.ajustada .th-btn span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .tabla.ajustada { width: 100% !important; table-layout: auto; }
  .tabla.ajustada td { white-space: normal; }
}
.generar .g-sombrear { display: flex; align-items: flex-start; gap: .5rem; margin: 0 0 .6rem; font-size: .9rem; font-weight: 500; cursor: pointer; }
.generar .g-sombrear input { margin-top: .15rem; }
.generar .g-sombrear .muted { font-weight: 400; font-size: .84rem; }

/* Aviso de listado vacío: conserva el margen interior de la tarjeta (.vacio le quitaba el de los lados) */
.seccion.vacio { padding: 1.1rem 1.25rem; }

/* ---------------- Listados: casillas de selección y barra de acciones ---------------- */
.tabla .sel-col { width: 44px; padding: 0 0 0 1rem; cursor: pointer; }
.tabla th.sel-col { padding: .7rem 0 .7rem 1rem; }
.tabla .sel-col input { display: block; cursor: pointer; }
.tabla tbody tr.seleccionada { background: var(--primary-soft); }
.tabla tbody tr.hecho td:not(.sel-col) { color: var(--muted); text-decoration: line-through; }
.barra-sel {
  position: sticky; top: calc(var(--barra-alto) + .25rem); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap;
  margin-bottom: .75rem; padding: .5rem .6rem .5rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--primary); box-shadow: var(--shadow-lg);
}
.barra-sel:not([hidden]) { animation: menu-entra 160ms var(--ease-out); }
.barra-sel[hidden] { display: none; }
.barra-sel strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.barra-sel .btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (max-width: 900px) { .barra-sel { top: calc(56px + env(safe-area-inset-top, 0px)); } }
@media (max-width: 720px) {
  .tabla tr { position: relative; }
  .tabla td.sel-col { position: absolute; top: .55rem; right: .55rem; width: auto; padding: .35rem; display: block; }
  .tabla td.sel-col::before { display: none; }
  .tabla td.sel-col + td { padding-right: 2.5rem; }
  .tabla tbody tr.seleccionada { background: var(--primary-soft); border-color: var(--primary); }
  .barra-sel .acciones { width: 100%; }
}
.form-acciones .form-borrar { margin-right: auto; }
/* Con la casilla delante, el «título» de cada fila es la celda que va tras ella */
.tabla td.sel-col + td { font-weight: 500; }
@media (max-width: 720px) {
  .tabla td.sel-col + td { font-weight: 600; font-size: 1rem; text-align: left; padding-bottom: .3rem; }
  .tabla td.sel-col + td::before { display: none; }
}

/* Flecha «Volver» a la izquierda del título al entrar en un registro */
.titulo-volver { display: flex; align-items: flex-start; gap: .75rem; min-width: 0; }
.btn-volver {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; margin-top: -2px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05); transition: background-color 160ms var(--ease-out), transform 100ms var(--ease-out);
}
.btn-volver .ico { width: 20px; height: 20px; }
.btn-volver:active { transform: scale(.94); background: var(--surface-3); }
@media (hover: hover) and (pointer: fine) { .btn-volver:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; } }

/* Completar un plazo desde el panel: botón grande y claro */
.btn.btn-completar { min-height: 40px; padding: .45rem .9rem; gap: .4rem; font-size: .9rem; border-color: var(--ok); color: var(--ok-text); background: var(--ok-soft); }
.btn.btn-completar .ico { width: 18px; height: 18px; stroke-width: 2.5; }
.btn.btn-completar:active { background: var(--ok); color: #fff; }
@media (hover: hover) and (pointer: fine) { .btn.btn-completar:hover { background: var(--ok); border-color: var(--ok); color: #fff; } }

/* «Hecho» dentro de la tabla de plazos: mismo botón que en el panel, sin estirar la fila */
.tabla .btn.btn-completar { min-height: 34px; padding: .3rem .75rem; }
.barra-sel .btn.btn-completar { min-height: 32px; padding: .3rem .75rem; font-size: .85rem; }

/* Plazo: el estado se cambia con su botón dentro del formulario */
.campo-hecho > div { display: flex; }
.campo-hecho .btn-completar { min-height: 40px; }
.hecho-fila { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-height: 40px; }

/* Clientes: «Mostrar solo activos» junto al título, en verde para que se distinga */
.titulo-lista { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; }
.solo-activos {
  display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .8rem .4rem .6rem; border-radius: 999px;
  background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok-text);
  font-size: .88rem; font-weight: 600; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.solo-activos input { width: 17px; height: 17px; accent-color: var(--ok); cursor: pointer; }
.solo-activos:has(input:not(:checked)) { background: var(--surface); border-color: var(--border-strong); color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .solo-activos:hover { border-color: var(--ok); } }

/* ---------------- Usuarios e invitaciones ---------------- */
.invitar { display: flex; gap: .5rem; flex-wrap: wrap; }
.invitar input { flex: 1; min-width: 220px; }
.invitacion-lista { margin: .9rem 0 0; }
.invitacion-lista > div { display: flex; flex-direction: column; gap: .35rem; min-width: 0; flex: 1; }
.enlace-copiar { display: flex; gap: .4rem; }
.enlace-copiar input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; min-height: 34px; padding: .3rem .6rem; }
.tabla tr.inactiva td { color: var(--muted); }
.interruptor-mini input {
  appearance: none; -webkit-appearance: none; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 999px;
  background: var(--border-strong); cursor: pointer; transition: background-color 160ms var(--ease-out);
}
.interruptor-mini input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .25); transition: transform 160ms var(--ease-out); }
.interruptor-mini input:checked { background: var(--primary); }
.interruptor-mini input:checked::after { transform: translateX(16px); }
.interruptor-mini input:disabled { opacity: .5; cursor: not-allowed; }
