:root {
  --brand: #1A194E;
  --brand-2: #2B2A6E;
  --accent: #CEA14E;
  --accent-soft: #F7EEDC;
  --bg: #F4F4F8;
  --surface: #FFFFFF;
  --surface-2: #F8F8FB;
  --line: #E2E2EC;
  --text: #1E2421;
  --muted: #6B716D;
  --danger: #B3402F;
  --danger-soft: #F8E2DE;
  --ok: #2E7D4F;
  --ok-soft: #DDF0E4;
  --info-soft: #E3ECF6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,30,25,.06), 0 4px 16px rgba(20,30,25,.06);
  font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 10px 22px; }
.side-logo { width: 150px; height: auto; display: block; }
.logo > span { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { width: 200px; height: auto; display: block; margin: 0 auto 6px; }
.auth-logo span { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.stat.seg-dog { border-top: 3px solid #B5705A; } .stat.seg-cat { border-top: 3px solid #F2B52E; } .stat.seg-both { border-top: 3px solid var(--accent); }
.seg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.seg-card { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; white-space: normal; text-align: left; border-radius: 12px; }
.seg-card .ic { font-size: 18px; }
.seg-card b { font-size: 14px; }
.seg-card small { font-weight: 400; color: var(--muted); font-size: 12px; }
.seg-card.on { border-color: var(--brand); background: #ECECF6; box-shadow: inset 0 0 0 1px var(--brand); }
.seg-card.on small { color: var(--brand-2); }
.style-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-pick { flex-direction: column; align-items: flex-start; gap: 4px; white-space: normal; text-align: left; border-radius: 12px; padding: 10px 12px; }
.style-pick small { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.35; }
.style-pick.on { border-color: var(--brand); background: #ECECF6; box-shadow: inset 0 0 0 1px var(--brand); }
.inbox-score { display: flex; align-items: baseline; gap: 6px; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.inbox-score b { font-size: 26px; }
.inbox-score.ok { background: var(--ok-soft); color: #1F5A38; } .inbox-score.mid { background: var(--accent-soft); color: #5E4615; } .inbox-score.bad { background: var(--danger-soft); color: #7D2A1E; }
.inbox-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.inbox-list li { display: flex; gap: 8px; padding: 5px 0; line-height: 1.4; }
.inbox-list li.good { color: var(--muted); }
.brand-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brand-pick { padding: 8px; gap: 10px; white-space: normal; text-align: left; border-radius: 12px; justify-content: flex-start; }
.brand-pick .bp-img { width: 72px; height: 40px; display: grid; place-items: center; flex: none; }
.brand-pick img { max-width: 72px; max-height: 40px; border-radius: 6px; }
.brand-pick .bp-label { font-size: 14px; line-height: 1.2; }
.brand-pick small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand-pick.on { border-color: var(--brand); background: #ECECF6; box-shadow: inset 0 0 0 1px var(--brand); }
.brand-pick.on .bp-label::after { content: " ✓"; color: var(--brand); }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: var(--brand); font-weight: 800; }
.nav a { display: flex; align-items: center; gap: 10px; color: #DCDCEC; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; font-size: 12px; color: #BDBDD6; padding: 8px; display: grid; gap: 8px; }
.side-foot button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; }
.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.demo-banner { background: var(--accent-soft); border: 1px solid #E8D3A8; color: #5E4615; border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; font-size: 13px; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }

button, .btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--brand); }
.btn-accent:hover { background: #BF9140; }
.btn-danger { color: var(--danger); border-color: #EBC3BC; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-link { border: none; background: none; padding: 0; color: var(--brand-2); text-decoration: underline; font-weight: 500; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.dog { background: #E7F0FB; border-color: #C9DCF3; color: #23548F; }
.pill.cat { background: #F5E8F6; border-color: #E6CBE9; color: #7A3483; }
.pill.both { background: var(--accent-soft); border-color: #F0D3A4; color: #7A5414; }
.pill.ok { background: var(--ok-soft); border-color: #BFE2CC; color: var(--ok); }
.pill.warn { background: var(--danger-soft); border-color: #EBC3BC; color: var(--danger); }
.pill.info { background: var(--info-soft); border-color: #C9D8EA; color: #2B4E78; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #FAFAFD; }
table.data tr.clickable { cursor: pointer; }
table.data td.nowrap { white-space: nowrap; }
.table-foot { padding: 10px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- composer ---------- */
.composer { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 16px; align-items: start; }
.composer .form { padding: 18px 20px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.preview-pane { position: sticky; top: 16px; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.preview-bar .subj { font-size: 13px; min-width: 0; }
.preview-bar .subj b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 6px 10px; font-size: 13px; }
.seg button.on { background: var(--brand); color: #fff; }
.preview-frame-wrap { background: #E6E6EF; padding: 14px; display: flex; justify-content: center; border-radius: 0 0 var(--radius) var(--radius); }
.preview-frame-wrap iframe { width: 100%; max-width: 680px; height: 78vh; border: 0; background: #EEEEF4; border-radius: 8px; transition: max-width .2s; }
.preview-frame-wrap.mobile iframe { max-width: 380px; }
.audience-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; }
.audience-box b { font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.starter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.starter { text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: block; white-space: normal; }
.starter b { display: block; margin-bottom: 4px; }
.starter span { font-size: 13px; color: var(--muted); font-weight: 400; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stats-row .stat { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.stats-row .stat .v { font-size: 22px; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,28,25,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 920px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head button { border: none; font-size: 22px; padding: 0 6px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.notice.ok { background: var(--ok-soft); color: #1F5A38; }
.notice.warn { background: var(--danger-soft); color: #7D2A1E; }
.notice.info { background: var(--info-soft); color: #23446B; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; background: var(--surface-2); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.map-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center; font-size: 14px; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--brand); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.list-plain li:last-child { border-bottom: none; }
#qr { background: #fff; padding: 12px; display: inline-block; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand); }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }

/* ---------- responsive ---------- */
.menu-btn { display: none; }
@media (max-width: 1080px) {
  .composer { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .brand-picks, .style-picks { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: inline-flex; margin-bottom: 12px; }
  .main { padding: 16px 16px 60px; }
  .row, .row3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .toolbar input[type=search] { max-width: none; }
  .map-grid { grid-template-columns: 1fr; }
  .preview-frame-wrap { padding: 6px; }
}
@media print {
  .side, .menu-btn, .actions, .demo-banner { display: none !important; }
  .shell { display: block; }
}

/* ---------- results ---------- */
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi .v { font-size: 32px; }
.kpi .s { margin-top: 6px; line-height: 1.4; color: var(--text); font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 6px; border-radius: 999px; margin-top: 4px; }
.status i { font-style: normal; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 11px; }
.status.good { background: #E3F4E3; color: #006300; } .status.good i { background: #0ca30c; }
.status.ok { background: #FEF3DA; color: #6B4A00; } .status.ok i { background: #c98500; }
.status.low { background: #FBE3E3; color: #9B2222; } .status.low i { background: #d03b3b; }
.status.none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.results-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.results-grid > *, .redeem-wrap > *, .composer > *, .two-col > * { min-width: 0; }
.results-grid .wide { grid-column: 1 / -1; }
.chart-card h2 { margin-bottom: 2px; }
.chart-card > p { margin: 0 0 10px; }
.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 220px; }
.chart-card.wide .chart-box { height: 300px; }
.chart-empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 16px; }
.as-table { margin-top: 10px; font-size: 13px; }
.as-table summary { cursor: pointer; color: var(--brand-2); font-weight: 600; }
.as-table table { margin-top: 8px; }
.explain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 10px; }
.explain-grid p { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- redeem ---------- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .5px; }
.redeem-wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.redeem-form { display: flex; gap: 8px; }
.redeem-form input { font-size: 22px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 2px; text-transform: uppercase; padding: 12px 14px; }
.redeem-form button { font-size: 16px; padding: 0 22px; }
.redeem-result { margin-top: 16px; text-align: center; border-radius: 14px; padding: 22px 16px; border: 2px solid var(--line); }
.redeem-result .big { font-size: 34px; line-height: 1; margin-bottom: 4px; }
.redeem-result > b { font-size: 20px; display: block; }
.redeem-result.ok { border-color: #0ca30c; background: #F1FAF1; }
.redeem-result.ok .big { color: #0ca30c; }
.redeem-result.info { border-color: #2a78d6; background: #EEF5FD; }
.redeem-result.warn { border-color: #d03b3b; background: #FDF1F1; }
.redeem-result.warn .big { color: #d03b3b; }
.redeem-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 26px; font-weight: 700; letter-spacing: 3px; color: var(--brand); margin: 10px 0 2px; text-align: center; }
.redeem-offer { font-size: 22px; font-weight: 700; color: var(--brand); }
.big-btn { font-size: 18px; padding: 14px 34px; margin-top: 14px; border-radius: 999px; }
.unique-toggle { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; cursor: pointer; }
.switch input { width: 40px; height: 22px; appearance: none; background: #CFCFDC; border-radius: 99px; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; }
.switch input:checked { background: #0ca30c; }
.switch input:checked::after { left: 21px; }
@media (max-width: 1080px) { .results-grid, .redeem-wrap { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .redeem-form input { font-size: 18px; } .chart-box { height: 230px; } }

/* ---------- clicks ---------- */
.clicks-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.who-clicked { max-height: 280px; overflow-y: auto; }
@media (max-width: 900px) { .clicks-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- scanner ---------- */
.scan-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.scan-card { overflow: hidden; }
.cam { position: relative; background: #0d0c2b; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.cam.live video { opacity: 1; }
.cam-frame { position: absolute; width: 58%; aspect-ratio: 1; opacity: 0; }
.cam.live .cam-frame { opacity: 1; }
.cam-frame i { position: absolute; width: 28px; height: 28px; border: 4px solid var(--accent); }
.cam-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.cam-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.cam-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.cam-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.cam-idle { position: relative; text-align: center; color: #DCDCEC; padding: 16px; }
.cam-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px; background: rgba(13,12,43,.7); color: #fff; font-size: 13px; text-align: center; }
.cam-msg:empty { display: none; }
.redeem-result.amber { border-color: #c98500; background: #FEF8EA; }
.redeem-result.amber .big { color: #c98500; }
.redeem-result.done-big { padding: 30px 16px; }
.redeem-result.done-big .big { font-size: 64px; }
.id-check { background: #fff; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px auto 0; max-width: 420px; }
.shell.till .menu-btn { display: none; }
@media (max-width: 900px) { .scan-wrap { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .shell.till .side { display: none; }
  .shell.till .main { padding-top: 12px; }
}
.till-bar { display: none; }
@media (max-width: 760px) {
  .shell.till .till-bar { display: flex; align-items: center; gap: 10px; background: var(--brand); color: #fff; margin: -12px -16px 12px; padding: 10px 16px; }
  .till-bar img { width: 110px; height: auto; }
  .till-bar span { color: var(--accent); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: 12px; flex: 1; }
  .till-bar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
}

/* ---------- writing check + AI ---------- */
.read-chip { margin-left: auto; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.7); border-radius: 99px; padding: 3px 9px; align-self: center; }
.inbox-list li { align-items: flex-start; }
.fix-btn { padding: 3px 9px; font-size: 12px; flex: none; }
.ai-box { background: linear-gradient(135deg, #F3F2FB, #FBF6EC); border: 1px solid #E2DFF2; border-radius: 12px; padding: 12px; margin-top: 12px; }
.ai-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 8px; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-diff { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.ai-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 6px; }
.ai-before, .ai-after { white-space: pre-wrap; font-size: 14px; line-height: 1.5; border-radius: 8px; padding: 8px 10px; margin-top: 2px; }
.ai-before { background: #F7F7FA; color: var(--muted); }
.ai-after { background: #EEF8F0; color: var(--text); }
@media (max-width: 640px) { .ai-cols { grid-template-columns: minmax(0, 1fr); } }
.radio-list { display: grid; gap: 8px; }
.radio-list .check { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-weight: 400; }
.radio-list .check:has(input:checked) { border-color: var(--brand); background: #ECECF6; }

/* =====================================================================
   Phones & tablets
   ===================================================================== */
.topbar, .tabbar, .composer-tabs { display: none; }
@media (pointer: coarse) {
  button, .btn { min-height: 44px; }
  .btn-sm, .chip, .fix-btn { min-height: 36px; }
  .nav a { padding: 12px; }
}

/* Tablet (portrait iPad etc.): compact icon sidebar */
@media (min-width: 761px) and (max-width: 1100px) {
  .shell { grid-template-columns: 84px 1fr; }
  .side { padding: 16px 8px; align-items: center; }
  .side .logo { padding: 4px 0 18px; align-items: center; }
  .side .side-logo { width: 64px; }
  .side .logo > span { display: none; }
  .nav { width: 100%; }
  .nav a { flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; padding: 10px 2px; text-align: center; line-height: 1.15; }
  .nav a svg { width: 22px; height: 22px; }
  .side-foot { padding: 4px 0; text-align: center; }
  .side-foot > div { display: none; }
  .side-foot button { font-size: 11px; padding: 6px 4px; white-space: normal; }
  .main { padding: 22px 22px 60px; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-stats.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Composer: Edit / Preview tabs whenever the two columns stack */
@media (max-width: 1080px) {
  .composer-tabs { display: inline-flex; margin-bottom: 12px; }
  .composer.tabbed:not(.show-preview) > .preview-pane { display: none; }
  .composer.tabbed.show-preview > .form { display: none; }
  .composer.tabbed .preview-frame-wrap iframe { height: calc(100dvh - 230px); min-height: 480px; }
}

/* Phone */
@media (max-width: 760px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px !important; } /* stops iOS zooming into fields */
  .shell:not(.till) .side, .menu-btn { display: none !important; }
  .shell:not(.till) .main { padding: 0 14px calc(88px + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 35; background: var(--brand); color: #fff;
    margin: 0 -14px 14px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .topbar img { width: 104px; height: auto; }
  .tb-title { flex: 1; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); font-weight: 700; }
  .tb-icon { color: #fff; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; }
  .tb-icon svg { width: 22px; height: 22px; }
  .tb-icon.active { background: rgba(255,255,255,.15); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff;
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(20,30,25,.06); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 6px 0; border-radius: 10px; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--brand); background: #ECECF6; }
  .demo-banner { font-size: 12px; padding: 8px 10px; }
  h1 { font-size: 21px; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > button { flex: 1; justify-content: center; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .v { font-size: 24px; }
  .kpi .v { font-size: 26px; }
  .card-pad { padding: 14px; }
  .toolbar { padding: 10px; }
  .toolbar select { flex: 1; min-width: 0; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { white-space: nowrap; }

  /* Composer actions: sticky bar above the tab bar */
  .composer-actions { position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 34; background: rgba(255,255,255,.97);
    border-top: 1px solid var(--line); padding: 8px 10px; display: grid !important; grid-template-columns: auto 1fr 1fr 1.2fr; gap: 6px; }
  .composer-actions #save-state { display: none; }
  .composer-actions button { padding: 8px 6px; font-size: 14px; justify-content: center; }
  .composer-actions #del .lbl { display: none; }
  .composer-actions #del::before { content: "🗑"; }
  .composer.tabbed { padding-bottom: 70px; }
  .composer .form { padding: 14px; }
  .composer.tabbed .preview-frame-wrap iframe { height: calc(100dvh - 260px); min-height: 420px; }
  .composer-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .composer-tabs button { padding: 10px; }
  .preview-pane { margin: 0 -14px; border-radius: 0; border-left: 0; border-right: 0; }

  /* Tables become cards */
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody { display: block; }
  table.data.cards tr { display: grid; border-bottom: 1px solid var(--line); padding: 12px 12px 12px 4px; }
  table.data.cards td { border: 0; padding: 0; }
  .customers-table tr { grid-template-columns: 40px 1fr auto; grid-template-areas: "chk name type" "chk email email" "chk pet status"; row-gap: 3px; align-items: center; }
  .customers-table .c-check { grid-area: chk; display: grid; place-items: center; }
  .customers-table .c-check input { width: 20px; height: 20px; }
  .customers-table .c-name { grid-area: name; font-size: 15px; }
  .customers-table .c-type { grid-area: type; }
  .customers-table .c-email { grid-area: email; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .customers-table .c-pet { grid-area: pet; font-size: 13px; }
  .customers-table .c-status { grid-area: status; justify-self: end; }
  .customers-table .c-phone, .customers-table .c-loc { display: none; }
  .campaigns-table tr { grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; padding: 14px; }
  .campaigns-table .k-name { grid-column: 1 / -1; }
  .campaigns-table .k-aud { grid-column: 1 / 3; font-size: 13px; }
  .campaigns-table .k-status { justify-self: end; }
  .campaigns-table .k-num { font-size: 13px; font-weight: 600; }
  .campaigns-table .k-num::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
  .campaigns-table .k-date { grid-column: 1 / -1; color: var(--muted); }
  .table-foot span:last-child { display: none; }

  /* Dialogs become bottom sheets */
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { max-width: none; width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot button { flex: 1; justify-content: center; }
  .map-grid select { margin-bottom: 6px; }
  .redeem-form { flex-direction: row; }
  .results-grid { gap: 12px; }
  .explain-grid { grid-template-columns: 1fr; }
}
body.modal-open { overflow: hidden; }
/* keep dialogs inside the screen */
.modal-back { grid-template-columns: minmax(0, 1fr); }
.modal { min-width: 0; }
.modal-body { overflow-x: hidden; }
.modal-body .table-wrap { overflow-x: auto; }
@media (max-width: 760px) {
  .modal-back { grid-template-columns: minmax(0, 1fr); }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar input[type=search] { grid-column: 1 / -1; }
  .toolbar select { width: 100%; }
  .toolbar > span[style] { display: none; }
  .toolbar #del-sel { grid-column: 1 / -1; }
  #toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
  .modal-open #toast { bottom: 20px; }
}

/* ---------- pets editor ---------- */
.pet-row { display: grid; grid-template-columns: 1.1fr auto 1fr 1.4fr auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--surface-2); }
.pet-row .pet-type button { padding: 7px 10px; font-size: 13px; }
.pet-row .pet-bday { display: flex; gap: 6px; align-items: center; }
.pet-row .pet-bday .row { flex: 1; }
.pet-rm { padding: 6px 10px; }
@media (max-width: 900px) {
  .pet-row { grid-template-columns: 1fr auto; }
  .pet-row [data-pf=breed], .pet-row .pet-bday { grid-column: 1 / -1; }
  .pet-row .pet-rm { grid-column: 2; grid-row: 1; justify-self: end; }
  .pet-row .pet-type { grid-column: 1 / -1; }
}
/* pets editor: two lines per pet so the birthday pickers have room */
.pet-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name type rm" "breed bday bday"; }
.pet-row [data-pf=name] { grid-area: name; }
.pet-row .pet-type { grid-area: type; }
.pet-row .pet-rm { grid-area: rm; }
.pet-row [data-pf=breed] { grid-area: breed; }
.pet-row .pet-bday { grid-area: bday; min-width: 230px; }
@media (max-width: 900px) {
  .pet-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name rm" "type type" "breed breed" "bday bday"; }
  .pet-row .pet-bday { min-width: 0; }
}
.pet-row .pet-type { justify-self: start; }
.pet-row .pet-rm { justify-self: end; width: auto; }
.stack-warn { background: #FEF3DA; border: 1px solid #E9C46A; color: #5E4615; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px auto 0; max-width: 440px; text-align: left; line-height: 1.45; }
.stack-confirm { max-width: 440px; margin: 10px auto 0; text-align: left; background: #fff; border: 2px solid #E9C46A; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.stack-confirm:has(input:checked) { border-color: #0ca30c; background: #F1FAF1; }
.stack-confirm input { width: 22px; height: 22px; }

/* ---------- extra sections ---------- */
.sec-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-tools { display: flex; gap: 4px; }
.sec-tools button { padding: 4px 9px; min-height: 32px; }
.add-sec { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.camp-kpis .status { margin-top: 4px; }
.camp-kpis .stat .s { margin-top: 4px; }

.campaigns-table .k-check { width: 34px; }
.campaigns-table .k-check input, #camp-all { width: 18px; height: 18px; cursor: pointer; }
@media (max-width: 760px) {
  .campaigns-table tr { position: relative; }
  .campaigns-table .k-name { padding-right: 34px; }
  .campaigns-table .k-check { position: absolute; top: 12px; right: 12px; width: auto; padding: 0; }
  .campaigns-table .k-check input { width: 22px; height: 22px; }
}

.seg-filter { padding: 10px 16px 0; margin: 0; }
.seg-filter .chip .muted { font-weight: 500; margin-left: 2px; }
@media (max-width: 760px) { .seg-filter { padding: 10px 10px 0; flex-wrap: nowrap; overflow-x: auto; } .seg-filter .chip { flex: none; } }
.chip.on .muted { color: #fff; opacity: .8; }
.cust-full { margin: 12px auto 0; max-width: 420px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; font-size: 14px; line-height: 1.6; }
