:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --text: #1f1a14;
  --muted: #7a6f63;
  --border: #e4ddd2;
  --accent: #d9480f;
  --accent-soft: #fde8dc;
  --ok: #2b8a3e;
  --ok-soft: #e3f4e6;
  --warn: #b7791f;
  --warn-soft: #fdf1d8;
  --info: #1c6dd0;
  --info-soft: #e1edfb;
  --danger: #c92a2a;
  --danger-soft: #fde2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 26, 20, .06), 0 2px 8px rgba(31, 26, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --surface: #1f1b17;
    --surface-2: #2a2520;
    --text: #f3ede5;
    --muted: #a59a8c;
    --border: #3a332c;
    --accent: #ff7a3d;
    --accent-soft: #3d2416;
    --ok: #69c27a;
    --ok-soft: #1b3321;
    --warn: #e3b04b;
    --warn-soft: #3a2e14;
    --info: #6aa8f0;
    --info-soft: #172a42;
    --danger: #ff6b6b;
    --danger-soft: #3d1a1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h2 { font-size: 17px; margin: 0 0 10px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* barra superior */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar form { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 16px;
}
.status-pill {
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.status-pill.on { background: var(--ok-soft); color: var(--ok); }
.status-pill.off { background: var(--danger-soft); color: var(--danger); }

.tabs {
  display: flex; gap: 4px; padding: 8px 16px 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 12px 10px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 12px; text-align: center;
}

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.active { display: block; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-gap { margin-top: 32px; }

/* botones y formularios */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.chips { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; flex: 1; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
label.check input { width: auto; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 140px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}

/* pedidos */
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.order {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 8px;
  border-top: 4px solid var(--border);
}
.order.s-nuevo { border-top-color: var(--accent); }
.order.s-preparando { border-top-color: var(--warn); }
.order.s-listo, .order.s-en_camino { border-top-color: var(--info); }
.order.s-entregado { border-top-color: var(--ok); opacity: .75; }
.order.s-cancelado { opacity: .5; }
.order.flash { animation: flash 1.2s ease-in-out 3; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
.order-head { display: flex; align-items: baseline; gap: 8px; }
.folio { font-size: 24px; font-weight: 800; }
.order-head .time { margin-left: auto; color: var(--muted); font-size: 13px; }
.badge {
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .02em;
}
.badge.domicilio { background: var(--info-soft); color: var(--info); }
.badge.recoger { background: var(--warn-soft); color: var(--warn); }
.badge.st-nuevo { background: var(--accent-soft); color: var(--accent); }
.customer { font-weight: 600; }
.customer a { color: inherit; font-weight: 400; }
.address { font-size: 14px; }
.address .ref { color: var(--muted); }
.items { list-style: none; margin: 0; padding: 8px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.items li { display: flex; gap: 8px; padding: 2px 0; }
.items .qty { font-weight: 800; min-width: 22px; }
.items .mods { display: block; color: var(--muted); font-size: 13px; }
.items .price { margin-left: auto; white-space: nowrap; }
.order-notes { background: var(--warn-soft); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 14px; }
.totals { display: flex; justify-content: space-between; align-items: baseline; }
.totals .total { font-size: 18px; font-weight: 800; }
.totals .pay { color: var(--muted); font-size: 13px; text-align: right; }
.order-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.order-actions .btn.primary { flex: 1; }

/* menú */
.category { margin-bottom: 18px; }
.category-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.category-head h3 { margin: 0; font-size: 16px; }
.category-head .actions { margin-left: auto; display: flex; gap: 4px; }
.item-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px;
}
.item-row.soldout .item-name { text-decoration: line-through; color: var(--muted); }
.item-name { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 13px; }
.item-price { margin-left: auto; font-weight: 700; white-space: nowrap; }
.soldout-toggle {
  display: flex; flex-direction: row; flex: none; align-items: center; gap: 6px; margin: 0;
  font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--danger); }
.switch input:checked + span::after { transform: translateX(16px); }

.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.group h3 { margin: 0; font-size: 15px; }
.group .rule { font-size: 12px; color: var(--muted); }
.mod-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.mod-row:last-child { border-bottom: 0; }
.mod-row.soldout .mod-name { text-decoration: line-through; color: var(--muted); }
.mod-row .mod-price { margin-left: auto; color: var(--muted); font-size: 13px; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.group-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.group-checks label { flex: none; margin: 0; }
.hour-row label.check { flex: none; }

/* ajustes */
.settings { max-width: 760px; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.mode {
  display: block; position: relative; border: 2px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; margin: 0; color: var(--text); font-weight: 400;
}
.mode input { position: absolute; opacity: 0; }
.mode strong { display: block; font-size: 14px; }
.mode span { font-size: 12px; color: var(--muted); }
.mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.hours { display: grid; gap: 6px; margin-bottom: 8px; }
.hour-row { display: grid; grid-template-columns: 90px 1fr 1fr auto; gap: 8px; align-items: center; }
.hour-row .day { font-weight: 600; }
.hour-row label { margin: 0; }
.hour-row.closed input[type=time] { opacity: .35; }
.sticky-save {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px;
  padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%);
}
.list { list-style: none; padding: 0; margin: 8px 0 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li .grow { flex: 1; }
.key-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.key-row code { background: var(--surface-2); padding: 6px 10px; border-radius: 8px; word-break: break-all; }

/* llamadas */
.call { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.call-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.call-head .when { color: var(--muted); font-size: 13px; margin-left: auto; }
.call details { margin-top: 6px; }
.call pre { white-space: pre-wrap; font: 13px/1.5 inherit; background: var(--surface-2); padding: 8px; border-radius: 8px; max-height: 300px; overflow: auto; }

/* diálogo */
dialog {
  border: 0; border-radius: 16px; padding: 20px; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 15, 10, .45); }
.dialog-actions { display: flex; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; box-shadow: var(--shadow);
}
.login-card .muted { margin: 4px 0 16px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; font-size: 14px; }

@media (max-width: 600px) {
  main { padding: 12px; }
  .status-pill { display: none; }
  .hour-row { grid-template-columns: 70px 1fr 1fr auto; gap: 6px; }
  .orders { grid-template-columns: 1fr; }
}

/* agente de voz */
.voice-live { margin: 4px 0 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.voice-status { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); font-weight: 600; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); }
.dot.talking { background: var(--accent); animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.4); opacity: .6; } }
.voice-transcript { max-height: 280px; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 85%; padding: 6px 10px; border-radius: 12px; font-size: 14px; }
.bubble.agent { background: var(--surface-2); align-self: flex-start; }
.bubble.user { background: var(--accent-soft); align-self: flex-end; }
.badge.prueba { background: var(--warn-soft); color: var(--warn); }
.call-summary { font-size: 14px; margin-top: 6px; }

.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.voice {
  display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 8px 10px;
  border: 2px solid var(--border); border-radius: 10px; cursor: pointer; color: var(--text); font-weight: 400;
}
.voice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.voice input { position: absolute; opacity: 0; width: 0; }
.voice .v-info { flex: 1; min-width: 0; }
.voice .v-name { display: block; font-weight: 700; font-size: 14px; }
.voice .v-meta { display: block; font-size: 12px; color: var(--muted); }
.play {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 12px;
}
.play.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge.premium { background: var(--info-soft); color: var(--info); text-transform: none; letter-spacing: 0; }
