/* ==========================================================================
   Legalbit · Prototipo
   Índice: 1 Tokens · 2 Base · 3 Sidebar · 4 Topbar · 5 Componentes
           6 En curso · 7 Bóveda · 8 Calculadora · 9 Legalbit AI · 10 NOM
           11 Diálogos · 12 Toasts · 13 Responsive
   ========================================================================== */

/* 1. TOKENS ---------------------------------------------------------------- */
:root {
  /* Marca. logo.png es blanco monocromo, por lo que los tonos provienen de la
     identidad de Legalbit (landing): zafiro, océano y marino profundo. */
  --color-primary: #0042AC;
  --color-primary-hover: #00358A;
  --color-primary-soft: #EAF0FA;
  --color-accent: #00D3FB;          /* Solo sobre fondo oscuro; sin contraste suficiente sobre blanco */

  /* Neutros cálidos */
  --color-bg: #F8F7F5;
  --color-surface: #FFFFFF;
  --color-surface-hover: #F6F5F2;
  --color-border: #E7E5E0;
  --color-border-strong: #8C8A84;   /* Contornos de controles: 3:1 sobre blanco */
  --color-text: #171A21;
  --color-text-muted: #5C616B;

  /* Estado */
  --color-success: #1C7345;
  --color-success-soft: #E8F4ED;
  --color-warning: #8A5A00;
  --color-warning-soft: #FAF2E0;
  --color-danger: #B3322A;
  --color-danger-soft: #FBECEA;

  /* Tonos de apoyo para badges de etapa */
  --color-teal: #0B5F73;
  --color-teal-soft: #E4F5F9;
  --color-slate: #454C5C;
  --color-slate-soft: #EEEFF2;

  /* Sidebar */
  --color-sidebar: #020B1F;
  --color-sidebar-text: #DDE5F3;    /* Más claro para conservar contraste AA sobre el fondo azul animado */
  --color-sidebar-line: rgba(221, 229, 243, .22);
  --color-sidebar-hover: rgba(2, 11, 31, .38);

  /* Gráficas: orden fijo, validado para daltonismo sobre blanco.
     Las leyendas siempre muestran nombre y valor en texto. */
  --chart-1: #0A4FBF;
  --chart-2: #20B4D2;
  --chart-3: #7A5BA8;
  --chart-4: #D89A3A;

  /* Fases del caso en la línea de tiempo, de claro a oscuro según avanza */
  --fase-conciliacion: #20B4D2;
  --fase-juicio: #4A7BD0;
  --fase-resolucion: #4040B4;
  --fase-pendiente: #E2E4E9;

  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 26, 33, .03);
  --shadow-float: 0 12px 32px rgba(2, 11, 31, .12);
  --sidebar-w: 264px;
  --gutter: 32px;
  --ease: 160ms ease;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* 2. BASE ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: 400 14px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--color-accent); }
#view-title:focus-visible, #tabla-titulo:focus-visible, .main:focus-visible { outline: none; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--lg { width: 24px; height: 24px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--color-surface); box-shadow: var(--shadow-float);
  transform: translateY(-200%); transition: transform var(--ease);
}
.skip-link:focus { transform: none; }

