/* ==========================================================
   Gestor de Casos · Azul marino, dorado y blanco
   ========================================================== */
:root {
  --navy: #0d1b36;
  --navy-2: #15264a;
  --navy-3: #22375f;
  --gold: #c5a059;
  --gold-2: #b08a43;
  --gold-soft: #f6efdf;
  --white: #ffffff;
  --bg: #f7f7f5;
  --line: #e8e6e0;
  --line-2: #f0eee9;
  --text: #16213a;
  --muted: #6b7489;
  --faint: #9aa1b1;
  --ok: #2f8f6b;
  --ok-soft: #e7f4ee;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --err: #c0392b;
  --err-soft: #fbeae8;
  --info: #2c5aa0;
  --info-soft: #e8eef8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(13, 27, 54, .04), 0 4px 16px rgba(13, 27, 54, .04);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif; /* títulos de página y cifras */
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bottom-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }
svg.ic { display: inline-block; vertical-align: middle; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; background: var(--line-2); padding: 2px 6px; border-radius: 5px; word-break: break-all; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; overflow-x: clip; } /* red de seguridad: nunca desplazamiento lateral */
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--navy);
  color: #c9cfdc;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 22px 16px;
  z-index: 60;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 26px; font-weight: 700;
  color: var(--navy); background: linear-gradient(135deg, #e3c887, var(--gold) 55%, var(--gold-2));
}
.brand-logo { width: 40px; height: 50px; object-fit: contain; border-radius: 3px; flex-shrink: 0; background: #fff; display: block; }
.auth-logo { width: 220px; max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.35); position: relative; }
.auth-logo-sm { width: 120px; height: auto; border-radius: 6px; display: block; margin-bottom: 28px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 19px; color: #fff; font-weight: 600; }
.brand-text small { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-weight: 500; color: #b4bccd;
  transition: background .15s, color .15s;
  position: relative;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: rgba(197,160,89,.12); color: #fff; }
.nav a.active::before {
  content: ''; position: absolute; left: -16px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--gold);
}
.nav a.active .ic { color: var(--gold); }

.sidebar-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid rgba(255,255,255,.07); padding-top: 14px; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--radius-sm); min-width: 0; }
.me:hover, .me.active { background: rgba(255,255,255,.05); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong { color: #fff; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--faint); font-size: 11.5px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  background: var(--navy-3); color: var(--gold); border: 1px solid rgba(197,160,89,.35);
}
.avatar-lg { width: 56px; height: 56px; font-size: 18px; background: var(--navy); border-color: var(--gold); }
.avatar-xl { width: 96px; height: 96px; font-size: 30px; background: var(--navy); border: 2px solid var(--gold); }
.avatar-md { width: 40px; height: 40px; }
.avatar-xs { width: 20px; height: 20px; font-size: 8.5px; border-width: 1px; display: inline-grid; vertical-align: -5px; margin-right: 6px; }
img.avatar { object-fit: cover; padding: 0; background: var(--line-2); }
.topbar-avatar { border-radius: 50%; flex-shrink: 0; }
.foto-body { display: flex; align-items: center; gap: 22px; }
.foto-acciones { flex: 1; min-width: 0; }
.avatar-gold { background: var(--gold-soft); color: var(--gold-2); border: 0; }
.logout { padding: 8px; border-radius: 8px; color: var(--faint); }
.logout:hover { color: #fff; background: rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 32px;
  background: rgba(247,247,245,.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1; max-width: 520px;
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px; color: var(--faint);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(197,160,89,.12); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; padding: 10px 0; font: inherit; color: var(--text); }
.topbar-new { margin-left: auto; }
.topbar-brand, .topbar-avatar { display: none; }
.content { padding: 28px 32px 60px; max-width: 1320px; width: 100%; }
.backdrop { display: none; }
.bottom-nav { display: none; }

/* ---------- Encabezados de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--gold); }
.page-title { font-family: var(--display); font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.15; letter-spacing: -.025em; text-wrap: balance; }
.page-sub { color: var(--muted); margin: 6px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  font: 500 13.5px/1 var(--sans);
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn .ic { width: 16px; height: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); }
.btn-gold { background: var(--gold); color: var(--navy); font-weight: 600; }
.btn-gold:hover { background: #d0ad68; box-shadow: 0 4px 14px rgba(197,160,89,.35); }
.btn-ghost { background: var(--white); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); color: var(--navy); }
.btn-danger { background: transparent; color: var(--err); border-color: #f0cdc8; }
.btn-danger:hover { background: var(--err-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-2); color: var(--navy); }
.icon-btn.danger:hover { background: var(--err-soft); color: var(--err); }
.icon-btn.copied { background: var(--ok-soft); color: var(--ok); }
.icon-btn .ic { width: 16px; height: 16px; }

.segmented { display: inline-flex; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: 13px; color: var(--muted); }
.segmented a .ic { width: 15px; height: 15px; }
.segmented a.active { background: var(--navy); color: #fff; }

/* ---------- Tarjetas ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 15px; font-weight: 600; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.card-head h2 .ic { color: var(--gold); }
.card-head a.link { font-size: 13px; color: var(--gold-2); font-weight: 500; white-space: nowrap; }
.card-head a.link:hover { color: var(--navy); }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid > *, .stack > *, .kpis > *, .main, .tab-panel { min-width: 0; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { padding: 20px 22px; position: relative; overflow: hidden; display: block; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(13,27,54,.08); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label .ic { color: var(--gold); width: 20px; height: 20px; }
.kpi-value { font-family: var(--display); font-size: 36px; font-weight: 700; color: var(--navy); line-height: 1; margin-top: 14px; letter-spacing: -.03em; font-variant-numeric: lining-nums tabular-nums; }
.kpi-value.kpi-money { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.kpi-foot { font-size: 12px; color: var(--faint); margin-top: 8px; }
.kpi.dark { background: var(--navy); border-color: var(--navy); }
.kpi.dark .kpi-value { color: #fff; }
.kpi.dark .kpi-label, .kpi.dark .kpi-foot { color: #9aa6c0; }
.kpi.dark::after {
  content: '§'; position: absolute; right: -6px; bottom: -34px;
  font-family: var(--serif); font-size: 140px; color: rgba(197,160,89,.12); line-height: 1;
}

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 12px 22px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fbfaf7; }
.t-main { font-weight: 600; color: var(--navy); }
.t-sub { font-size: 12.5px; color: var(--muted); }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--gold-2); font-weight: 600; }
.row-link { cursor: pointer; }
.t-right { text-align: right; }

/* Listas simples (reemplazan tablas en tarjetas) */
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line-2); transition: background .12s; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #fbfaf7; }
.list-main { flex: 1; min-width: 0; }
.list-main .t-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row { display: block; margin-bottom: 14px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .progress { margin-top: 6px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.st-abierto { background: var(--info-soft); color: var(--info); }
.st-en_tramite { background: var(--gold-soft); color: var(--gold-2); }
.st-suspendido { background: var(--warn-soft); color: var(--warn); }
.st-cerrado { background: var(--ok-soft); color: var(--ok); }
.st-archivado { background: #eef0f3; color: var(--muted); }
/* Etapas del proceso */
.st-etapa_preliminar, .st-etapa_preparatoria, .st-antejuicio, .st-termino_probatorio { background: var(--info-soft); color: var(--info); }
/* Audiencias y juicio */
.st-audiencia_preliminar, .st-audiencia_complementaria, .st-juicio, .st-incidentes_excepciones { background: var(--gold-soft); color: var(--gold-2); }
.st-sentencia { background: var(--navy); color: var(--gold); }
/* Recursos */
.st-apelacion_incidental, .st-apelacion_restringida, .st-apelacion_devolutiva, .st-apelacion_suspensiva,
.st-apelacion_diferida, .st-casacion, .st-revision { background: #efe9f7; color: #5b3a8c; }
.st-ejecucion_sentencia { background: var(--ok-soft); color: var(--ok); }
.st-fase_escrita { background: var(--info-soft); color: var(--info); }
.st-resolucion, .st-auto_definitivo { background: #e3e8f3; color: var(--navy); }

/* ---------- Materias (color por materia) ---------- */
.mat {
  --c: #8a93a6; --t: #fff;
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px 3px 9px; border-radius: 999px; border: 1px solid var(--c);
  background: var(--c); color: var(--t);
  font-size: 11.5px; font-weight: 600; line-height: 1.35; white-space: nowrap; vertical-align: middle;
}
.mat i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; flex-shrink: 0; }
.mat-penal          { --c: #d32f2f; }
.mat-civil          { --c: #1f5fd1; }
.mat-laboral        { --c: #f4c20d; --t: #3d3000; }
.mat-familiar, .mat-familia { --c: #ec6fa7; }
.mat-constitucional { --c: #1b5e36; }
.mat-tributario     { --c: #45bfea; --t: #06324a; }
.mat-administrativo { --c: #16161a; }
.mat-agrario        { --c: #8bc540; --t: #1f3a05; }
.mat-comercial      { --c: #f07f13; }
.mat-notarial       { --c: #ffffff; --t: var(--navy); border-color: #c9cdd6; }
.mat-otro           { --c: #8a93a6; }
.case-hero .mat { box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
.case-hero .meta span:has(> .mat) { gap: 8px; }

/* ---------- Aplicación instalable ---------- */
.install-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 10px 0 14px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px dashed rgba(197,160,89,.55); background: rgba(197,160,89,.08); color: var(--gold);
  font: 600 13px var(--sans); text-align: left;
}
.install-btn:hover { background: rgba(197,160,89,.16); color: #fff; }
.install-btn[hidden] { display: none; }
.install-login {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 14px;
  padding: 11px; border: 1px dashed var(--line); border-radius: 999px; background: none; cursor: pointer;
  color: var(--gold-2); font: 600 13px var(--sans);
}
.install-login:hover { border-color: var(--gold); background: var(--gold-soft); }
.install-login .ic { width: 16px; height: 16px; }
.app-body { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.app-body img { border-radius: 16px; box-shadow: 0 6px 18px rgba(13,27,54,.18); flex-shrink: 0; }
.app-texto { flex: 1; min-width: 200px; }
.app-texto strong { color: var(--navy); font-size: 15px; }
.app-texto .ic { width: 15px; height: 15px; vertical-align: -3px; }
dialog.sm-modal { width: min(460px, calc(100vw - 32px)); }
.instalar-app { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.instalar-app img { border-radius: 16px; box-shadow: 0 6px 18px rgba(13,27,54,.18); }
.instalar-app strong { display: block; color: var(--navy); }
.instalar-app small { color: var(--muted); font-size: 12.5px; }
.instalar-paso h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--navy); font-size: 14px; }
.instalar-paso h4 .ic { color: var(--gold); }
.instalar-paso ol { margin: 0; padding-left: 20px; }
.instalar-paso li { margin-bottom: 8px; line-height: 1.5; }
.kbd { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); vertical-align: middle; font-weight: 700; }
.kbd .ic { width: 14px; height: 14px; }

/* Abierta como app instalada: sin barra del navegador */
@media (display-mode: standalone) {
  .install-btn, .install-login { display: none !important; }
  body { overscroll-behavior-y: none; }
}

/* ---------- Honorarios por conceptos ---------- */
.subtitulo { font-size: 15px; font-weight: 600; color: var(--navy); display: flex; align-items: center; gap: 8px; margin: 0; }
.subtitulo .ic { color: var(--gold); }
.concepto { overflow: hidden; }
.concepto.is-pendiente { border-style: dashed; border-color: #d9c48f; background: #fffdf7; }
.concepto.is-pagado .concepto-monto small { color: var(--ok); font-weight: 600; }
.concepto-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px 10px; }
.concepto-info { min-width: 0; }
.concepto-info strong { display: block; color: var(--navy); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.concepto-info .t-sub { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.concepto-monto { text-align: right; flex-shrink: 0; }
.concepto-monto b { display: block; font-family: var(--display); font-size: 19px; font-weight: 700; color: var(--navy); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.concepto-monto b.gold { color: var(--gold-2); font-size: 15px; }
.concepto-monto small { font-size: 12px; color: var(--muted); }
.concepto-avance { display: flex; align-items: center; gap: 10px; padding: 0 18px 12px; }
.concepto-avance .progress { flex: 1; }
.concepto-pagos { border-top: 1px solid var(--line-2); background: #fcfbf8; }
.concepto-pagos .list-row { padding: 8px 12px 8px 18px; }
.concepto-pagos .list-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.concepto-acciones { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); }
.tag-cuantia { background: var(--gold-soft); color: var(--gold-2); font-weight: 600; }
.seg-radio { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-radio label { margin: 0; flex: 1 1 180px; cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 500; font-size: 13.5px; color: var(--text); background: var(--white);
}
.seg-radio input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; }
.seg-radio input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg-radio .ic { width: 16px; height: 16px; }
.cuantia-calculo { background: var(--gold-soft); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; color: var(--navy); }
.cuantia-calculo:empty { display: none; }

/* Equipo y clientes del caso */
.equipo-grupo + .equipo-grupo { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.equipo-titulo { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
.cliente-item + .cliente-item { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); }

/* Selector múltiple (clientes / abogados / procuradores) */
.multi-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 32px; align-items: center; }
.chip-sel {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--info-soft); color: var(--navy);
  font-size: 13px; font-weight: 500; border: 1px solid #d3def1;
}
.chip-sel > span { overflow-wrap: anywhere; }
.chip-sel:first-child { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-sel:first-child::before { content: 'Principal'; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.chip-x {
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: rgba(13,27,54,.08); color: inherit; font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.chip-sel:first-child .chip-x { background: rgba(255,255,255,.15); }
.chip-x:hover { background: var(--err); color: #fff; }
.multi-vacio { font-size: 13px; color: var(--faint); }
.link-btn { background: none; border: 0; padding: 0; margin-left: 6px; color: var(--gold-2); font: 600 12px var(--sans); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link-btn .ic { width: 14px; height: 14px; }
.link-btn:hover { color: var(--navy); }

/* Selector de materia en el formulario */
.mat-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-picker .mat {
  display: inline-flex; margin: 0; /* anula .field label */
  cursor: pointer; background: var(--white); color: var(--text); border-color: var(--line);
  padding: 8px 14px 8px 11px; font-size: 13px; font-weight: 500; transition: all .12s;
}
.mat-picker .mat i { width: 11px; height: 11px; background: var(--c); opacity: 1; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.mat-picker .mat:hover { border-color: var(--c); }
.mat-picker .mat input { position: absolute; opacity: 0; pointer-events: none; }
.mat-picker .mat:has(input:checked) { background: var(--c); color: var(--t); border-color: var(--c); font-weight: 600; box-shadow: 0 2px 8px rgba(13,27,54,.18); }
.mat-picker .mat:has(input:checked) i { background: currentColor; box-shadow: none; }
.mat-picker .mat-notarial:has(input:checked) { border-color: var(--navy); }
.mat-picker .mat:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.badge { max-width: 100%; white-space: normal; text-align: center; line-height: 1.25; }
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.prio span { width: 7px; height: 7px; border-radius: 50%; }
.prio-alta span { background: var(--err); }
.prio-media span { background: var(--gold); }
.prio-baja span { background: #b9c0cc; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 3px 9px; border-radius: 6px; background: var(--line-2); color: var(--muted); font-weight: 500; white-space: nowrap; }
.tag .ic { width: 12px; height: 12px; }
.tag-private { background: var(--navy); color: var(--gold); }
.tag-audiencia { background: #e3e8f3; color: var(--navy); }
.tag-plazo { background: var(--err-soft); color: var(--err); }
.tag-reunion { background: var(--gold-soft); color: var(--gold-2); }
.role-admin { background: var(--navy); color: #fff; }
.role-abogado { background: var(--gold-soft); color: var(--gold-2); }
.role-procurador { background: var(--info-soft); color: var(--info); }
.role-cliente { background: var(--ok-soft); color: var(--ok); }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 7px; }
.field label .req { color: var(--gold-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--white); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:disabled { background: var(--bg); color: var(--muted); }
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: 0; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(197,160,89,.12); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236b7489' stroke-width='2' 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 14px center;
}
.hint { font-size: 12px; color: var(--faint); margin-top: 6px; }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line-2); }
.form-foot.rev { flex-direction: row-reverse; }
.section-label { grid-column: 1/-1; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-2); padding-top: 8px; border-top: 1px solid var(--line-2); }
.section-label:first-child { border-top: 0; padding-top: 0; }
.subform { background: #fdfcf9; border: 1px dashed #e0d7c2; border-radius: 12px; padding: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line-2); }
.filters .input { width: auto; min-width: 160px; padding: 9px 14px; }
.filters .input[type=search] { flex: 1; min-width: 200px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--white);
  font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.chip:hover { border-color: var(--gold); color: var(--navy); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip b { font-weight: 600; margin-left: 4px; opacity: .6; }

.copy-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 8px 8px 14px; margin: 10px 0; }
.copy-box code { background: none; padding: 0; flex: 1; font-size: 12px; }
.steps { padding-left: 20px; margin: 12px 0; }
.steps li { margin-bottom: 10px; }

/* ---------- Alertas ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; transition: opacity .4s; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--err-soft); color: var(--err); }

/* ---------- Detalle de caso ---------- */
.case-hero {
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 28px 30px;
  position: relative; overflow: hidden; margin-bottom: 20px;
}
.case-hero::after {
  content: '§'; position: absolute; right: 24px; top: -40px;
  font-family: var(--serif); font-size: 240px; line-height: 1; color: rgba(197,160,89,.08); pointer-events: none;
}
.case-hero .code { color: var(--gold); font-size: 12.5px; letter-spacing: .05em; }
.case-hero h1 { font-family: var(--serif); font-size: 34px; margin: 6px 0 14px; line-height: 1.1; max-width: 80%; }
.case-hero .meta { display: flex; gap: 10px 22px; flex-wrap: wrap; align-items: center; color: #aeb8cd; font-size: 13px; position: relative; z-index: 1; }
.case-hero .meta span { display: inline-flex; align-items: center; gap: 7px; }
.case-hero .meta .ic { color: var(--gold); width: 15px; height: 15px; }
.case-hero .hero-actions { position: absolute; top: 24px; right: 26px; display: flex; gap: 8px; z-index: 1; }
.case-hero .btn-ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; }
.case-hero .btn-ghost:hover { background: rgba(255,255,255,.14); border-color: var(--gold); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; padding: 12px 16px; font: 500 13.5px var(--sans); color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap;
}
.tabs button:hover { color: var(--navy); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); }
.tabs .count { font-size: 11px; background: var(--line-2); padding: 1px 7px; border-radius: 999px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; text-align: right; color: var(--navy); word-break: break-word; }

.person { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.person > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.person small { color: var(--faint); font-size: 11.5px; }
.person strong { color: var(--navy); font-weight: 600; }
.person a { color: var(--gold-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }

/* Nueva actuación */
.composer textarea { border: 0; padding: 0; min-height: 70px; box-shadow: none !important; font-size: 14.5px; }
.composer-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.composer-bar .input { width: auto; padding: 8px 12px; }
.composer-bar select.input { padding-right: 32px; }
.composer-send { margin-left: auto; }
.attach-btn { cursor: pointer; }
.attach-preview { display: flex; gap: 10px; flex-wrap: wrap; }
.attach-preview:not(:empty) { margin-top: 12px; }
.prev-item { width: 88px; display: flex; flex-direction: column; gap: 4px; }
.prev-item img, .prev-item .doc-ic { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.prev-item small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 24px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -24px; top: 8px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--gold);
}
.tl-item.is-private::before { border-color: var(--navy); background: var(--navy); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 36px; }
.tl-date { font-size: 12.5px; color: var(--muted); }
.tl-body { margin-top: 4px; white-space: pre-line; color: var(--text); word-break: break-word; }
.tl-by { font-size: 12px; color: var(--faint); margin-top: 8px; }
.tl-actions { margin-left: auto; display: inline-flex; gap: 2px; }
/* Edición de adjuntos */
.adj-list { display: flex; flex-direction: column; gap: 8px; }
.adj-edit { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fdfcf9; transition: opacity .15s; }
.adj-edit img, .adj-edit .doc-ic { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.adj-edit .adj-nombre { flex: 1; min-width: 0; font-size: 13px; color: var(--navy); font-weight: 500; overflow-wrap: anywhere; }
.adj-edit:has(input:checked) { opacity: .5; border-style: dashed; }
.adj-edit:has(input:checked) .adj-nombre { text-decoration: line-through; }
.adj-edit .check { flex-shrink: 0; color: var(--err); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.thumb:hover img { transform: scale(1.05); }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 10px; max-width: 260px; background: #fdfcf9; }
.file-chip:hover { border-color: var(--gold); }
.file-chip > span:last-child { display: flex; flex-direction: column; min-width: 0; font-size: 13px; font-weight: 500; color: var(--navy); }
.file-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip small { color: var(--faint); font-size: 11px; font-weight: 400; }
.file-chip .doc-ic { width: 34px; height: 34px; }

.progress { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); border-radius: 999px; }
.progress-lg { height: 10px; }

.money-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.money { padding: 16px 18px; }
.money small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.money b { display: block; font-family: var(--display); font-size: 21px; font-weight: 700; color: var(--navy); margin-top: 4px; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.money.ok b { color: var(--ok); }
.money.gold-b b { color: var(--gold-2); }

/* ---------- Agenda / eventos ---------- */
.event { display: flex; gap: 14px; padding: 12px 18px 12px 22px; border-bottom: 1px solid var(--line-2); align-items: center; }
.event:last-child { border-bottom: 0; }
.event-date {
  width: 50px; flex-shrink: 0; text-align: center; border-radius: 10px; padding: 6px 0;
  background: var(--gold-soft); color: var(--navy);
}
.event-date b { display: block; font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.event-date small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-2); font-weight: 600; }
.event-date.today { background: var(--navy); color: #fff; }
.event-date.today small { color: var(--gold); }
.event-date.past { background: var(--err-soft); }
.event-date.past small { color: var(--err); }
.event-info { flex: 1; min-width: 0; }
.event-info[role=button] { cursor: pointer; }
.event-info strong { display: block; color: var(--navy); font-weight: 600; }
.event-info .t-sub { display: flex; gap: 6px 12px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.event-info .t-sub span, .event-info .t-sub a { display: inline-flex; gap: 5px; align-items: center; }
.event-info .t-sub .ic { width: 13px; height: 13px; }
.event.done { opacity: .5; }
.event.done strong { text-decoration: line-through; }

/* Calendario (FullCalendar) */
.cal-body { padding: 14px 18px 18px; }
.cal-card > #calendario { padding: 18px; }
.fc {
  --fc-border-color: var(--line-2);
  --fc-button-bg-color: var(--white);
  --fc-button-border-color: var(--line);
  --fc-button-text-color: var(--navy);
  --fc-button-hover-bg-color: var(--gold-soft);
  --fc-button-hover-border-color: var(--gold);
  --fc-button-active-bg-color: var(--navy);
  --fc-button-active-border-color: var(--navy);
  --fc-today-bg-color: rgba(197,160,89,.1);
  --fc-event-bg-color: var(--navy);
  --fc-event-border-color: var(--navy);
  --fc-list-event-hover-bg-color: #fbfaf7;
  --fc-neutral-bg-color: var(--bg);
  --fc-page-bg-color: var(--white);
  font-size: 13px;
}
.fc .fc-toolbar { gap: 8px; flex-wrap: wrap; }
.fc .fc-toolbar-title { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--navy); text-transform: capitalize; }
.fc .fc-button { border-radius: 999px !important; padding: 6px 14px; font-weight: 500; font-size: 13px; text-transform: capitalize; box-shadow: none !important; }
.fc .fc-button-group { gap: 4px; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-button-primary:disabled { opacity: .45; }
.fc .fc-col-header-cell-cushion { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 8px 4px; }
.fc .fc-daygrid-day-number { font-size: 12.5px; color: var(--muted); padding: 6px 8px; }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--navy); color: #fff; border-radius: 999px; min-width: 24px; text-align: center; margin: 4px; padding: 2px 6px; }
.fc .fc-daygrid-event { border-radius: 6px; padding: 1px 4px; font-size: 11.5px; margin-top: 2px; }
.fc .fc-h-event, .fc .fc-v-event { border: 0; }
.fc .fc-daygrid-dot-event .fc-event-title { font-weight: 500; color: var(--text); }
.fc .fc-daygrid-dot-event:hover { background: var(--line-2); }
.fc-theme-standard .fc-scrollgrid { border-radius: 10px; overflow: hidden; }
.fc .fc-list { border-radius: 10px; overflow: hidden; }
.fc .fc-list-day-cushion { background: var(--bg); }
.fc .fc-list-day-text, .fc .fc-list-day-side-text { color: var(--navy); font-weight: 600; text-transform: capitalize; }
.fc .fc-daygrid-more-link { font-size: 11px; color: var(--gold-2); font-weight: 600; }
.fc-event { cursor: pointer; }
.fc .ev-audiencia { --fc-event-bg-color: var(--navy); background: var(--navy); }
.fc .ev-plazo { background: var(--err); }
.fc .ev-reunion { background: var(--gold); }
.fc .ev-reunion .fc-event-title, .fc .ev-reunion .fc-event-time { color: var(--navy); }
.fc .ev-otro { background: #7b8497; }
.fc .ev-done { opacity: .45; text-decoration: line-through; }
.fc .fc-daygrid-event-dot { border-color: var(--navy); }
.fc .ev-plazo .fc-daygrid-event-dot, .fc .ev-plazo .fc-list-event-dot { border-color: var(--err); }
.fc .ev-reunion .fc-daygrid-event-dot, .fc .ev-reunion .fc-list-event-dot { border-color: var(--gold); }
.fc .ev-otro .fc-daygrid-event-dot, .fc .ev-otro .fc-list-event-dot { border-color: #7b8497; }
.fc .ev-audiencia .fc-list-event-dot { border-color: var(--navy); }
.fc .fc-list-event { background: transparent !important; }
.fc .fc-list-event .fc-list-event-title { color: var(--text); }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-audiencia { background: var(--navy); } .dot-plazo { background: var(--err); }
.dot-reunion { background: var(--gold); } .dot-otro { background: #7b8497; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; color: var(--gold); margin-bottom: 10px; stroke-width: 1.25; }
.empty p { margin: 0 0 16px; }

/* ---------- Documentos ---------- */
.doc { display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 22px; border-bottom: 1px solid var(--line-2); }
.doc:last-child { border-bottom: 0; }
.doc-ic { width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; background: var(--gold-soft); color: var(--gold-2); display: grid; place-items: center; font-size: 10px; font-weight: 700; text-transform: uppercase; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-info { flex: 1; min-width: 0; }
.doc-info strong { display: block; font-weight: 500; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info small { color: var(--faint); font-size: 12px; }
.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-direction: column;
  border: 1.5px dashed #d9d3c4; border-radius: var(--radius-sm); padding: 26px; color: var(--muted);
  cursor: pointer; transition: all .15s; text-align: center; background: #fdfcf9;
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: var(--gold-soft); color: var(--navy); }
.dropzone .ic { color: var(--gold); width: 26px; height: 26px; }
.dropzone input { display: none; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; border-radius: 18px; padding: 0; width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow: auto;
  box-shadow: 0 30px 80px rgba(13,27,54,.3); color: var(--text);
}
dialog::backdrop { background: rgba(13,27,54,.5); backdrop-filter: blur(3px); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-head h3 { font-family: var(--serif); font-size: 24px; color: var(--navy); }
.modal-body { padding: 20px 22px; }
dialog.modal .form-foot { position: sticky; bottom: 0; background: var(--white); }

dialog.lightbox { border: 0; background: transparent; padding: 0; max-width: 96vw; max-height: 96vh; overflow: visible; text-align: center; }
dialog.lightbox img { max-width: 96vw; max-height: 82vh; border-radius: 12px; display: block; margin: 0 auto 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
dialog.lightbox > .icon-btn { position: absolute; top: -44px; right: 0; background: rgba(255,255,255,.15); color: #fff; }

/* ---------- Ayuda de roles ---------- */
.roles-help { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.roles-help div { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 12.5px; color: var(--muted); }
.roles-help b { display: block; color: var(--navy); margin-bottom: 4px; font-size: 13px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-art::before {
  content: '§'; position: absolute; right: -60px; bottom: -160px;
  font-family: var(--serif); font-size: 620px; line-height: 1; color: rgba(197,160,89,.07);
}
.auth-art .brand { border: 0; padding: 0; margin: 0; }
.auth-art blockquote { font-family: var(--serif); font-size: 40px; line-height: 1.15; margin: 0; max-width: 460px; position: relative; }
.auth-art blockquote em { color: var(--gold); font-style: normal; }
.auth-art .foot { color: #7f8aa5; font-size: 12.5px; position: relative; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--white); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-family: var(--serif); font-size: 36px; color: var(--navy); }
.auth-box p { color: var(--muted); margin: 6px 0 28px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .btn { width: 100%; padding: 14px; margin-top: 8px; }
.auth-mobile-brand { display: none; }

/* ---------- Utilidades ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 20px; }
.mt-sm { margin-top: 12px; }
.gold { color: var(--gold-2); }
.inline { display: inline; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line-2); }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 1200px) {
  .roles-help { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
  /* minmax(0,1fr): la columna nunca se ensancha por su contenido (pestañas, tablas, textos largos) */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tablet y celular ---------- */
@media (max-width: 860px) {
  body { font-size: 15px; }
  .input, select.input, textarea.input, .search input { font-size: 16px; } /* evita el zoom automático en iPhone */

  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-100%); transition: transform .25s ease; width: 280px; padding-bottom: calc(22px + var(--safe-b)); }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(13,27,54,.45); z-index: 55; }

  .topbar { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); gap: 10px; background: var(--navy); border-bottom: 0; }
  .topbar-brand, .topbar-avatar { display: grid; }
  .topbar-brand .brand-logo { width: 32px; height: 40px; }
  .topbar .search { background: rgba(255,255,255,.1); border-color: transparent; color: #aeb8cd; }
  .topbar .search input { color: #fff; }
  .topbar .search input::placeholder { color: #8f9bb5; }
  .topbar .search:focus-within { background: #fff; box-shadow: none; }
  .topbar .search:focus-within input { color: var(--text); }
  .topbar-new { display: none; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + var(--safe-b));
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border: 0; background: none; color: var(--faint);
    font: 500 10.5px var(--sans); cursor: pointer; border-radius: 10px;
  }
  .bottom-nav .ic { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav a.active .ic { color: var(--gold-2); }

  .content { padding: 20px 16px calc(var(--bottom-h) + 32px + var(--safe-b)); }
  .page-head { margin-bottom: 18px; align-items: flex-start; }
  .page-title { font-size: 25px; }
  .foto-body { flex-direction: column; text-align: center; }
  .foto-body .flex { justify-content: center; }
  .page-head > .btn, .page-head > .actions { width: 100%; }
  .page-head > .btn { justify-content: center; }
  .actions .btn, .actions .segmented { flex: 1; justify-content: center; }
  .segmented a { flex: 1; justify-content: center; }

  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .form-foot { padding: 14px 16px; }
  .filters { padding: 12px 16px; }
  .filters .input { flex: 1; min-width: 0; }
  .filters .input[type=search] { flex-basis: 100%; }
  .chips-scroll { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px; scrollbar-width: none; }
  .chips-scroll::-webkit-scrollbar { display: none; }

  .kpi { padding: 16px; }
  .kpi-value { font-size: 30px; margin-top: 10px; }
  .kpi-value.kpi-money { font-size: 19px; }

  /* Tablas convertidas en tarjetas */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line-2); position: relative; }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { padding: 3px 0; border: 0; text-align: left !important; }
  .table-cards td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; }
  .table-cards td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 12px; flex-shrink: 0; }
  .table-cards td.td-main { padding-bottom: 8px; }
  .table-cards td.td-actions { position: absolute; top: 10px; right: 8px; width: auto; }
  .table-cards .t-sub br { display: none; }

  .case-hero { padding: 20px; border-radius: 12px; margin-left: -4px; margin-right: -4px; }
  .case-hero h1 { font-size: 26px; max-width: 100%; }
  .case-hero .hero-actions { position: static; margin-bottom: 12px; }
  .case-hero .meta { font-size: 12.5px; }
  .case-hero .code { overflow-wrap: anywhere; line-height: 1.6; }
  .tabs { margin-left: -16px; margin-right: -16px; padding: 0 12px; position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); background: var(--bg); z-index: 20; }
  .tabs button { padding: 12px 10px; font-size: 13px; gap: 6px; }
  .tabs button .ic { width: 16px; height: 16px; }

  /* Actuaciones del caso */
  .composer-bar { gap: 8px; }
  .composer-bar .input { flex: 1 1 130px; min-width: 0; }
  .composer-bar .attach-btn, .composer-bar .check { flex: 1 1 auto; justify-content: center; }
  .composer-send { width: 100%; justify-content: center; padding: 12px; }
  .timeline { padding-left: 22px; }
  .timeline::before { left: 6px; }
  .tl-item::before { left: -21px; }
  .tl-head { gap: 6px; }
  .tl-body { font-size: 14.5px; }
  .attachments { gap: 6px; }
  .thumb { width: calc(33.333% - 4px); height: auto; aspect-ratio: 1; max-width: 110px; }
  .file-chip { max-width: 100%; flex: 1 1 100%; }

  /* Textos largos (NUREJ, correos, juzgados) nunca desbordan */
  .tl-body, .dl dd, .t-main, .t-sub, .case-hero h1, .person a, .person strong, .doc-info small, .event-info strong { overflow-wrap: anywhere; }
  .person a { white-space: normal; }
  .card-head { flex-wrap: wrap; }
  .card .flex { flex-wrap: wrap; }
  .form-foot { flex-wrap: wrap; }
  .table-cards td[data-label] { overflow-wrap: anywhere; }
  .table-cards td[data-label] > * { min-width: 0; text-align: right; }
  .table-cards tr:has(.td-actions) .td-main { padding-right: 84px; }

  .event { padding: 12px 10px 12px 16px; }
  .doc { padding: 12px 10px 12px 16px; }
  .list-row { padding: 14px 16px; }
  .money-grid { gap: 8px; }
  .money { padding: 12px; }
  .money b { font-size: 18px; }

  .cal-body, .cal-card > #calendario { padding: 10px; }
  .fc .fc-toolbar-title { font-size: 20px; }
  .fc .fc-toolbar.fc-header-toolbar { margin-bottom: 12px; }
  .fc .fc-button { padding: 6px 10px; font-size: 12px; }
  .fc .fc-daygrid-day-frame { min-height: 52px; }
  .fc .fc-daygrid-event .fc-event-time { display: none; }
  .fc .fc-daygrid-event { font-size: 10.5px; }

  /* Ventanas como hoja inferior */
  dialog.modal {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
    max-height: 92vh; padding-bottom: var(--safe-b);
  }
  dialog.modal[open] { animation: subir .22s ease-out; }
  .modal-head { padding: 16px; }
  .modal-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--line); }
  .modal-body { padding: 16px; }

  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { align-items: start; padding-top: 48px; }
  .auth-mobile-brand { display: block; }

  .roles-help { grid-template-columns: 1fr; }
  .dl dd { max-width: 60%; }
}

@media (max-width: 520px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
  .kpi-value.kpi-money { font-size: 17px; overflow-wrap: anywhere; }
  .money-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .money b { overflow-wrap: anywhere; }
  .doc .icon-btn { width: 32px; height: 32px; }
  .kpi.dark::after { font-size: 100px; bottom: -24px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-label .ic { width: 16px; height: 16px; }
  .hide-xs { display: none !important; }
  .page-title { font-size: 23px; }
  .money-grid { grid-template-columns: 1fr 1fr 1fr; }
  .money b { font-size: 14px; }
}

@keyframes subir { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

@media print {
  .sidebar, .topbar, .bottom-nav, .composer, .hero-actions { display: none !important; }
  .content { padding: 0; }
}

/* ================= v8 · Trámites y notificaciones ================= */
/* Estados de trámite */
.tr-pendiente  { background: var(--line-2); color: var(--muted); }
.tr-en_proceso { background: var(--info-soft); color: var(--info); }
.tr-presentado { background: var(--gold-soft); color: var(--gold-2); }
.tr-observado  { background: var(--err-soft); color: var(--err); }
.tr-concluido  { background: var(--ok-soft); color: var(--ok); }
.tr-entregado  { background: var(--navy); color: #fff; }
.tr-cancelado  { background: #eceae6; color: var(--faint); text-decoration: line-through; }
.limite { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.limite.vencido { background: var(--err-soft); color: var(--err); }
.limite.hoy     { background: var(--warn-soft); color: var(--warn); }
.limite.pronto  { background: var(--gold-soft); color: var(--gold-2); }
.chip.chip-alerta { border-color: #f1c9c4; color: var(--err); }
.chip.chip-alerta.active { background: var(--err); border-color: var(--err); color: #fff; }
.tramite-hero .code .ic { width: 14px; height: 14px; vertical-align: -2px; }

/* Campana */
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); flex-shrink: 0; margin-left: auto; transition: background .15s, color .15s; }
.topbar-new + .bell { margin-left: 0; }
.bell:hover { background: var(--white); color: var(--navy); }
.bell .ic { width: 20px; height: 20px; }
.bell.has { color: var(--navy); }
.bell b, .nav-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--gold); color: var(--navy); font: 700 10.5px/18px var(--display); text-align: center;
}
.bell b { position: absolute; top: 3px; right: 1px; box-shadow: 0 0 0 2px var(--bg); }
.nav-count { margin-left: auto; }

/* Lista de notificaciones */
.notif-list { display: flex; flex-direction: column; }
.notif { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; color: inherit; border-bottom: 1px solid var(--line-2); transition: background .15s; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--bg); }
.notif.unread { background: #fcfaf5; }
.notif-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--gold-soft); color: var(--gold-2); flex-shrink: 0; }
.notif-ic .ic { width: 18px; height: 18px; }
.notif-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-txt strong { color: var(--navy); font-weight: 600; }
.notif:not(.unread) .notif-txt strong { font-weight: 500; }
.notif-txt span { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.notif-txt small { color: var(--faint); font-size: 12px; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); flex-shrink: 0; margin-top: 6px; }

/* Preferencias de notificación (perfil) */
.notif-pref { display: flex; flex-direction: column; gap: 10px; }
.notif-pref-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); flex-wrap: wrap; }
.notif-pref-txt { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.notif-pref-txt strong { color: var(--navy); font-weight: 600; }
.notif-pref-txt small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--gold); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(197,160,89,.3); }

@media (max-width: 860px) {
  .topbar .search { min-width: 0; }
  .bell { color: #d6dcea; width: 38px; height: 38px; margin-left: 0; }
  .bell.has, .bell:hover { color: #fff; background: rgba(255,255,255,.08); }
  .bell b { box-shadow: 0 0 0 2px var(--navy); }
  .notif { padding: 14px 16px; }
  .notif-pref-row > .btn { width: 100%; justify-content: center; }
}

.tag-tramite { background: var(--info-soft); color: var(--info); font-family: var(--sans, Inter, sans-serif); font-weight: 600; font-size: 10.5px; padding: 2px 7px; margin-right: 4px; vertical-align: 1px; }
.list-row .t-sub .ic { width: 12px; height: 12px; vertical-align: -1px; }

/* ================= v10 · Honorarios del caso como estado de cuenta ================= */
.hon-resumen { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px 24px; padding: 22px 24px; align-items: center; }
.hon-saldo small, .hon-cifras small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.hon-saldo b { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 34px; font-weight: 800; color: var(--navy); letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; margin-top: 2px; }
.hon-saldo b.ok { color: var(--ok); font-size: 26px; }
.hon-saldo b.ok .ic { width: 26px; height: 26px; }
.hon-saldo b.muted-b { color: var(--faint); font-size: 18px; font-weight: 600; }
.hon-cifras { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hon-cifras > div { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 0; }
.hon-cifras span { display: block; font-family: var(--display); font-size: 17px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hon-cifras span.ok { color: var(--ok); }
.hon-barra { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.hon-barra .progress { flex: 1; }
.hon-barra > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.hon-aviso { display: flex; gap: 12px; align-items: flex-start; margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--gold-soft); border: 1px solid #ecdcb5; color: var(--text); flex-wrap: wrap; }
.hon-aviso > .ic { color: var(--gold-2); flex-shrink: 0; margin-top: 2px; }
.hon-aviso p { margin: 0; flex: 1; min-width: 200px; font-size: 14px; line-height: 1.55; }
.hon-aviso .btn { margin-left: auto; }

.hon-tabla .t-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hon-tabla th.t-right { text-align: right; }
.hon-tabla td.td-main { min-width: 150px; }
.hon-tabla th, .hon-tabla td { padding-left: 10px; padding-right: 10px; }
.hon-tabla th:first-child, .hon-tabla td:first-child { padding-left: 20px; }
.hon-tabla .hon-acc { padding-right: 14px; }
.hon-tabla .hon-acc .icon-btn { width: 30px; height: 30px; }
.hon-tabla .t-sub { white-space: normal; }
.hon-tabla tfoot td { border-top: 2px solid var(--line); background: var(--bg); color: var(--navy); }
.hon-acc { white-space: nowrap; text-align: right; }
.icon-btn.gold { color: var(--gold-2); }
.icon-btn.gold:hover { background: var(--gold-soft); }

.pg-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pg-ok { background: var(--ok-soft); color: var(--ok); }
.pg-parcial { background: var(--info-soft); color: var(--info); }
.pg-pend { background: var(--warn-soft); color: var(--warn); }
.pg-final { background: var(--line-2); color: var(--muted); }

.pago-row { gap: 14px; }
.pago-fecha { width: 48px; flex-shrink: 0; text-align: center; background: var(--bg); border-radius: 10px; padding: 6px 0; line-height: 1.1; }
.pago-fecha b { display: block; font-family: var(--display); font-size: 18px; color: var(--navy); }
.pago-fecha small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.pago-monto { font-family: var(--display); font-size: 16px; color: var(--ok); white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .hon-resumen { grid-template-columns: 1fr; padding: 18px; }
  .hon-saldo b { font-size: 30px; }
  .hon-tabla tfoot, .hon-tabla tfoot tr, .hon-tabla tfoot td { display: block; width: 100%; }
  .hon-tabla tfoot tr { padding: 12px 16px; }
  .hon-tabla tfoot td { border: 0; padding: 3px 0; background: none; }
  .hon-tabla tfoot td:empty { display: none; }
  .hon-tabla tfoot td[data-label] { display: flex; justify-content: space-between; }
  .hon-tabla tfoot td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 12px; }
  .hon-tabla tfoot tr { background: var(--bg); }
  .pago-row { flex-wrap: wrap; row-gap: 6px; }
  .pago-row .list-main { flex: 1 1 140px; }
}

.hon-tabla .t-main .pg-badge { margin-left: 4px; font-size: 11px; padding: 2px 8px; vertical-align: 1px; }
.hon-cifras span { white-space: nowrap; font-size: clamp(14px, 1.4vw, 17px); }
