/* Layout: app de panel con barra lateral fija en escritorio y pestañas arriba en móvil; cada vista es una columna de 72rem */
/* Marca kobi.es: azul marino #1E3A5F + cian #00B4D8 sobre gris muy claro; Plus Jakarta Sans + Inter. Barra lateral marina, contenido claro. */
:root {
  --bg: #F8FAFC; --surface: #ffffff; --surface-2: #F1F5F9; --ink: #1E2A38; --muted: #4A5568; --faint: #94A3B8; --line: #E2E8F0;
  --navy: #1E3A5F; --navy-2: #24466F; --on-navy: #ffffff; --on-navy-muted: rgba(255,255,255,.68);
  --cyan: #00B4D8; --accent: #007C99; --accent-ink: #ffffff; --accent-soft: #E6F7FB;
  --ok: #15803D; --ok-soft: #E8F6EE; --warn: #A16207; --warn-soft: #FDF4DC; --bad: #C2413A; --bad-soft: #FDECEA; --info: #1E5FA8; --info-soft: #E8F0FB;
  --series-1: #0096B8; --series-2: #D97300;
  --shadow-sm: 0 1px 3px rgba(30,58,95,.07), 0 1px 2px rgba(30,58,95,.05);
  --shadow: 0 4px 16px rgba(30,58,95,.09), 0 1px 4px rgba(30,58,95,.06);
  --radius: 14px;
  --font-display: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1826; --surface: #16263D; --surface-2: #1D3150; --ink: #E7EDF5; --muted: #A3B1C4; --faint: #6E809A; --line: #263C5C;
    --navy: #0A1422; --navy-2: #132238; --on-navy: #ffffff; --on-navy-muted: rgba(255,255,255,.62);
    --cyan: #22C3E6; --accent: #3CC8E8; --accent-ink: #0A1422; --accent-soft: #123A4E;
    --ok: #5FCB8A; --ok-soft: #14352A; --warn: #E8B45A; --warn-soft: #3A2E14; --bad: #F28B82; --bad-soft: #43201F; --info: #8DB8F0; --info-soft: #1B2D4A;
    --series-1: #1BA3C4; --series-2: #C27A12;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.35); --shadow: 0 4px 16px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1826; --surface: #16263D; --surface-2: #1D3150; --ink: #E7EDF5; --muted: #A3B1C4; --faint: #6E809A; --line: #263C5C;
  --navy: #0A1422; --navy-2: #132238; --on-navy: #ffffff; --on-navy-muted: rgba(255,255,255,.62);
  --cyan: #22C3E6; --accent: #3CC8E8; --accent-ink: #0A1422; --accent-soft: #123A4E;
  --ok: #5FCB8A; --ok-soft: #14352A; --warn: #E8B45A; --warn-soft: #3A2E14; --bad: #F28B82; --bad-soft: #43201F; --info: #8DB8F0; --info-soft: #1B2D4A;
  --series-1: #1BA3C4; --series-2: #C27A12;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35); --shadow: 0 4px 16px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* `hidden` oculta siempre, aunque la clase del elemento fije un display (p. ej. .check es inline-flex). */
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.98rem; }
p { margin: 0; }
.num, td.n, .tab { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.82em; }
.muted { color: var(--muted); }