/* 3. SIDEBAR --------------------------------------------------------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  overflow: hidden;
  transition: width 200ms ease;
}
.sidebar__fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sidebar__inner {
  position: relative; height: 100%;
  display: flex; flex-direction: column;
  padding: 24px 16px 16px;
  overflow: hidden auto;
}
.sidebar__top { position: relative; display: flex; align-items: center; justify-content: center; min-height: 36px; }
.icon-btn.sidebar__close { display: none; position: absolute; right: 0; top: 0; }
.brand { display: block; border-radius: 6px; }
/* Recorta el margen transparente de logo.png (área útil: x 133–1891, y 703–1201 de 2000) */
.brand__crop { position: relative; display: block; width: 112px; height: 32px; overflow: hidden; transition: width 200ms ease; }
.brand__crop img { position: absolute; width: 127.4px; height: 127.4px; max-width: none; left: -8.5px; top: -44.8px; transition: width 200ms ease, height 200ms ease, left 200ms ease, top 200ms ease; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 10px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.avatar--dark { background: var(--color-sidebar-hover); color: #fff; }

.workspace {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0; padding: 12px 8px;
  border-block: 1px solid var(--color-sidebar-line);
}
.workspace__text, .profile__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.workspace__text, .profile__text { white-space: nowrap; transition: opacity 120ms ease; }
.workspace__label, .profile__role { font-size: 12px; }
.workspace__name, .profile__name { color: #fff; font-weight: 600; font-size: 13px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--color-sidebar-text); text-align: left;
  transition: background var(--ease), color var(--ease);
}
.nav__text { white-space: nowrap; transition: opacity 120ms ease; }
.icon--nav { width: 20px; height: 20px; }
.nav__link:hover { background: var(--color-sidebar-hover); color: #fff; --duo: .28; }
.nav__link[aria-current="page"] { background: var(--color-sidebar-hover); color: #fff; font-weight: 600; }
.nav__link[aria-current="page"] .icon--nav { color: var(--color-accent); --duo: .24; }
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 2px;
  border-radius: 0 2px 2px 0; background: var(--color-accent);
}
.sidebar__foot { margin-top: auto; padding-top: 24px; }
.profile { display: flex; align-items: center; gap: 10px; padding: 12px 8px; border-top: 1px solid var(--color-sidebar-line); }

/* Panel retráctil: solo en escritorio; en pantallas menores el sidebar es un drawer */
.sidebar-toggle {
  position: fixed; top: 21px; left: calc(var(--sidebar-w) - 14px); z-index: 41;
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: 0 1px 3px rgba(2, 11, 31, .1);
  color: var(--color-text-muted);
  transition: left 200ms ease, color var(--ease), border-color var(--ease);
}
.sidebar-toggle:hover { color: var(--color-primary); border-color: var(--color-border-strong); }
.sidebar-toggle .icon { width: 15px; height: 15px; transition: transform 200ms ease; }
.sidebar-tip {
  position: fixed; z-index: 45; transform: translateY(-50%); padding: 5px 10px; border-radius: 8px;
  background: var(--color-sidebar); color: #fff; font-size: 12px; white-space: nowrap;
  box-shadow: var(--shadow-float); pointer-events: none; animation: fade 120ms ease;
}

@media (min-width: 1025px) {
  html[data-sidebar="colapsado"] { --sidebar-w: 72px; }
  html[data-sidebar="colapsado"] .sidebar-toggle .icon { transform: rotate(180deg); }
  /* El logo se recorta a la "l": x 135–258 de 2000, aumentada para que tenga presencia */
  html[data-sidebar="colapsado"] .brand__crop { width: 9.6px; }
  html[data-sidebar="colapsado"] .brand__crop img { width: 156px; height: 156px; left: -10.5px; top: -54.3px; }
  html[data-sidebar="colapsado"] .workspace, html[data-sidebar="colapsado"] .profile { gap: 0; padding-inline: 4px; }
  html[data-sidebar="colapsado"] .nav__link { gap: 0; }
  /* El texto se oculta sin display:none para que siga dando nombre a los enlaces en lectores de pantalla */
  html[data-sidebar="colapsado"] .nav__text,
  html[data-sidebar="colapsado"] .workspace__text,
  html[data-sidebar="colapsado"] .profile__text { width: 0; overflow: hidden; opacity: 0; }
}
@media (max-width: 1024px) {
  .sidebar-toggle, .sidebar-tip { display: none; }
}

/* 4. TOPBAR ---------------------------------------------------------------- */
.shell { margin-left: var(--sidebar-w); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; transition: margin-left 200ms ease; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 16px var(--gutter);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.icon-btn.topbar__menu { display: none; }
.topbar__title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; margin-right: auto; white-space: nowrap; }
.topbar__date { color: var(--color-text-muted); font-size: 13px; white-space: nowrap; }
.topbar__date::first-letter { text-transform: uppercase; }

.search { position: relative; width: min(320px, 30vw); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 38px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  transition: border-color var(--ease);
}
.search input:hover { border-color: var(--color-border-strong); }
.search input::placeholder, .chat__form input::placeholder { color: var(--color-text-muted); opacity: 1; }

.notif { position: relative; }
.notif__badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--color-primary); color: #fff;
  font-size: 10px; font-weight: 600; line-height: 1;
  box-shadow: 0 0 0 2px var(--color-bg);
}
.notif__panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; z-index: 30;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-float);
  animation: pop var(--ease);
}
.notif__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 6px 8px 6px 16px; }
.notif__title { font-weight: 600; }
.notif__clear { padding: 5px 8px; border-radius: 8px; color: var(--color-text-muted); font-size: 12px; transition: background var(--ease), color var(--ease); }
.notif__clear:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.notif__list li { position: relative; padding: 12px 44px 12px 16px; border-top: 1px solid var(--color-border); }
.notif__list .notif__del { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; opacity: 0; transition: opacity var(--ease), background var(--ease), color var(--ease); }
.notif__list .notif__del .icon { width: 15px; height: 15px; }
.notif__list li:hover .notif__del, .notif__list li:focus-within .notif__del { opacity: 1; }
.notif__list .notif__del:hover:not(:disabled) { background: var(--color-danger-soft); color: var(--color-danger); }
@media (hover: none) { .notif__list .notif__del { opacity: 1; } }
.notif__empty { padding: 24px 16px 28px; border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 13px; text-align: center; }
.notif__list strong { display: block; font-weight: 600; font-size: 13px; }
.notif__list span { display: block; color: var(--color-text-muted); font-size: 13px; }
.notif__list time { display: block; margin-top: 4px; color: var(--color-text-muted); font-size: 12px; }

