/* ==========================================================================
   Cárnicos Antioqueñitos — hoja única para login, chat y cola.
   Todo el color sale de variables para que el MODO OSCURO sea un solo bloque
   ([data-theme="dark"]) y no una segunda hoja que se desincroniza.
   El tema se fija en <head> (inline) para que no haya destello blanco al cargar.
   ========================================================================== */
:root {
  --red: #b91c1c;
  --red-ink: #b91c1c;      /* rojo para TEXTO (necesita más luz en oscuro) */
  --ink: #1a1a1a;
  --muted: #667;
  --muted-2: #889;
  --muted-3: #556;
  --bg: #f2f3f5;
  --card: #ffffff;
  --line: #e2e4e8;
  --line-2: #d5d8dd;
  --bubble-user: #dcf8c6;
  --bubble-agent: #ffffff;
  --input-bg: #ffffff;
  --shadow: 0 8px 30px rgba(0, 0, 0, .10);
  --shadow-sm: 0 8px 30px rgba(0, 0, 0, .08);
  --avatar: #eef0f3;
  --avatar-ink: #445;
  --pill-bg: #f1f5f9;
  --pill-line: #e2e8f0;
  --btn-bg: #ffffff;
  --btn-line: #ddd;
  --topbar: #b91c1c;
  --filecard-ic: #fee2e2;
  --filecard-ic-line: #fecaca;
  --st-pend-bg: #fef3c7; --st-pend-ink: #92400e;
  --st-list-bg: #e8f7ee; --st-list-ink: #146c3a;
  --st-print-bg: #e0e7ff; --st-print-ink: #3730a3;
  --st-rev-bg: #fee2e2; --st-rev-ink: #b91c1c;
  color-scheme: light;
}

