/* ==========================================================================
   Agustina — sistema de diseño
   Móvil primero. Objetivos táctiles ≥ 44px. Sin dependencias.
   ========================================================================== */

:root {
  --ground: #F6F5F2;
  --surface: #FFFFFF;
  --surface-2: #FAF9F7;
  --ink: #1B1D1F;
  --ink-2: #3F4448;
  --muted: #5B6066;
  --line: #E2E0DA;
  --line-2: #CFCCC4;
  --accent: #0E6B5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3F2EE;
  --accent-dark: #09493F;
  --nav: #13211E;
  --nav-ink: #D5E2DE;
  --danger: #8C2F24;
  --danger-soft: #FBEAE7;
  --warning: #6B3A00;
  --warning-soft: #FFF4E0;
  --info: #1F4FA3;
  --info-soft: #E8EFFB;
  --success: #0E6B5C;
  --success-soft: #E3F2EE;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 10px 28px rgba(27, 29, 31, .12);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sidebar: 264px;
  --bottombar: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--nav); color: var(--nav-ink);
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidebar.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
.main { min-width: 0; padding-bottom: calc(var(--bottombar) + env(safe-area-inset-bottom)); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .scrim { display: none !important; }
  .main { margin-left: var(--sidebar); padding-bottom: 0; }
  .bottombar, .menu-btn { display: none !important; }
}

.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 600; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 12px; color: #9DB3AD; }

