/* Hispanaweb Facturación — interfaz. Azules de marca: #1E4FA0 (azul), #38B3E7 (cohete), #0B2450 (navy).
   El modo oscuro solo se aplica en el backoffice (html[data-theme]); el área de cliente y los documentos públicos van en claro. */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@600;700;800&display=swap');

:root {
  --navy: #0B2450; --blue: #1E4FA0; --sky: #38B3E7; --mint: #16C79A; --coral: #FF6B4A; --amber: #FFB020;
  --bg: #F3F6FB; --card: #FFFFFF; --text: #0B2450; --muted: #5A6B85; --line: #E3E9F3; --soft: #F7F9FD; --focus: rgba(56,179,231,.35);
  --hover: #FAFCFF; --input: #FFFFFF; --input-line: #CFD9EA; --link: #1E4FA0;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11,36,80,.05), 0 6px 24px -8px rgba(11,36,80,.10);
  --shadow-lg: 0 24px 60px -12px rgba(11,36,80,.30);
  /* Barra lateral */
  --side-w: 248px; --side-bg: #0A1F45; --side-bg2: #0D2A5C; --side-text: #C4D5EF; --side-muted: #7F97BD; --side-hover: rgba(255,255,255,.07);
  /* Estados */
  --ok-bg: #E2F8F1; --ok-fg: #0B6F54; --err-bg: #FFE9E4; --err-fg: #A33013; --warn-bg: #FFF3DA; --warn-fg: #7A4E00;
  --info-bg: #EAF0FA; --grey-bg: #EEF1F6; --grey-fg: #5A6B85;
  /* Gráficos: paleta categórica validada (daltonismo) sobre fondo claro */
  --c1: #1E4FA0; --c2: #E0772F; --c3: #16A37F; --c4: #D9A300; --c5: #C0579A; --c6: #38B3E7; --c-other: #A3B0C4;
  --grid: #E8EDF5; --axis: #8595AE;
  --good: #0B8A68; --bad: #C23A1B;
}
html[data-theme="dark"] {
  --bg: #0B1222; --card: #131B2E; --text: #E6EDF8; --muted: #93A3BE; --line: #243049; --soft: #18223A; --focus: rgba(56,179,231,.30);
  --hover: #172139; --input: #0F172A; --input-line: #2B3854; --link: #7FB2FF;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -10px rgba(0,0,0,.55);
  --side-bg: #080F1F; --side-bg2: #0C1730;
  --ok-bg: rgba(22,199,154,.14); --ok-fg: #5EE0B8; --err-bg: rgba(255,107,74,.14); --err-fg: #FF9C85; --warn-bg: rgba(255,176,32,.14); --warn-fg: #FFC960;
  --info-bg: rgba(91,141,239,.16); --grey-bg: rgba(147,163,190,.14); --grey-fg: #A9B6CC;
  --c1: #4A7FE0; --c2: #D26A2A; --c3: #169A76; --c4: #B88A00; --c5: #C0579A; --c6: #2A9FD0; --c-other: #5C6B85;
  --grid: #1F2A42; --axis: #7D8CA8; --good: #3FD3A4; --bad: #FF8A70;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Manrope, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: Sora, Manrope, sans-serif; letter-spacing: -.015em; margin: 0 0 .6em; }
h1 { font-size: 24px; font-weight: 700; } h2 { font-size: 16px; font-weight: 700; } h3 { font-size: 14px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
::selection { background: rgba(56,179,231,.3); }

/* ── Estructura ── */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0,1fr); min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--side-bg2) 0%, var(--side-bg) 55%); color: var(--side-text); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 10; }
.side .brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 14px 14px 18px; min-height: 64px; }
.side .brand a { display: flex; align-items: center; }
.side .brand a > img { height: 40px; opacity: .6; transition: opacity .3s; }
.side .brand a:hover > img { opacity: 1; }
.side .brand .mark { display: none; width: 42px; height: 42px; align-items: center; justify-content: center; }
/* Menú plegado: el símbolo del logo (planeta y cohete) en negativo, como el logo abierto */
.side .brand .mark img { width: 42px; height: 42px; object-fit: contain; opacity: .6; transition: opacity .3s; }
/* Atenuados como en el panel: blancos del todo solo al pasar el ratón */
.side .brand a:hover .mark img { opacity: 1; }
/* Botón de plegar: redondo, en el borde del menú a media altura (como en el panel) */
.side-collapse { position: fixed; top: 50%; left: calc(var(--side-w) - 12px); transform: translateY(-50%); z-index: 50; width: 24px; height: 40px; border-radius: 999px; background: var(--side-bg2); border: 1px solid rgba(255,255,255,.12); color: var(--side-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px -6px rgba(4,10,24,.6); transition: left .2s, background .15s, color .15s, transform .15s; }
.side-collapse:hover { background: var(--blue); color: #fff; transform: translateY(-50%) scale(1.1); }
.side-collapse svg { width: 14px; height: 14px; transition: transform .2s; }
body.resizing .side-collapse { transition: none; }
.side nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.side nav a { display: flex; align-items: center; gap: 11px; color: var(--side-text); padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 13.5px; white-space: nowrap; position: relative; transition: background .12s, color .12s; }
.side nav a svg { flex: none; width: 18px; height: 18px; opacity: .85; }
.side nav a .lbl { overflow: hidden; text-overflow: ellipsis; }
.side nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.side nav a.on { background: linear-gradient(90deg, rgba(56,179,231,.22), rgba(56,179,231,.06)); color: #fff; box-shadow: inset 2px 0 0 var(--sky); }
.side nav a.on svg { opacity: 1; color: var(--sky); }
.side nav .grp { margin-top: 6px; }
.side nav .sep { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; cursor: pointer; font: 700 10.5px Manrope, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 12px 10px 5px; }
.side nav .sep:hover { color: #cfe0f7; }
.side nav .sep svg { width: 12px; height: 12px; transition: transform .15s; }
.side nav .grp.closed .sep svg { transform: rotate(-90deg); }
.side nav .grp.closed .items { display: none; }
.side .count { margin-left: auto; background: var(--coral); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 1px 7px; font-weight: 800; line-height: 1.5; }
.side-foot { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: var(--side-muted); display: flex; align-items: center; gap: 10px; }
.side-foot .av { flex: none; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--sky), var(--blue)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.side-foot .nm { color: #fff; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .txt { min-width: 0; }
.side-resize { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; z-index: 11; }
.side-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 2px; width: 2px; background: transparent; transition: background .15s; }
.side-resize:hover::after, body.resizing .side-resize::after { background: var(--sky); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .shell { transition: none; }

/* Menú plegado: solo iconos */
html.side-min { --side-w: 72px; }
html.side-min .side .brand { flex-direction: column; padding: 16px 8px 10px; }
html.side-min .side .brand a > img { display: none; }
html.side-min .side .brand .mark { display: inline-flex; }
html.side-min .side-collapse { left: 60px; }
html.side-min .side-collapse svg { transform: rotate(180deg); }
html.side-min .side nav { padding: 4px 12px 16px; }
html.side-min .side nav a { justify-content: center; padding: 10px 0; }
html.side-min .side nav a .lbl { display: none; }
html.side-min .side .count { position: absolute; top: 3px; right: 2px; font-size: 9.5px; padding: 0 5px; }
html.side-min .side nav .sep { justify-content: center; padding: 10px 0 4px; font-size: 0; }
html.side-min .side nav .sep::before { content: ''; display: block; width: 18px; height: 1px; background: rgba(255,255,255,.14); }
html.side-min .side nav .sep svg { display: none; }
html.side-min .side nav .grp.closed .items { display: block; }
html.side-min .side-foot { justify-content: center; }
html.side-min .side-foot .txt { display: none; }
html.side-min .side-resize { display: none; }
/* Ventana del menú plegado: los enlaces del grupo, con los colores del menú */
.side-fly { position: fixed; z-index: 55; min-width: 220px; padding: 8px 0; border-radius: 12px; background: var(--side-bg); border: 1px solid rgba(255,255,255,.08); box-shadow: 0 24px 50px -12px rgba(4,10,24,.6); animation: side-fly-in .15s ease-out; }
.side-fly::before { content: ''; position: absolute; right: 100%; top: 0; width: 10px; height: 100%; }
.side-fly .t { padding: 0 14px 8px; margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,.06); font: 700 10.5px Manrope, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); }
.side-fly .l { padding: 0 6px; display: flex; flex-direction: column; gap: 1px; }
.side-fly a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--side-text); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.side-fly a svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.side-fly a .lbl { flex: 1; }
.side-fly a:hover, .side-fly a.hov { background: var(--side-hover); color: #fff; text-decoration: none; }
.side-fly a.on { background: linear-gradient(90deg, rgba(56,179,231,.22), rgba(56,179,231,.06)); color: #fff; box-shadow: inset 2px 0 0 var(--sky); }
.side-fly a.on svg { opacity: 1; color: var(--sky); }
.side-fly .count { margin-left: auto; background: var(--coral); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 1px 7px; font-weight: 800; line-height: 1.5; }
@keyframes side-fly-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.side-tip { position: fixed; z-index: 60; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 7px; pointer-events: none; box-shadow: var(--shadow-lg); white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .search { flex: 1; max-width: 560px; position: relative; }
.top .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.top .search input { width: 100%; padding-left: 36px; padding-right: 40px; background: var(--soft); border-color: transparent; border-radius: 10px; }
.top .search input:focus { background: var(--input); border-color: var(--sky); }
.top .search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 600 11px ui-monospace, Menlo, monospace; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--card); }
.top .who { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--soft); }
.icon-btn svg { width: 18px; height: 18px; }
.ai-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 0; cursor: pointer; font: 700 13px Manrope, sans-serif; color: #fff; background: linear-gradient(135deg, var(--blue), var(--sky)); box-shadow: 0 6px 16px -6px rgba(30,79,160,.6); }
.ai-btn:hover { filter: brightness(1.08); }
.ai-btn svg { width: 16px; height: 16px; }
.content { padding: 26px 28px 70px; max-width: 1480px; width: 100%; }
.menu-toggle { display: none !important; }
.theme-ico .sun, html[data-theme="dark"] .theme-ico .moon { display: none; }
html[data-theme="dark"] .theme-ico .sun { display: block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  html.side-min { --side-w: 248px; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(290px, 84vw); z-index: 40; transform: translateX(-105%); transition: transform .22s ease; height: 100%; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vw rgba(4,10,24,.5); }
  .side-resize, .side-collapse, .side-fly { display: none; }
  html.side-min .side nav a .lbl, html.side-min .side .brand a > img { display: initial; }
  html.side-min .side .brand .mark { display: none; }
  html.side-min .side nav a { justify-content: flex-start; padding: 8px 10px; }
  .menu-toggle { display: inline-flex !important; }
  .content { padding: 18px 16px 70px; }
  .top { padding: 10px 16px; }
  .ai-btn .lbl, .top .search kbd { display: none; }
  .ai-btn { padding: 0 11px; }
}

/* ── Componentes ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; min-width: 0; }
.card > h2:first-child { margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 20px 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card.flush .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid > .card { margin-bottom: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-side { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.span2 { grid-column: span 2; }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-side, .g3 { grid-template-columns: 1fr 1fr; } .g-side > :first-child { grid-column: 1 / -1; } }
@media (max-width: 760px) { .g2, .g3, .g4, .g-side { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi .label a { color: inherit; }
.kpi .value { font-family: Sora, sans-serif; font-size: 25px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .hint { color: var(--muted); font-size: 12px; }
.kpi.warn .value { color: var(--bad); }
.kpi .spark { margin-top: 8px; height: 34px; }
.kpi .spark svg { display: block; width: 100%; height: 34px; overflow: visible; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 3px; font-family: Manrope, sans-serif; letter-spacing: 0; }
.delta.up { background: var(--ok-bg); color: var(--ok-fg); } .delta.down { background: var(--err-bg); color: var(--err-fg); } .delta.flat { background: var(--grey-bg); color: var(--grey-fg); }
.kpi-hero { background: linear-gradient(135deg, #0D2A5C 0%, #1E4FA0 60%, #2F86C9 100%); color: #fff; border: 0; }
.kpi-hero .label, .kpi-hero .hint { color: rgba(255,255,255,.75); }
.kpi-hero .delta.up { background: rgba(255,255,255,.18); color: #fff; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
table.t th a { color: inherit; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--hover); }
table.t .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 700; background: var(--soft); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--info-bg); color: var(--link); }
.badge.green { background: var(--ok-bg); color: var(--ok-fg); } .badge.red { background: var(--err-bg); color: var(--err-fg); }
.badge.amber { background: var(--warn-bg); color: var(--warn-fg); } .badge.grey { background: var(--grey-bg); color: var(--grey-fg); } .badge.navy { background: var(--navy); color: #fff; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: var(--input-line); text-decoration: none; background: var(--soft); }
.btn.primary { background: linear-gradient(180deg, #2459B3, var(--blue)); border-color: var(--blue); color: #fff; box-shadow: 0 4px 12px -4px rgba(30,79,160,.55); }
.btn.primary:hover { background: #193f82; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--link); box-shadow: none; }
form.inline { display: inline; margin: 0; }

label { display: block; font-weight: 700; font-size: 12.5px; margin-bottom: 4px; color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); border: 1px solid var(--input-line); border-radius: 10px; padding: 8px 11px; background: var(--input); width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok-fg); } .flash.err { background: var(--err-bg); color: var(--err-fg); } .flash.warn { background: var(--warn-bg); color: var(--warn-fg); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--link); border-bottom-color: var(--link); }
.tabs a:hover { text-decoration: none; color: var(--text); }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-weight: 600; font-size: 12.5px; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bar-chart .bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar-chart .b { width: 42%; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .b.inv { background: var(--c1); } .bar-chart .b.col2 { background: var(--c6); }
.bar-chart .m { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 2px; border-radius: 0; vertical-align: 3px; width: 14px; }
.legend i.dash { height: 0; border-top: 2px dashed; background: none !important; border-radius: 0; vertical-align: 3px; width: 14px; }
.lines-editor td { padding: 6px; }
.lines-editor input { padding: 6px 8px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.msg { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: var(--card); }
.msg.admin { background: var(--info-bg); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.msg.internal { background: var(--warn-bg); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pre { white-space: pre-wrap; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
tr.row-pending td { background: var(--warn-bg); }

/* ── Gráficos (SVG en servidor) ── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; opacity: .6; }
.chart text { fill: var(--muted); font: 600 10.5px Manrope, sans-serif; font-variant-numeric: tabular-nums; }
.chart .hx .xh { opacity: 0; transition: opacity .1s; }
.chart .hx:hover .xh { opacity: 1; }
.chart .hx rect.hit { fill: transparent; }
.chart .bar { transition: opacity .12s; }
.chart:has(.bar:hover) .bar:not(:hover) { opacity: .45; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.dash { stroke-dasharray: 4 4; stroke-width: 1.75; }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .slice { stroke: var(--card); stroke-width: 2; transition: opacity .12s; cursor: default; }
.chart:has(.slice:hover) .slice:not(:hover) { opacity: .45; }
.card { container-type: inline-size; }
.donut-wrap { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 18px; align-items: center; }
.donut-wrap .center-v { font: 700 17px Sora, sans-serif; fill: var(--text); }
.donut-wrap .center-l { font: 700 9.5px Manrope, sans-serif; fill: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.dlegend { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.dlegend li { display: grid; grid-template-columns: 12px minmax(0,1fr) auto auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.dlegend li:last-child { border-bottom: 0; }
.dlegend i { width: 10px; height: 10px; border-radius: 3px; }
.dlegend .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dlegend .v { font-variant-numeric: tabular-nums; font-weight: 700; }
.dlegend .p { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
@container (max-width: 440px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .dlegend { width: 100%; } }
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { padding: 7px 0; }
.hbars .hb { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.hbars .hb a, .hbars .hb span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hbars .hb .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbars .track { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.hbars .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--c1), var(--c6)); }
.meter { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; display: flex; gap: 2px; }
.meter > span { display: block; height: 100%; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.stat-row > div { padding: 4px 16px; border-left: 1px solid var(--line); }
.stat-row > div:first-child { border-left: 0; padding-left: 0; }
.stat-row .k { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat-row .v { font: 700 19px Sora, sans-serif; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -.01em; }
.stat-row .h { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) { .stat-row > div { border-left: 0; padding: 8px 0; border-top: 1px solid var(--line); } .stat-row > div:first-child { border-top: 0; } }
.alert-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.alert-strip a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 12.5px; color: var(--text); box-shadow: var(--shadow); }
.alert-strip a:hover { text-decoration: none; border-color: var(--sky); }
.alert-strip a b { background: var(--coral); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; }
.tabs-mini { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs-mini a { padding: 4px 11px; border-radius: 7px; font-weight: 700; font-size: 12.5px; color: var(--muted); }
.tabs-mini a.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.tabs-mini a:hover { text-decoration: none; color: var(--text); }

/* Tooltip común (gráficos y data-tip) */
#tip { position: fixed; z-index: 70; pointer-events: none; background: #0B1730; color: #EAF1FC; border-radius: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.45; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .08s; max-width: 280px; white-space: pre-line; font-variant-numeric: tabular-nums; }
#tip.on { opacity: 1; }
#tip b { color: #fff; }

/* ── Asistente ── */
.ai-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--ai-w, 440px); max-width: 100vw; background: var(--card); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 50; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
body.ai-open .ai-panel { transform: none; }
.ai-panel.wide { --ai-w: min(820px, 100vw); }
.ai-resize { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.ai-resize:hover { background: var(--sky); opacity: .5; }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ai-head .orb { width: 34px; height: 34px; border-radius: 11px; background: radial-gradient(circle at 30% 30%, #7FD4F7, var(--blue) 70%); display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; box-shadow: 0 6px 16px -6px rgba(30,79,160,.7); }
.ai-head .orb svg { width: 18px; height: 18px; }
.ai-head .t { font: 700 15px Sora, sans-serif; }
.ai-head .s { font-size: 12px; color: var(--muted); }
.ai-head .sp { flex: 1; }
.ai-head .icon-btn { width: 32px; height: 32px; }
.ai-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.ai-msg { max-width: 100%; font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--blue), #2B6CC4); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; }
.ai-msg.bot { align-self: stretch; }
.ai-msg.bot p { margin: 0 0 .6em; } .ai-msg.bot p:last-child { margin-bottom: 0; }
.ai-msg.bot ul, .ai-msg.bot ol { margin: .2em 0 .7em; padding-left: 1.3em; }
.ai-msg.bot h3, .ai-msg.bot h4 { font-size: 14px; margin: .8em 0 .4em; }
.ai-msg.bot table { border-collapse: collapse; width: 100%; font-size: 12.5px; margin: .4em 0 .8em; display: block; overflow-x: auto; }
.ai-msg.bot th, .ai-msg.bot td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; }
.ai-msg.bot th { background: var(--soft); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ai-msg.bot td.n, .ai-msg.bot th.n { text-align: right; font-variant-numeric: tabular-nums; }
.ai-msg.bot code { background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.ai-msg.bot pre { background: var(--soft); padding: 10px; border-radius: 8px; overflow-x: auto; }
.ai-msg.err { color: var(--err-fg); background: var(--err-bg); padding: 9px 12px; border-radius: 10px; }
.ai-tools { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.ai-tools span { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.ai-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sky); animation: aiblink 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiblink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-welcome { text-align: center; padding: 20px 6px 6px; }
.ai-welcome h3 { font: 700 17px Sora, sans-serif; margin: 10px 0 4px; }
.ai-welcome p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.ai-sugs { display: grid; gap: 7px; }
.ai-sugs button { text-align: left; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font: 600 13px Manrope, sans-serif; color: var(--text); cursor: pointer; }
.ai-sugs button:hover { border-color: var(--sky); background: var(--card); }
.ai-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.ai-form { display: flex; gap: 8px; align-items: flex-end; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 12px; }
.ai-form:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px var(--focus); }
.ai-form textarea { border: 0; background: transparent; min-height: 24px; max-height: 160px; padding: 6px 0; resize: none; box-shadow: none !important; }
.ai-form button { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 0; background: linear-gradient(135deg, var(--blue), var(--sky)); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.ai-form button:disabled { opacity: .45; cursor: default; }
.ai-note { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }
@media (max-width: 700px) { .ai-panel { --ai-w: 100vw; } .ai-resize { display: none; } }

/* ── Área pública / cliente ── */
.public-top { background: var(--navy); padding: 14px 20px; display: flex; align-items: center; gap: 16px; }
.public-top img { height: 30px; }
.public-top nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 12px; }
.public-top nav a { color: #cfe0f7; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.public-top nav a.on, .public-top nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.public-top .who { margin-left: auto; color: #cfe0f7; display: flex; gap: 10px; align-items: center; }
.public-top .who a { color: #fff; }
.stripe { height: 4px; background: linear-gradient(90deg, var(--blue), var(--sky)); }
.public-main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; }
.auth-box { max-width: 420px; margin: 48px auto; }
.auth-box .card { padding: 28px; }
.doc-view .doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pay-box { border: 2px solid var(--sky); }
@media (max-width: 700px) { .public-top { flex-wrap: wrap; } .public-top nav { margin-left: 0; width: 100%; order: 3; } }

@media print { .side, .side-collapse, .side-fly, .top, .ai-panel, #tip { display: none !important; } .shell { display: block; } .content { padding: 0; } }

/* ── Móvil: tablas como tarjetas (movil.js pone data-label y .t-cards) y campos a 16 px (iOS no hace zoom) ── */
@media (max-width: 700px) {
  table.t-cards, table.t-cards > tbody, table.t-cards > tfoot { display: block; width: 100%; }
  table.t-cards > thead { display: none; }
  table.t-cards > tbody > tr { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line); }
  table.t-cards > tbody > tr:last-child { border-bottom: 0; }
  table.t-cards > tbody > tr > td { display: block; padding: 3px 0; border: 0; text-align: right; background: none !important; overflow-wrap: anywhere; }
  table.t-cards > tbody > tr > td[data-label]::before { content: attr(data-label); float: left; margin-right: 14px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  table.t-cards > tbody > tr > td.t-title { text-align: left; font-weight: 600; padding-bottom: 6px; }
  table.t-cards > tbody > tr > td.t-title::before { content: none; }
  table.t-cards > tbody > tr > td[colspan] { text-align: left; }
  table.t-cards > tbody > tr > td:empty { display: none; }
  table.t-cards > tfoot > tr { display: flex; justify-content: space-between; gap: 14px; padding: 7px 16px; background: var(--soft); }
  table.t-cards > tfoot > tr > td { padding: 0; border: 0; background: none; }
  table.t-cards > tfoot > tr > td:empty { display: none; }
}
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
