:root {
  --bg: #f4f6f6;
  --panel: #ffffff;
  --ink: #17201f;
  --ink-2: #4a5655;
  --ink-3: #7c8786;
  --line: #e1e6e5;
  --brand: #0f5c5a;
  --brand-2: #e3f0ef;
  --ingreso: #1f7a43;
  --ingreso-bg: #e6f4ea;
  --gasto: #b4432c;
  --gasto-bg: #fbece8;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 31, .06), 0 4px 14px rgba(16, 32, 31, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Barra superior / navegación ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.marca { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.marca img { border-radius: 7px; }
.nav { display: flex; gap: 4px; }
.nav a { color: #d7ecea; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.nav a.activo, .nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.tabbar { display: none; }

.main { max-width: 1320px; margin: 0 auto; padding: 22px 24px 60px; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.cabecera { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.cabecera p { margin: 0; color: var(--ink-2); }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px;
  text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: #c5cfce; }
.btn.primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primario:hover { background: #0b4a48; }
.btn.peligro { color: var(--gasto); }
.btn.chico { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=month], input[type=tel], input[type=search], select, textarea {
  border: 1px solid #ccd5d4; background: #fff; border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 92, 90, .25); border-color: var(--brand); }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.grid-campos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-campos .ancho { grid-column: span 2; }
.grid-campos .todo { grid-column: 1 / -1; }

.chips { display: inline-flex; background: #e7ecec; border-radius: 10px; padding: 3px; }
.chips button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.chips a { padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); text-decoration: none; }
.chips a.activo, .chips button.activo { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 18px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.ingreso { background: var(--ingreso-bg); color: var(--ingreso); }
.badge.gasto { background: var(--gasto-bg); color: var(--gasto); }
.badge.buena { background: var(--ingreso-bg); color: var(--ingreso); }
.badge.regular { background: var(--warn-bg); color: var(--warn); }
.badge.mala { background: var(--gasto-bg); color: var(--gasto); }
.badge.neutro { background: #eef1f1; color: var(--ink-2); }

.aviso { background: var(--warn-bg); color: #5c3d00; border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.aviso ul { margin: 4px 0 0; padding-left: 18px; }
.aviso.error { background: var(--gasto-bg); color: #6d2010; }
.aviso.ok { background: var(--ingreso-bg); color: #164f2c; }

/* ---------- Resumen ---------- */
.resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.tarjeta { padding: 14px 16px; }
.tarjeta .titulo { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 6px; }
.tarjeta .grande { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tarjeta .det { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.tarjeta.ingreso .grande { color: var(--ingreso); }
.tarjeta.gasto .grande { color: var(--gasto); }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filtros input[type=search] { max-width: 260px; }
.filtros input[type=month] { max-width: 170px; }

/* ---------- Resumen / gráficos ---------- */
.graficos { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.hbarras { display: flex; flex-direction: column; gap: 10px; }
.hfila { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; cursor: default; }
.hnom { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hpista { height: 20px; display: block; }
.hpista i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hval { font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; min-width: 120px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
svg .eje { font-size: 11px; fill: #898781; }
svg .tope { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; }
.tabla-viz { margin-top: 10px; }
.tabla-viz summary { font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.tabla-viz table { margin-top: 6px; }
.viz-tip { position: fixed; z-index: 90; display: none; pointer-events: none; background: #fff; color: var(--ink); border: 1px solid rgba(11,11,11,.1); box-shadow: 0 6px 20px rgba(0,0,0,.12); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; max-width: 260px; font-variant-numeric: tabular-nums; }
.viz-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.tabla-prov td { min-width: 110px; }
.tabla-prov td:nth-child(3) { min-width: 150px; }

.sel-prov { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.sel-prov select { width: auto; min-width: 240px; font-weight: 600; font-size: 15px; color: var(--ink); }
@media (max-width: 820px) { .sel-prov { flex: 1; } .sel-prov select { flex: 1; min-width: 0; } }

/* ---------- Período ---------- */
.periodo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.periodo select { width: auto; }
.periodo label { display: flex; gap: 6px; align-items: center; }
.periodo input[type=date] { width: 150px; }

/* ---------- Clasificación ---------- */
.badge.cat-ingreso { background: var(--ingreso-bg); color: var(--ingreso); font-weight: 600; }
.badge.cat-gasto { background: #eef1f1; color: var(--ink-2); font-weight: 600; }
.por-cat { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 18px; }
.por-cat .titulo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 8px; }
.barra-cat { display: grid; grid-template-columns: 120px 1fr 100px; gap: 10px; align-items: center; font-size: 13.5px; padding: 3px 0; }
.barra-cat .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-cat .bar { height: 10px; background: #eef2f1; border-radius: 99px; overflow: hidden; }
.barra-cat .bar i { display: block; height: 100%; border-radius: 99px; }
.barra-cat.ingreso .bar i { background: var(--ingreso); }
.barra-cat.gasto .bar i { background: var(--gasto); }

/* ---------- Tabla libro ---------- */
.tabla-wrap { overflow-x: auto; }
table.libro { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.libro th, table.libro td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.libro thead th { position: sticky; top: 0; background: #f8faf9; font-size: 12px; color: var(--ink-2); text-align: left; font-weight: 700; }
table.libro thead tr.grupo th { text-align: center; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; border-bottom: 0; }
table.libro thead th.ing { background: #eff8f2; color: var(--ingreso); }
table.libro thead th.gas { background: #fcf2ef; color: var(--gasto); }
table.libro tbody tr { cursor: pointer; }
table.libro tbody tr:hover { background: #f5faf9; }
table.libro td.coment { max-width: 240px; color: var(--ink-2); }
table.libro td:first-child { white-space: nowrap; }
table.libro td.vacio { color: #c2c9c8; }
.det-icono { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--brand); font-weight: 700; background: var(--brand-2); padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.lista-movs { display: none; }

/* ---------- Modal ---------- */
.modal-fondo { position: fixed; inset: 0; background: rgba(10, 20, 20, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 980px; background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.angosto { max-width: 560px; }
.modal-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-cab h2 { margin: 0; }
.modal-cuerpo { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-pie { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Editor de líneas ---------- */
table.lineas { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lineas th { text-align: left; font-size: 11.5px; color: var(--ink-3); padding: 4px 4px; font-weight: 700; }
table.lineas td { padding: 2px 3px; }
table.lineas input { min-height: 32px; padding: 4px 6px; font-size: 13px; border-color: #dde3e2; }
table.lineas input.num { text-align: right; }
table.lineas .c-cod { width: 120px; }
table.lineas .c-cant { width: 70px; }
table.lineas .c-un { width: 70px; }
table.lineas .c-pu, table.lineas .c-desc, table.lineas .c-tot { width: 105px; }
table.lineas .c-x { width: 34px; }
table.lineas.lectura td { padding: 6px 6px; border-bottom: 1px solid var(--line); }
.cuadre { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: #f3f6f5; display: flex; gap: 14px; flex-wrap: wrap; }
.cuadre.mal { background: var(--warn-bg); color: #5c3d00; }

/* ---------- Subir factura ---------- */
.zona { border: 2px dashed #b9c7c5; border-radius: 14px; padding: 28px; text-align: center; background: #fbfdfc; transition: .15s; }
.zona.encima { border-color: var(--brand); background: var(--brand-2); }
.zona .acciones { justify-content: center; margin-top: 12px; }
.miniaturas { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; justify-content: center; }
.mini { position: relative; width: 92px; height: 120px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #eef2f1; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--ink-2); text-align: center; padding: 4px; }
.mini img { width: 100%; height: 100%; object-fit: cover; }
.mini button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 99px; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.consejos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 16px; }
.consejo { font-size: 13px; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.consejo b { color: var(--ink); display: block; margin-bottom: 2px; }
.cargando { display: flex; align-items: center; gap: 14px; padding: 22px; }
.spinner { width: 26px; height: 26px; border-radius: 99px; border: 3px solid var(--brand-2); border-top-color: var(--brand); animation: gira 0.9s linear infinite; flex: none; }
@keyframes gira { to { transform: rotate(360deg); } }
.doc-leido { margin-top: 16px; }
.doc-leido .cab { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.doc-leido .cuerpo { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.doc-leido .pie { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.doc-leido.guardado .cuerpo, .doc-leido.guardado .pie { display: none; }

/* foto al lado del formulario */
.doc-leido .cuerpo.con-foto { display: grid; grid-template-columns: minmax(260px, 0.8fr) 1.2fr; gap: 18px; align-items: start; }
.form-doc { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.foto-doc { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 100px); overflow: auto; border-radius: 10px; background: #eef2f1; padding: 6px; }
.foto-doc img { width: 100%; display: block; border-radius: 6px; }
.foto-doc iframe { width: 100%; height: 70vh; border: 0; border-radius: 6px; background: #fff; }
.foto-doc.fila { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; }
.foto-doc.fila img { width: 160px; height: 200px; object-fit: cover; }
.foto-doc.fila iframe { width: 100%; height: 420px; }
.doc-leido .pie { align-items: center; }

/* ---------- La Cocina ---------- */
.productos { display: flex; flex-direction: column; }
.producto { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.producto:last-child { border-bottom: 0; }
.producto .nombre { font-weight: 600; }
.producto.con-cant { background: #f4faf9; }
.stepper { display: inline-flex; align-items: center; border: 1px solid #ccd5d4; border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--brand); font-weight: 700; }
.stepper input { width: 52px; border: 0; text-align: center; min-height: 40px; padding: 0; font-weight: 700; border-radius: 0; }
.stepper input:focus { outline: none; }
.subtotal { width: 96px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pie-pedido { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: #fff; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.pedido-card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pedido-card:last-child { border-bottom: 0; }
.pedido-card ul { margin: 6px 0 8px; padding-left: 18px; color: var(--ink-2); font-size: 14px; columns: 2; }
.dos-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
textarea.mensaje { min-height: 240px; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: #17201f; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; z-index: 80; font-size: 14px; pointer-events: none; max-width: 90vw; }
.toast.ver { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Celular ---------- */
@media (max-width: 820px) {
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .nav { display: none; }
  .main { padding: 16px 14px calc(90px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600; }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a.activo { color: var(--brand); }
  .resumen { grid-template-columns: 1fr; gap: 8px; }
  .por-cat { grid-template-columns: 1fr; gap: 14px; }
  .graficos { grid-template-columns: 1fr; }
  .hfila { grid-template-columns: 90px 1fr; }
  .hval { grid-column: 1 / -1; text-align: left; min-width: 0; margin-top: -6px; }
  .periodo input[type=date] { width: 132px; }
  .barra-cat { grid-template-columns: 100px 1fr 86px; }
  .filtros select { max-width: none !important; flex: 1; }
  .tarjeta .grande { font-size: 22px; }
  .tabla-wrap.escritorio { display: none; }
  .lista-movs { display: flex; flex-direction: column; }
  .mov { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .mov:last-child { border-bottom: 0; }
  .mov .p { font-weight: 650; }
  .mov .m { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
  .mov .m.ingreso { color: var(--ingreso); }
  .mov .m.gasto { color: var(--gasto); }
  .mov .s { font-size: 12.5px; color: var(--ink-3); }
  .modal-fondo { padding: 0; align-items: stretch; }
  .modal, .modal.angosto { max-width: none; border-radius: 0; min-height: 100%; }
  .modal-pie { position: sticky; bottom: 0; background: #fff; }
  .grid-campos { grid-template-columns: 1fr 1fr; }
  .grid-campos .ancho { grid-column: 1 / -1; }
  table.lineas.editable thead { display: none; }
  table.lineas.editable tr { display: grid; grid-template-columns: 1fr 1fr 1fr 34px; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.lineas.editable td { padding: 0; }
  table.lineas.editable td.c-descr { grid-column: 1 / -1; }
  table.lineas.editable td.c-cod, table.lineas.editable td.c-un, table.lineas.editable td.c-desc { display: none; }
  table.lineas .c-cod, table.lineas .c-cant, table.lineas .c-pu, table.lineas .c-tot { width: auto; }
  .dos-col { grid-template-columns: 1fr; }
  .doc-leido .cuerpo.con-foto { grid-template-columns: 1fr; }
  .foto-doc { position: static; max-height: 55vh; }
  .chips a { padding: 6px 9px; }
  .pie-pedido { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); border-radius: 0; box-shadow: 0 -4px 14px rgba(0,0,0,.06); z-index: 25; }
  .cocina-lista { margin-bottom: 90px; }
  .producto { grid-template-columns: 1fr auto; row-gap: 2px; padding: 10px 14px; }
  .producto .stepper { grid-row: 1 / span 2; grid-column: 2; }
  .producto .subtotal { grid-column: 1; grid-row: 2; width: auto; text-align: left; font-size: 13px; color: var(--brand); font-weight: 600; }
  .stepper button { width: 38px; }
  .stepper input { width: 44px; }
  .pedido-card ul { columns: 1; }
  .filtros input[type=search], .filtros input[type=month] { max-width: none; flex: 1; }
}

/* ---------- Semáforo de estado ---------- */
.luz { display: inline-block; width: 16px; height: 16px; border-radius: 99px; border: 0; padding: 0; cursor: pointer; vertical-align: -3px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); background: #fff; }
.luz.sin { background: #fff; box-shadow: inset 0 0 0 2px #c3cbca; }
.luz.verde { background: #1f9d55; }
.luz.amarillo { background: #f0b000; }
.luz.rojo { background: #d63c3c; }
button.luz:hover { outline: 3px solid rgba(15, 92, 90, .15); }
td.c-luz { width: 44px; text-align: center; }
td.c-luz .luz { margin-top: 1px; }
.mov .p .luz { margin-right: 8px; }
.modal-cab h2 .luz { margin-right: 10px; width: 18px; height: 18px; vertical-align: -2px; }
.menu-luz { position: fixed; z-index: 95; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 4px; min-width: 170px; }
.menu-luz button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; text-align: left; }
.menu-luz button:hover { background: #f1f5f4; }
.menu-luz button.activo { background: var(--brand-2); font-weight: 700; }
.menu-luz .luz { cursor: inherit; }
.semaforo-aj { display: flex; flex-direction: column; gap: 8px; }
.semaforo-aj label { display: flex; align-items: center; gap: 10px; }
.semaforo-aj input { max-width: 260px; }

/* ---------- Libro: proveedor y comentarios ---------- */
a.link-prov { color: var(--ink); text-decoration: underline; text-decoration-color: #b9c7c5; text-underline-offset: 3px; }
a.link-prov:hover { color: var(--brand); text-decoration-color: var(--brand); }
.mov .p a.link-prov { color: inherit; }
.coment-n { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #d5dedd; background: #fff; border-radius: 99px; padding: 2px 9px 2px 7px; font-size: 12.5px; font-weight: 700; color: var(--brand); cursor: pointer; }
.coment-n svg { width: 14px; height: 14px; }
.coment-n.cero { color: #a3adac; border-color: transparent; background: transparent; }
table.libro tbody tr:hover .coment-n.cero { border-color: #d5dedd; }
td.c-coment { width: 70px; }
tr.fila-coment, tr.fila-coment:hover { background: #f7faf9 !important; cursor: default; }
tr.fila-coment td { padding: 10px 14px 14px 58px; }
.caja-coment { max-width: 720px; }
ul.comentarios { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.comentarios li { display: grid; grid-template-columns: 118px 1fr auto; gap: 10px; align-items: start; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
ul.comentarios .cuando { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
ul.comentarios .texto { white-space: pre-wrap; word-break: break-word; }
ul.comentarios .btn { min-height: 24px; padding: 0 6px; color: var(--ink-3); }
.nuevo-coment { display: flex; gap: 8px; }
.nuevo-coment input { min-height: 34px; }

/* ---------- Formulario: montos en una línea ---------- */
.montos { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }

/* ---------- Ficha de proveedor ---------- */
.ficha-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ficha-datos .panel { box-shadow: none; background: #fbfcfc; }
.grid-campos.uno { grid-template-columns: 1fr; }
table.historial td { vertical-align: middle; }

/* ---------- Pedidos anteriores (productos × pedidos) ---------- */
table.matriz { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
table.matriz th, table.matriz td { padding: 7px 10px; border-bottom: 1px solid var(--line); border-left: 1px solid #eef1f0; }
table.matriz th { background: #f8faf9; font-size: 12px; color: var(--ink-2); font-weight: 700; text-align: center; white-space: nowrap; }
table.matriz tr.fechas th { background: #fff; color: var(--ink-3); font-weight: 600; border-bottom: 0; }
table.matriz .prod { text-align: left; position: sticky; left: 0; background: #fff; min-width: 170px; border-left: 0; z-index: 1; }
table.matriz thead .prod { background: #f8faf9; }
table.matriz tr.fechas .prod { background: #fff; }
table.matriz tfoot td { font-weight: 700; background: #fbfcfc; }
table.matriz tfoot .prod { background: #fbfcfc; }
table.matriz tfoot tr.acc td { font-weight: 400; background: #fff; }
table.matriz td.num { min-width: 64px; }
.acc-ped { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.acc-ped .btn { min-height: 28px; }
.b-estado { border: 0; cursor: pointer; margin-top: 4px; font-size: 11.5px; }

/* ---------- Resumen: torta ---------- */
.cab-graf { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.chips.chico button { padding: 4px 10px; font-size: 12.5px; }
.torta { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.torta svg { flex: none; }
.torta svg path { cursor: default; }
svg .centro { font-size: 19px; font-weight: 750; fill: var(--ink); font-variant-numeric: tabular-nums; }
.leyenda-torta { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 8px; }
.leyenda-torta .lt { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; }
.leyenda-torta i { width: 12px; height: 12px; border-radius: 3px; }

/* ---------- Productos ---------- */
.productos-tabla th.prov-col { background: #f1f5f4; color: var(--ink); text-align: center; border-left: 2px solid #fff; }
.productos-tabla td, .productos-tabla th { white-space: nowrap; }
.productos-tabla td:nth-child(2) { white-space: normal; min-width: 220px; }
.productos-tabla td.barato { color: var(--ingreso); font-weight: 750; background: #eef8f1; }
.productos-tabla .caja { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.precio-chip { display: inline-block; background: #eef1f1; color: var(--ink-2); border-radius: 6px; padding: 1px 7px; margin: 2px 2px 0 0; font-variant-numeric: tabular-nums; }
.precio-chip.barato { background: var(--ingreso-bg); color: var(--ingreso); font-weight: 700; }
.prod-campos { grid-template-columns: 2fr 0.6fr 1fr 1fr 1fr; }
table.precios-prov td { padding: 4px; vertical-align: middle; }
table.precios-prov input { max-width: 140px; margin-left: auto; display: block; }

@media (max-width: 1000px) {
  .ficha-datos { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .tabbar { grid-template-columns: repeat(6, 1fr); }
  .tabbar a { font-size: 10.5px; }
  .montos { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
  .prod-campos { grid-template-columns: 1fr 1fr; }
  .prod-campos .ancho { grid-column: 1 / -1; }
  ul.comentarios li { grid-template-columns: 1fr auto; }
  ul.comentarios .cuando { grid-column: 1 / -1; }
  .torta { justify-content: center; }
  table.precios-prov input { max-width: 100px; }
}
table.libro:not(.historial):not(.productos-tabla) td:nth-child(2), table.historial td:nth-child(2) { white-space: nowrap; }
@media (max-width: 820px) {
  #f-cat, #f-prov, #f-estado { flex: 1 1 calc(50% - 10px); min-width: 0; }
  #f-q { flex: 1 1 100%; max-width: none; }
}
.montos { align-items: end; }

/* ---------- Inicio de sesión ---------- */
body.sin-sesion .tabbar { display: none; }
.login { max-width: 380px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; }
.login .btn { width: 100%; }
.login code { font-size: 12.5px; word-break: break-all; }