[data-theme="dark"] {
  --red: #c62c2c;
  --red-ink: #f87171;
  --ink: #e7eaee;
  --muted: #98a2ad;
  --muted-2: #8d97a2;
  --muted-3: #aeb7c0;
  --bg: #0f1216;
  --card: #1a1f26;
  --line: #2b323a;
  --line-2: #3a424c;
  --bubble-user: #1e4636;
  --bubble-agent: #1a1f26;
  --input-bg: #232a32;
  --shadow: 0 8px 30px rgba(0, 0, 0, .50);
  --shadow-sm: 0 8px 30px rgba(0, 0, 0, .40);
  --avatar: #262d35;
  --avatar-ink: #c3cad2;
  --pill-bg: #242b33;
  --pill-line: #343d47;
  --btn-bg: #1a1f26;
  --btn-line: #3a424c;
  --topbar: #7f1414;
  --filecard-ic: #3a1f22;
  --filecard-ic-line: #5a2b2f;
  --st-pend-bg: #3a2f12; --st-pend-ink: #fcd34d;
  --st-list-bg: #16352a; --st-list-ink: #6ee7a8;
  --st-print-bg: #232a4d; --st-print-ink: #a5b4fc;
  --st-rev-bg: #3d1d1d; --st-rev-ink: #fca5a5;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--red-ink); text-decoration: none; }
b { color: var(--ink); }

/* ---- botón de tema (login + barra superior) ---- */
.themebtn {
  border: none; cursor: pointer; font-size: 15px; line-height: 1;
  background: rgba(255, 255, 255, .16); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
}
.themebtn:hover { background: rgba(255, 255, 255, .3); }
.login-card .themebtn {
  position: absolute; top: 12px; right: 12px;
  background: var(--pill-bg); color: var(--ink); border: 1px solid var(--pill-line);
}

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { position: relative; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { width: 52px; height: 52px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; margin: 0 auto 12px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card input[type=password] { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; background: var(--input-bg); color: var(--ink); }
.login-card button[type=submit] { width: 100%; background: var(--red); color: #fff; border: none; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; }
.err { color: var(--red-ink); font-size: 12.5px; margin-bottom: 10px; }

/* ---- app shell (chat + review) ---- */
.topbar { background: var(--topbar); color: #fff; padding: 12px 18px; display: flex; align-items: center; gap: 11px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 800; }
.topbar .t { font-weight: 700; font-size: 15px; }
.topbar .s { font-size: 11px; opacity: .85; }
.topbar .nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.topbar .nav a { color: #fff; font-size: 12.5px; padding: 6px 11px; border-radius: 20px; background: rgba(255,255,255,.14); font-weight: 600; }
.topbar .nav a.here { background: #fff; color: var(--red); }
.topbar .tstats { margin-left: 14px; font-size: 11.5px; font-weight: 600; background: rgba(255,255,255,.16); padding: 5px 10px; border-radius: 20px; }

/* ---- chat ---- */
/* --- armazón de pantalla completa (arreglo móvil 2026-09-24) --------------
   Antes: .topbar (sticky) + .chat-wrap{height:100vh}. En un celular 100vh es MÁS
   ALTO que la ventana visible, así que el compositor quedaba por debajo del borde
   (se veía una franja del fondo, negra en modo oscuro) y el topbar rojo se perdía
   porque scrolleaba la página por fuera del scroller interno.
   Ahora el <body> es la única caja con la altura VISIBLE (dvh) y el topbar rojo
   nunca se va: solo scrollean los mensajes. */
body.app-shell { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
@supports not (height: 100dvh) { body.app-shell { height: 100vh; } }
body.app-shell .topbar { position: static; flex: 0 0 auto; }
.chat-wrap { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; }
.msgs { flex: 1; overflow-y: auto; min-height: 0; padding: 16px 14px; display: flex; flex-direction: column; gap: 9px; }
.b { max-width: 78%; padding: 9px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.b.user { align-self: flex-end; background: var(--bubble-user); border-bottom-right-radius: 4px; }
.b.agent { align-self: flex-start; background: var(--bubble-agent); border-bottom-left-radius: 4px; }
.b.agent b.q { color: var(--red-ink); }
.b .time { display: block; font-size: 10px; color: var(--muted-2); margin-top: 3px; text-align: right; }
.b img { width: 100%; max-width: 220px; border-radius: 8px; margin-top: 7px; display: block; }
.confirm { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; margin-top: 7px; font-size: 12.5px; }
.confirm .typebadge { display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; padding: 1px 7px; border-radius: 5px; margin-bottom: 5px; color: #fff; }
.confirm .l { color: var(--muted-3); }
.confirm .l b { display: block; font-size: 13.5px; }
.confirm .yesno { margin-top: 8px; display: flex; gap: 6px; }
.confirm .yesno button { flex: 1; padding: 6px; border-radius: 8px; border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--ink); font-size: 12px; cursor: pointer; }
.confirm .yesno button.ok { background: var(--red); color: #fff; border-color: var(--red); }
/* ficha de pedido (confirmación ANTES de llenar) */
.pedido { margin-top: 6px; }
.pedido table { width: 100%; border-collapse: collapse; }
.pedido td { padding: 3px 0; vertical-align: top; font-size: 12.5px; }
.pedido td.k { color: var(--muted-2); width: 78px; padding-right: 8px; }
.pedido td.v { color: var(--ink); }
.pedido .tot { font-weight: 700; }
.nota { margin-top: 6px; font-size: 11.5px; color: var(--muted-2); }
.nota.warn { color: var(--st-pend-ink); background: var(--st-pend-bg); border-radius: 7px; padding: 5px 8px; }
.nota .alt { color: var(--ink); }
.filecard { display: flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-top: 7px; font-size: 12px; }
.filecard .fic { width: 30px; height: 38px; background: var(--filecard-ic); border: 1px solid var(--filecard-ic-line); border-radius: 5px; display: grid; place-items: center; color: var(--red-ink); font-weight: 700; flex: 0 0 30px; }
.filecard .fn { flex: 1; min-width: 0; }
.filecard .fn b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filecard .fn small { color: var(--muted-2); }

.composer { background: var(--card); border-top: 1px solid var(--line);
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); position: relative; z-index: 5; }
/* campo de autofill cliente/proveedor ELIMINADO (2026-09-21): el chat es
   conversacional, resuelve el cliente del propio mensaje; no es un formulario. */
/* revisión dentro del chat: la imagen del formulario lleno + botones */
.confirm .shot { display: block; margin: 8px 0; }
.confirm .shot img { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; }
.confirm .yesno button[disabled] { opacity: .6; cursor: default; }
.sendrow { display: flex; gap: 6px; align-items: center; }
.sendrow input[type=text] { flex: 1; border: 1px solid var(--line-2); border-radius: 20px; padding: 9px 12px; font-size: 13.5px; background: var(--input-bg); color: var(--ink); }
.sendrow input[type=text]::placeholder { color: var(--muted-2); }
.icn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--ink); display: grid; place-items: center; cursor: pointer; font-size: 16px; position: relative; }
.icn.send { background: var(--red); color: #fff; border: none; }
.icn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.preview-strip .pill-f { background: var(--pill-bg); border: 1px solid var(--pill-line); border-radius: 12px; padding: 3px 9px; font-size: 11.5px; display: flex; align-items: center; gap: 6px; }
.preview-strip .pill-f button { border: none; background: none; color: var(--red-ink); cursor: pointer; font-size: 13px; padding: 0; }

/* ---- pantallas angostas (celular) ---- */
@media (max-width: 560px) {
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar .tstats, .topbar .s { display: none; }   /* no caben y empujan el nav */
  .topbar .nav a { font-size: 12px; padding: 5px 9px; }
  .themebtn { width: 30px; height: 30px; }
  .msgs { padding: 12px 10px; }
  .b { max-width: 88%; }
}

/* ── ADJUNTOS: zona de arrastre + miniaturas (2026-09-24) ─────────────── */
.preview-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.strip-hint { font-size: 12px; color: var(--mut, #6b7280); margin-right: 4px; }
.pill-f { display: inline-flex; align-items: center; gap: 6px; background: var(--bg, #f2f3f5);
          border: 1px solid var(--line, #ddd); border-radius: 999px; padding: 3px 8px; font-size: 12px; }
.pill-f img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; display: block; }
.pill-f button { border: 0; background: transparent; cursor: pointer; color: var(--mut, #6b7280);
                 font-size: 13px; line-height: 1; padding: 0 2px; }
.dropz { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
         background: rgba(0, 0, 0, .55); }
.dropz[hidden] { display: none; }            /* el atributo hidden vs display:flex */
.dropz .dz { background: var(--card, #fff); color: var(--ink, #111); border: 2px dashed var(--brand, #b91c1c);
             border-radius: 14px; padding: 26px 34px; text-align: center; font-size: 18px; max-width: 80%; }
.dropz .dz small { display: block; margin-top: 8px; font-size: 13px; color: var(--mut, #6b7280); }

/* ---- review ---- */
.review-wrap { max-width: 900px; margin: 0 auto; padding: 16px 14px 60px; }
.review-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.review-head .t { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--btn-line); background: var(--btn-bg); border-radius: 20px; padding: 6px 13px; font-size: 12.5px; cursor: pointer; color: var(--ink); }
.tabs button.active { background: var(--ink); color: var(--bg); }
.tabs button.rev-tab { border-color: var(--st-rev-bg); color: var(--st-rev-ink); background: var(--btn-bg); }
.tabs button.rev-tab.active { background: var(--red); color: #fff; }
.list { background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: none; }
.row-item .who { width: 42px; height: 42px; border-radius: 10px; background: var(--avatar); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--avatar-ink); flex: 0 0 42px; }
.row-item .mid { flex: 1; min-width: 0; }
.row-item .mid b { font-size: 14px; }
.row-item .mid .items { font-size: 12.5px; color: var(--muted-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .mid .meta { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.tpill { font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 2px 8px; border-radius: 5px; margin-right: 6px; color: #fff; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; flex: 0 0 auto; }
.pill.pend { background: var(--st-pend-bg); color: var(--st-pend-ink); }
.pill.list { background: var(--st-list-bg); color: var(--st-list-ink); }
.pill.print { background: var(--st-print-bg); color: var(--st-print-ink); }
.pill.rev { background: var(--st-rev-bg); color: var(--st-rev-ink); }
.actions { display: flex; gap: 4px; flex: 0 0 auto; }
.actions button { border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--muted-3); border-radius: 8px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
.actions button:hover { border-color: var(--muted-2); }
.empty { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13.5px; }
.tp-factura{background:#3730a3}.tp-recibo{background:#b91c1c}.tp-compra{background:#92400e}.tp-gasto{background:#7c2d12}.tp-comprobante{background:#146c3a}
.shot img { max-width: 220px; border-radius: 8px; border: 1px solid var(--line); margin-top: 6px; display: block; cursor: pointer; }
.sendbtn { background: #16a34a; color: #fff; border: none; border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.sendbtn:hover { background: #15803d; }
.errline { font-size: 11px; color: var(--st-rev-ink); margin-top: 4px; }