/* 5. COMPONENTES ----------------------------------------------------------- */
.main { flex: 1; padding: 28px var(--gutter) 56px; width: 100%; max-width: 1440px; margin-inline: auto; }
.view { display: flex; flex-direction: column; gap: 20px; animation: fade 180ms ease; }
.view__count { margin-bottom: -6px; }

.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.card--flush { padding: 0; }
.card__title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.card__sub { color: var(--color-text-muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--color-surface); border: 1px solid var(--color-border);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover { background: var(--color-surface-hover); border-color: var(--color-border-strong); }
.btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--color-text-muted); padding: 0 10px; }
.btn--quiet:hover { border-color: transparent; color: var(--color-text); }
.btn--block { width: 100%; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: background var(--ease), color var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--color-slate-soft); color: var(--color-text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn--dark { color: var(--color-sidebar-text); }
.icon-btn--dark:hover:not(:disabled) { background: var(--color-sidebar-hover); color: #fff; }
.icon-btn--primary { background: var(--color-primary); color: #fff; }
.icon-btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-muted); font-size: 13px; white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.chip:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.chip[aria-pressed="true"] { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary); font-weight: 600; }
.chip__n { margin-left: 4px; opacity: .8; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 8px;
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.badge--conciliacion { background: var(--color-primary-soft); color: var(--color-primary); }
.badge--demanda, .badge--pendiente { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--audiencia { background: var(--color-teal-soft); color: var(--color-teal); }
.badge--desahogo, .badge--revision { background: var(--color-slate-soft); color: var(--color-slate); }
.badge--laudo, .badge--cumple { background: var(--color-success-soft); color: var(--color-success); }

.progress { height: 4px; border-radius: 2px; background: var(--color-slate-soft); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--color-primary); border-radius: 2px; transition: width 200ms ease; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar__right { display: flex; align-items: center; gap: 12px; }
.segmented { display: flex; padding: 2px; gap: 2px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.segmented .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.segmented .icon-btn[aria-pressed="true"] { background: var(--color-primary-soft); color: var(--color-primary); }

.empty { padding: 48px 24px; text-align: center; color: var(--color-text-muted); }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field__hint { font-weight: 400; color: var(--color-text-muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--ease);
}
.field textarea { resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--color-text-muted); }
.field [aria-invalid="true"] { border-color: var(--color-danger); }
.field__error { color: var(--color-danger); font-size: 12px; }
.field__error:empty { display: none; }

/* 6. EN CURSO -------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi__label { color: var(--color-text-muted); font-size: 13px; }
.kpi__value { margin-top: 6px; font-size: 32px; line-height: 1.15; letter-spacing: -.02em; }
.kpi__note { margin-top: 4px; color: var(--color-text-muted); font-size: 12px; }

.table-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 14px; }
.chips--table { padding: 0 24px 16px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--color-border); }
.table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 13px; }
.table th { padding: 0; text-align: left; font-weight: 600; font-size: 12px; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table th > span { display: block; padding: 11px 12px; }
.table th:first-child > *, .table td:first-child { padding-left: 24px; }
.table th:last-child > span, .table td:last-child { padding-right: 16px; }
.th-btn { display: inline-flex; align-items: center; gap: 4px; padding: 11px 12px; font-weight: 600; color: inherit; border-radius: 6px; transition: color var(--ease); }
.th-btn:focus-visible { outline-offset: -2px; }
.th-btn:hover { color: var(--color-text); }
.th-btn .icon { width: 13px; height: 13px; opacity: .55; }
th[aria-sort="ascending"] .th-btn, th[aria-sort="descending"] .th-btn { color: var(--color-primary); }
th[aria-sort="ascending"] .icon, th[aria-sort="descending"] .icon { opacity: 1; }
.table td { padding: 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background var(--ease); }
.table tbody tr:hover { background: var(--color-surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-name { font-weight: 600; white-space: nowrap; }
.cell-id { color: var(--color-text-muted); white-space: nowrap; }
.cell-organo { min-width: 210px; max-width: 240px; line-height: 1.4; }
.cell-date { white-space: nowrap; }
.cell-muted { color: var(--color-text-muted); }
.cell-comment { color: var(--color-text-muted); line-height: 1.4; max-width: 240px; }
.cell-comment span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-actions { display: flex; gap: 2px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 10px 24px; border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 13px; }
.pager__btns { display: flex; align-items: center; gap: 4px; }
.pager__num { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; color: var(--color-text-muted); transition: background var(--ease), color var(--ease); }
.pager__num:hover { background: var(--color-slate-soft); color: var(--color-text); }
.pager__num[aria-current="page"] { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

.donut-block { display: flex; align-items: center; gap: 24px; margin-top: 18px; }
.donut-block--main { gap: 48px; padding: 8px 8px 8px 16px; }
.donut { position: relative; flex: none; width: 112px; height: 112px; }
.donut-block--main .donut { width: 196px; height: 196px; }
.donut svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; transition: opacity var(--ease); }
.donut__track { stroke: var(--color-slate-soft); }
.donut__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 0 22%; }
.donut__value { font-size: 20px; line-height: 1.15; letter-spacing: -.01em; }
.donut__label { color: var(--color-text-muted); font-size: 11px; line-height: 1.25; }
.donut-block--main .donut__value { font-size: 32px; letter-spacing: -.02em; }
.donut-block--main .donut__label { font-size: 13px; margin-top: 2px; }
.donut.is-hovering circle[data-seg]:not(.is-active) { opacity: .3; }

.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; line-height: 1.35; border-top: 1px solid var(--color-border); }
.legend li:first-child { border-top: 0; }
.legend__swatch { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.legend__name { min-width: 0; flex: 1; }
.legend__value { color: var(--color-text-muted); white-space: nowrap; }
.donut-block--main .legend li { padding: 14px 0; font-size: 14px; }
.donut-block--main .legend__pct { font-weight: 600; color: var(--color-text); margin-left: 12px; }

.fact { display: flex; flex-direction: column; }
.fact__head { display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); }
.fact__head .card__title { color: var(--color-text); }
.fact__body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 0; }
.fact__text { font-size: 17px; line-height: 1.55; letter-spacing: -.005em; animation: fade 200ms ease; }
.fact__ref { margin-top: 12px; color: var(--color-text-muted); font-size: 13px; }
.fact__next { align-self: flex-start; margin-left: -10px; }

/* 7. BÓVEDA ---------------------------------------------------------------- */
.upload { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 18px; }
.upload__row { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: 13px; }
.upload__row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload__row span:last-child { color: var(--color-text-muted); }

.docs--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.doc {
  position: relative; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  transition: border-color var(--ease);
}
.doc:hover { border-color: var(--color-border-strong); }
.doc__top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; color: var(--color-text-muted); }
.doc__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--color-slate-soft); color: var(--color-slate); }
.doc__name { font-weight: 600; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.doc__meta { margin-top: 6px; color: var(--color-text-muted); font-size: 12px; }
.doc__type { font-size: 12px; color: var(--color-text-muted); }
.doc .icon-btn { margin: -6px -6px 0 0; }

.docs--list { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.docs--list .doc { display: grid; grid-template-columns: 36px minmax(0, 1fr) 150px 170px 36px; align-items: center; gap: 14px; padding: 10px 16px; border: 0; border-top: 1px solid var(--color-border); border-radius: 0; box-shadow: none; }
.docs--list .doc:first-child { border-top: 0; }
.docs--list .doc:hover { background: var(--color-surface-hover); }
.docs--list .doc__top { display: contents; }
.docs--list .doc__main { grid-column: 2; grid-row: 1; }
.docs--list .doc__icon { grid-column: 1; grid-row: 1; }
.docs--list .doc__type { grid-column: 3; grid-row: 1; white-space: nowrap; }
.docs--list .doc__tail { grid-column: 4; grid-row: 1; margin: 0; white-space: nowrap; }
.docs--list .icon-btn { grid-column: 5; grid-row: 1; margin: 0; }
.doc__tail { margin-top: 6px; color: var(--color-text-muted); font-size: 12px; }

/* 8. CALCULADORA ------------------------------------------------------------ */
.calc { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form > .card__sub { margin-top: -14px; }
.calc__total { padding-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.calc__total-label { color: var(--color-text-muted); font-size: 13px; }
.calc__total-value { margin-top: 2px; font-size: 36px; line-height: 1.2; letter-spacing: -.02em; }
.calc__meta { margin-top: 6px; color: var(--color-text-muted); font-size: 13px; }
.calc__group { margin-top: 20px; font-size: 13px; font-weight: 600; }
.calc__lines { margin-top: 4px; }
.calc__line { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.calc__concept { display: block; }
.calc__formula { display: block; margin-top: 1px; color: var(--color-text-muted); font-size: 12px; }
.calc__amount { white-space: nowrap; }
.calc__line--na .calc__concept, .calc__line--na .calc__amount { color: var(--color-text-muted); }
.calc__note { margin-top: 18px; color: var(--color-text-muted); font-size: 12px; line-height: 1.55; }

/* 9. LEGALBIT AI ------------------------------------------------------------ */
/* Esta sección ocupa todo el alto y ancho bajo la barra superior, con el historial pegado al sidebar */
.shell[data-vista="legalbit-ai"] { height: 100dvh; min-height: 560px; }
.shell[data-vista="legalbit-ai"] .main { display: flex; min-height: 0; max-width: none; padding: 0; }
.view--chat { flex: 1; min-width: 0; min-height: 0; }
.ai { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr); }

/* Historial de conversaciones */
.hist { display: flex; flex-direction: column; min-height: 0; padding: 16px 12px 12px; background: var(--color-surface); border-right: 1px solid var(--color-border); }
.hist__top { display: flex; align-items: center; gap: 8px; }
.hist__new { flex: 1; }
.icon-btn.hist__close { display: none; }
.hist__search { width: 100%; margin-top: 8px; }
.hist__search input { height: 36px; font-size: 13px; }
.hist__list { flex: 1; min-height: 0; overflow-y: auto; margin-top: 8px; padding: 2px; }
.hist__group { padding: 12px 8px 4px; color: var(--color-text-muted); font-size: 12px; font-weight: 400; }
.hist__item { position: relative; }
.hist__open {
  display: block; width: 100%; padding: 8px 34px 8px 8px; border-radius: 8px;
  font-size: 13px; line-height: 1.45; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background var(--ease), color var(--ease);
}
.hist__open:hover { background: var(--color-surface-hover); }
.hist__open:focus-visible { outline-offset: -2px; }
.hist__open[aria-current="true"] { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.hist__item .hist__del { position: absolute; top: 3px; right: 3px; width: 30px; height: 30px; border-radius: 8px; opacity: 0; transition: opacity var(--ease), background var(--ease), color var(--ease); }
.hist__item .hist__del .icon { width: 15px; height: 15px; }
.hist__item:hover .hist__del, .hist__item:focus-within .hist__del { opacity: 1; }
.hist__item .hist__del:hover:not(:disabled) { background: var(--color-danger-soft); color: var(--color-danger); }
@media (hover: none) { .hist__item .hist__del { opacity: 1; } }
.hist__empty { padding: 24px 8px; color: var(--color-text-muted); font-size: 13px; text-align: center; }
.hist__scrim { position: fixed; inset: 0; z-index: 35; background: rgba(2, 11, 31, .32); animation: fade 160ms ease; }

/* Conversación */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; width: 100%; max-width: calc(760px + 2 * var(--gutter)); margin-inline: auto; padding: 20px var(--gutter) 24px; }
.chat__bar { display: none; align-items: center; gap: 10px; padding-bottom: 12px; }
.chat__bar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); font-size: 13px; }
.chat__log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; padding: 8px 4px 24px; border-radius: var(--radius-sm); }
.chat__intro { margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; color: var(--color-primary); }
.chat__hello { color: var(--color-text); font-size: 24px; font-weight: 400; letter-spacing: -.015em; margin-top: 6px; }
.chat__suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 24px; width: 100%; }
.suggestion {
  padding: 14px 16px; text-align: left; font-size: 13px; line-height: 1.45; color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  transition: border-color var(--ease), background var(--ease);
}
.suggestion:hover { border-color: var(--color-border-strong); }
.msg { max-width: 88%; animation: fade 180ms ease; white-space: pre-line; }
.msg--user { align-self: flex-end; padding: 9px 14px; background: var(--color-primary-soft); border-radius: var(--radius); }
.msg--ai { align-self: flex-start; display: flex; gap: 12px; line-height: 1.65; }
.msg--ai > .icon { margin-top: 3px; color: var(--color-primary); }
.msg__ref { display: block; margin-top: 8px; color: var(--color-text-muted); font-size: 12px; }
.dots { display: inline-flex; gap: 4px; align-items: center; height: 22px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--color-text-muted); animation: blink 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
.chat__form {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius);
  transition: border-color var(--ease);
}
.chat__form:focus-within { border-color: var(--color-primary); }
.chat__form input { flex: 1; min-width: 0; height: 36px; border: 0; background: none; }
.chat__form input:focus-visible { outline: none; }

