/* ═══════════════════════════════════════════════════════════════
   Maison — sistema de diseño "botica de lujo"
   Papel marfil · tinta · latón. Fraunces (display) + Hanken Grotesk (texto)
   ═══════════════════════════════════════════════════════════════ */
:root {
  --paper: #f5efe4;
  --paper-2: #efe6d6;
  --card: #fffbf4;
  --ink: #1d1915;
  --ink-2: #4a423a;
  --muted: #8a7f72;
  --line: #e2d6c3;
  --line-2: #d3c3aa;
  --brass: #a8792f;
  --brass-2: #c99a4b;
  --brass-soft: #f3e6cc;
  --oxblood: #7a2633;
  --oxblood-soft: #f6e3e2;
  --sage: #4f6b4a;
  --sage-soft: #e3ecdc;
  --amber-soft: #fbedd0;
  --amber: #9a6411;
  --side: #191512;
  --side-2: #241f1a;
  --side-ink: #e9dfcf;

  --c-fragancia: #8a4b2e;
  --c-fragancia-soft: #f6e4d8;
  --c-frasco: #2f5d6b;
  --c-frasco-soft: #dfecef;
  --c-tercero: #5b4b7a;
  --c-tercero-soft: #e9e4f1;

  --font-display: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --font-body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(29, 25, 21, .04), 0 10px 30px -18px rgba(29, 25, 21, .35);
  --shadow-lg: 0 30px 80px -30px rgba(29, 25, 21, .55);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
/* atmósfera: degradados + grano en una capa fija propia (sin blend ni background-attachment, más liviano al hacer scroll) */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.3 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(1200px 600px at 100% -10%, rgba(201, 154, 75, .14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(122, 38, 51, .07), transparent 60%);
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; margin: 0; font-variation-settings: "opsz" 72, "SOFT" 50; }
h1 { font-size: clamp(1.8rem, 2.6vw, 2.4rem); line-height: 1.1; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
a { color: var(--brass); }
.num, .money { font-variant-numeric: tabular-nums; }
.money { font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.serif { font-family: var(--font-display); }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }
::selection { background: var(--brass-soft); }

/* ───────── Layout ───────── */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, var(--side) 0%, #14110e 100%);
  color: var(--side-ink); padding: 26px 16px 18px;
  border-right: 1px solid #000;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(201, 154, 75, .55); color: var(--brass-2);
  font-family: var(--font-display); font-size: 1.3rem; font-style: italic;
  background: radial-gradient(circle at 30% 25%, rgba(201, 154, 75, .25), transparent 60%);
}
.brand-name { font-family: var(--font-display); font-size: 1.35rem; line-height: 1; letter-spacing: .02em; }
.brand-sub { font-size: .66rem; letter-spacing: .28em; text-transform: uppercase; color: #9c8f7d; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .66rem; letter-spacing: .22em; text-transform: uppercase; color: #7d7163; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #cfc3b1; text-decoration: none; font-weight: 500; transition: background .2s var(--ease), color .2s;
  position: relative;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(201, 154, 75, .2), rgba(201, 154, 75, .04)); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brass-2); }
