/* Estilo único para todas las apps. Botones grandes para dedos, alto contraste, modo oscuro automático. */
:root {
  --brand: #0f766e; --brand-ink: #fff;
  --bg: #f4f4f5; --panel: #ffffff; --panel-2: #fafafa; --line: #e4e4e7;
  --ink: #18181b; --ink-2: #52525b; --ink-3: #a1a1aa;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2; --info-bg: #e0f2fe;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --tap: 48px;
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e; --panel: #18181b; --panel-2: #1f1f23; --line: #2e2e33;
    --ink: #f4f4f5; --ink-2: #b4b4bb; --ink-3: #71717a;
    --ok-bg: #052e16; --warn-bg: #3a2405; --bad-bg: #3b0a0a; --info-bg: #082f49; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0e; --panel: #18181b; --panel-2: #1f1f23; --line: #2e2e33;
  --ink: #f4f4f5; --ink-2: #b4b4bb; --ink-3: #71717a;
  --ok-bg: #052e16; --warn-bg: #3a2405; --bad-bg: #3b0a0a; --info-bg: #082f49; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--ink-2); } .small { font-size: .85rem; } .big { font-size: 1.6rem; font-weight: 700; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Estructura */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--brand); color: var(--brand-ink); min-height: 56px; }
.topbar .title { font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.15); border: 0; border-radius: 999px; padding: .35rem .8rem; cursor: pointer; color: inherit; }
.topbar .net { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }
.topbar .net.off { background: #f87171; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.nav { width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: .5rem; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a .ico { font-size: 1.25rem; width: 1.6rem; text-align: center; }
.nav a.on { background: var(--brand); color: var(--brand-ink); }
.nav a:hover:not(.on) { background: var(--panel-2); }
.main { flex: 1; min-width: 0; padding: 1rem; }
.banner { padding: .6rem 1rem; background: var(--warn-bg); color: var(--warn); font-weight: 600; text-align: center; }
@media (max-width: 820px) {
  .nav { position: fixed; bottom: 0; left: 0; right: 0; width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-top: 1px solid var(--line); z-index: 30; padding: .25rem; padding-bottom: calc(.25rem + env(safe-area-inset-bottom)); }
  .nav a { flex-direction: column; gap: 0; padding: .35rem .6rem; font-size: .72rem; min-width: 64px; }
  .nav a .ico { font-size: 1.3rem; }
  .main { padding: .75rem .75rem 90px; }
}

/* Componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: .75rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .label { color: var(--ink-2); font-size: .85rem; } .kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; } .kpi .sub { font-size: .8rem; color: var(--ink-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; user-select: none; }
.btn:hover { filter: brightness(.97); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn.lg { min-height: 64px; font-size: 1.15rem; padding: .8rem 1.4rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label.f { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--ink-2); font-weight: 600; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 1rem; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; color: var(--ink); }
.search { max-width: 360px; }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
table.t th, table.t td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); background: var(--panel-2); position: sticky; top: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--panel-2); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-bg); border-color: transparent; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .7rem 1rem; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

/* Modal y avisos */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--panel); border-radius: 16px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal header h2 { margin: 0; }
.modal .body { padding: 1.2rem; }
.modal footer { display: flex; gap: .5rem; justify-content: flex-end; padding: 1rem 1.2rem; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); flex-wrap: wrap; }
@media (max-width: 560px) { .overlay { padding: 0; align-items: flex-end; } .modal { border-radius: 16px 16px 0 0; max-height: 96vh; } }
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: .5rem; max-width: calc(100vw - 24px); }
@media (max-width: 820px) { #toasts { bottom: 96px; } }
.toast { background: var(--ink); color: var(--bg); padding: .8rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; animation: pop .2s ease-out; max-width: 380px; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.empty { text-align: center; color: var(--ink-3); padding: 2.5rem 1rem; }
.empty .ico { font-size: 2.5rem; }

/* Inicio de sesión */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; gap: 1.2rem; }
.login .logo { font-size: 3rem; } .login h1 { text-align: center; }
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; width: 100%; max-width: 720px; }
.utile { border: 2px solid var(--line); background: var(--panel); border-radius: 14px; padding: 1rem .5rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.utile .av { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.4rem; }
.utile .rl { font-size: .78rem; color: var(--ink-2); }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: .6rem; justify-content: center; }
.pinpad button { height: 68px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 1.6rem; font-weight: 600; cursor: pointer; }
.pindots { display: flex; gap: .6rem; justify-content: center; margin: .5rem 0 1rem; }
.pindots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-3); }
.pindots span.on { background: var(--brand); border-color: var(--brand); }
.nfc-hint { display: flex; align-items: center; gap: .5rem; color: var(--ink-2); font-size: .9rem; }

