:root {
  --bg: #F4F1EA;
  --card: #FFFFFF;
  --ink: #2B2A27;
  --muted: #7A776E;
  --line: #E4DDCD;
  --gold: #B48A3C;
  --gold-d: #8E6B2B;
  --gold-l: #F3EAD7;
  --green: #2F7D4F;
  --green-l: #E2F1E7;
  --blue: #2D5F8A;
  --blue-l: #E3EDF6;
  --red: #B23A2E;
  --red-l: #F8E3E0;
  --amber: #A9650B;
  --amber-l: #FBEFD9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 42, 39, .06), 0 4px 14px rgba(43, 42, 39, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--gold-d); }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 18px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.big { font-size: 19px; }
code { background: var(--gold-l); padding: 1px 6px; border-radius: 4px; }

/* ---- cabecera ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--ink); color: #fff;
}
.top-l, .top-r { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark, .login-logo {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--gold); color: #fff; font: 700 14px/1 Georgia, serif; letter-spacing: 1px; flex: none;
}
.back { color: #fff; text-decoration: none; font-size: 34px; line-height: 1; padding: 0 6px 4px 0; }
.who { color: #E8E1D2; font-size: 14px; }
.top-link { color: #fff; font-size: 14px; text-decoration: none; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, .08); }
.demo-banner { background: var(--amber-l); color: var(--amber); text-align: center; font-size: 13px; font-weight: 600; padding: 6px; letter-spacing: .5px; }

/* ---- botones y formularios ---- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-big { padding: 15px 22px; font-size: 18px; min-height: 54px; }
.btn-small { padding: 7px 11px; font-size: 14px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.form input, .form select, .inline input {
  font: inherit; font-size: 18px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%;
}
.form-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.inline input { font-size: 14px; padding: 7px 9px; width: 170px; }
.err-box, .ok-box { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; }
.err-box { background: var(--red-l); color: var(--red); }
.ok-box { background: var(--green-l); color: var(--green); }

/* ---- login ---- */
.login { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); text-align: center; }
.login-card .form { text-align: left; margin-top: 18px; }
.login-logo { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; margin-bottom: 10px; }
.login-card h1 { margin: 0; }

.narrow { max-width: 560px; margin: 0 auto; padding: 24px 16px 60px; }
.narrow.wide { max-width: 980px; }

