:root {
  /* Colores de marca (Floristería Cataleya): orquídea #6D2E5B, rosa #B0406A */
  --bg: #faf6f5;
  --card: #ffffff;
  --text: #1b1a1a;
  --muted: #5b6475;
  --line: #ecdfe4;
  --brand: #6d2e5b;       /* fondos: barra superior, botones, tarjetas destacadas */
  --on-brand: #ffffff;
  --primary: #6d2e5b;     /* texto y enlaces */
  --primary-2: #57224a;
  --primary-soft: #f6e7ee;
  --accent: #a83a63;      /* rosa (contraste suficiente con texto blanco) */
  --on-accent: #ffffff;
  --danger: #c62f2f;
  --danger-soft: #fbe8e8;
  --warn: #a35f00;
  --warn-soft: #fff3dc;
  --info: #0077bd;
  --info-soft: #e1f1fa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(87,34,74,.06), 0 2px 8px rgba(87,34,74,.05);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1218; --card: #251a22; --text: #f3e9ee; --muted: #b9a5b0; --line: #3a2a35;
    --brand: #7a3566; --primary: #e7a6c6; --primary-2: #dc93b8; --primary-soft: #3a2233;
    --accent: #b8457a; --danger: #ef6b62; --danger-soft: #3a1d1b; --warn: #f0b24a; --warn-soft: #3a2e14;
    --info: #5fb8ea; --info-soft: #12304a; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
  min-height: 100dvh;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 18px 0 10px; }
h3 { font-size: 1rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
.bold { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--primary); }
.neg { color: var(--danger); }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.wrap { flex-wrap: wrap; }

/* ---------- Top bar & tab bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: var(--on-brand); padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
}
.topbar h1 { font-size: 1.1rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 0; color: inherit; font-size: 2rem; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }
.cash-badge { font-size: .75rem; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.cash-badge.open { background: var(--accent); color: var(--on-accent); font-weight: 700; box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); }

.view { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .72rem; color: var(--muted); gap: 2px; }
.tabbar a .ti { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--primary); font-weight: 700; }
.tabbar a[data-tab="vender"] .ti { background: var(--brand); color: var(--on-brand); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-top: -14px; box-shadow: 0 3px 10px rgba(11,122,85,.35); }

/* ---------- Cards, lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.card + .card { margin-top: 12px; }
.card.hero { background: var(--brand); color: var(--on-brand); border: 0; }
.card.hero .muted { color: rgba(255,255,255,.8); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: .78rem; color: var(--muted); }
.kpi .value { font-size: 1.35rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.big { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 4px; color: var(--text); font-size: .75rem; text-align: center; cursor: pointer; }
.action .ai { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: .82rem; color: var(--muted); }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; font-weight: 700; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--primary-soft); color: var(--primary); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }

.alert { border-radius: 12px; padding: 12px 14px; font-size: .9rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* ---------- Forms & buttons ---------- */
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input.money { font-size: 1.5rem; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.field + .field { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: var(--text); font-weight: 400; }
.check input { width: 22px; height: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700;
  border: 0; border-radius: 12px; padding: 13px 18px; cursor: pointer; background: var(--brand); color: var(--on-brand); min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--accent); color: var(--on-accent); }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: .88rem; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: transparent; font: inherit; font-size: .88rem; padding: 9px 8px; border-radius: 9px; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 600; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 10px 0; scrollbar-width: none; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: .85rem; white-space: nowrap; cursor: pointer; color: var(--text); font: inherit; font-size: .85rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.search { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; background: var(--bg); padding: 4px 0 6px; }

/* ---------- Productos (vender) ---------- */
.pgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .pgrid { grid-template-columns: repeat(3, 1fr); } .actions { grid-template-columns: repeat(4, 1fr); } .kpis { grid-template-columns: repeat(4, 1fr); } }
.pcard { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 108px; user-select: none; }
.pcard.in { border-color: var(--primary); background: var(--primary-soft); }
.pcard.out { opacity: .5; }
.pcard .pname { font-weight: 600; font-size: .92rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .pprice { font-weight: 800; font-size: 1.05rem; margin-top: auto; }
.pcard .pstock { font-size: .75rem; color: var(--muted); }
.pcard .qbadge { position: absolute; top: -8px; right: -8px; background: var(--brand); color: var(--on-brand); border-radius: 99px; min-width: 26px; height: 26px; display: grid; place-items: center; font-weight: 800; font-size: .85rem; padding: 0 6px; }

.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)); z-index: 15;
  max-width: 696px; margin: 0 auto; background: var(--brand); color: var(--on-brand); border-radius: 16px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.2); cursor: pointer; border: 0; font: inherit; font-weight: 700; width: calc(100% - 24px);
}
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 36px; height: 36px; border: 0; background: var(--card); color: var(--primary); font-size: 1.2rem; font-weight: 800; cursor: pointer; }
.stepper input { width: 58px; border: 0; border-radius: 0; text-align: center; padding: 6px 2px; font-weight: 700; }