.nav-search { padding: 4px 14px 10px; }
.nav-search input {
  width: 100%; height: 40px; border-radius: 8px; border: 1px solid #2C3B37;
  background: #1B2C28; color: #fff; padding: 0 12px; font: inherit;
}
.nav-search input::placeholder { color: #8DA39D; }
.nav { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.nav-group { margin-top: 10px; }
.nav-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8DA39D; padding: 8px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px;
  color: var(--nav-ink); text-decoration: none; border-radius: 8px;
}
.nav a:hover { background: #1F302C; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav .soon { margin-left: auto; font-size: 11px; color: #8DA39D; }
.sidebar-foot { padding: 12px 18px 18px; border-top: 1px solid #23332F; font-size: 13px; }
.sidebar-foot strong { display: block; color: #fff; font-weight: 500; }

.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title strong { display: block; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-badge { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); border: 1px solid #F0CF95; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 2px 6px 2px 2px; border-radius: 999px; border: 1px solid var(--line); }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.user-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(320px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px; display: grid; gap: 14px; z-index: 50;
}

.page { max-width: 1320px; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 20px; }
@media (min-width: 768px) { .page { padding: 24px 24px 40px; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.page-head > div:first-child { flex: 1 1 260px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }

/* Barra inferior (móvil) */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--bottombar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.bottombar a, .bottombar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; font-size: 12px; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.bottombar svg { width: 22px; height: 22px; }
.bottombar .active { color: var(--accent); font-weight: 600; }
.bottombar .primary span.icon { background: var(--accent); color: #fff; width: 44px; height: 32px; border-radius: 16px; display: grid; place-items: center; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
@media (min-width: 768px) { .card { padding: 20px; } }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.step { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--line); border-color: var(--line); color: #6B7075; cursor: not-allowed; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line-2);
  border-radius: var(--radius); background: var(--surface); font: inherit; font-size: 16px; color: var(--ink);
}
.textarea { padding: 10px 12px; min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: 13px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.alert { border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #A9D5CA; color: #0A4A40; }
.alert-warning { background: var(--warning-soft); border-color: #F0CF95; color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-color: #EDBFB7; color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: #C3D3F0; color: var(--info); }
.alert a { color: inherit; font-weight: 600; }

.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: #0A4A40; }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #ECEAE5; color: var(--ink-2); }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 4px; }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .value { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat-dark .label, .stat-dark .sub { color: #BFC4C9; }

/* Listas que se vuelven tarjetas en móvil */
.list { display: grid; }
.list-row {
  display: grid; gap: 4px 12px; padding: 14px 4px; border-top: 1px solid var(--line);
  grid-template-columns: 1fr auto; align-items: center; text-decoration: none; color: inherit;
}
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); color: inherit; }
.list-row .title { font-weight: 600; overflow-wrap: anywhere; }
.list-row .meta { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 12px; white-space: nowrap; }
.table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr.link:hover td { background: var(--surface-2); cursor: pointer; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar .field { flex: 1 1 160px; }
.toolbar .grow { flex: 3 1 240px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; cursor: pointer; font: inherit; font-size: 14px; }
.chip.active, .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.empty { border: 2px dashed #DAD7CF; border-radius: var(--radius); padding: 32px 16px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--ink); }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv span:first-child { color: var(--ink-2); }

dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(480px, calc(100vw - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-body { padding: 20px; display: grid; gap: 14px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Facturación ---------- */
.invoice-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.invoice-main { flex: 999 1 600px; min-width: 0; display: grid; gap: 16px; }
.invoice-side { flex: 1 1 340px; min-width: 0; display: grid; gap: 16px; }
@media (min-width: 1024px) { .invoice-side { position: sticky; top: 84px; } }

.search-box { position: relative; }
.search-input {
  display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 14px;
  border: 2px solid var(--accent); border-radius: 12px; background: var(--surface);
}
.search-input svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.search-input input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 16px; background: transparent; }
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; max-height: 360px; overflow-y: auto;
}
.result { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.result:hover, .result.active { background: var(--accent-soft); }
.result .r-main { flex: 1; min-width: 0; display: grid; }
.result .r-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.result .r-add { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.result .r-add svg { width: 18px; height: 18px; }
.stock-low { color: var(--danger); }

.selected-customer { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.selected-customer .info { flex: 1; min-width: 0; }
.selected-customer .name { font-weight: 600; overflow-wrap: anywhere; }

.line-items { display: grid; gap: 10px; }
.line {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface);
  display: grid; gap: 12px;
}
.line.flash { animation: flash 1s ease; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--surface); } }
.line-top { display: flex; align-items: flex-start; gap: 10px; }
.line-top .info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.line-top .name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.line-top .name input { width: 100%; font: inherit; font-weight: 600; border: 1px solid var(--line-2); border-radius: 8px; min-height: 40px; padding: 0 10px; }
.line-top .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.line-remove { width: 44px; height: 44px; margin: -6px -8px 0 0; border: 0; border-radius: 8px; background: none; color: var(--danger); cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.line-remove svg { width: 20px; height: 20px; }
.line-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.line-controls .f-qty { flex: 1 1 160px; min-width: 0; }
.line-controls .f-price { flex: 1 1 130px; min-width: 0; }
.line-controls .f-end { flex: 1 1 260px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.mini-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 4px; }
.stepper { display: flex; align-items: center; height: 48px; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.stepper button { width: 48px; height: 48px; border: 0; background: #F1EFEA; font-size: 22px; cursor: pointer; flex-shrink: 0; color: var(--ink); }
.stepper button:active { background: #E2E0DA; }
.stepper input { flex: 1; min-width: 0; width: 100%; height: 48px; border: 0; text-align: center; font-family: var(--mono); font-size: 18px; font-weight: 600; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.price-input { width: 100%; height: 48px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; font-family: var(--mono); font-size: 16px; text-align: right; }
.tax-select { height: 44px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 14px; background: var(--surface); }
.line-amount { text-align: right; }
.line-amount small { display: block; font-size: 12px; color: var(--muted); }
.line-amount strong { font-family: var(--mono); font-size: 17px; }

.totals .kv span:last-child { font-family: var(--mono); }
.grand-total { background: var(--ink); color: #fff; border-radius: 12px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grand-total span:first-child { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.grand-total strong { font-family: var(--mono); font-size: 30px; letter-spacing: -.02em; }
.methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.methods label { position: relative; }
.methods input { position: absolute; opacity: 0; inset: 0; }
.methods span { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid var(--line-2); border-radius: 10px; font-weight: 600; cursor: pointer; background: var(--surface); }
.methods input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.methods input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.cash-box { background: var(--surface-2); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 46px; font-weight: 600; cursor: pointer; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }

details.more > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; color: var(--accent); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+'; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 15px; line-height: 1; }
details.more[open] > summary::before { content: '−'; }

/* Barra fija de total (móvil) */
.mobile-total {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bottombar) + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(27,29,31,.08);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
}
.mobile-total .t { flex: 1; min-width: 0; }
.mobile-total small { display: block; font-size: 12px; color: var(--muted); }
.mobile-total strong { font-family: var(--mono); font-size: 20px; }
.has-mobile-total .page { padding-bottom: 96px; }
@media (min-width: 1024px) { .mobile-total { display: none; } .has-mobile-total .page { padding-bottom: 40px; } }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--nav) 0 38%, var(--ground) 38% 100%); }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 18px; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 52px; }
.pass-wrap button { position: absolute; right: 2px; top: 1px; width: 44px; height: 44px; border: 0; background: none; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.pass-wrap svg { width: 20px; height: 20px; }

@media print {
  .sidebar, .topbar, .bottombar, .mobile-total, .no-print { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
}

/* ---------- Gráfica de barras (una serie) ---------- */
.barchart-plot { position: relative; padding-left: 52px; }
.barchart-grid { position: absolute; left: 52px; right: 0; border-top: 1px dashed var(--line); }
.barchart-grid span { position: absolute; left: -52px; top: -8px; width: 46px; white-space: nowrap; letter-spacing: -.02em; text-align: right; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.barchart-bars { position: absolute; left: 52px; right: 0; top: 0; bottom: 0; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line-2); }
.barchart-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; outline: none; }
.barchart-bar { width: 100%; max-width: 36px; margin: 0 auto; background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.barchart-col:hover .barchart-bar, .barchart-col:focus .barchart-bar { background: var(--accent-dark); }
.barchart-tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; z-index: 5; pointer-events: none; }
.barchart-col:hover .barchart-tip, .barchart-col:focus .barchart-tip { display: block; }
.barchart-col .barchart-tip { bottom: auto; top: -8px; transform: translate(-50%, -100%); }
.barchart-labels { display: flex; gap: 2px; padding-left: 52px; margin-top: 6px; }
.barchart-labels span { flex: 1 1 0; min-width: 0; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; }
.hbar { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.hbar-track { grid-column: 1 / -1; height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.delta-up { color: var(--accent); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .ok { color: var(--accent); }
.checklist .no { color: var(--danger); }
.url-box { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

/* ---------- Caja rápida (punto de venta) ---------- */
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .75; margin-left: 4px; }
.pos-mode .bottombar { display: none; }
.pos-mode .main { padding-bottom: 0; }
.pos-mode .page { max-width: none; padding: 12px; gap: 12px; }
@media (min-width: 1024px) {
  .pos-mode .sidebar { transform: translateX(-100%); }
  .pos-mode .sidebar.open { transform: none; }
  .pos-mode .main { margin-left: 0; }
  .pos-mode .menu-btn { display: inline-flex !important; }
}
.pos { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .pos { grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - 92px); }
  .pos-catalog { overflow: auto; }
  .pos-cart { position: static !important; height: 100%; }
}
.pos-catalog { display: grid; gap: 12px; align-content: start; min-width: 0; }
.pos-top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pos-search { flex: 1 1 320px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); padding: 0 6px 0 12px; min-height: 52px; }
.pos-search svg { color: var(--accent); flex: none; }
.pos-search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 18px; background: transparent; min-width: 0; height: 48px; }
.pos-status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pos-cats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.pos-cats .chip { flex: none; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pos-tile { display: grid; gap: 4px; align-content: space-between; text-align: left; min-height: 104px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); transition: border-color .12s, transform .06s; }
.pos-tile:hover { border-color: var(--accent); }
.pos-tile:active { transform: scale(.98); }
.pos-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pos-tile.is-out { opacity: .6; }
.pos-tile-name { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pos-tile-meta { font-size: 11px; color: var(--muted); }
.pos-tile-price { font-size: 17px; font-weight: 700; color: var(--accent-dark); }
.pos-cart { display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; min-height: 0; }
.pos-cart-head { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.pos-cart-head .select { width: auto; max-width: 150px; }
.pos-customer { flex: 1; display: flex; gap: 8px; align-items: center; text-align: left; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px dashed var(--line-2); background: var(--surface-2); cursor: pointer; font: inherit; color: var(--ink); min-height: 48px; }
.pos-customer span { display: grid; min-width: 0; }
.pos-customer small { color: var(--muted); font-size: 11px; }
.pos-customer strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-close-cart { display: none; }
.pos-lines { list-style: none; margin: 0; padding: 0; overflow: auto; min-height: 0; }
.pos-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 32px; gap: 4px 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.pos-line-main { display: grid; min-width: 0; }
.pos-line-main strong { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.pos-line-main span { font-size: 12px; }
.pos-qty { display: flex; align-items: center; gap: 2px; }
.pos-qty .btn-icon { width: 36px; height: 36px; min-height: 36px; font-size: 18px; }
.pos-qty .input { width: 56px; height: 36px; min-height: 36px; text-align: center; padding: 0 4px; }
.pos-line-total { font-weight: 700; min-width: 76px; text-align: right; }
.pos-line-x { width: 32px; height: 32px; min-height: 32px; color: var(--danger); font-size: 20px; }
.pos-line-edit { grid-column: 1 / -1; justify-self: start; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }
.pos-empty { display: grid; gap: 6px; place-content: center; text-align: center; color: var(--muted); padding: 24px; }
.pos-empty[hidden] { display: none; }
.pos-totals { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: grid; gap: 4px; background: var(--surface-2); }
.pos-grand { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; padding-top: 4px; }
.pos-grand strong { font-size: 28px; }
.pos-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; margin-top: 6px; }
.pos-mobilebar { display: none; }
.pos-flash { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100vw - 32px); }
.pos-flash.show { opacity: 1; transform: translate(-50%, 0); }
.pos-dialog { width: min(520px, calc(100vw - 24px)); }
.pos-pay-total { display: flex; justify-content: space-between; align-items: baseline; }
.pos-pay-total strong { font-size: 30px; }
.pos-pay-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pos-pay-row .input { font-size: 18px; }
.pos-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pos-change { font-size: 18px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin-top: 10px; }
.pos-change.ok { background: var(--success-soft); color: #0A4A40; }
.pos-change.bad { background: var(--danger-soft); color: var(--danger); }
.pos-change.big { font-size: 26px; }
.pos-change:empty { display: none; }
@media (max-width: 899px) {
  .pos-cart { position: fixed; inset: 0; z-index: 40; border-radius: 0; transform: translateY(100%); transition: transform .2s; }
  .pos.cart-open .pos-cart { transform: none; }
  .pos-close-cart { display: inline-flex; }
  .pos-mobilebar { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); z-index: 30; }
  .pos-mobilebar .btn-primary { flex: 1; }
  .pos-catalog { padding-bottom: 84px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pos-pay-row { grid-template-columns: 1fr 1fr; }
  .pos-pay-row .select { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .pos-cart, .pos-flash, .pos-tile { transition: none; } }

/* ---------- Estados financieros ---------- */
.fin-report h2 { margin: 14px 0 6px; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.fin-report h2:first-child { margin-top: 0; }
.fin-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.fin-row.lvl-1, .fin-row.lvl-2 { font-weight: 700; }
.fin-row.lvl-4 { padding-left: 16px; }
.fin-total { font-weight: 700; border-bottom: 0; border-top: 1.5px solid var(--ink); }
.fin-grand { font-weight: 700; font-size: 16px; border-bottom: 3px double var(--ink); border-top: 1.5px solid var(--ink); margin-top: 8px; }
@media print { .fin-report { box-shadow: none; border: 0; } }