/* 10. NOM ------------------------------------------------------------------- */
.noms { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.nom { display: flex; flex-direction: column; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.nom__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.nom__code { font-size: 15px; font-weight: 600; }
.nom__title { margin-top: 8px; color: var(--color-text-muted); font-size: 13px; flex: 1; }
.nom__progress { margin-top: 20px; }
.nom__row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; color: var(--color-text-muted); }
.nom__row b { color: var(--color-text); font-weight: 600; }
.nom .progress[data-estado="cumple"] span { background: var(--color-success); }

/* 11. DIÁLOGOS -------------------------------------------------------------- */
dialog { color: inherit; border: 0; padding: 0; background: var(--color-surface); }
dialog::backdrop { background: rgba(2, 11, 31, .32); animation: fade 160ms ease; }

.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); border-radius: var(--radius); box-shadow: var(--shadow-float); }
.modal[open] { animation: pop 180ms ease; }
.modal__inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--color-border); }
.modal__body { padding: 20px 24px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--color-border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field--full { grid-column: 1 / -1; }

/* Detalle del asunto */
.modal--caso { width: min(1040px, calc(100vw - 32px)); }
.caso { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.caso__head { display: flex; align-items: flex-start; gap: 16px; padding: 24px 20px 20px 32px; border-bottom: 1px solid var(--color-border); }
.caso__title { flex: 1; min-width: 0; }
.caso__name { font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -.015em; }
.caso__name:focus-visible { outline: none; }
.caso__id { margin-top: 2px; color: var(--color-text-muted); font-size: 13px; }
.caso__facts { display: flex; flex-wrap: wrap; gap: 6px 32px; margin-top: 12px; font-size: 13px; }
.caso__facts div { display: flex; gap: 6px; }
.caso__facts dt { font-weight: 600; }
.caso__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.caso__body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 32px 32px; }
.caso__section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; }
.caso__section { font-size: 15px; font-weight: 600; }
.caso__columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--color-border); }
.caso__sub { margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.caso__text { line-height: 1.6; }
.caso__meta { color: var(--color-text-muted); font-size: 13px; }
.caso__block + .caso__block { margin-top: 24px; }

.detail { border-top: 1px solid var(--color-border); }
.detail div { display: grid; grid-template-columns: 136px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.detail dt { color: var(--color-text-muted); }

.fases { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--color-text-muted); font-size: 12px; }
.fases li { display: flex; align-items: center; gap: 6px; }
.fases i { width: 10px; height: 10px; border-radius: 3px; }
.fases .fases__propio { width: 8px; height: 8px; margin-inline: 1px; border-radius: 2px; background: var(--color-text-muted); transform: rotate(45deg); }
.caso__section-head .fases { margin-left: auto; }
.hito-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px 16px; margin-top: 16px; padding: 16px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); animation: pop var(--ease); }
.hito-form__actions { display: flex; justify-content: flex-end; gap: 8px; }
.hito-del { margin: 6px 0 0 -10px; }
.hito-del:hover { color: var(--color-danger); }
.exp__act-text { margin-top: 4px; }