.totals .line { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .line.total { font-size: 1.3rem; font-weight: 800; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }

/* ---------- Barras (reportes) ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.bars-labels { display: flex; gap: 4px; font-size: .65rem; color: var(--muted); margin-top: 4px; }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; }
.hbar { height: 8px; background: var(--primary-soft); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.hbar > div { height: 100%; background: var(--brand); border-radius: 99px; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t td, table.t th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Modal (hoja inferior) ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet .sheet-head h3 { font-size: 1.15rem; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 760px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 90px); z-index: 60; background: #1b1a1a; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 90vw; font-size: .92rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--brand); }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 10vh auto 0; }
.login .logo { width: 84px; height: 84px; margin: 0 auto 12px; display: block; }
.login h1 { text-align: center; font-size: 1.6rem; margin-bottom: 4px; }

/* ---------- Ticket ---------- */
.ticket { background: #fff; color: #000; font-family: ui-monospace, "Courier New", monospace; font-size: 13px; line-height: 1.35; padding: 16px 14px; border-radius: 8px; max-width: 340px; margin: 0 auto; border: 1px dashed #bbb; }
.ticket .c { text-align: center; }
.ticket .b { font-weight: 700; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 8px 0; }
.ticket .l { display: flex; justify-content: space-between; gap: 8px; }
.ticket .anulada { text-align: center; font-weight: 900; font-size: 18px; border: 2px solid #000; margin: 8px 0; }
.print-area { display: none; }

@media print {
  @page { size: 58mm auto; margin: 0; }
  body { background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  /* Papel de 58 mm: el área imprimible real es de ~48 mm */
  .print-area .ticket { border: 0; border-radius: 0; max-width: none; width: 48mm; margin: 0 auto; padding: 1mm 0 6mm; font-size: 11px; line-height: 1.3; word-break: break-word; }
  .print-area .ticket .tname { font-size: 13px; }
  .print-area .ticket .tlogo { max-height: 22mm; }
}
input[type=date] { min-width: 0; -webkit-appearance: none; appearance: none; min-height: 48px; }

/* Reportes */
.kpi .value.warn { color: var(--warn); }
.t tr.b td { border-top: 2px solid var(--line, #ddd); }
a.alert { text-decoration: none; }

/* Logo del negocio */
.brand-logo { height: 30px; width: auto; max-width: 90px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; }
.login .logo.custom { width: auto; height: auto; max-width: 180px; max-height: 110px; object-fit: contain; }
.ticket .tlogo { max-width: 70%; max-height: 80px; object-fit: contain; margin-bottom: 4px; filter: grayscale(1) contrast(1.6); }
.ticket .tname { font-size: 15px; }
.ticket .small { font-size: 11px; }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 110px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; padding: 10px; }
.logo-preview img { max-width: 220px; max-height: 110px; object-fit: contain; }

/* Fotos */
img.avatar { object-fit: cover; background: var(--card); border: 1px solid var(--line); }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.pcard .pimg { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; border-radius: 10px; }
.photo-box { position: relative; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); display: grid; place-items: center; min-height: 140px; overflow: hidden; }
.photo-box img { width: 100%; max-height: 320px; object-fit: contain; }
.photo-box .muted { padding: 24px; }
.home-logo { height: 40px; width: auto; max-width: 140px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }

/* Catálogo virtual público (sin barra de pestañas) */
.catalog-page .cartbar { bottom: calc(14px + env(safe-area-inset-bottom)); }
.catalog-page .view { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.pcard .stepper { align-self: stretch; justify-content: space-between; }
.pcard .stepper input { width: 100%; }