/* Estructura */
.app { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: env(safe-area-inset-top, 0px); align-self: start; height: 100vh; border-right: 1px solid var(--line); background: var(--surface); padding: 20px 14px calc(20px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.brand strong { font-family: var(--font-display); font-size: 1.15rem; display: block; line-height: 1.1; }
.brand span { font-size: 0.75rem; color: var(--muted); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav .badge { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.nav .badge.alert { background: var(--bad-soft); color: var(--bad); }
.side .foot { margin-top: auto; font-size: 0.78rem; color: var(--muted); padding: 0 8px; display: grid; gap: 4px; }
main { min-width: 0; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.view { max-width: 110rem; margin: 0 auto; display: grid; gap: 22px; }
.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; }
.view-head .sub { color: var(--muted); margin-top: 4px; }
.crumb { font-size: 0.85rem; }

/* Bloques */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; gap: 12px; min-width: 0; align-content: start; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-head a { font-size: 0.88rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 4px; }
.kpi .label { font-size: 0.82rem; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .note { font-size: 0.8rem; color: var(--muted); }
.kpi.bad .value { color: var(--bad); }
.alert-bar { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--bad); background: var(--bad-soft); border-radius: 12px; padding: 12px 16px; }
.alert-bar .icon { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--bad); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; }
.alert-bar strong { display: block; }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
tr.sub-row td:first-child { padding-left: 26px; }
.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Estados */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.notified { background: var(--info-soft); color: var(--info); }
.pill.invoiced { background: var(--accent-soft); color: var(--accent); }
.pill.paid, .pill.active, .pill.completed { background: var(--ok-soft); color: var(--ok); }
.pill.overdue, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.cancelled, .pill.ended, .pill.archived { background: var(--surface-2); color: var(--muted); }
.tag { font-family: var(--font-mono); font-size: 0.72rem; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.days { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.days.bad { color: var(--bad); font-weight: 600; }
.days.soon { color: var(--warn); font-weight: 600; }

/* Controles */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: none; background: none; padding: 6px 12px; cursor: pointer; font-size: 0.88rem; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.search { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 6px 12px; min-width: 0; width: 16rem; max-width: 100%; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 0.84rem; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.84rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 2px; border-radius: 1px; vertical-align: 3px; width: 16px; }
.legend i.dash { height: 0; border-top: 2px dashed var(--muted); background: none; width: 16px; vertical-align: 3px; }

/* Listas */
.rows { display: grid; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.row:last-child { border-bottom: none; }
.row .t { font-weight: 600; min-width: 0; }
.row .s { font-size: 0.84rem; color: var(--muted); grid-column: 1; }
.row .r { text-align: right; grid-row: 1 / span 2; grid-column: 2; display: grid; gap: 2px; justify-items: end; }
.empty { color: var(--muted); padding: 10px 0; }
details.rev { border-top: 1px solid var(--line); }
details.rev:first-of-type { border-top: none; }
details.rev summary { cursor: pointer; padding: 10px 0; display: flex; justify-content: space-between; gap: 10px; font-weight: 600; list-style: none; }
details.rev summary::-webkit-details-marker { display: none; }
details.rev summary::before { content: "▸"; color: var(--muted); margin-right: 8px; transition: transform .15s; display: inline-block; }
details.rev[open] summary::before { transform: rotate(90deg); }
details.rev summary .left { display: flex; flex: 1; min-width: 0; }
details.rev ul { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 5px; color: var(--muted); font-size: 0.9rem; }
.kv { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 6px 12px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Gráficos */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--font-body); font-size: 11px; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--ink); stroke-width: 1; opacity: .6; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem; box-shadow: 0 4px 14px rgb(0 0 0 / .12); min-width: 11rem; z-index: 5; }
.tip strong { display: block; margin-bottom: 4px; }
.tip .l { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.tip .l i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 0.9rem; z-index: 20; max-width: calc(100vw - 32px); }
.proto { font-size: 0.78rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; height: auto; flex-direction: column; gap: 10px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); border-right: none; border-bottom: 1px solid var(--line); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 11; background: var(--surface); }
  .nav { grid-auto-flow: column; overflow-x: auto; gap: 4px; margin: 0 -4px; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .side .foot { display: none; }
  main { padding-block: 18px 56px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .search { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Marca kobi.es ---------- */
body { font-size: 14.5px; letter-spacing: -0.003em; }
h1, h2, h3 { letter-spacing: -0.015em; font-weight: 700; }
h1 { font-size: 1.7rem; font-weight: 800; }
.side { background: var(--navy); border-right: none; color: var(--on-navy); }
.brand .mark { background: none; width: 34px; height: 34px; }
.brand .mark svg { width: 34px; height: 34px; display: block; }
.brand strong { color: var(--on-navy); font-weight: 800; letter-spacing: -0.02em; }
.brand span { color: var(--on-navy-muted); }
.nav a { color: var(--on-navy-muted); font-weight: 600; border-radius: 10px; }
.nav a:hover { background: rgba(255,255,255,.07); color: var(--on-navy); }
.nav a[aria-current="page"] { background: rgba(0,180,216,.18); color: var(--on-navy); box-shadow: inset 3px 0 0 var(--cyan); }
.nav .badge { background: rgba(255,255,255,.12); color: var(--on-navy); }
.nav .badge.alert { background: #F87171; color: #fff; }
.side .foot { color: var(--on-navy-muted); border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; gap: 8px; }
.side .foot .btn { background: transparent; color: var(--on-navy); border-color: rgba(255,255,255,.25); }
.side .foot .btn:hover { border-color: var(--cyan); color: var(--cyan); }
.side .foot #sync-btn { background: var(--cyan); border-color: var(--cyan); color: #0A1422; }
.side .foot #sync-btn:hover { filter: brightness(1.08); color: #0A1422; }
.side .foot #sync-btn:disabled { opacity: .7; cursor: progress; }
.panel, .kpi { border-radius: var(--radius); box-shadow: var(--shadow-sm); border-color: var(--line); }
.kpi { gap: 6px; padding: 16px 18px; }
.kpi .label { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.kpi .value { font-weight: 800; font-size: 1.7rem; letter-spacing: -0.02em; }
.btn { border-radius: 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.seg { border-radius: 10px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.search { border-radius: 10px; }
th { color: var(--faint); font-size: 0.72rem; }
.alert-bar { border-radius: var(--radius); }

/* Cabecera de Inicio: el único degradado de la marca */
.hero { background: linear-gradient(135deg, #1E3A5F 0%, #0F6E8C 55%, #00B4D8 100%); color: #fff; border-radius: 18px; padding: 24px 26px; display: grid; gap: 16px; box-shadow: var(--shadow); }
.hero h1 { color: #fff; font-size: 1.9rem; }
.hero .sub { color: rgba(255,255,255,.82); }
.hero .kpis { gap: 10px; }
.hero .kpi { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); box-shadow: none; backdrop-filter: blur(2px); }
.hero .kpi .label { color: rgba(255,255,255,.72); }
.hero .kpi .value { color: #fff; }
.hero .kpi .note { color: rgba(255,255,255,.72); }
.hero .kpi.bad .value { color: #FFC9C4; }
.hero .alert-bar { background: rgba(0,0,0,.18); border-color: rgba(255,201,196,.55); color: #fff; }
.hero .alert-bar .muted { color: rgba(255,255,255,.8); }
.hero .alert-bar a { color: #9BE7F7; font-weight: 600; }
.hero .alert-bar .icon { background: #F87171; color: #fff; }

@media (max-width: 760px) {
  .side { border-bottom: none; }
  body::before { background: var(--navy); }
  .hero { padding: 18px; border-radius: 14px; }
}

.tag.sepa { background: var(--info-soft); color: var(--info); font-weight: 600; }
.sub-h { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* Formularios */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: grid; gap: 5px; font-weight: 600; font-size: 0.88rem; min-width: 0; }
.field small { font-weight: 400; }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 11px; width: 100%; min-width: 0; font-weight: 400; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: var(--bad); background: var(--bad-soft); border-radius: 10px; padding: 8px 12px; }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 18rem); gap: 6px 24px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: none; }
.setting-label { font-weight: 600; }
.setting .muted { font-size: 0.85rem; margin-top: 2px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
tr.muted-row td { opacity: .6; }
@media (max-width: 760px) {
  .form-grid, .setting { grid-template-columns: minmax(0, 1fr); }
}

/* Tablas ordenables */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: .9em; }
th.sortable[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
th.sortable[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Ventas */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; min-width: 0; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 2px 4px 4px; }
.col-head h3 { font-size: .9rem; }
.opp { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); box-shadow: var(--shadow-sm); }
.opp:hover { border-color: var(--accent); text-decoration: none; }
.opp .muted, .opp-next { font-size: .82rem; }
.opp .tag { justify-self: start; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; }
.stage { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.stage.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stage:disabled { cursor: default; opacity: .6; }
.btn.primary.armed { background: var(--ok); border-color: var(--ok); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { border-left: 2px solid var(--line); padding-left: 12px; display: grid; gap: 2px; }
textarea.input { resize: vertical; font: inherit; }
a.row { color: inherit; } a.row:hover { text-decoration: none; background: var(--surface-2); }
@media (max-width: 980px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .board { grid-template-columns: minmax(0, 1fr); } }
.opp[draggable="true"] { cursor: grab; }
.opp.dragging { opacity: .45; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }

/* Revisión A/B/C */
.rev-items { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.rev-items li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.rev-items li.decided { background: var(--surface-2); }
.rev-items li p { color: var(--ink); font-size: .92rem; }
.rev-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.choice { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px; cursor: pointer; font-size: .84rem; color: var(--muted); }
.choice b { color: var(--accent); }
.choice.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice.on b { color: var(--accent-ink); }
.choice:disabled { cursor: default; }
.rev-note { flex: 1 1 14rem; padding: 5px 10px; font-size: .86rem; }

/* Catálogo editable */
tr.edit-row td { background: var(--surface-2); padding: 16px; }
.editor { display: grid; gap: 14px; }
.editor h3 { margin-bottom: 8px; }
table.mini { font-size: .86rem; }
table.mini th { font-size: .7rem; }

/* Botones de icono */
.btn.icon { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 10px; color: var(--muted); }
.btn.icon:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn.icon:disabled { opacity: .5; cursor: progress; }
.btn.icon svg { display: block; }
.tag.notice { background: var(--warn-soft); color: var(--warn); font-weight: 600; }

/* Ventana de correo */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgb(14 24 38 / .45); display: grid; place-items: start center; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.modal { width: 100%; max-width: 44rem; box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.modal textarea { font: inherit; line-height: 1.5; }
.chips .tag { cursor: pointer; border: none; }
.chips .tag:hover { background: var(--accent-soft); color: var(--accent); }

/* Descuentos */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; padding: 12px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.inline-form .field { flex: 1 1 14rem; }
fieldset.checks { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset.checks legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }

/* Enlace a Holded junto al número de factura */
a.ext { text-decoration: none; font-size: .85em; color: var(--muted); }
a.ext:hover { color: var(--accent); }

/* Historial del cliente */
.hist { display: grid; gap: 0; margin-top: 12px; }
.hist-entry { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.hist-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .85rem; }
.hist-remind { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .88rem; }

/* Prueba de correo: resultado correcto */
.alert-bar.ok-bar { border-color: var(--ok); background: var(--ok-soft); }
.alert-bar.ok-bar .icon { background: var(--ok); }

/* Mi cuenta */
.sig-preview { width: 100%; min-height: 140px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.side .foot a.me-link { color: inherit; text-decoration: none; }
.side .foot a.me-link:hover { text-decoration: underline; }

/* Responsive: pantallas grandes aprovechan el ancho; en el móvil las tablas pasan a tarjetas. */
@media (min-width: 1200px) { main { padding-left: 32px; padding-right: 32px; } }
.chips .tag, .kv dd .tag { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .table-wrap { overflow: visible; margin: 0; }
  .table-wrap table { min-width: 0 !important; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table-wrap tbody tr:last-child { border-bottom: none; }
  .table-wrap td { display: block; padding: 3px 0; border: none; text-align: right; overflow-wrap: anywhere; }
  .table-wrap td::after { content: ""; display: block; clear: both; }
  .table-wrap td::before { content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; color: var(--muted); font-size: 0.8rem; line-height: 1.6; text-align: left; }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td:first-child { display: block; text-align: left; font-size: 1rem; }
  .table-wrap td:first-child::before { content: none; }
  .table-wrap td:not([data-label]) { text-align: left; }
  .table-wrap td .actions { justify-content: flex-start; flex-wrap: wrap; }
  .table-wrap tr.sub-row { padding-left: 14px; border-left: 3px solid var(--line); }
}

/* Gráficos: el texto del SVG escala con el ancho. En grande se limita; en el móvil se desplazan de lado. */
.chart.hbar { max-width: 900px; }
.chart svg { max-height: 340px; }
@media (max-width: 760px) {
  .chart:not(.hbar) { overflow-x: auto; overscroll-behavior-x: contain; }
  .chart:not(.hbar) svg { min-width: 640px; }
  .chart.hbar svg { min-width: 0; }
}
details.rev ul.rev-items { padding-left: 0; color: inherit; font-size: inherit; }