/* Línea de tiempo: cada hito es una columna; los hitos alternan su etiqueta arriba y abajo.
   El anillo blanco del nodo recorta los extremos del tramo que lo une con el siguiente. */
.hitos { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(108px, 1fr); margin-top: 12px; overflow-x: auto; }
.hito { position: relative; --color-hito: var(--fase-pendiente); --tramo: var(--fase-pendiente); }
.hito[data-fase="conciliacion"]:not([data-estado="pendiente"]) { --color-hito: var(--fase-conciliacion); }
.hito[data-fase="juicio"]:not([data-estado="pendiente"]) { --color-hito: var(--fase-juicio); }
.hito[data-fase="resolucion"]:not([data-estado="pendiente"]) { --color-hito: var(--fase-resolucion); }
.hito[data-tramo="lleno"] { --tramo: var(--color-hito); }
.hito:not(:last-child)::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: 100%; height: 18px;
  transform: translateY(-50%); background: var(--tramo);
}
.hito__btn {
  position: relative; display: grid; grid-template-rows: 112px 32px 112px; justify-items: center;
  width: 100%; padding: 0; border-radius: 8px;
}
.hito__btn:focus-visible { outline: none; }
.hito__area { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; }
.hito__area--arriba { grid-row: 1; justify-content: flex-end; }
.hito__area--abajo { grid-row: 3; justify-content: flex-start; }
.hito__stem { flex: none; width: 2px; height: 38px; background: var(--color-hito); transition: height var(--ease); }
.hito__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--color-hito); }
.hito[data-estado="pendiente"] .hito__stem, .hito[data-estado="pendiente"] .hito__dot { background: var(--color-border-strong); opacity: .55; }
.hito__nodo {
  grid-row: 2; position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--color-hito);
  box-shadow: 0 0 0 5px var(--color-surface); transition: box-shadow var(--ease), transform var(--ease);
}
.hito[data-estado="pendiente"] .hito__nodo { background: var(--color-surface); border: 2px solid var(--color-border-strong); }
.hito[data-estado="actual"] .hito__nodo::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--color-surface); }
.hito__btn:hover .hito__nodo { transform: scale(1.08); }
/* Los hitos capturados a mano se distinguen por su forma de rombo */
.hito[data-propio] .hito__nodo { width: 24px; height: 24px; margin-top: 4px; border-radius: 6px; transform: rotate(45deg); }
.hito[data-propio] .hito__btn:hover .hito__nodo { transform: rotate(45deg) scale(1.08); }
.hito__btn[aria-pressed="true"] .hito__nodo { box-shadow: 0 0 0 4px var(--color-surface), 0 0 0 6px var(--color-text); }
.hito__btn:focus-visible .hito__nodo { box-shadow: 0 0 0 4px var(--color-surface), 0 0 0 6px var(--color-primary); }
.hito__label { width: 196%; padding: 4px 6px; text-align: center; font-size: 12px; line-height: 1.35; }
.hito:first-child .hito__label { width: 150%; margin-left: 50%; text-align: left; }
.hito:last-child .hito__label { width: 150%; margin-right: 50%; text-align: right; }
.hito__name { display: block; font-weight: 600; }
.hito[data-estado="pendiente"] .hito__name { font-weight: 400; color: var(--color-text-muted); }
.hito__date { display: block; color: var(--color-text-muted); }
.hito__tag { color: var(--color-primary); font-weight: 600; }