/* Punto de venta */
.pos > * { min-width: 0; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: .75rem; height: calc(100vh - 56px - 2rem); }
.pos .left { display: flex; flex-direction: column; min-height: 0; gap: .6rem; }
.pos .orders-bar { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; flex: none; }
.pos .orders-bar .btn { flex: none; }
.pos .orders-bar .btn.on { outline: 3px solid var(--brand); }
.cats { display: flex; gap: .4rem; overflow-x: auto; flex: none; }
.cats button { flex: none; border: 0; padding: .6rem 1rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; cursor: pointer; min-height: 44px; }
.cats button.on { color: #fff; }
.prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; overflow-y: auto; align-content: start; flex: 1; padding: 2px; }
.prod { border: 1px solid var(--line); border-left: 6px solid var(--c, var(--brand)); background: var(--panel); border-radius: 12px; padding: .7rem; min-height: 96px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; text-align: left; box-shadow: var(--shadow); }
.prod .em { font-size: 1.6rem; } .prod .nm { font-weight: 700; line-height: 1.15; } .prod .pr { color: var(--ink-2); font-weight: 600; }
.prod:active { transform: scale(.97); }
.ticket { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow); }
.ticket .head { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.ticket .lines { flex: 1; overflow-y: auto; }
.ticket .line { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; padding: .55rem 1rem; border-bottom: 1px dashed var(--line); }
.ticket .line .qty { display: flex; align-items: center; gap: .25rem; }
.ticket .line .qty button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; cursor: pointer; }
.ticket .line .mods { font-size: .8rem; color: var(--ink-2); }
.ticket .line.sent .nm::after { content: " ✓ cocina"; font-size: .7rem; color: var(--ok); font-weight: 700; }
.ticket .foot { padding: .75rem 1rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .5rem; }
.ticket .total { display: flex; justify-content: space-between; font-size: 1.6rem; font-weight: 800; }
@media (max-width: 980px) {
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; }
  .mini-total:not(.hidden) { display: flex !important; }
  .prods { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); max-height: none; }
  .ticket { position: static; }
}
.bills { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; }
.methods .btn.on { outline: 3px solid var(--brand); }
.change { font-size: 2rem; font-weight: 800; color: var(--ok); }

/* Cocina */
.kds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; align-items: start; }
.kcard { background: var(--panel); border-radius: var(--radius); border: 2px solid var(--line); overflow: hidden; }
.kcard .kh { padding: .6rem .8rem; display: flex; justify-content: space-between; align-items: center; font-weight: 800; background: var(--panel-2); }
.kcard.late { border-color: var(--warn); } .kcard.late .kh { background: var(--warn-bg); }
.kcard.very-late { border-color: var(--bad); } .kcard.very-late .kh { background: var(--bad-bg); }
.kcard .ki { padding: .6rem .8rem; border-top: 1px solid var(--line); cursor: pointer; display: flex; gap: .6rem; }
.kcard .ki .q { font-size: 1.3rem; font-weight: 800; min-width: 2.2rem; }
.kcard .ki.listo { opacity: .45; text-decoration: line-through; }
.kcard .ki.preparando { background: var(--info-bg); }

/* Agenda */
.agenda { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--panel); position: relative; }
.agenda .hcell { position: sticky; top: 0; background: var(--panel-2); z-index: 2; padding: .5rem; font-weight: 700; text-align: center; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font-size: .9rem; }
.agenda .tcell { font-size: .75rem; color: var(--ink-2); padding: 0 .4rem; text-align: right; border-top: 1px solid var(--line); position: sticky; left: 0; background: var(--panel); z-index: 1; }
.agenda .slot { border-top: 1px solid var(--line); border-left: 1px solid var(--line); cursor: pointer; }
.agenda .slot.half { border-top-style: dotted; }
.agenda .slot:hover { background: var(--panel-2); }
.appt { position: absolute; border-radius: 8px; padding: .25rem .4rem; font-size: .8rem; color: #fff; overflow: hidden; cursor: pointer; box-shadow: var(--shadow); border-left: 5px solid rgba(0,0,0,.25); line-height: 1.2; }
.appt.cancelada, .appt.no_asistio { opacity: .45; text-decoration: line-through; }
.appt .st { font-size: .7rem; opacity: .9; }

/* Odontograma */
.odonto { display: flex; flex-direction: column; gap: .3rem; align-items: center; overflow-x: auto; padding: .5rem 0; }
.odonto .arch { display: flex; gap: 4px; }
.odonto .gap { width: 14px; }
.tooth { width: 40px; display: flex; flex-direction: column; align-items: center; cursor: pointer; font-size: .7rem; color: var(--ink-2); }
.tooth svg { width: 36px; height: 36px; }
.legend { display: flex; flex-wrap: wrap; gap: .6rem; font-size: .8rem; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; background: var(--c); }

/* Impresión de ticket (impresora térmica de 58/80 mm instalada como impresora normal) */
#print { display: none; }
@media print {
  body * { visibility: hidden; }
  #print, #print * { visibility: visible; }
  #print { display: block; position: absolute; left: 0; top: 0; width: 72mm; font-family: "Courier New", monospace; font-size: 12px; color: #000; }
  #print .c { text-align: center; } #print .r { text-align: right; } #print hr { border: 0; border-top: 1px dashed #000; }
  #print table { width: 100%; border-collapse: collapse; } #print img { width: 40mm; }
  @page { margin: 2mm; }
}
.chart-box { position: relative; height: 260px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.mini-total { display: none; position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 25; justify-content: space-between; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
