/* =====================================================================
   Tomate Stock — estética de Necesidades Diarias (mobile-first)
   ===================================================================== */
:root {
  --navy: #102a43; --navy-l: #cfe1f5;
  --blue: #1565c0; --blue-d: #0d47a1; --blue-l: #e3edf9;
  --red: #ef4444; --red-d: #dc2626; --red-t: #b71c1c; --red-l: #ffebee;
  --green: #2e7d32; --green-d: #1b5e20; --green-l: #e8f5e9;
  --yellow-l: #fff8e1; --yellow-t: #6d4c00;
  --gray: #6b7280; --gray-2: #94a3b8; --line: #e5e7eb; --input: #cbd5e1; --soft: #fafbfc; --th: #f1f5f9;
  --text: #1f2937; --bg: #f4f6fa; --r: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; min-height: 100vh; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .6rem; color: var(--navy); }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .4rem; }
p { margin: 0 0 .6rem; }
a { color: var(--blue); }
.muted { color: var(--gray); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: .6rem; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.6rem; } .mb { margin-bottom: 1rem; }

/* ============================ Barra superior ============================ */
.topbar { background: var(--navy); color: #fff; padding: .65rem 1rem; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; position: sticky; top: 0; z-index: 20; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 20px; height: 20px; border-radius: 50%; background: #e53935; display: inline-block; position: relative; flex: none; }
.brand .dot::after { content: ""; position: absolute; top: -3px; left: 7px; width: 7px; height: 7px; background: #66bb6a; border-radius: 7px 0 7px 0; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: .5rem .9rem; flex-wrap: wrap; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .9rem; font-size: .95rem; }
.nav a { color: var(--navy-l); text-decoration: none; padding: .25rem 0; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.topbar .logout, .topbar .menu-btn { appearance: none; border: 0; font: inherit; font-size: .9rem; cursor: pointer; border-radius: 6px; padding: .35rem .75rem; }
.topbar .logout { background: var(--red); color: #fff; }
.topbar .logout:hover { background: var(--red-d); }
.topbar .menu-btn { background: rgba(255,255,255,.12); color: #fff; }
.topbar .menu-btn:hover { background: rgba(255,255,255,.22); }
.user-chip { background: rgba(255,255,255,.12); color: #fff; padding: .25rem .65rem; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .4rem; margin-left: .3rem; min-width: 18px; display: inline-block; text-align: center; font-weight: 600; }

.page { max-width: 720px; margin: 0 auto; padding: 1.2rem 1rem 2rem; }
.page.wide { max-width: 1100px; }
.footer { text-align: center; color: var(--gray-2); padding: 1rem 1rem 6rem; font-size: .85rem; }

/* ============================ Tarjetas ============================ */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin-bottom: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card.soft { background: var(--soft); box-shadow: none; }
.card.warn { background: var(--yellow-l); border-color: #ffe082; }
.card.bad { background: var(--red-l); border-color: #ffcdd2; color: var(--red-t); }
.card.good { background: var(--green-l); border-color: #c8e6c9; }

/* ============================ Botones ============================ */
.btn { appearance: none; border: 0; background: var(--blue); color: #fff; font: inherit; font-size: .95rem; font-weight: 500; padding: .65rem 1rem; border-radius: 8px; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; text-decoration: none; transition: background .15s; }
.btn:hover { background: var(--blue-d); text-decoration: none; }
.btn:disabled { background: #e5e7eb; color: var(--gray-2); cursor: not-allowed; }
.btn.secondary { background: #e5e7eb; color: #111; }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger, .btn.red { background: var(--red); color: #fff; }
.btn.danger:hover, .btn.red:hover { background: var(--red-d); }
.btn.green { background: var(--green); } .btn.green:hover { background: var(--green-d); }
.btn.text { background: transparent; color: var(--blue); padding: .5rem .7rem; min-height: 40px; }
.btn.text:hover { background: var(--blue-l); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 54px; font-weight: 600; }
.btn.sm { min-height: 36px; padding: .4rem .65rem; font-size: .85rem; }
.btn.icon { padding: 0; width: 44px; min-height: 44px; font-size: 1.4rem; line-height: 1; }

/* ============================ Formularios ============================ */
label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-size: .95rem; font-weight: 500; color: #374151; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], input[type=email], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: #111; background: #fff; border: 1px solid var(--input); border-radius: 8px; padding: .6rem .75rem; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { min-height: 84px; resize: vertical; }
.search { background: #fff; padding-left: .9rem; }
.err { color: var(--red-t); font-size: .9rem; margin: .4rem 0; min-height: 1.2em; }
.switch { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); cursor: pointer; user-select: none; }
.switch input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; }

/* ============================ Chips / pestañas ============================ */
.chips { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem; border-radius: 999px; background: #e5e7eb; font-size: .8rem; font-weight: 600; color: #475569; white-space: nowrap; border: 1px solid transparent; }
.chip.blue { background: #dbeafe; color: var(--blue-d); }
.chip.red { background: #ffcdd2; color: var(--red-t); }
.chip.green { background: #c8e6c9; color: var(--green-d); }
.chip.yellow { background: #ffe082; color: var(--yellow-t); }
.chip.pick { cursor: pointer; font-size: .9rem; font-weight: 500; padding: .45rem .9rem; background: #fff; color: var(--text); border-color: var(--input); font-family: inherit; }
.chip.pick.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { appearance: none; background: none; border: 0; border-bottom: 3px solid transparent; font: inherit; font-weight: 600; color: var(--gray); padding: .7rem .9rem; cursor: pointer; white-space: nowrap; min-height: 46px; }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); }

/* ============================ Listas ============================ */
.list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 1rem; background: #fff; }
.item { display: flex; align-items: center; gap: .7rem; padding: .75rem .9rem; border-bottom: 1px solid var(--line); background: #fff; min-height: 54px; }
.item:last-child { border-bottom: 0; }
.item.tap { cursor: pointer; } .item.tap:hover { background: var(--soft); }
.item .name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: break-word; }
.item.head { background: var(--th); color: #334155; font-weight: 600; min-height: 38px; padding: .45rem .9rem; font-size: .9rem; }
.item.inactive .name { text-decoration: line-through; color: var(--gray); }
.item.lines { flex-wrap: wrap; row-gap: .4rem; }
.item.lines > .grow { flex: 1 1 100%; }
.item.lines .stepper { margin-right: auto; }

/* Stepper de cantidad (cajeras) */
.stepper { display: flex; align-items: center; gap: .3rem; }
.stepper input { width: 80px; text-align: center; font-size: 1.15rem; font-weight: 600; padding: .5rem .2rem; min-height: 46px; }
.stepper .btn.icon { background: #e5e7eb; color: var(--navy); border-radius: 8px; }
.stepper .btn.icon:hover { background: #d1d5db; }

/* Conteo (celular) */
.count-row { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); background: #fff; }
.count-row .name { flex: 1; font-weight: 600; font-size: 1rem; overflow-wrap: break-word; }
.count-row input { width: 110px; text-align: right; font-size: 1.15rem; font-weight: 600; min-height: 48px; }
.count-row.done { background: #f6fbf6; box-shadow: inset 3px 0 0 #66bb6a; }
.unit { font-size: .8rem; color: var(--gray); display: block; font-weight: 400; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .7rem; z-index: 15; }
.savebar .grow { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: .7rem; width: 100%; }
.status { font-size: .85rem; color: var(--gray); }
.status.ok { color: var(--green); } .status.bad { color: var(--red-t); }

/* ============================ Tablas ============================ */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 1rem; background: #fff; }
table.t { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.t th { text-align: left; background: var(--th); color: #334155; font-weight: 600; padding: .55rem .5rem; position: sticky; top: 0; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.t td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.sec td { background: var(--soft); font-weight: 600; color: var(--navy); }
.pos { color: var(--red-t); font-weight: 700; } .neg { color: var(--blue); font-weight: 700; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; }
.grid3 > .card { margin: 0; }
.stat { font-size: 1.6rem; font-weight: 700; color: var(--navy); }

/* ============================ Modal y avisos ============================ */
.overlay { position: fixed; inset: 0; background: rgba(16,42,67,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: #fff; width: 100%; max-width: 520px; border-radius: 14px 14px 0 0; padding: 1.3rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
@media (min-width: 640px) { .overlay { align-items: center; } .modal { border-radius: 12px; } }
.modal .actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
#toasts { position: fixed; left: 0; right: 0; bottom: 5.2rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 60; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: .75rem 1.2rem; border-radius: 8px; font-size: .95rem; max-width: 90%; box-shadow: 0 3px 10px rgba(0,0,0,.25); animation: pop .2s ease-out; }
.toast.bad { background: var(--red-d); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Pantalla de agradecimiento */
.thanks { text-align: center; padding: 2.5rem 1rem 1rem; }
.thanks .check { width: 96px; height: 96px; margin: 0 auto 1.2rem; border-radius: 50%; background: #c8e6c9; display: flex; align-items: center; justify-content: center; animation: pop .35s ease-out; }
.thanks h1 { font-size: 1.5rem; }
.hello { padding: 1rem 0 .8rem; }
.hello h1 { font-size: 1.6rem; }

/* Fotos */
.photo-card { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; background: #fff; }
.photo-card img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex: none; background: var(--soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; gap: .2rem; } }

/* ============================ Ingreso ============================ */
body.login-body { background: var(--navy); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 380px; border-radius: 12px; padding: 1.75rem 1.5rem; box-shadow: 0 8px 24px rgba(0,0,0,.15); margin: 0; }
.auth .brand { color: var(--navy); justify-content: center; font-size: 1.5rem; margin-bottom: .2rem; }
.auth .brand .dot { width: 26px; height: 26px; } .auth .brand .dot::after { left: 9px; top: -4px; width: 9px; height: 9px; }
.auth .sub { text-align: center; color: var(--gray); font-size: .95rem; margin: 0 0 1.25rem; }
.auth .switch-mode { margin-top: 1rem; }
.auth .switch-mode .btn.text { color: var(--navy-l); }
.auth .switch-mode .btn.text:hover { background: rgba(255,255,255,.08); color: #fff; }
.auth .foot { color: #7b93ab; font-size: .8rem; margin-top: 1.5rem; }
