/* Base compartida de los sistemas demo de Blackbird Labs (va encima de app.css).
   Computadora: barra lateral con nombre + lienzo. Celular (≤860px): barra de arriba de 48px y barra de pestañas abajo. */
:root { --tabbar: 60px; --pill-accent-bg: var(--raised); --pill-accent-ink: var(--text); }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.strong { font-weight: 500; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.neg { color: var(--negative); }
.pos { color: var(--positive); }

/* ---------- marca en la barra lateral ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand svg { width: 28px; height: 28px; flex: none; color: var(--accent); }
.brand b { display: block; font-weight: 600; line-height: 18px; }
.brand span { display: block; font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.nav-item { width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
.nav-item .count { margin-left: auto; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar .bottom { display: grid; gap: 8px; padding: 12px 8px 0; font-size: var(--fs-small); color: var(--muted); }
.sidebar .bottom .btn { justify-self: start; }

/* ---------- vistas ---------- */
.canvas { padding: 32px var(--pad) 64px; }
.view { max-width: 1240px; margin: 0 auto; }
.title-row .actions { display: flex; gap: 8px; flex: none; }
.title-row .sub { max-width: 68ch; }
.stack { display: grid; gap: var(--gap); align-content: start; }
.panel > header .card-link, .panel > header .btn { flex: none; }
.panel.flush { padding-bottom: 6px; }
.btn { white-space: nowrap; text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.small { height: 28px; padding: 0 10px; font-size: var(--fs-small); }
.btn.big { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.danger { color: var(--negative); }
.btn svg { width: 16px; height: 16px; flex: none; }
.pill.accent { background: var(--pill-accent-bg); color: var(--pill-accent-ink); }
.pill { flex: none; }

/* filas de lista: identidad a la izquierda, cifra o acción a la derecha */
.row .id { min-width: 0; flex: 1; }
.row .id b { font-weight: 500; display: block; overflow-wrap: anywhere; }
.row .id span { display: block; font-size: var(--fs-small); color: var(--muted); }
.row .fig { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.row .fig b { font-weight: 500; display: block; }
.row .fig span { display: block; font-size: var(--fs-small); color: var(--muted); }
.row.click { cursor: pointer; }
.row .acts { display: flex; gap: 6px; flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600; font-size: 14px; background: var(--raised); color: var(--text); }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* tarjetas de conteo que filtran una lista */
.counts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-bottom: var(--gap); }
.counts button { text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); cursor: pointer; }
.counts button span { display: block; font-size: 13px; color: var(--muted); }
.counts button b { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counts button[aria-pressed="true"] { border-color: var(--text); outline: 1px solid var(--text); outline-offset: -2px; background: var(--raised); }

/* formularios */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.field { gap: 6px; }
.field > span, .field > label { font-size: var(--fs-small); color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; min-width: 0; height: 40px; }
textarea.input { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--text); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; }
.filters .search { flex: 1 1 240px; max-width: 320px; }

/* buscador de productos y ticket */
.results { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); overflow: hidden; }
.results button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 12px; min-height: 52px; border: 0; background: none; text-align: left; cursor: pointer; }
.results button + button { border-top: 1px solid var(--rule); }
.results button:hover, .results button:focus-visible { background: var(--raised); }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 12px; padding: 12px 0; align-items: center; }
.line + .line { border-top: 1px solid var(--rule); }
.line .ctl { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line .hint { grid-column: 1 / -1; font-size: var(--fs-small); color: var(--muted); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--control); border-radius: var(--radius-control); height: 32px; }
.qty button { width: 32px; height: 30px; border: 0; background: none; cursor: pointer; font-size: 16px; }
.qty output { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; }
.x { width: 32px; height: 32px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
.x:hover { background: var(--raised); color: var(--negative); }
.sum { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.sum div { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.sum .total { align-items: baseline; font-weight: 500; }
.sum .total b { font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
.notice { padding: 10px 12px; border: 1px solid #fde68a; background: var(--pill-warning-bg); color: var(--pill-warning-ink); border-radius: var(--radius-control); font-size: 13px; }
.kv { display: grid; gap: 0; }
.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-variant-numeric: tabular-nums; }
.kv div + div { border-top: 1px solid var(--rule); }
.kv .tot { font-weight: 600; border-top: 1px solid var(--border) !important; }

/* diálogo: centrado en computadora, hoja desde abajo en celular */
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 16px 48px rgba(0,0,0,.18); overscroll-behavior: contain; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg { padding: 20px; display: grid; gap: 16px; }
.dlg > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg h2 { font-size: 18px; line-height: 1.3; font-weight: 600; }
.dlg .foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 999px; font-weight: 500; z-index: 80; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.demo-note { font-size: var(--fs-small); color: var(--muted); }

/* ---------- celular y tableta ---------- */
.topbar, .tabbar { display: none; }
@media (max-width: 860px) {
  :root { --fs-small: 13px; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; position: sticky; top: 0; z-index: 15; background: var(--ground); border-bottom: 1px solid var(--border); }
  .topbar svg.mark { width: 24px; height: 24px; color: var(--accent); flex: none; }
  .topbar b { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--surface); border-top: 1px solid var(--border); }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 500; cursor: pointer; }
  .tabbar button svg { width: 22px; height: 22px; stroke-width: 1.5; }
  .tabbar button[aria-current="page"] { color: var(--text); }
  .tabbar button[aria-current="page"] svg { color: var(--accent); }
  .canvas { padding: 20px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom, 0px)); }
  .title-row { margin-bottom: 16px; }
  .title-row .actions { width: 100%; }
  .title-row .actions .btn { flex: 1; height: 44px; }
  .btn { height: 40px; }
  .btn.small { height: 34px; }
  .input, select.input { height: 44px; font-size: 16px; }
  .qty { height: 40px; } .qty button { width: 36px; height: 38px; }
  .counts { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { top: 58px; bottom: auto; }
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0; max-height: 92dvh; }
  .dlg { padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .dlg .foot .btn { flex: 1; height: 44px; }
  .hide-phone { display: none !important; }
  .filters .search { max-width: none; flex-basis: 100%; }
  /* tablas → filas de dos líneas */
  table.fold thead { display: none; }
  table.fold tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  table.fold tbody tr:last-child { border-bottom: 0; }
  table.fold td { padding: 0; border: 0; }
  table.fold td.c1 { grid-column: 1; grid-row: 1; }
  table.fold td.c2 { grid-column: 2; grid-row: 1; text-align: right; }
  table.fold td.c3 { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--muted); }
  table.fold td.c4 { grid-column: 2; grid-row: 2; text-align: right; }
  table.fold td.c0 { display: none; }
}
@media (min-width: 861px) { .only-phone { display: none !important; } }

/* recibo impreso */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; font: 12pt/1.4 var(--font); color: #111; max-width: 80mm; }
  #print h1 { font-size: 15pt; margin: 0 0 2pt; }
  #print table { width: 100%; border-collapse: collapse; margin: 8pt 0; }
  #print td { padding: 3pt 0; border-bottom: 1px dotted #999; }
  #print .r { text-align: right; }
}
.card-link.plain::after { content: none; }
