/* Gestión San Carlos — estilos de la interfaz */

@font-face { font-family: "Catamaran"; src: url(fonts/catamaran-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url(fonts/catamaran-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url(fonts/catamaran-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url(fonts/catamaran-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url(fonts/titillium-web-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url(fonts/titillium-web-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url(fonts/titillium-web-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #0F3764;
  --ink-2: #184677;
  --ink-3: #24578E;
  --text: #1B2633;
  --muted: #586474;
  --faint: #8792A0;
  --paper: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --line: #DAE1EA;
  --line-strong: #C2CCD8;
  --cobre: #325FA4;
  --cobre-dark: #0F3764;
  --cobre-light: #5D95D0;
  --cobre-tint: #E3ECF8;
  --senal: #1C7FC4;
  --senal-tint: #E1F0FA;
  --ok: #2B7A4B;
  --ok-tint: #E2F0E7;
  --warn: #9A5F0C;
  --warn-tint: #FBEFD9;
  --bad: #B42318;
  --bad-tint: #FBE5E3;
  --radius-sm: 6px;
  --radius: 10px;
  --font: "Catamaran", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-cond: "Titillium Web", "Catamaran", system-ui, sans-serif;
  --sidebar-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--paper); font-variant-numeric: tabular-nums; }
a { color: var(--senal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-cond); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: 0.005em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--senal); outline-offset: 2px; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.small { font-size: 13px; }

/* ------------------------------------------------------------ Estructura */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, #0F3764 0%, #143F72 55%, #1B4C86 100%); color: #D7DFEA; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-logo { width: 148px; height: auto; display: block; }
.brand-sub { font-family: var(--font-cond); font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase; color: #9DB6D6; font-weight: 600; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; background: var(--ink-2); display: grid; place-items: center; flex: none; }
.brand-mark svg, .login-mark svg { width: 20px; height: 20px; fill: var(--cobre-light); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-family: var(--font-cond); font-size: 15.5px; font-weight: 600; color: #fff; line-height: 1.15; }
.brand-text small { color: #98A0A7; font-size: 12.5px; }
.nav { padding: 10px 10px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group-title { font-family: var(--font-cond); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: #8FA9CB; padding: 6px 10px 4px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 6px; color: #CDD2D6; font-weight: 500; position: relative; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #7FB6EA; }
.nav a .i { color: #9FB4CF; }
.nav a.active .i { color: #9CCBF5; }
.nav .count { margin-left: auto; font-size: 12px; background: var(--ink-3); color: #fff; border-radius: 10px; padding: 0 7px; min-width: 22px; text-align: center; }
.nav .count.hot { background: var(--cobre); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 12px 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot form { margin: 0; }
.me { flex: 1; min-width: 0; color: #E3E6E9; display: flex; flex-direction: column; line-height: 1.25; }
.me:hover { text-decoration: none; color: #fff; }
.me strong { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: #9DB6D6; font-size: 12.5px; }
.sidebar .btn-icon { color: #AEB5BB; }
.sidebar .btn-icon:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.topbar-title h1 { font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .025em; color: var(--ink); }
.topbar-title .crumb { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .menu-toggle { display: none; }
.view { padding: 24px 28px 48px; max-width: 1360px; width: 100%; outline: none; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.scrim { display: none; }

/* ------------------------------------------------------------ Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 8px; font-family: var(--font-cond); letter-spacing: .01em; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: #AEB5B0; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .i { width: 17px; height: 17px; }
.btn-primary { background: var(--cobre); border-color: var(--cobre); color: #fff; }
.btn-primary:hover { background: var(--cobre-dark); border-color: var(--cobre-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); border-color: var(--ink-3); }
.btn-danger { color: var(--bad); border-color: #E3B4AF; }
.btn-danger:hover { background: var(--bad-tint); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ Paneles y grillas */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; gap: 8px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head > .btn-group { flex-wrap: wrap; justify-content: flex-end; }
.panel-head h2 { font-size: 17px; flex: 1; color: var(--ink); }
.panel-head .hint { color: var(--muted); font-size: 13.5px; }
.panel-body { padding: 16px 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.grid-detail > .col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.grid-detail > .col > .panel + .panel { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.grid-cards > .panel + .panel { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* Tira de indicadores: un solo bloque dividido, no tarjetas sueltas */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.strip > a, .strip > div { padding: 14px 18px; border-left: 1px solid var(--line); color: inherit; display: block; min-width: 0; }
.strip > :first-child { border-left: 0; }
.strip > a:hover { background: var(--surface-2); text-decoration: none; }
.strip .lbl { color: var(--muted); font-size: 13.5px; }
.strip .val { font-family: var(--font-cond); font-size: 27px; font-weight: 600; line-height: 1.15; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .sub { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ Filtros */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search { position: relative; min-width: 240px; flex: 1; max-width: 420px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 36px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 0 11px; height: 32px; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button.on { background: var(--cobre); color: #fff; }
.seg button .n { font-size: 12px; opacity: .75; margin-left: 4px; }

/* ------------------------------------------------------------ Formularios */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 12.5px; color: var(--faint); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], input[type=tel], input:not([type]), select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.search input[type=search] { padding-left: 36px; }
input:focus, select:focus, textarea:focus { border-color: var(--senal); box-shadow: 0 0 0 3px var(--senal-tint); }
input[readonly] { background: var(--surface-2); }
input.num, .num input { text-align: right; }
select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B636B' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--cobre); margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-family: var(--font-cond); font-weight: 600; font-size: 17px; margin-bottom: 8px; padding: 0; }

/* ------------------------------------------------------------ Tablas */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.t th:first-child { border-top-left-radius: var(--radius); }
.t th:last-child { border-top-right-radius: var(--radius); }
.t th.num { text-align: right; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #FAFBFA; }
.t td .sub { color: var(--muted); font-size: 13px; }
.t td.actions { text-align: right; white-space: nowrap; width: 1%; }
.t td.check-col, .t th.check-col { width: 36px; padding-right: 0; }
.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.t .cell-main { font-weight: 600; }
.panel > .table-wrap .t th { background: var(--surface-2); }
.panel-head + .table-wrap .t th:first-child, .panel-head + .table-wrap .t th:last-child { border-radius: 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; font-weight: 600; }
.empty .btn { margin-top: 12px; }
.pager { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------ Estados */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px; border-radius: 12px; font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.b-ok { background: var(--ok-tint); color: var(--ok); border-color: #BFDCC9; }
.b-warn { background: var(--warn-tint); color: var(--warn); border-color: #EBCF9C; }
.b-bad { background: var(--bad-tint); color: var(--bad); border-color: #EDB9B3; }
.b-info { background: #E2F3FB; color: #0B6E99; border-color: #B5DCEE; }
.b-cobre { background: var(--cobre-tint); color: #23508F; border-color: #BCD0EC; }
.b-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.prio-alta { color: var(--bad); font-weight: 600; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin: 0 0 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert .i { margin-top: 2px; }
.alert-info { background: var(--senal-tint); border-color: #BCD0EA; color: #183F6E; }
.alert-ok { background: var(--ok-tint); border-color: #BFDCC9; color: #1E5634; }
.alert-warn { background: var(--warn-tint); border-color: #EBCF9C; color: #6E4408; }
.alert-error { background: var(--bad-tint); border-color: #EDB9B3; color: #8A1A12; }
.alert .grow { flex: 1; }

/* ------------------------------------------------------------ Línea del pedido (conductor con bornes) */
.track { --done: var(--cobre); --todo: var(--line-strong); display: grid; grid-template-columns: repeat(5, 1fr); position: relative; padding: 4px 0 0; }
.track .step { position: relative; text-align: center; padding-top: 30px; min-width: 0; }
.track .step::before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 3px; background: var(--todo); }
.track .step:first-child::before { display: none; }
.track .step.done::before, .track .step.current::before { background: var(--done); }
.track .node { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 25px; height: 25px; border-radius: 50%; background: var(--surface); border: 3px solid var(--todo); display: grid; place-items: center; z-index: 1; }
.track .node::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--todo); }
.track .step.done .node { border-color: var(--done); background: var(--done); }
.track .step.done .node::after { background: #fff; }
.track .step.current .node { border-color: var(--done); box-shadow: 0 0 0 5px var(--cobre-tint); }
.track .step.current .node::after { background: var(--done); width: 9px; height: 9px; }
.track .step.alert .node { border-color: var(--bad); box-shadow: 0 0 0 5px var(--bad-tint); }
.track .step.alert .node::after { background: var(--bad); }
.track .lbl { font-family: var(--font-cond); font-weight: 700; font-size: 14.5px; display: block; }
.track .step.todo .lbl { color: var(--faint); font-weight: 500; }
.track .meta { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; padding: 0 4px; }
.track.cancelled { --done: var(--faint); }
.track.cancelled .step.current .node { box-shadow: none; }
/* Versión mini para listados */
.mini-track { display: inline-flex; align-items: center; gap: 0; vertical-align: middle; }
.mini-track i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: block; }
.mini-track b { width: 12px; height: 2px; background: var(--line-strong); display: block; }
.mini-track i.d { background: var(--cobre); border-color: var(--cobre); }
.mini-track b.d { background: var(--cobre); }
.mini-track i.c { border-color: var(--cobre); background: var(--surface); box-shadow: 0 0 0 3px var(--cobre-tint); }
.mini-track i.x { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-tint); }
.mini-track.cancel i, .mini-track.cancel b { opacity: .35; }
.stage-cell { display: inline-flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.stage-cell .stage-name { font-size: 13.5px; font-weight: 500; }

/* Medidor de cobro */
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); }
.meter.partial > span { background: var(--warn); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv dd.left { text-align: left; }
.totals-box { margin-left: auto; width: min(100%, 360px); }
.totals-box .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; }
.totals-box .row.grand { border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 10px; font-family: var(--font-cond); font-size: 22px; font-weight: 600; }
.totals-box input, .totals-box select { width: 92px; height: 32px; }

/* Lista de pendientes */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li a { display: grid; grid-template-columns: 4px 1fr auto; gap: 14px; align-items: center; padding: 11px 18px 11px 0; border-bottom: 1px solid var(--line); color: inherit; }
.todo-list li:last-child a { border-bottom: 0; }
.todo-list li a:hover { background: var(--surface-2); text-decoration: none; }
.todo-list .lvl { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--line-strong); }
.todo-list .lvl.alto { background: var(--bad); }
.todo-list .lvl.medio { background: var(--warn); }
.todo-list .lvl.bajo { background: var(--ok); }
.todo-list .t-type { font-size: 12.5px; color: var(--muted); }
.todo-list .t-title { font-weight: 600; }
.todo-list .t-detail { font-size: 13.5px; color: var(--muted); }
.todo-list .i { color: var(--faint); }

/* Línea de negocio en el panel */
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); }
.pipeline a { padding: 16px 18px 14px; color: inherit; border-left: 1px solid var(--line); position: relative; }
.pipeline a:first-child { border-left: 0; }
.pipeline a:hover { background: var(--surface-2); text-decoration: none; }
.pipeline .p-n { font-family: var(--font-cond); font-size: 32px; font-weight: 600; line-height: 1; }
.pipeline .p-l { color: var(--muted); font-size: 14px; margin-top: 4px; }
.pipeline .wire { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--line); }
.pipeline a.has .wire { background: var(--cobre); }

/* Historial */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.hl::before { background: var(--cobre); }
.timeline .tl-text { font-size: 14px; }
.timeline .tl-meta { font-size: 12.5px; color: var(--muted); }

/* Editor de ítems */
.items-editor { width: 100%; border-collapse: collapse; }
.items-editor th { font-size: 13px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 6px 6px; white-space: nowrap; }
.items-editor td { padding: 4px 6px; vertical-align: top; }
.items-editor td:first-child, .items-editor th:first-child { padding-left: 0; }
.items-editor td.desc { width: 44%; }
.items-editor .w-qty { width: 92px; }
.items-editor .w-unit { width: 64px; }
.items-editor .w-price { width: 130px; }
.items-editor .w-pct { width: 72px; }
.items-editor .w-orig { width: 120px; }
.items-editor .line-total { padding-top: 13px; text-align: right; font-weight: 600; white-space: nowrap; }
.items-editor .stock-hint { font-size: 12.5px; margin-top: 3px; }
.items-editor .stock-hint.ok { color: var(--ok); }
.items-editor .stock-hint.warn { color: var(--warn); }
.items-editor .stock-hint.bad { color: var(--bad); }
.items-editor tbody tr { border-bottom: 1px dashed var(--line); }

/* Autocompletar */
.ac { position: relative; }
.ac-list { position: fixed; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 10px 28px rgba(29, 33, 37, .18); z-index: 1100; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.ac-prod { display: flex; gap: 8px; align-items: baseline; }
.ac-code { flex: none; font-weight: 700; font-size: 13px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.ac-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-list button:last-child { border-bottom: 0; }
.ac-list button:hover, .ac-list button.hl { background: var(--senal-tint); }
.ac-list .ac-sub { font-size: 12.5px; color: var(--muted); }
.ac-list .ac-empty { padding: 9px 11px; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------ Diálogos y avisos */
.overlay { position: fixed; inset: 0; background: rgba(29, 33, 37, .48); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .12s ease-out; }
.dialog { background: var(--surface); border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); display: flex; flex-direction: column; animation: rise .16s ease-out; }
.dialog.lg { max-width: 820px; }
.dialog.xl { max-width: 1080px; }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 19px; flex: 1; }
.dialog-body { padding: 18px 20px 6px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 10px 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 7px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); max-width: 380px; display: flex; gap: 10px; align-items: flex-start; animation: rise .16s ease-out; }
.toast.err { background: var(--bad); }
.toast.ok .i { color: #8FD3A8; }
.secret { font-family: var(--font-cond); font-size: 26px; letter-spacing: .06em; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 10px 14px; text-align: center; user-select: all; }

/* ------------------------------------------------------------ Encabezado de ficha */
.doc-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.doc-head .who { flex: 1; min-width: 240px; }
.doc-head .who .client { font-family: var(--font-cond); font-size: 26px; font-weight: 600; line-height: 1.15; }
.doc-head .who .client a { color: inherit; }
.doc-head .who .meta { color: var(--muted); margin-top: 3px; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.doc-head .amount { text-align: right; }
.doc-head .amount .v { font-family: var(--font-cond); font-size: 30px; font-weight: 600; line-height: 1.1; }
.doc-head .amount .l { color: var(--muted); font-size: 13.5px; }
.actionbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.actionbar .grow { flex: 1; }
.actionbar .next-hint { color: var(--muted); font-size: 14px; }

/* Reportes */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 190px; padding: 6px 0 0; }
.bars .bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; min-width: 0; }
.bars .bar { cursor: pointer; }
.bars .bar span { display: block; width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--cobre); min-height: 2px; }
.bars .bar.cur span { background: var(--ink); }
.bars-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
.hbar { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.hbar .track-h { height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.hbar .track-h span { display: block; height: 100%; background: var(--cobre); }
.hbar .track-h span.alt { background: var(--warn); }
.hbar .track-h span.bad { background: var(--bad); }

/* ------------------------------------------------------------ Ingreso e instalación */
.login-body { background: var(--paper); }
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.login-brand { background: linear-gradient(120deg, #0F3764 0%, #1B4C86 60%, #325FA4 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-mark { width: 54px; height: 54px; border-radius: 12px; background: var(--ink-2); display: grid; place-items: center; margin-bottom: 26px; }
.login-mark svg { width: 30px; height: 30px; }
.login-logo { width: min(320px, 70%); height: auto; display: block; margin-bottom: 18px; }
.login-company { font-family: var(--font-cond); font-size: 14px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase; color: #A9C6EA; margin: 0 0 22px; }
.login-tag { color: #D3E1F2; font-size: 18px; margin: 0; max-width: 32ch; }
.login-wire { position: absolute; left: 0; right: 0; bottom: 64px; width: 100%; height: 60px; }
.login-wire path { stroke: #7FB6EA; stroke-width: 3; fill: none; opacity: .7; }
.login-wire circle { fill: #183F70; stroke: #7FB6EA; stroke-width: 3; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 80px); max-width: 520px; width: 100%; }
.login-panel h1 { font-size: 28px; margin-bottom: 20px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink); }
.login-panel .btn-block { height: 44px; margin-top: 6px; font-size: 16px; }
.login-help { color: var(--muted); font-size: 14px; margin-top: 18px; }
.install { max-width: 760px; margin: 0 auto; padding: 40px 20px 60px; }
.install h1 { font-size: 30px; margin-bottom: 18px; }
.install-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.install .hint { color: var(--muted); margin: -2px 0 12px; font-size: 14px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.checks .ok { color: var(--ok); }
.checks .no { color: var(--bad); font-weight: 600; }
.install-steps li { margin-bottom: 8px; }

/* ------------------------------------------------------------ Celular */
@media (max-width: 1100px) {
  .grid-detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .2s ease-out; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(29, 33, 37, .45); z-index: 25; }
  .topbar .menu-toggle { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 8px 14px; min-height: 58px; gap: 8px; }
  .topbar-title h1 { font-size: 20px; }
  .topbar-actions .btn .lbl-long { display: none; }
  .view { padding: 16px 14px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .pipeline a:nth-child(3) { border-left: 0; }
  .pipeline a:nth-child(n+3) { border-top: 1px solid var(--line); }
  .search { max-width: none; min-width: 0; flex-basis: 100%; }
  .seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .doc-head .amount { text-align: left; }
  .track .lbl { font-size: 11.5px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
  .track .meta { display: none; }
  .track .step.current .meta { display: block; }
  /* Tablas como filas apiladas */
  .t.stackable thead { display: none; }
  .t.stackable, .t.stackable tbody, .t.stackable tr, .t.stackable td { display: block; width: 100%; }
  .t.stackable tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .t.stackable tbody tr:last-child { border-bottom: 0; }
  .t.stackable td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .t.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .t.stackable td > .cell { min-width: 0; }
  .t.stackable td:not(.cell-first) .stage-cell { align-items: flex-end; }
  .t.stackable td.cell-first { text-align: left; display: block; padding-bottom: 4px; }
  .t.stackable td.cell-first::before { display: none; }
  .t.stackable td.actions { width: 100%; justify-content: flex-end; padding-top: 6px; }
  .t.stackable td.actions::before { display: none; }
  .t.stackable td.check-col { width: auto; }
  .t.stackable td:empty { display: none; }
  .items-editor thead { display: none; }
  .items-editor, .items-editor tbody, .items-editor tr { display: block; }
  .items-editor tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px 0; }
  .items-editor td { padding: 0; min-width: 0; }
  .items-editor td input, .items-editor td select { width: 100%; min-width: 0; }
  .items-editor td.desc { grid-column: 1 / -1; width: auto; }
  .items-editor td.line-total { grid-column: 1 / 3; text-align: left; padding-top: 4px; }
  .items-editor td.del { text-align: right; }
  .items-editor td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  .items-editor .w-qty, .items-editor .w-unit, .items-editor .w-price, .items-editor .w-pct, .items-editor .w-orig { width: 100%; min-width: 0; }
  .overlay { padding: 0; align-items: flex-start; }
  .dialog, .dialog.lg, .dialog.xl { max-width: none; border-radius: 0; min-height: 100%; }
  .dialog-foot { border-radius: 0; position: sticky; bottom: 0; }
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 30px 24px 70px; }
  .login-logo { width: 220px; }
  .login-wire { bottom: 10px; }
  #toast-root { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .hbar { grid-template-columns: 96px 1fr auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .actionbar { display: none !important; }
  .shell { display: block; }
}
.brand:hover { text-decoration: none; }

/* ------------------------------------------------------------ Presupuestos en tarjetas (formato panel de Consultas) */
.leads-view { max-width: 980px; }
.chips-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.chip { height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; }
.chip:hover { border-color: var(--cobre); color: var(--cobre); }
.chip.on { background: var(--cobre); border-color: var(--cobre); color: #fff; }
.chip-warn { border-color: #E3B868; color: #8A5A08; background: #FFF8EA; }
.chip-warn.on { background: #C98A16; border-color: #C98A16; color: #fff; }
.chip-select { width: auto; height: 32px; border-radius: 16px; font-size: 14px; }
.lead-list { display: flex; flex-direction: column; gap: 14px; }
.lead-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; position: relative; }
.lead-card.hot { border-left: 4px solid var(--cobre); }
.lead-card.due { box-shadow: inset 0 0 0 1px #E8B04A; }
.lead-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; }
.lead-who { min-width: 0; }
.lead-name { font-family: var(--font-cond); font-weight: 700; font-size: 19px; color: var(--ink); line-height: 1.2; display: inline-block; }
.lead-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.lead-amount { font-family: var(--font-cond); font-weight: 700; font-size: 20px; color: var(--text); white-space: nowrap; }
.origin-tag { font-family: var(--font-cond); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--cobre); background: var(--cobre-tint); border: 1px solid #BCD0EC; border-radius: 12px; padding: 3px 10px; white-space: nowrap; }
.lead-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kchip { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; }
.kchip strong { color: var(--text); font-weight: 600; }
.kchip-alert { background: #FFF5E0; border-color: #EBC57A; color: #8A5A08; font-weight: 600; }
.lead-box { margin-top: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 14.5px; }
.lead-box-lbl { font-family: var(--font-cond); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-bottom: 2px; }
.lead-items { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.btn-wa { background: #25D366; border-color: #25D366; color: #06331A; font-weight: 700; }
.btn-wa:hover { background: #1EBE5B; border-color: #1EBE5B; }
.lead-controls { display: grid; grid-template-columns: 190px 170px 1fr; gap: 8px; margin-top: 12px; }
.lead-controls textarea { min-height: 38px; height: 38px; resize: vertical; }
.lead-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.lead-foot-lbl { font-family: var(--font-cond); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.lead-foot input[type=date] { width: 160px; height: 34px; }
.lead-foot .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.link-btn { border: 0; background: none; color: var(--senal); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.counter { display: inline-flex; gap: 5px; }
.count-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--muted); }
.count-btn.on { background: var(--cobre); border-color: var(--cobre); color: #fff; }
.count-btn:disabled, .link-btn:disabled { opacity: .5; cursor: default; }
@media (max-width: 860px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .chips .chip { flex: none; }
  .lead-head { flex-direction: column; }
  .lead-side { align-items: flex-start; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .lead-controls { grid-template-columns: 1fr 1fr; }
  .lead-controls textarea { grid-column: 1 / -1; }
  .lead-actions .btn { flex: 1 1 auto; }
}
.text-bad { color: var(--bad, #B42318); font-weight: 600; }
tr.row-faint td { color: var(--faint); }
.pedir-inline { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.pedir-inline select { min-width: 175px; max-width: 230px; }
.input-sm, select.input-sm { height: 32px; padding: 4px 28px 4px 8px; font-size: 14px; }
.nav-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }

/* Tablas que no entran en el ancho disponible (tablet, ventanas angostas): se apilan solas */
.table-wrap.is-stacked .t.stackable thead { display: none; }
.table-wrap.is-stacked .t.stackable, .table-wrap.is-stacked .t.stackable tbody, .table-wrap.is-stacked .t.stackable tr, .table-wrap.is-stacked .t.stackable td { display: block; width: 100%; }
.table-wrap.is-stacked .t.stackable tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table-wrap.is-stacked .t.stackable tbody tr:last-child { border-bottom: 0; }
.table-wrap.is-stacked .t.stackable td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
.table-wrap.is-stacked .t.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
.table-wrap.is-stacked .t.stackable td > .cell { min-width: 0; }
.table-wrap.is-stacked .t.stackable td:not(.cell-first) .stage-cell { align-items: flex-end; }
.table-wrap.is-stacked .t.stackable td.cell-first { text-align: left; display: block; padding-bottom: 4px; }
.table-wrap.is-stacked .t.stackable td.cell-first::before { display: none; }
.table-wrap.is-stacked .t.stackable td.actions { width: 100%; justify-content: flex-end; padding-top: 6px; }
.table-wrap.is-stacked .t.stackable td.actions::before { display: none; }
.table-wrap.is-stacked .t.stackable td.check-col { width: auto; }
.table-wrap.is-stacked .t.stackable td:empty { display: none; }
.table-wrap.is-stacked .items-editor thead { display: none; }
.table-wrap.is-stacked .items-editor, .table-wrap.is-stacked .items-editor tbody, .table-wrap.is-stacked .items-editor tr { display: block; }
.table-wrap.is-stacked .items-editor tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px 0; }
.table-wrap.is-stacked .items-editor td { padding: 0; min-width: 0; }
.table-wrap.is-stacked .items-editor td input, .table-wrap.is-stacked .items-editor td select { width: 100%; min-width: 0; }
.table-wrap.is-stacked .items-editor td.desc { grid-column: 1 / -1; width: auto; }
.table-wrap.is-stacked .items-editor td.line-total { grid-column: 1 / 3; text-align: left; padding-top: 4px; }
.table-wrap.is-stacked .items-editor td.del { text-align: right; }
.table-wrap.is-stacked .items-editor td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
.table-wrap.is-stacked .items-editor .w-qty, .table-wrap.is-stacked .items-editor .w-unit, .table-wrap.is-stacked .items-editor .w-price, .table-wrap.is-stacked .items-editor .w-pct, .table-wrap.is-stacked .items-editor .w-orig { width: 100%; min-width: 0; }
.table-wrap.is-stacked { overflow-x: visible; }

/* ------------------------------------------------------------ Seguimiento comercial (inicio) */
.section-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 4px 0 10px; }
.section-head h2 { font-size: 18px; flex: 1; color: var(--ink); }
.seg-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-filtros select { width: auto; min-width: 0; max-width: 240px; }
.strip-seg a.kpi-warn .val { color: var(--warn); }
.strip-seg a.kpi-bad .val { color: var(--bad); }
.att-list { list-style: none; margin: 0; padding: 0; }
.att-list li + li { border-top: 1px solid var(--line); }
.att-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: transparent; border: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.att-row:hover, .att-row:focus-visible { background: var(--surface-2); outline: none; }
.att-row > svg { flex: none; color: var(--faint); }
.att-main { flex: 1; min-width: 0; }
.att-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.att-name { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.att-amount { font-weight: 700; white-space: nowrap; }
.att-meta { font-size: 13px; color: var(--muted); margin-top: 1px; }
.att-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.att-chip { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.att-chip.bad { background: var(--bad-tint); color: var(--bad); border-color: transparent; }
.att-chip.warn { background: var(--warn-tint, #FFF4DC); color: var(--warn); border-color: transparent; }
.text-warn { color: var(--warn); }
/* Panel lateral (vista rápida) */
.drawer-overlay { position: fixed; inset: 0; background: rgba(29, 33, 37, .42); z-index: 90; display: flex; justify-content: flex-end; animation: fade .12s ease-out; }
.drawer { width: min(560px, 100%); height: 100%; background: var(--paper); display: flex; flex-direction: column; box-shadow: -18px 0 48px rgba(0, 0, 0, .22); animation: slidein .18s ease-out; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; font-size: 18px; color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 40px; overscroll-behavior: contain; }
.drawer-body .lead-card { margin: 0; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.drawer-sub { font-size: 15px; margin: 20px 0 8px; color: var(--ink); }
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-overlay { animation: none; } }

.drawer .lead-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.drawer .lead-controls textarea { grid-column: 1 / -1; height: 64px; }
.drawer .lead-foot { flex-wrap: wrap; row-gap: 8px; }