.nav a.active svg { color: var(--brass-2); opacity: 1; }
.nav a .nav-badge { margin-left: auto; font-size: .7rem; background: var(--oxblood); color: #fff; border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.nav-cta { margin-top: 8px; }
.nav-cta a { background: var(--brass); color: #1b140b; font-weight: 700; justify-content: center; }
.nav-cta a:hover { background: var(--brass-2); color: #1b140b; }
.nav-cta a svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 12px; font-size: .74rem; color: #7d7163; border-top: 1px solid #2c261f; }

.main { min-width: 0; padding: 34px clamp(18px, 3.4vw, 48px) 60px; }
.page { animation: rise .45s var(--ease) both; max-width: 1320px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: rise .5s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(6) { animation-delay: .25s; }

/* ───────── Grid utils ───────── */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ───────── Card ───────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-header h2, .card-header h3 { display: flex; align-items: center; gap: 10px; }
.card-flush .card-header { padding: 18px 22px 0; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* KPI */
.kpi { position: relative; overflow: hidden; }
.kpi-label { font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-foot { margin-top: 6px; font-size: .84rem; color: var(--muted); }
.kpi-accent { background: linear-gradient(150deg, #241d16 0%, #15110d 100%); color: var(--side-ink); border-color: #000; }
.kpi-accent .kpi-label, .kpi-accent .kpi-foot { color: #a39581; }
.kpi-accent .kpi-value { color: #f6e9d2; }
.kpi-accent::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; border: 1px solid rgba(201, 154, 75, .35); box-shadow: 0 0 0 18px rgba(201, 154, 75, .06); }

/* ───────── Buttons ───────── */
.btn {
  --b: var(--card); --c: var(--ink); --bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--bd);
  background: var(--b); color: var(--c); font: 600 .92rem/1 var(--font-body);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { --b: var(--ink); --c: #f8efe0; --bd: var(--ink); }
.btn-primary:hover { --b: #000; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .6); }
.btn-brass { --b: var(--brass); --c: #1b140b; --bd: var(--brass); }
.btn-brass:hover { --b: var(--brass-2); --bd: var(--brass-2); }
.btn-ghost { --b: transparent; --bd: transparent; }
.btn-ghost:hover { --b: var(--paper-2); --bd: transparent; }
.btn-danger { --b: var(--oxblood); --c: #fff; --bd: var(--oxblood); }
.btn-danger-ghost { --b: transparent; --c: var(--oxblood); --bd: transparent; }
.btn-danger-ghost:hover { --b: var(--oxblood-soft); --bd: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: .84rem; border-radius: 8px; }
.btn-lg { height: 50px; padding: 0 22px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ───────── Forms ───────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .78rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.field .hint { font-size: .78rem; color: var(--muted); }
.field .error-text { font-size: .78rem; color: var(--oxblood); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fffdf9; color: var(--ink);
  font: 500 .95rem var(--font-body); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%234a423a' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus { border-color: var(--brass); box-shadow: 0 0 0 4px rgba(168, 121, 47, .16); }
.input.is-invalid { border-color: var(--oxblood); box-shadow: 0 0 0 4px rgba(122, 38, 51, .12); }
.input::placeholder { color: #b3a796; }
.input-lg { height: 52px; font-size: 1.15rem; }
/* input con prefijo/sufijo:  <div class="input-group"><span class="affix">$</span><input class="input"></div> */
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 10px; background: #fffdf9; transition: border-color .15s, box-shadow .15s; }
.input-group:focus-within { border-color: var(--brass); box-shadow: 0 0 0 4px rgba(168, 121, 47, .16); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; }
.input-group .affix { display: grid; place-items: center; white-space: nowrap; flex: none; padding: 0 12px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.input-group .affix:first-child { border-right: 1px solid var(--line); }
.input-group .affix:last-child { border-left: 1px solid var(--line); }
.input-group.is-invalid { border-color: var(--oxblood); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; }

/* Segmented control (p. ej. Frasco: Regalado | Cobrado)
   <div class="segmented"><button class="active">A</button><button>B</button></div> */
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--paper-2); border: 1px solid var(--line); gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: 600 .85rem var(--font-body); color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; transition: background .2s, color .2s, box-shadow .2s; }
.segmented button svg { width: 15px; height: 15px; }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.segmented button.active[data-tone="gift"] { background: var(--sage); color: #fff; box-shadow: none; }
.segmented button.active[data-tone="paid"] { background: var(--ink); color: #fff; box-shadow: none; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px 12px; font: 600 .92rem var(--font-body); color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs button .count { font-size: .72rem; background: var(--paper-2); border-radius: 999px; padding: 1px 8px; color: var(--ink-2); }
.tabs button.active { color: var(--ink); }
.tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--brass); border-radius: 2px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ───────── Table ───────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); background: rgba(239, 230, 214, .45); white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: rgba(243, 230, 204, .35); }
.table tr.is-void td { opacity: .5; }
.table tr.is-void td .strike { text-decoration: line-through; }
.table .cell-title { font-weight: 600; }
.table .cell-sub { font-size: .8rem; color: var(--muted); }
.table td.actions { text-align: right; white-space: nowrap; }

/* ───────── Badges ───────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: var(--paper-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge-ok { background: var(--sage-soft); color: var(--sage); }
.badge-bajo { background: var(--amber-soft); color: var(--amber); }
.badge-agotado { background: var(--oxblood-soft); color: var(--oxblood); }
.badge-fragancia { background: var(--c-fragancia-soft); color: var(--c-fragancia); }
.badge-frasco { background: var(--c-frasco-soft); color: var(--c-frasco); }
.badge-tercero { background: var(--c-tercero-soft); color: var(--c-tercero); }
.badge-gift { background: var(--sage-soft); color: var(--sage); }
.badge-void { background: var(--oxblood-soft); color: var(--oxblood); }

/* ───────── Empty state ───────── */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; color: var(--line-2); margin-bottom: 10px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

/* Alertas inline */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: .9rem; border: 1px solid; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-error { background: var(--oxblood-soft); border-color: #e9c4c6; color: var(--oxblood); }
.alert-warn { background: var(--amber-soft); border-color: #efd8a8; color: var(--amber); }
.alert-info { background: var(--brass-soft); border-color: #e7d2a8; color: #6e4f1c; }
.alert ul { margin: 0; padding-left: 18px; }

/* ───────── Modal ───────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 16, 12, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .2s ease both; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .28s var(--ease) both; }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: rgba(239, 230, 214, .35); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ───────── Toast ───────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #f8efe0; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .3s var(--ease) both; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast-ok svg { color: #9fd09a; }
.toast-error { background: var(--oxblood); }
.toast-info svg { color: var(--brass-2); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }

/* Barra horizontal simple (rankings) */
.bar { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brass), var(--brass-2)); }

/* Recibo (también se usa al imprimir) */
.receipt { font-family: var(--font-body); color: var(--ink); max-width: 380px; margin: 0 auto; }
.receipt-head { text-align: center; padding-bottom: 12px; border-bottom: 1px dashed var(--line-2); }
.receipt-head .serif { font-size: 1.5rem; }
.receipt-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.receipt-total { display: flex; justify-content: space-between; padding: 12px 0; font-family: var(--font-display); font-size: 1.4rem; }

#print-root { display: none; }
@media print {
  body::before, .app, .modal-backdrop, .toasts { display: none !important; }
  body { background: #fff; }
  #print-root { display: block; padding: 10mm; }
}

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid #000; }
  .brand, .nav-label, .sidebar-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
  .nav a { flex-direction: column; gap: 3px; font-size: .66rem; padding: 6px 4px; flex: 1; }
  .nav a.active::before { display: none; }
  .nav a .nav-badge { position: absolute; top: 2px; right: 18%; }
  .nav-cta { margin: 0; flex: 1; display: flex; }
  .nav-cta a { flex: 1; }
  .main { padding: 22px 16px 100px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { max-width: none; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr 1fr; } .kpi-value { font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