/* ---- portada ---- */
.home { max-width: 980px; margin: 0 auto; padding: 22px 16px 40px; }
.hello { font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin: 10px 0 18px; }
.tile {
  display: block; text-decoration: none; color: #fff; border-radius: 22px; padding: 26px 24px;
  min-height: 230px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tile:active { transform: scale(.99); }
.tile-b2c { background: linear-gradient(140deg, #B48A3C, #8E6B2B); }
.tile-b2b { background: linear-gradient(140deg, #3F5A6E, #2B3E4D); }
.tile-title { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.tile-sub { opacity: .85; margin-top: 2px; }
.tile-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 28px; }
.tile-nums div { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 10px 8px; text-align: center; }
.tile-nums b { display: block; font-size: 34px; line-height: 1.1; }
.tile-nums span { font-size: 13px; opacity: .9; }

/* ---- lista de pedidos ---- */
.orders { max-width: 1100px; margin: 0 auto; padding: 16px 16px 140px; }
.orders-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 10px; }
.orders-head h1 { margin: 0; }
.tabs { display: flex; gap: 6px; background: #E9E3D6; padding: 4px; border-radius: 12px; overflow-x: auto; max-width: 100%; }
.tab {
  border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted);
  padding: 10px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; min-height: 44px;
}
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.count { display: inline-block; min-width: 24px; padding: 1px 7px; border-radius: 99px; background: var(--gold-l); color: var(--gold-d); font-size: 13px; margin-left: 4px; }
.sync { font-size: 13px; color: var(--muted); margin-left: auto; }
.sync.bad { color: var(--red); font-weight: 600; }

.selbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px 10px; }
.selall { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; min-height: 44px; }
.selall input { width: 24px; height: 24px; accent-color: var(--gold); }

.list { display: grid; gap: 12px; }
.card {
  display: grid; grid-template-columns: 56px 1fr; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 2px solid transparent; cursor: pointer; transition: border-color .15s, background .15s;
}
.card.sel { border-color: var(--gold); background: #FFFCF5; }
.card.nuevo { animation: flash 1.6s ease 2; }
@keyframes flash { 50% { background: var(--gold-l); } }
.chk { display: grid; place-items: center; border-right: 1px solid var(--line); }
.box {
  width: 30px; height: 30px; border: 2.5px solid #BDB49F; border-radius: 8px;
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px;
}
.card.sel .box { background: var(--gold); border-color: var(--gold); }
.card-main { padding: 12px 14px 12px; min-width: 0; }
.card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ord { font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.time { margin-left: auto; color: var(--muted); font-size: 14px; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .4px; }
.chip-pendiente { background: var(--amber-l); color: var(--amber); }
.chip-preparado { background: var(--green-l); color: var(--green); }
.chip-enviado { background: var(--blue-l); color: var(--blue); }
.chip-nuevo { background: var(--gold); color: #fff; }
.dest { margin: 4px 0 8px; font-size: 16px; overflow-wrap: anywhere; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; background: #F7F4EE; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.thumb .q {
  position: absolute; right: -6px; top: -6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.meta > span:not(.stepper):not(.pill):not(.muted) { font-weight: 600; color: var(--ink); }
.pill { background: #F1ECE1; color: var(--ink); padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: #F1ECE1; border-radius: 99px; padding: 2px; }
.st { width: 36px; height: 36px; border-radius: 99px; border: 0; background: #fff; font: 700 20px/1 system-ui; color: var(--ink); cursor: pointer; }
.st-n { min-width: 24px; text-align: center; font-weight: 800; color: var(--ink); font-size: 17px; }
.st-l { padding-right: 10px; color: var(--ink); font-weight: 600; }
.track { font-weight: 700; }
.ver { margin-top: 10px; background: none; border: 0; padding: 6px 0; font: inherit; font-weight: 700; color: var(--gold-d); cursor: pointer; }
.detail { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); cursor: default; }
.addr { background: #FAF8F3; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; line-height: 1.5; }
.lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.lines { width: 100%; border-collapse: collapse; font-size: 15px; }
.lines th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--gold); padding: 4px 6px; }
.lines td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: middle; }
.lines .loc { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; white-space: nowrap; }
.lines .qty { font-size: 20px; font-weight: 800; text-align: right; }
.mini { width: 40px; height: 40px; object-fit: contain; }

.empty { text-align: center; color: var(--muted); padding: 60px 10px; font-size: 18px; }
.empty-icon { font-size: 44px; color: var(--green); }

/* ---- barra de acciones ---- */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px max(10px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
}
.act {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; font: inherit; font-weight: 700; font-size: 15px;
  line-height: 1.15; color: var(--ink); cursor: pointer; text-align: left;
}
.act .ico { font-size: 26px; flex: none; }
.act > span:last-child { min-width: 0; max-width: 9em; }
.act { min-width: 0; }
.act-main { background: var(--gold); border-color: var(--gold); color: #fff; }
.act:disabled { opacity: .35; cursor: not-allowed; }
.act:active:not(:disabled) { transform: translateY(1px); }

/* ---- modal y aviso ---- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30, 28, 24, .45); display: grid; place-items: center; padding: 16px; }
.modal[hidden], .toast[hidden], [hidden] { display: none !important; }
.modal-box { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; background: #fff; border-radius: 18px; padding: 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal-box h2 { margin-top: 0; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.modal-btns:empty { display: none; }
.warn { background: var(--amber-l); color: var(--amber); padding: 8px 10px; border-radius: 8px; font-weight: 600; }
.ok-t { color: var(--green); }
.bad-t { color: var(--red); }
.res { padding-left: 20px; margin: 6px 0 12px; }
.res li { margin: 4px 0; }
.spinner { width: 46px; height: 46px; margin: 10px auto 14px; border: 5px solid var(--gold-l); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast.ok { background: var(--green); }
.toast.bad { background: var(--red); }

/* ---- tablas de administración ---- */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.table tr.off td { color: #B3AE9F; }
.table.small { font-size: 13px; }
.table .detail { border: 0; margin: 0; padding: 10px; max-width: 380px; overflow-wrap: anywhere; }
.row-ops { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 720px) {
  h1 { font-size: 22px; }
  .actions { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .act { flex-direction: column; gap: 2px; text-align: center; font-size: 12px; min-height: 72px; padding: 6px 3px; border-radius: 12px; }
  .act .ico { font-size: 24px; }
  .top { padding: 8px 12px; }
  .who { display: none; }
  .top-r { gap: 6px; }
  .brand span:last-child { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .tabs { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .tab { padding: 8px 4px; font-size: 14px; }
  .count { margin-left: 2px; padding: 1px 6px; }
  .orders { padding-top: 12px; }
  .card { grid-template-columns: 46px 1fr; }
  .ord { font-size: 19px; }
  .thumb { width: 54px; height: 54px; }
  .sync { margin-left: 0; width: 100%; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .table td { border: 0; padding: 4px 10px; }
  .inline input { width: 140px; }
}