/* Expediente */
.caso__back { margin-left: -10px; }
.exp__docs { border-top: 1px solid var(--color-border); }
.exp__doc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.exp__doc-main { flex: 1; min-width: 0; }
.exp__doc-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.exp__doc-meta { color: var(--color-text-muted); font-size: 12px; }
.exp__empty { padding: 20px 0; color: var(--color-text-muted); font-size: 13px; border-bottom: 1px solid var(--color-border); }
.exp__link { margin-top: 12px; }
.exp__act { padding: 10px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.exp__act b { display: block; font-weight: 600; }

@media (max-width: 760px) {
  .modal--caso { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: 0; height: 100dvh; border-radius: 0; }
  .caso { height: 100%; max-height: 100dvh; }
  .caso__head { flex-wrap: wrap; padding: 16px 12px 16px 16px; }
  .caso__title { flex-basis: calc(100% - 52px); order: 1; }
  .caso__actions { display: contents; }
  .caso__actions .icon-btn { order: 2; }
  .caso__actions .btn { order: 3; width: 100%; }
  .caso__name { font-size: 20px; }
  .caso__body { padding: 20px 16px 24px; }
  .caso__columns { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .detail div { grid-template-columns: 112px 1fr; }

  .hito-form { grid-template-columns: minmax(0, 1fr); }
  .caso__section-head .fases { margin-left: 0; order: 3; }

  /* En pantalla angosta la línea de tiempo se vuelve vertical */
  .hitos { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; }
  .hito:not(:last-child)::before { top: 12px; left: 15px; width: 10px; height: 100%; transform: none; }
  .hito__btn { display: flex; align-items: flex-start; gap: 16px; padding: 4px 0 20px 4px; text-align: left; }
  .hito:last-child .hito__btn { padding-bottom: 0; }
  .hito__nodo { flex: none; order: -1; }
  .hito[data-propio] .hito__nodo { margin: 4px; }
  .hito__area { display: block; }
  .hito__area:empty, .hito__stem, .hito__dot { display: none; }
  .hito__label, .hito:first-child .hito__label, .hito:last-child .hito__label { width: auto; margin: 0; padding: 4px 0 0; text-align: left; }
}

/* 12. TOASTS ---------------------------------------------------------------- */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--color-sidebar); color: #fff; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float); font-size: 13px; animation: pop 180ms ease;
}
.toast .icon { color: var(--color-accent); width: 16px; height: 16px; }
.toast__action { margin-left: auto; padding: 2px 6px; border-radius: 6px; font-weight: 600; color: var(--color-accent); }
.toast__action:focus-visible { outline-color: var(--color-accent); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

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

/* 13. RESPONSIVE ------------------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(2, 11, 31, .32); animation: fade 160ms ease; }

@media (max-width: 1280px) {
  .donut-block { gap: 16px; }
  .donut-block--main { gap: 32px; }
  .trio .donut-block { flex-direction: column; align-items: stretch; }
  .trio .donut { align-self: center; }
}

/* Tablet: el sidebar pasa a drawer */
@media (max-width: 1024px) {
  :root { --gutter: 24px; }
  .sidebar {
    transform: translateX(-100%); visibility: hidden;
    transition: transform 200ms ease, visibility 200ms;
    width: min(280px, 86vw);
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .icon-btn.sidebar__close { display: inline-grid; }
  .shell { margin-left: 0; }
  .icon-btn.topbar__menu { display: inline-grid; margin-left: -8px; }
  .topbar { gap: 12px; }
  .topbar__title { margin-right: auto; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .trio .donut-block { flex-direction: row; align-items: center; }
  .trio { grid-template-columns: minmax(0, 1fr); }
  .trio .donut { align-self: auto; }
  .calc { grid-template-columns: 1fr; }
}

/* Móvil: la tabla se convierte en tarjetas */
@media (max-width: 720px) {
  :root { --gutter: 16px; }
  .topbar { flex-wrap: wrap; position: static; row-gap: 8px; }
  .topbar__title { flex: 1; min-width: 0; font-size: 18px; margin-right: 0; }
  .notif { order: 2; }
  .topbar__date { order: 3; flex-basis: 100%; font-size: 12px; }
  .topbar .search { order: 4; flex-basis: 100%; width: 100%; }
  .notif__panel { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; }
  .main { padding-top: 20px; }

  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 26px; }
  .card { padding: 18px; }
  .card--flush { padding: 0; }

  .table-head { padding: 16px 16px 12px; }
  .chips--table { padding: 0 16px 14px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; }
  .table-wrap { overflow: visible; }
  .table { min-width: 0; display: block; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tbody tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table td:first-child, .table td:last-child {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    max-width: none; padding: 5px 0; border: 0; text-align: right;
  }
  .table td::before { content: attr(data-label); flex: none; width: 104px; color: var(--color-text-muted); font-size: 12px; font-weight: 400; text-align: left; }
  .table td.cell-name { font-size: 15px; padding-bottom: 8px; text-align: left; white-space: normal; }
  .table td.cell-name::before, .table td[data-label="Acciones"]::before { display: none; }
  .table td[data-label="Acciones"] { justify-content: flex-end; padding: 2px 0 0; }
  .table td.empty { display: block; text-align: center; }
  .table td.empty::before { display: none; }
  .cell-actions { justify-content: flex-end; }
  .pager { padding: 8px 12px 8px 16px; }

  .donut-block--main { flex-direction: column; align-items: stretch; gap: 16px; padding: 0; }
  .donut-block--main .donut { align-self: center; width: 180px; height: 180px; }

  .toolbar__right { width: 100%; justify-content: space-between; }
  #doc-chips, #nom-chips { flex-wrap: wrap; }
  .docs--grid { grid-template-columns: 1fr; }
  .docs--list .doc { grid-template-columns: 36px minmax(0, 1fr) 36px; }
  .docs--list .doc__type, .docs--list .doc__tail { display: none; }
  .docs--list .icon-btn { grid-column: 3; }

  .noms { grid-template-columns: 1fr; }
  .chat__suggestions { grid-template-columns: 1fr; }
  .chat__intro { margin: 0; padding-top: 8px; }
  .msg { max-width: 100%; }

  .form-grid { grid-template-columns: 1fr; }
  .toasts { right: 16px; left: 16px; bottom: 16px; max-width: none; }
}

@media (max-width: 420px) {
  .trio .donut-block { flex-direction: column; align-items: stretch; }
  .trio .donut { align-self: center; }
}

/* Historial como panel deslizable cuando no cabe junto a la conversación */
@media (max-width: 900px) {
  .ai { grid-template-columns: minmax(0, 1fr); }
  .chat__bar { display: flex; }
  .icon-btn.hist__close { display: inline-grid; }
  .hist {
    position: fixed; inset: 0 auto 0 0; z-index: 36;
    width: min(300px, 86vw); box-shadow: var(--shadow-float);
    transform: translateX(-100%); visibility: hidden;
    transition: transform 200ms ease, visibility 200ms;
  }
  .hist.is-open { transform: none; visibility: visible; }
}
