/* Intranet Árbol Chico. Base visual del bosquejo aprobado (barra lateral con 5 módulos, tablas densas, el "timbre" de escuadría). */
:root {
  --bg: #f2f3ee;
  --surface: #ffffff;
  --surface-2: #e9ebe4;
  --ink: #18201b;
  --ink-2: #56615a;
  --line: #d6dbd2;
  --accent: #2b5c41;
  --accent-ink: #ffffff;
  --accent-soft: #e0eae2;
  --wood: #9c6a2f;
  --wood-soft: #f4eadc;
  --ok: #2a6a49;
  --ok-soft: #ddece3;
  --warn: #94590a;
  --warn-soft: #f6e8d1;
  --crit: #a13d2a;
  --crit-soft: #f5ded8;
  --info: #2b5a85;
  --info-soft: #dde7f1;
  --scrim: rgb(12 18 14 / .48);
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #181e1a; --surface-2: #212923; --ink: #e4eae5; --ink-2: #9ba79f; --line: #2d3731;
    --accent: #72b38c; --accent-ink: #0d1911; --accent-soft: #1d3127; --wood: #d9a865; --wood-soft: #2f2416;
    --ok: #79c39a; --ok-soft: #1a3125; --warn: #e3a64c; --warn-soft: #382a13; --crit: #e57f69; --crit-soft: #3b211b;
    --info: #86b5df; --info-soft: #1a2937; --scrim: rgb(0 0 0 / .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111513; --surface: #181e1a; --surface-2: #212923; --ink: #e4eae5; --ink-2: #9ba79f; --line: #2d3731;
  --accent: #72b38c; --accent-ink: #0d1911; --accent-soft: #1d3127; --wood: #d9a865; --wood-soft: #2f2416;
  --ok: #79c39a; --ok-soft: #1a3125; --warn: #e3a64c; --warn-soft: #382a13; --crit: #e57f69; --crit-soft: #3b211b;
  --info: #86b5df; --info-soft: #1a2937; --scrim: rgb(0 0 0 / .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.rings { width: 34px; height: 34px; border-radius: 50%; flex: none; background: repeating-radial-gradient(circle at 46% 54%, var(--wood) 0 1.2px, var(--wood-soft) 1.2px 4px); border: 1.5px solid var(--wood); }
.logo { width: 46px; height: 46px; border-radius: 50%; background: #ffffff; flex: none; padding: 1px; }
.doc-logo { width: 92px; height: 92px; border-radius: 50%; background: #ffffff; }
.doc-num { font: 700 22px/1.2 var(--f-body); color: var(--ok); text-align: right; }
.brand b { display: block; font: 700 22px/1 var(--f-display); letter-spacing: .01em; }
.brand span { font-size: 11.5px; color: var(--ink-2); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: var(--r); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.nav .count { font: 600 12px/1 var(--f-body); padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav a[aria-current="page"] .count { background: rgb(255 255 255 / .2); color: inherit; }
.nav .sep { height: 1px; background: var(--line); margin: 6px 10px; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px clamp(16px, 3vw, 32px); background: var(--wood-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.top strong { color: var(--wood); font-weight: 600; }
#view { width: 100%; max-width: 1240px; padding: 24px clamp(16px, 3vw, 32px) 56px; display: flex; flex-direction: column; gap: 22px; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font: 700 34px/1.02 var(--f-display); letter-spacing: .005em; text-wrap: balance; }
h2 { margin: 0; font: 700 21px/1.1 var(--f-display); letter-spacing: .01em; text-wrap: balance; }
.lead { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; align-items: start; }
.cols > * { min-width: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.tile .k { font: 600 11.5px/1.2 var(--f-body); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.tile .v { font: 700 42px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.tile .v.warn { color: var(--warn); }
.tile .v.ok { color: var(--ok); }
.tile .s { color: var(--ink-2); font-size: 13px; }

.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font: 600 11px/1.2 var(--f-body); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
th.num { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
tfoot td { background: var(--surface-2); }
tfoot tr.total td { font-weight: 700; font-size: 15px; }
.empty { padding: 22px; text-align: center; color: var(--ink-2); }

.prod { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.stamp { display: inline-block; flex: none; min-width: 48px; padding: 4px 7px 3px; text-align: center; font: 700 15px/1 var(--f-display); letter-spacing: .03em; color: var(--wood); background: var(--wood-soft); border: 1.5px solid var(--wood); border-radius: 3px; }
.stamp.env { color: var(--info); background: var(--info-soft); border-color: var(--info); }
.pdesc { line-height: 1.3; }
.folio { font: 600 12.5px/1 var(--f-mono); letter-spacing: .02em; white-space: nowrap; }
.folio.cot { color: var(--info); }
.folio.ped { color: var(--ok); }

.pill { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-body); padding: 5px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--info); }
.due { font-weight: 600; white-space: nowrap; }
.due.late { color: var(--crit); }
.due.soon { color: var(--warn); }
.hl { color: var(--warn); font-weight: 700; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--ink-2); margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 40px; }
input.qty { width: 100px; text-align: right; font-variant-numeric: tabular-nums; }
.search { max-width: 280px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel.soft { background: var(--surface-2); }
.note { font-size: 13px; color: var(--ink-2); border-left: 2px solid var(--wood); padding: 2px 0 2px 10px; max-width: 80ch; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.list { display: flex; flex-direction: column; }
.list > * { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }
.hist-item { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.hist-item:last-child { border-bottom: 0; }
.hist-item.nota .htext { border-left: 2px solid var(--wood); padding-left: 8px; }
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav input { width: auto; }

.rank { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.rank-row .bar { grid-column: 1 / -1; height: 10px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 3px; }
.rank-row:hover .bar span { filter: brightness(1.15); }
.rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Vista tablet del taller: sin barra lateral, botones grandes para dedos */
.tablet .side { display: none; }
.tablet .app { grid-template-columns: 1fr; }
.tablet #view { max-width: 1100px; margin: 0 auto; }
.tcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.tcard .stamp { font-size: 26px; padding: 6px 10px 5px; }
.tcard .tdesc { font-size: 18px; line-height: 1.3; }
.tfalta { display: flex; align-items: baseline; gap: 8px; }
.tfalta b { font: 700 52px/1 var(--f-display); color: var(--warn); font-variant-numeric: tabular-nums; }
.stepper { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 8px; }
.stepper button, .tbtn { min-height: 60px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 26px; font-weight: 600; cursor: pointer; color: var(--ink); }
.stepper input { min-height: 60px; font-size: 28px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.tquick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tquick .tbtn { font-size: 18px; min-height: 52px; }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 22px; }

.clients { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 22px; align-items: start; }
.cli-item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; cursor: pointer; }
.cli-item:last-child { border-bottom: 0; }
.cli-item:hover { background: var(--surface-2); }
.cli-item[aria-current="true"] { background: var(--accent-soft); }
.cli-item b { font-weight: 600; }

.modal { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px 32px; overflow: auto; z-index: 30; }
.sheet { width: min(1000px, 100%); background: var(--surface); border-radius: 10px; box-shadow: 0 24px 60px rgb(0 0 0 / .28); display: flex; flex-direction: column; }
.sheet.narrow { width: min(560px, 100%); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { display: flex; flex-wrap: wrap; 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; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 6px; }

.guia { border: 1.5px solid var(--ink); padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); }
.guia-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; }
.sii { border: 2.5px solid var(--crit); color: var(--crit); padding: 10px 16px; text-align: center; font-weight: 700; line-height: 1.5; min-width: 220px; }
.sii span { display: block; }
.guia .kv { font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: 13.5px; max-width: min(580px, calc(100% - 32px)); z-index: 40; box-shadow: 0 10px 30px rgb(0 0 0 / .25); }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .nav .sep { display: none; }
  .side-foot { display: none; }
  .clients { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
}
@media print {
  body.print-doc .app, body.print-doc .sheet-head, body.print-doc .sheet-foot, body.print-doc .modal .note { display: none !important; }
  body.print-doc .modal { position: static; background: none; padding: 0; overflow: visible; }
  body.print-doc .sheet { box-shadow: none; width: 100%; }
  .side, .top, .noprint { display: none !important; }
  body { background: #fff; color: #000; }
  .app { display: block; }
  #view { padding: 0; max-width: none; }
  .tw { border-color: #999; }
}

/* ---------- Intranet real: agregados al bosquejo ---------- */
:root { --violet: #6a4c9c; --violet-soft: #ece5f5; --hero: #1e3d2c; --hero-ink: #f2f3ee; --hero-soft: #c9d8cd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --violet: #b9a3e3; --violet-soft: #2b2340; } }
:root[data-theme="dark"] { --violet: #b9a3e3; --violet-soft: #2b2340; }

.logo { width: 46px; height: 46px; border-radius: 50%; background: #ffffff; flex: none; padding: 1px; }
.logo.grande { width: 112px; height: 112px; border: 4px solid #ffffff; }
.doc-logo { width: 92px; height: 92px; border-radius: 50%; background: #ffffff; }
.doc-num { font: 700 22px/1.2 var(--f-body); color: var(--ok); text-align: right; }

/* Ingreso */
.ingreso { min-height: 100%; display: grid; place-items: center; background: var(--hero); padding: 24px 16px; }
.ingreso-caja { width: min(380px, 100%); background: var(--surface); border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; box-shadow: 0 24px 60px rgb(0 0 0 / .3); }
.ingreso-caja .logo { align-self: center; }
.ingreso-caja h1 { text-align: center; font-size: 30px; }
.ingreso-error { margin: 0; color: var(--crit); background: var(--crit-soft); padding: 8px 12px; border-radius: var(--r); font-size: 14px; }
.btn.grande { padding: 12px 18px; font-size: 16px; }

/* Estados de venta con color (verde entregada y pagada, naranja parcial, rojo por entregar, violeta falta pago) */
.pill.violeta { background: var(--violet-soft); color: var(--violet); }
tr.st-ok td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
tr.st-warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.st-crit td:first-child { box-shadow: inset 4px 0 0 var(--crit); }
tr.st-violeta td:first-child { box-shadow: inset 4px 0 0 var(--violet); }
tr.st-info td:first-child { box-shadow: inset 4px 0 0 var(--info); }
tr.st-ok td { color: var(--ink-2); }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); align-items: center; }
.sub-estado { display: block; font-size: 12px; color: var(--ink-2); margin-top: 3px; }

.opciones { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.opciones label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.opciones input { width: auto; }
.aviso { background: var(--warn-soft); color: var(--ink); border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; }
.vacio { padding: 28px 16px; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn.peligro { color: var(--crit); border-color: var(--crit-soft); }
.side-foot b { color: var(--ink); font-weight: 600; }
a.enlace { color: var(--info); }
@media (max-width: 880px) { .top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; } }
