/* UpLevel palette, taken from the reference design: indigo → ocean → aqua gradients with pink and violet accents.
   Bright aqua and pink are used as accents only; text and buttons use colors that pass WCAG AA. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1f2240;        /* deep indigo ink */
  --muted: #5c6280;
  --line: #e0e4f0;
  --line-strong: #c3c9dd;
  --accent: #1f6fb2;      /* blue: links, solid buttons */
  --accent-2: #7b3fb3;    /* violet: end of the button gradient */
  --accent-ink: #ffffff;
  --accent-soft: #e3f0fa;
  --grad: linear-gradient(120deg, #1f6fb2, #7b3fb3);           /* primary buttons */
  --grad-head: linear-gradient(100deg, #483e7b, #2c5c96 70%, #266589); /* header */
  --grad-hot: linear-gradient(120deg, #c2378a, #7b3fb3);       /* Dictar button */
  --pink: #6ef2f1;        /* light aqua: selected tab and highlights (name kept for older rules) */
  --gold: #7b3fb3;        /* violet text accent */
  --gold-line: #c894ff;   /* lilac lines */
  --ink: #483e7b;         /* indigo */
  --ink-text: #ffffff;
  --wa: #1f8f4e;
  --danger: #b42318;
  --radius: 14px;
  --serif: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15172e; --surface: #1e2140; --text: #eceefa; --muted: #a3a8c7; --line: #2e3256; --line-strong: #444a78;
    --accent: #7fd6f0; --accent-2: #c894ff; --accent-ink: #12142a; --accent-soft: #23345a; --pink: #6ef2f1;
    --grad: linear-gradient(120deg, #7fd6f0, #c894ff); --grad-head: linear-gradient(100deg, #2a2558, #1b4566);
    --grad-hot: linear-gradient(120deg, #f26b99, #c894ff);
    --gold: #c894ff; --gold-line: #7b5cc0; --ink: #2a2558; --ink-text: #eceefa;
    --wa: #3cc47c; --danger: #ff7a70;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); }
h1 { font-family: var(--serif); font-weight: 800; font-size: 1.75rem; margin: 1.25rem 0 .5rem; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-family: var(--serif); font-weight: 750; font-size: 1.2rem; margin: 1.5rem 0 .5rem; letter-spacing: -.01em; }
.tight { margin: 0 0 .25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

header#top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 16px; background: var(--ink); background-image: var(--grad-head); color: var(--ink-text);
}
.brand { font-family: var(--serif); font-weight: 800; font-size: 1.3rem; text-decoration: none; color: var(--ink-text); letter-spacing: -.02em; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
nav a { padding: .4rem .8rem; border-radius: 999px; text-decoration: none; color: var(--ink-text); font-size: .9rem; opacity: .85; }
nav a:hover { opacity: 1; }
nav a.active { background: var(--pink); color: #1f2240; font-weight: 600; opacity: 1; }
header#top button.ghost { color: var(--ink-text); opacity: .8; }
header#top button.ghost:hover { opacity: 1; }
.top-actions { display: flex; gap: .25rem; margin-left: auto; }

main { max-width: 980px; margin: 0 auto; padding: 0 16px 4rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; }
.error-box { border-color: var(--danger); }
.error-text { color: var(--danger); }

.btn, button.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  font: inherit; font-size: .9rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); background-image: var(--grad); color: var(--accent-ink); border-color: transparent; font-weight: 600; letter-spacing: .02em; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wa { background: var(--wa); color: #fff; border-color: var(--wa); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: none; background: transparent; color: var(--muted); font-size: 1.4rem; cursor: pointer; width: 40px; height: 40px; }
.icon-btn:hover { color: var(--danger); }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.back { display: inline-block; margin-top: 1rem; text-decoration: none; }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

.form label, .filters label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 500; margin-bottom: .75rem; }
input, select, textarea {
  font: inherit; font-size: 1rem; padding: .55rem .65rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=search] { margin: .5rem 0; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.form label.check { flex-direction: row; align-items: flex-start; gap: .6rem; }
.form label.check input { width: auto; margin-top: .25rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin: 0; }
legend { font-weight: 600; padding: 0 .3rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.filters label { margin: 0; }
.filters .grow { flex: 1; min-width: 200px; }
.filters input[type=search] { margin: 0; }
label.inline { flex-direction: row !important; align-items: center; gap: .5rem; margin: 0 !important; }
label.inline input { width: 6.5rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 1rem; }
.stats.mini { margin-top: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.stats.mini .stat { background: var(--bg); }
.stat span { color: var(--muted); font-size: .8rem; }
.stat strong { font-family: var(--serif); font-size: 1.5rem; }
.stats:not(.mini) > .stat { border-top: 3px solid var(--pink); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: none; }
.list > li.empty { padding: 1.5rem; }
.row-link { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; text-decoration: none; color: var(--text); }
.row-link:hover { background: var(--accent-soft); }
.fu { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; flex-wrap: wrap; }
.fu-main { display: flex; flex-direction: column; min-width: 0; }
.fu-main a { text-decoration: none; color: var(--text); }
.fu-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 .5rem; font-size: .85rem; }

.badge { display: inline-block; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.s-sent { color: var(--wa); border-color: var(--wa); }
.badge.s-pending, .badge.s-sending { color: var(--accent); border-color: var(--accent); }
.badge.s-failed { color: var(--danger); border-color: var(--danger); }
.badge.s-skipped { color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.num { text-align: right !important; white-space: nowrap; }

.items { margin: .5rem 0; }
.item-row { display: grid; grid-template-columns: 3fr 1.1fr .7fr 1.1fr 1.35fr 1.1fr 40px; gap: .5rem; align-items: end; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.item-row label { margin: 0 !important; }
.iline { display: flex; flex-direction: column; text-align: right; padding-bottom: .55rem; }
.iline .lbl { font-size: .9rem; font-weight: 500; }
.totals { margin: 1rem 0 .5rem auto; max-width: 340px; display: flex; flex-direction: column; gap: .4rem; }
.totals > div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.totals .grand { border-top: 2px solid var(--gold-line); padding-top: .4rem; font-size: 1.25rem; }
.totals .grand strong { color: var(--accent); }

.invoice { padding: 1.5rem; }
.inv-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--gold-line); padding-bottom: 1rem; margin-bottom: 1rem; }
.inv-head h2 { font-size: 1.4rem; }
.bill-to { margin-bottom: 1rem; }
.thanks { text-align: center; color: var(--accent); font-family: var(--serif); font-style: italic; font-size: 1.15rem; margin-top: 1.5rem; }
.notes { white-space: pre-wrap; background: var(--bg); padding: .6rem .8rem; border-radius: 8px; }

.login { max-width: 420px; margin: 10vh auto; padding: 2rem 1.75rem; border-top: 6px solid var(--pink); box-shadow: 0 10px 40px rgba(72, 62, 123, .10); }
.login h1 { color: var(--accent); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1rem;
  padding: .75rem 1rem; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--line-strong); }
.qr { display: block; width: 240px; max-width: 100%; height: auto; background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.badge.s-admin { color: var(--gold); border-color: var(--gold-line); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: .2s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.error { background: var(--danger); color: #fff; }

@media (max-width: 700px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: span 2; }
  .item-row { grid-template-columns: 1fr 1fr 40px; }
  .item-row .iname { grid-column: 1 / 3; }
  .item-row .isku { grid-column: 1 / 2; }
  .item-row .iqty { grid-column: 2 / 3; }
  .item-row .iprice { grid-column: 1 / 2; }
  .item-row .idisc { grid-column: 2 / 3; }
  .item-row .iline { grid-column: 1 / 3; text-align: left; padding-bottom: 0; }
  .item-row .icon-btn { grid-row: 1; grid-column: 3; }
  .inv-head { flex-direction: column; }
  .inv-head .right { text-align: left; }
  nav { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; margin: 0 -4px; }
  nav a { white-space: nowrap; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #555; --line: #ddd; }
  header#top, .no-print, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .invoice { border: none; padding: 0; }
}

/* ---- customer totals in list ---- */
.row-link .badge { margin-left: .35rem; vertical-align: middle; }
.lifetime { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; }
.lifetime strong { font-family: var(--serif); font-size: 1.1rem; color: var(--accent); }

/* ---- type-to-filter customer picker ---- */
.combo { position: relative; }
.combo input.picked { border-color: var(--pink); background: var(--accent-soft); font-weight: 500; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto; font-weight: 400;
}
.combo-list li { display: flex; flex-direction: column; padding: .55rem .8rem; cursor: pointer; }
.combo-list li:hover, .combo-list li.active { background: var(--accent-soft); }
.combo-list li.empty { cursor: default; color: var(--muted); }

/* ---- AI / voice ---- */
.btn.ai { background: var(--ink); color: var(--pink); border-color: var(--ink); font-weight: 600; }
.btn.ai:hover { border-color: var(--pink); }
.actions.tight { margin-top: 0; }
.voice { text-align: left; }
.mic {
  display: block; margin: 1.25rem auto .5rem; width: 112px; height: 112px; border-radius: 50%;
  border: 6px solid var(--pink); background: var(--accent); background-image: var(--grad); cursor: pointer; position: relative;
  box-shadow: 0 8px 30px rgba(72, 62, 123, .3); transition: transform .15s;
}
.mic:hover { transform: scale(1.04); }
.mic:disabled { cursor: progress; opacity: .7; }
.mic-icon { position: absolute; inset: 0; margin: auto; width: 30px; height: 46px; border-radius: 15px; background: #fff; }
.mic-icon::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 4px; height: 12px; margin-left: -2px; background: #fff; }
.mic.rec { background: var(--ink); background-image: none; animation: pulse 1.2s ease-in-out infinite; }
.mic.rec .mic-icon { width: 34px; height: 34px; border-radius: 6px; }
.mic.rec .mic-icon::after { display: none; }
.mic.busy .mic-icon { animation: spin 1s linear infinite; width: 40px; height: 40px; border-radius: 50%; background: transparent; border: 5px solid #fff; border-top-color: transparent; }
.mic.busy .mic-icon::after { display: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(110, 242, 241, .7); } 50% { box-shadow: 0 0 0 18px rgba(110, 242, 241, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mic.rec, .mic.busy .mic-icon { animation: none; } }
.vstatus { font-weight: 600; margin: .25rem 0; }
.example { background: var(--bg); border-left: 3px solid var(--gold-line); padding: .6rem .8rem; border-radius: 6px; font-style: italic; margin: 1rem 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; margin: .5rem 0; }
.ai-note { border-left: 4px solid var(--pink); }
.ai-note blockquote { margin: .25rem 0 .75rem; padding: .5rem .8rem; background: var(--bg); border-radius: 6px; font-style: italic; }
.ai-note ul.warn { margin: .5rem 0; padding-left: 1.2rem; color: var(--gold); }
fieldset.newcust { border-color: var(--pink); margin-bottom: 1rem; }
input.needs { border: 2px solid var(--accent); background: var(--accent-soft); }

/* ---- logo ---- */
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; height: 40px; width: auto; }
.login-logo { display: block; width: 200px; max-width: 70%; height: auto; margin-bottom: .5rem; }
@media (max-width: 700px) { .brand img { height: 34px; } }

/* ---- help / docs ---- */
.help-head { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.help-head img { flex: none; }
.help-toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.chip { font: inherit; font-size: .88rem; padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 36px; }
.chip:hover { background: var(--accent-soft); }
.doc { scroll-margin-top: 90px; line-height: 1.6; }
.doc h2 { color: var(--accent); margin-bottom: .5rem; }
.doc h4 { font-family: var(--serif); font-size: 1.02rem; margin: 1.1rem 0 .35rem; }
.doc ol, .doc ul { padding-left: 1.3rem; }
.doc li { margin: .25rem 0; }
.doc code { background: var(--accent-soft); padding: .05rem .35rem; border-radius: 4px; font-size: .9em; }
.doc .tip, .doc .warn { padding: .6rem .8rem; border-radius: 8px; margin: .75rem 0; }
.doc .tip { background: var(--bg); border-left: 3px solid var(--gold-line); }
.doc .warn { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.doc details { border-top: 1px solid var(--line); padding: .35rem 0; }
.doc details:last-child { border-bottom: 1px solid var(--line); }
.doc details p { margin: .25rem 0 .5rem; }
header#top[hidden] { display: none; }
.brand img { height: 46px; }
.login-logo { width: 240px; }
@media (max-width: 700px) { .brand img { height: 38px; } }

/* ---- Admin / Más dropdown ---- */
.navmenu { position: relative; }
.navmenu summary { list-style: none; cursor: pointer; padding: .4rem .8rem; border-radius: 999px; color: var(--ink-text); font-size: .9rem; opacity: .85; white-space: nowrap; }
.navmenu summary::-webkit-details-marker { display: none; }
.navmenu summary:hover, .navmenu[open] summary { opacity: 1; }
.navmenu summary.active { background: var(--pink); color: #1f2240; font-weight: 600; opacity: 1; }
.navmenu .menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; z-index: 40; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.navmenu .menu a { display: block; color: var(--text); opacity: 1; padding: .6rem .8rem; border-radius: 8px; font-size: .95rem; }
.navmenu .menu a:hover { background: var(--accent-soft); }
.navmenu .menu a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 700px) { nav { overflow: visible; } }

/* ---- floating Dictar button ---- */
.fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 30;
  display: inline-flex; align-items: center; gap: .45rem; padding: .85rem 1.2rem .85rem 1rem; border-radius: 999px;
  background: #c2378a; background-image: var(--grad-hot); color: #fff; text-decoration: none; font-weight: 600; font-size: 1rem;
  border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 10px 28px rgba(123, 63, 179, .38); transition: transform .15s; }
.fab:hover { transform: translateY(-2px); }
.fab[hidden] { display: none; }
.fab span:first-child { font-size: 1.25rem; line-height: 1; }
main { padding-bottom: 6.5rem; }
@media (prefers-color-scheme: dark) { .fab { color: #12142a; border-color: rgba(0, 0, 0, .3); } }

/* ---- invoice copy ---- */
.banner.ok { background: #e7f6ee; border-color: #9fd9b8; color: #145c34; }
@media (prefers-color-scheme: dark) { .banner.ok { background: #12301f; border-color: #2b7a4b; color: #b9efcf; } }
label.sendcopy { background: var(--accent-soft); border-radius: 10px; padding: .7rem .8rem; margin-top: .5rem; }
nav { align-items: center; }
nav > a, .navmenu summary { display: inline-flex; align-items: center; gap: .25rem; line-height: 1.2; padding: .45rem .85rem; }
/* invoices on narrow phones: drop the product-code column so amounts fit */
@media (max-width: 520px) {
  .invoice .table th:nth-child(2), .invoice .table td:nth-child(2) { display: none; }
  .invoice .table th, .invoice .table td { padding: .5rem .4rem; }
}

/* ---- install button ---- */
.install-btn[hidden] { display: none !important; }
.install-login { background: var(--ink); color: var(--pink); border-color: var(--ink); font-weight: 600; margin-bottom: .6rem; }
.menu-install { display: block; width: 100%; text-align: left; font: inherit; font-size: .95rem; color: var(--accent); background: none;
  border: 0; border-top: 1px solid var(--line); margin-top: 4px; padding: .6rem .8rem; cursor: pointer; border-radius: 0 0 8px 8px; }
.menu-install:hover { background: var(--accent-soft); }

/* ---- demo requests (admin) ---- */
.lead { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; padding: .9rem 1rem; flex-wrap: wrap; }
.lead.is-new { border-left: 4px solid var(--accent); }
.lead-main { flex: 1; min-width: 240px; }
.lead-contact { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .35rem 0; }
.lead-contact a { text-decoration: none; font-weight: 500; }
.lead-msg { white-space: pre-wrap; background: var(--bg); border-radius: 6px; padding: .45rem .65rem; margin: .4rem 0 0; font-size: .92rem; }
.lead-side { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; }
.lead-side select { width: auto; min-width: 170px; }
.lead-side .btn { font-size: .85rem; padding: .35rem .7rem; }

.hist-note { background: var(--accent-soft); border-radius: 8px; padding: .5rem .75rem; }

/* ---- editor (formatting toolbar + emojis) ---- */
.editor { position: relative; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--bg); }
.toolbar .tb { font: inherit; font-size: .9rem; min-width: 36px; height: 34px; padding: 0 .55rem; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; }
.toolbar .tb:hover { background: var(--accent-soft); border-color: var(--pink); }
.toolbar .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.editor textarea { border-radius: 0 0 10px 10px; min-height: 6.5em; resize: vertical; line-height: 1.5; }
.editor-foot { display: flex; justify-content: space-between; gap: 1rem; margin-top: 4px; flex-wrap: wrap; }
.emoji-pop { position: absolute; z-index: 25; top: 46px; left: 6px; right: 6px; max-width: 420px; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.emoji-pop[hidden] { display: none; }
.emoji-pop button { font-size: 1.35rem; height: 40px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.emoji-pop button:hover { background: var(--accent-soft); }

/* ---- segmented choices ---- */
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin: .25rem 0 .5rem; }
.seg label { margin: 0 !important; display: inline-flex !important; flex-direction: row !important; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-block; padding: .55rem 1rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg label.disabled span { opacity: .45; cursor: not-allowed; }

/* ---- composer ---- */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.composer h2 { margin-top: 1.4rem; }
.composer h2.tight { margin-top: 0; }
.preview-col { position: sticky; top: 90px; }
@media (max-width: 900px) { .composer { grid-template-columns: 1fr; } .preview-col { position: static; order: -1; } }
.wa-phone { background: #1a1a1a; border-radius: 28px; padding: 8px; }
.wa-chat { background: #efe7dd; border-radius: 22px; min-height: 220px; padding: 18px 12px; display: flex; flex-direction: column; justify-content: flex-end; }
.wa-bubble { align-self: flex-end; max-width: 92%; background: #dcf8c6; color: #111; border-radius: 10px 2px 10px 10px; padding: 4px; box-shadow: 0 1px .5px rgba(0,0,0,.15); font-size: .9rem; line-height: 1.4; }
.wa-bubble img { display: block; width: 100%; border-radius: 8px; }
.wa-text { padding: 4px 6px 0; word-wrap: break-word; }
.wa-time { display: block; text-align: right; font-size: .68rem; color: #667781; padding: 2px 6px 2px; }
.wa-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
.wa-quote { display: block; border-left: 3px solid #25d366; padding-left: 6px; color: #3b4a54; }
.time-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; max-width: 360px; }
.time-row input { flex: 1; }
.pick-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.pick-bar input { flex: 1; min-width: 200px; margin: 0; }
.pick-list { list-style: none; margin: .25rem 0 0; padding: 0; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.pick-list li { border-bottom: 1px solid var(--line); }
.pick-list li:last-child { border-bottom: 0; }
.pick-list label { display: flex !important; flex-direction: row !important; align-items: center; gap: .6rem; margin: 0 !important; padding: .55rem .75rem; cursor: pointer; font-weight: 400 !important; }
.pick-list input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.pick-list label.disabled { opacity: .5; cursor: default; }

/* ---- message list ---- */
.msg-card { display: flex; gap: 1rem; padding: 1rem; align-items: flex-start; }
.msg-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: none; border: 1px solid var(--line); background: #fff; }
.msg-body { flex: 1; min-width: 0; }
.msg-text { background: var(--bg); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .5rem; line-height: 1.45; word-wrap: break-word; }
.runs { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .3rem; }
.runs li { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .92rem; }
@media (max-width: 560px) { .msg-card { flex-direction: column; } .msg-thumb { width: 100%; height: 160px; } }

/* ---- settings: logo + follow-up steps ---- */
.logo-row { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.logo-box { width: 128px; height: 128px; border-radius: 14px; border: 1.5px dashed var(--line-strong); display: grid; place-items: center; background: #fff; overflow: hidden; flex: none; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.step { padding: .9rem; margin: .6rem 0; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.step-head input[name=amount] { width: 5.5rem; }
.step-head select { width: auto; }
.step-head .icon-btn { margin-left: auto; }
.step-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--serif); }
.inv-logo { max-height: 64px; max-width: 180px; object-fit: contain; margin-bottom: .4rem; display: block; }

.ph { display: inline-block; font-size: .78em; font-weight: 600; padding: 0 .45em; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line-strong); vertical-align: 1px; }
.step .toolbar { gap: 2px; padding: 4px; }
.step .toolbar .tb { min-width: 30px; height: 30px; padding: 0 .35rem; font-size: .85rem; }
.step .tb-sep { margin: 0 2px; }
@media (max-width: 700px) {
  nav { flex-wrap: wrap; gap: 2px; margin: 0; }
  nav > a, .navmenu summary { padding: .4rem .55rem; font-size: .86rem; }
  .navmenu .menu { right: 0; left: auto; max-width: calc(100vw - 24px); }
}
@media (max-width: 900px) { .preview-col { order: 0; } .wa-chat { min-height: 120px; } }

/* ---- loyalty ---- */
.loybar { height: 10px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; margin: .35rem 0; border: 1px solid var(--line); }
.loybar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--accent)); border-radius: 999px; }
.badge.s-reward { color: var(--gold); border-color: var(--gold-line); background: #f3ecfd; }
.banner.reward { background: #f3ecfd; border-color: var(--gold-line); }
.banner.small { padding: .5rem .7rem; margin-top: .4rem; font-size: .9rem; }
.loycard h2 { margin-bottom: .5rem; }
.loyhist { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .88rem; color: var(--muted); }
.loyhist li { padding: .15rem 0; }
.loyline { margin-top: .75rem; padding: .55rem .8rem; border-radius: 8px; background: #f3ecfd; border: 1px solid var(--gold-line); }
.loyrow { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; }
.loyrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.loyrow-main a { text-decoration: none; color: var(--text); }
.loyrow .pct { font-family: var(--serif); font-weight: 600; color: var(--accent); min-width: 3.2rem; text-align: right; }
.remind-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.remind-row label.check { margin: 0 !important; }
.remind-row input[name=days] { width: 5.5rem; }
.remind-row select { width: auto; }
label.switch { background: var(--accent-soft); border-radius: 12px; padding: .8rem .9rem; }
.wa-phone.narrow { max-width: 360px; }
details.loymsgs { margin-top: 1rem; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
details.loymsgs h3 { margin: 1rem 0 .4rem; font-family: var(--sans); }
@media print { .loyline { border: 1px solid #999; background: #fff; } }

/* ---- Clientas section tabs (Clientas · Prospectos · Rifas · Lealtad) ---- */
.subtabs { display: flex; gap: 6px; margin: 1rem 0 0; padding-bottom: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { flex: 0 0 auto; padding: .55rem .9rem; border-radius: 10px 10px 0 0; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .92rem; border-bottom: 3px solid transparent; margin-bottom: -3px; white-space: nowrap; }
.subtabs a:hover { color: var(--text); background: var(--accent-soft); }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.subtabs + h1, .subtabs + .row-between h1, .subtabs + .back { margin-top: 1rem; }

/* ---- raffles ---- */
.raffle-intro .howto { padding-left: 1.25rem; margin: .5rem 0 1rem; }
.raffle-intro .howto li { margin: .35rem 0; }
.raffle-facts { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .35rem; }
.raffle-facts li { display: flex; gap: .5rem; align-items: flex-start; }
.qr-card { display: flex; gap: 1.25rem; align-items: center; }
.qr-card .qr { width: 180px; height: 180px; flex: 0 0 auto; border-radius: 10px; background: #fff; padding: 6px; border: 1px solid var(--line); }
.break { word-break: break-all; }
.btn.big { font-size: 1.1rem; padding: .8rem 1.4rem; }
.winner-name { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; margin: .25rem 0; }
.winner-name.shuffle { color: var(--muted); }
.entry-row { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .7rem 1rem; }
.danger-text { color: var(--danger) !important; }

/* printable sign */
.poster-tools { margin-top: .5rem; }
.poster { background: #fff; color: #1f2240; border: 2px solid var(--ink); border-radius: 22px; padding: 2rem 1.5rem; margin: 1rem auto 2rem; max-width: 640px; text-align: center; }
.poster-logo { max-height: 90px; max-width: 70%; margin: 0 auto .5rem; display: block; }
.poster-emoji { font-size: 3rem; }
.poster-kicker { text-transform: uppercase; letter-spacing: .14em; color: #7b3fb3; font-weight: 700; font-size: .95rem; margin: .5rem 0 0; }
.poster-title { font-family: var(--serif); font-size: 2.3rem; margin: .25rem 0 .5rem; color: #1f2240; font-weight: 800; letter-spacing: -.02em; }
.poster-prize { font-size: 1.15rem; margin: 0 auto 1rem; max-width: 30em; }
.poster-qr { width: min(320px, 78%); aspect-ratio: 1; display: block; margin: .5rem auto; }
.poster-scan { font-weight: 600; font-size: 1.15rem; margin: .5rem 0; }
.poster-meta { color: #3e4466; margin: .75rem 0 0; }
.poster-rep { font-family: var(--serif); font-size: 1.1rem; margin: 1rem 0 0; color: #483e7b; font-weight: 700; }
.poster-url { font-size: .75rem; color: #5c6280; word-break: break-all; margin: .5rem 0 0; }

/* prospects */
.prow { padding: .8rem 1rem; }
.prow-main { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.prow-main .actions { flex: 0 0 auto; justify-content: flex-end; }
.prow-main .badge { margin-left: .3rem; vertical-align: middle; }
.prow-edit { margin-top: .5rem; }
.prow-edit summary { cursor: pointer; color: var(--accent); font-size: .88rem; font-weight: 500; }
.prow-edit form { margin-top: .6rem; }
#ptabs { margin-top: .75rem; }
.stats + .filters { margin-top: .9rem; }
.filters select { width: auto; max-width: 100%; margin: 0; }
.filters input[type=search] { flex: 1 1 240px; }
@media (max-width: 640px) {
  .qr-card { flex-direction: column; text-align: center; }
  .qr-card .actions { justify-content: center; }
  .prow-main { flex-direction: column; }
  .prow-main .actions { justify-content: flex-start; }
  .poster-title { font-size: 1.8rem; }
  .subtabs { gap: 0; }
  .subtabs a { padding: .5rem .55rem; font-size: .84rem; }
}
@media print {
  .subtabs, #fab { display: none !important; }
  .poster { border: 3px solid #483e7b; margin: 0 auto; max-width: none; padding: 1.5cm 1cm; page-break-inside: avoid; }
  .poster-qr { width: 9cm; }
}
@media (max-width: 380px) { .subtabs a > span[aria-hidden] { display: none; } }

/* trial accounts */
.banner.trial, .banner.demo { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.banner.trial > span, .banner.demo > span { display: flex; flex-direction: column; gap: .15rem; }
.banner.demo { background: var(--surface); border-style: dashed; }
.ok-text { color: var(--wa); }

/* password prompt */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(31, 34, 64, .5); display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 92vh; overflow: auto; margin: 0; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .5); }
[hidden] { display: none !important; }

/* Plan picker (payments) */
.plan-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.plan-opt { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.plan-opt:hover:not(:disabled), .plan-opt:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.plan-opt:disabled { opacity: .6; cursor: wait; }
.plan-opt.busy { border-color: var(--accent); opacity: 1; }
.plan-opt .plan-price { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.plan-opt .plan-price small { font-size: .85rem; font-weight: 500; color: var(--muted); }
@media (max-width: 480px) { .plan-opts { grid-template-columns: 1fr; } }

/* Discounts and installments on the invoice form */
.disc { display: flex; gap: 4px; }
.disc input { min-width: 0; flex: 1; }
.disc select { width: 4.2em; flex: none; }
.disc-inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.disc-inline .disc { width: 9.5em; }
.totals .disc-inline input { width: 100%; }
fieldset.plan { border: 1.5px solid var(--line); border-radius: 14px; padding: .75rem 1rem 1rem; margin: 1rem 0; }
fieldset.plan legend { font-weight: 600; padding: 0 .4rem; }
.plan-split { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .5rem 0; }
.plan-split input[type=number] { width: 4.5em; }
.plan-row { display: grid; grid-template-columns: 1fr 1.2fr auto 40px; gap: .5rem; align-items: end; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.plan-row label { margin: 0 !important; }
.plan-row .check { padding-bottom: .55rem; }
@media (max-width: 640px) { .plan-row { grid-template-columns: 1fr 1fr 40px; } .plan-row .check { grid-column: 1 / 3; padding: 0; } }
.ok-text { color: #1f7a45; font-weight: 500; }
.plan-list { list-style: none; padding: 0; margin: .5rem 0; }
.plan-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.plan-list .paid { color: var(--muted); }
.balance { font-size: 1.1rem; }
.balance strong { color: var(--accent); }
.plan-view { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.btn.small, select.small { padding: .3rem .6rem; font-size: .85rem; min-height: 0; }

/* Show / hide password */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 2.9rem; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px; }
.pw-eye:hover, .pw-eye:focus-visible { color: var(--accent); background: var(--accent-soft); outline: none; }
.op-steps { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.op-steps li { margin: .2rem 0; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.installing { text-align: center; padding: 2rem 1.25rem; }
