/* =========================================================
   DUNA POS — estilos
   Paleta arena / terracota / café
   ========================================================= */
:root {
  --bg: #f5f0e8;
  --surface: #fffdf9;
  --surface-2: #f0e9dd;
  --line: #e4d9c8;
  --line-strong: #d3c4ad;
  --ink: #2a201a;
  --ink-2: #5b4d42;
  --muted: #8b7b6c;
  --accent: #b4532a;
  --accent-ink: #fff;
  --accent-soft: #f6e2d6;
  --ok: #4f7a3a;
  --ok-soft: #e4eed9;
  --warn: #b07d12;
  --warn-soft: #f7ecd0;
  --bad: #b3362b;
  --bad-soft: #f7dcd8;
  --side: #2a201a;
  --side-ink: #eadfce;
  --side-muted: #a7967f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(42, 32, 26, .06), 0 4px 16px rgba(42, 32, 26, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; }
.brand b { font-family: var(--display); font-size: 20px; letter-spacing: .12em; display: block; }
.brand small { color: var(--side-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 20px var(--display); flex: none; }
.brand-mark.big { width: 56px; height: 56px; font-size: 30px; border-radius: 16px; margin: 0 auto 12px; }
nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
nav .sep { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--side-muted); padding: 14px 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: var(--side-ink); text-decoration: none; border-radius: 8px; font-weight: 500; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.active { background: var(--accent); color: #fff; }
nav a .ic { width: 18px; text-align: center; opacity: .9; }
nav a .kbd { margin-left: auto; font-size: 10px; opacity: .55; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.me { display: flex; gap: 10px; align-items: center; min-width: 0; }
.me b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: var(--side-muted); font-size: 11px; text-transform: capitalize; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #4a3a2f; display: grid; place-items: center; font-weight: 700; flex: none; }
.sidebar .btn.ghost { color: var(--side-ink); border-color: rgba(255,255,255,.15); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 22px; flex: 1; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.view { padding: 24px 28px 48px; }
.only-mobile { display: none; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #9d4622; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--bad); border-color: #e8b9b3; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 14px 18px; font-size: 16px; border-radius: 10px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: inherit; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); }

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: 5px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); font: 14px var(--font); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.input-lg { font-size: 18px; padding: 13px 14px; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fbf6ee; }
.tbl tr.click { cursor: pointer; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.tbl input { padding: 6px 8px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar > * { flex: none; }
.toolbar .search { flex: 1; min-width: 220px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.kpi .val { font: 600 28px/1.15 var(--display); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Barras simples */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bars, .bars-x { justify-content: center; }
.bars .b, .bars-x span { max-width: 56px; }
.bars .b { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6px); background: var(--ink); color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; z-index: 2; }
.bars-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); margin-top: 4px; }
.bars-x span { flex: 1; text-align: center; white-space: nowrap; overflow: visible; width: 0; }
.thumb { text-transform: uppercase; font-size: 13px; letter-spacing: .04em; }
.thumb.lg { font-size: 22px; }
.hbar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Tallas */
.sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.size { min-width: 46px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; text-align: center; cursor: pointer; font-weight: 700; font-size: 13px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.size small { display: block; font-weight: 500; font-size: 10px; color: var(--muted); }
.size:hover { border-color: var(--accent); background: var(--accent-soft); }
.size.out { opacity: .4; cursor: not-allowed; background: var(--surface-2); }
.size.out:hover { border-color: var(--line-strong); }
.size.low small { color: var(--warn); }
.size-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.size-chips span { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.size-chips span.z { opacity: .45; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 400px; gap: 18px; align-items: start; }
.pos-search { position: relative; }
.pos-search input { padding-left: 44px; }
.pos-search .ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.pos-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.pcard { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pcard .top { display: flex; gap: 10px; }
.thumb { width: 56px; height: 56px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); font: 600 18px var(--display); }
.thumb.lg { width: 120px; height: 120px; font-size: 32px; }
.pcard .t b { display: block; font-size: 14px; }
.pcard .top .badge { align-self: flex-start; }
.pcard .price { font: 600 18px var(--display); color: var(--accent); }
.pcard .price s { font: 12px var(--font); color: var(--muted); margin-left: 4px; }
.cart { position: sticky; top: 84px; display: flex; flex-direction: column; max-height: calc(100vh - 110px); }
.cart-items { overflow-y: auto; flex: 1; min-height: 120px; }
.ci { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ci .n { font-weight: 600; }
.ci .meta { font-size: 12px; color: var(--muted); }
.ci .ctrl { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; }
.ci .ctrl input { width: 86px; padding: 5px 7px; font-size: 12px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); width: 28px; height: 28px; cursor: pointer; font-weight: 700; }
.qty span { min-width: 30px; text-align: center; font-weight: 600; }
.cart-tot { padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.cart-tot .l { display: flex; justify-content: space-between; padding: 2px 0; }
.cart-tot .grand { font: 600 30px var(--display); padding: 6px 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
.cart-tot .grand small { font: 600 12px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pay-methods button { padding: 12px 4px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; cursor: pointer; font: 600 12px var(--font); }
.pay-methods button .e { display: block; font-size: 20px; margin-bottom: 2px; }
.pay-methods button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font-weight: 600; }
.change-box { text-align: center; padding: 14px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); }
.change-box b { display: block; font: 600 32px var(--display); }
.change-box.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(42, 32, 26, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .14s; }
.modal.wide { width: min(920px, 100%); }
.modal.xwide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 19px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: pop .15s; font-weight: 500; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% -10%, #ead9c3 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e7c9b3 0, transparent 55%), var(--bg); }
.auth-card { width: min(380px, 100%); background: var(--surface); padding: 32px 28px; border-radius: 18px; box-shadow: 0 10px 40px rgba(42,32,26,.12); display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-card h1 { text-align: center; font-size: 30px; letter-spacing: .14em; }
.auth-card > p { text-align: center; margin: -8px 0 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }

.price-calc { background: var(--surface-2); border-radius: 10px; padding: 14px; }
.price-calc .l { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.price-calc .l.t { border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.price-calc .l.f { font: 600 22px var(--display); color: var(--accent); }

.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.size-grid .cell { border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px; text-align: center; background: #fff; }
.size-grid .cell b { display: block; font-size: 13px; margin-bottom: 4px; }
.size-grid .cell input { text-align: center; padding: 5px; }
.size-grid .cell small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .pos { grid-template-columns: 1fr 340px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .only-mobile { display: inline-block; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px; }
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; max-height: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .val { font-size: 22px; }
  .pay-methods { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .sidebar, .topbar, .toolbar, .no-print { display: none !important; }
  .layout { display: block; } .view { padding: 0; } .card { box-shadow: none; }
}
