/* TV Manager – single stylesheet, no build step */
:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --ink: #14201d;
  --ink-2: #4b5a56;
  --muted: #7a8784;
  --line: #e3e7e3;
  --line-2: #eef1ee;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3f0;
  --wa: #1faa59;
  --wa-dark: #128c4b;
  --wa-soft: #e5f7ec;
  --green: #15803d; --green-soft: #e4f5e9;
  --amber: #b45309; --amber-soft: #fdf1df;
  --red: #c2410c; --red-soft: #fde9e1;
  --grey: #5b6b67; --grey-soft: #eceeec;
  --violet: #6d28d9; --violet-soft: #efe8fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 29, .05), 0 4px 16px rgba(20, 32, 29, .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --card: #161e1c; --ink: #e7eeec; --ink-2: #b8c4c1; --muted: #8a9895;
    --line: #26312e; --line-2: #1d2624; --brand: #2bb3a6; --brand-ink: #062320; --brand-soft: #123532;
    --wa-soft: #13301f; --green: #4ade80; --green-soft: #12301c; --amber: #fbbf24; --amber-soft: #3a2b0d;
    --red: #fb923c; --red-soft: #3b1d10; --grey: #a3b0ad; --grey-soft: #222b29; --violet: #c4b5fd; --violet-soft: #2a1f47;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
code { font-family: var(--mono); font-size: .92em; background: var(--line-2); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.txt-red { color: var(--red); } .txt-amber { color: var(--amber); } .txt-green { color: var(--green); }
.ico { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); }
.brand-mark.big { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 6px; }
.brand-mark.big .ico { width: 28px; height: 28px; }
.mainnav { display: flex; gap: 2px; flex: 1; }
.mainnav a {
  position: relative; display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 550; font-size: 14px;
}
.mainnav a:hover { background: var(--line-2); text-decoration: none; }
.mainnav a.on { background: var(--brand-soft); color: var(--brand); }
.mainnav .dot {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.topright { display: flex; align-items: center; gap: 10px; }
.credits {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink); font-weight: 650;
}
.credits small { color: var(--muted); font-weight: 500; }
.credits:hover { text-decoration: none; border-color: var(--brand); }
.iconbtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--line-2); color: var(--ink); }
.iconbtn.sm { width: 28px; height: 28px; vertical-align: middle; }
.iconbtn.sm .ico { width: 15px; height: 15px; }
.withcopy { position: relative; display: block; }
.sortby { margin: -4px 2px 12px; }
.tracker { border: 1px solid var(--line, #ddd); border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 16px; }
.tracker legend { font-weight: 700; padding: 0 6px; }
.device-copy { margin: -4px 0 10px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.statgrid > div { background: var(--line-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.statgrid b { font-size: 22px; line-height: 1.1; }
.statgrid span { font-size: 13px; font-weight: 600; }
.statgrid small { font-size: 12px; color: var(--muted); }
.tips li { margin: 6px 0; line-height: 1.5; }
.hourbars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 110px; align-items: end; margin: 8px 0; }
.hourbars div { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.hourbars i { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.hourbars small { font-size: 10px; color: var(--muted); height: 14px; }
.zoomwrap { position: relative; display: table; margin: 0 auto; }
.zoomwrap img { cursor: crosshair; display: block; }
#zoomspot { position: absolute; width: 60px; height: 60px; margin: -30px 0 0 -30px; border: 3px solid var(--brand); border-radius: 50%; pointer-events: none; animation: zoompulse 1s infinite; }
@keyframes zoompulse { 50% { transform: scale(1.3); opacity: .5; } }
.scanlist { display: grid; gap: 14px; }
.scanitem { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 14px; align-items: start; }
.scanitem img { width: 100%; border-radius: 10px; display: block; }
.scanitem .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.scantext { white-space: pre-wrap; max-height: 220px; overflow: auto; background: var(--bg, #f4f4f4); padding: 8px; border-radius: 8px; }
@media (max-width: 640px) { .scanitem { grid-template-columns: 1fr; } }
.whoami { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted, #666); }
.whoami svg { width: 16px; height: 16px; }
.chips.owners { margin-top: -6px; }
.chips.owners .chip svg { width: 14px; height: 14px; margin-right: 3px; vertical-align: -2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }
#navbar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--brand); z-index: 100; opacity: 0; transition: width 8s cubic-bezier(.1,.7,.2,1), opacity .2s; }
#navbar.go { width: 90%; opacity: 1; }
.guide ol, .guide ul { padding-left: 22px; margin: 6px 0 12px; }
.guide li { margin: 6px 0; line-height: 1.5; }
.guide li ul { margin: 4px 0; }
.guide textarea { width: 100%; font-size: 12px; }
.sortby a { color: inherit; text-decoration: none; }
.sortby a.on { color: var(--ink, inherit); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.withcopy input { padding-right: 46px; }
.withcopy .iconbtn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.center { justify-content: center; margin-top: 12px; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid2 > .card { margin-bottom: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow, .narrow { max-width: 720px; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cardhead.pad { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--line-2); }
.cardhead h2, .h2 { display: flex; align-items: center; gap: 9px; }
.h2 { margin-bottom: 14px; }
.h3 { font-size: 15px; margin: 22px 0 6px; }
summary.cardhead { cursor: pointer; list-style: none; }
summary.cardhead::-webkit-details-marker { display: none; }
details:not([open]) > summary.cardhead { border-bottom: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 15px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); border-color: var(--wa-dark); }
.btn-wa-outline { color: var(--wa-dark); border-color: color-mix(in srgb, var(--wa) 45%, var(--line)); background: var(--wa-soft); }
@media (prefers-color-scheme: dark) { .btn-wa-outline { color: #6ee7a0; } }
.btn.danger-outline { color: var(--red); }
.btn.ok-outline { color: var(--green); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.lg { min-height: 46px; padding: 10px 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.is-done { opacity: .7; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: 13px; }
.link { font-size: 14px; font-weight: 550; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.btnrow form { margin: 0; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.grey { background: var(--grey-soft); color: var(--grey); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.pip { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pip.green { background: var(--green); } .pip.amber { background: var(--amber); } .pip.red { background: var(--red); } .pip.grey { background: var(--grey); }

/* ---------- flash & hints ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }
.flash .ico { margin-top: 2px; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err { background: var(--red-soft); color: var(--red); }
.flash.info { background: var(--violet-soft); color: var(--violet); }
.hint { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--ink-2); font-size: 14px; margin: 0 0 16px; }
.hint .ico { color: var(--brand); margin-top: 2px; }
.callout {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; margin-bottom: 18px;
  border-radius: var(--radius); background: var(--wa-soft); border: 1px solid color-mix(in srgb, var(--wa) 35%, transparent);
}
.preview { white-space: pre-wrap; font: 13.5px/1.5 var(--font); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; max-width: 560px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.stats.small { grid-template-columns: repeat(5, 1fr); }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow);
}
a.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 550; }
.stat-label .ico { width: 15px; height: 15px; }
.stat strong { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.tone-amber strong { color: var(--amber); } .stat.tone-red strong { color: var(--red); } .stat.tone-green strong { color: var(--green); }

/* ---------- rows / lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.rows li:first-child { border-top: 0; }
.card.flush .row { padding: 12px 18px; }
.row-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--ink); }
.row-main:hover { text-decoration: none; }
.row-main > span:last-child { min-width: 0; }
.row-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { display: block; color: var(--muted); }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.sent-note { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.sent-note .ico { width: 13px; height: 13px; color: var(--green); }
.row.is-sent { background: color-mix(in srgb, var(--green-soft) 40%, transparent); }
.avatar {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.more { margin: 10px 0 0; font-size: 14px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; font-size: 14px; border-top: 1px solid var(--line-2); }
.feed li:first-child { border-top: 0; }
.feed.big li { padding: 10px 0; }
.feed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); transform: translateY(-1px); }
.feed-dot.green { background: var(--wa); }
.feed li.bad .feed-dot { background: var(--red); }
.feed li.bad .feed-text { color: var(--red); }
.feed time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.tag { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-right: 4px; }

/* ---------- customers ---------- */
.searchbar {
  display: flex; align-items: center; gap: 10px; padding: 0 14px; margin-bottom: 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.searchbar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.searchbar .ico { color: var(--muted); }
.searchbar input { flex: 1; border: 0; outline: 0; background: transparent; padding: 13px 0; font: inherit; font-size: 16px; color: var(--ink); }
.searchbar .clear { color: var(--muted); display: grid; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--card); }
.custlist { list-style: none; margin: 0; padding: 0; }
.custlist li + li { border-top: 1px solid var(--line-2); }
.cust { display: flex; align-items: center; gap: 14px; padding: 13px 18px; color: var(--ink); }
.cust:hover { background: var(--line-2); text-decoration: none; }
.cust-main { min-width: 170px; }
.cust-main strong { display: block; }
.cust-main small { color: var(--muted); }
.cust-devs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: 1; }
.devchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 9px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.devchip .ico { width: 14px; height: 14px; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }

/* ---------- customer page ---------- */
.who { display: flex; align-items: center; gap: 14px; }
.device-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.device-title { flex: 1; min-width: 0; }
.device-title h2 { display: flex; align-items: center; gap: 4px; }
.devicon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; }
.devicon .ico { width: 22px; height: 22px; }
.devicon.green { background: var(--green-soft); color: var(--green); } .devicon.amber { background: var(--amber-soft); color: var(--amber); }
.devicon.red { background: var(--red-soft); color: var(--red); } .devicon.grey { background: var(--grey-soft); color: var(--grey); }
.inline-edit { display: flex; gap: 8px; margin: -4px 0 14px; }
.inline-edit input { flex: 1; max-width: 300px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 20px; margin: 0 0 18px; padding: 14px 16px; background: var(--line-2); border-radius: 12px; }
.facts.one { grid-template-columns: 1fr; background: none; padding: 0; }
.facts div.wide { grid-column: 1 / -1; }
.facts dt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 2px 0 0; font-size: 14.5px; }
.facts dd.big { font-size: 17px; font-weight: 650; }
.facts dd.big small { display: block; font-weight: 500; }
.facts dd.url code { font-size: 12.5px; }
.facts code { background: var(--card); }
.device-actions { display: flex; flex-direction: column; gap: 12px; }
.renew { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
.renew .lbl { font-weight: 600; font-size: 14px; }
.danger-zone { text-align: right; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field small.err { color: var(--red); }
.field small.err:empty, .lookup-result:empty { display: none; }
.lookup-result { color: var(--brand) !important; font-weight: 550; }
.field.has-err input, .field.has-err select { border-color: var(--red); }
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-size: 15px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two.tight { gap: 6px; flex: 1; max-width: 460px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-top: 8px; }
.step:first-of-type { margin-top: 0; }
.step span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 13px; }
.formfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.formfoot .muted { display: flex; align-items: center; gap: 6px; }
.more-opts summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }
.more-opts[open] summary { margin-bottom: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; cursor: pointer; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--brand); }

/* segmented control */
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 3px; border-radius: 12px; background: var(--line-2); border: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); user-select: none; }
.seg input:checked + label { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + label { outline: 2px solid var(--brand); }
.seg.big { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.seg.big label { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; }
.seg.big label .ico { width: 22px; height: 22px; color: var(--brand); margin-bottom: 4px; }
.seg.big label small { font-weight: 500; color: var(--muted); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty > .ico { width: 34px; height: 34px; color: var(--brand); opacity: .7; }
.empty h3 { color: var(--ink); margin: 8px 0 4px; font-size: 16px; }
.empty p { margin: 0; }

/* ---------- settings ---------- */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tpl-grid .formfoot { grid-column: 1 / -1; }
.tpl details summary { cursor: pointer; font-size: 13px; color: var(--brand); margin-top: 6px; }
.tok { font-size: 12px; margin: 2px 0; display: inline-block; }
.copyline { display: flex; align-items: center; gap: 6px; background: var(--line-2); padding: 8px 10px; border-radius: 10px; }
.copyline code { background: none; font-size: 12px; flex: 1; }

/* ---------- import ---------- */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px; counter-reset: s; flex-wrap: wrap; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--line-2); font-size: 12px; }
.steps li.on { color: var(--ink); border-color: var(--brand); }
.steps li.on::before { background: var(--brand); color: var(--brand-ink); }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drop {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 22px 14px;
  border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background .12s;
}
.drop:hover, .drop.has-file { border-color: var(--brand); background: var(--brand-soft); }
.drop > .ico { width: 30px; height: 30px; color: var(--brand); margin-bottom: 4px; }
.drop small { color: var(--muted); }
.drop input { margin-top: 10px; max-width: 100%; font-size: 13px; }
.drop-file { font-size: 13px; font-weight: 600; color: var(--brand); }
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl th { background: var(--line-2); font-weight: 650; }
.imp .row select { max-width: 330px; }
.tick input { width: 18px; height: 18px; accent-color: var(--brand); }
.row.unticked { opacity: .45; }

/* ---------- sync ---------- */
.progress { height: 10px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin: 14px 0 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column; gap: 14px; }
.login-card.wide { max-width: 460px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -8px 0 4px; }
.login-card .field, .login-card .flash { text-align: left; }

/* ---------- toast & modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--card); font-size: 14px; font-weight: 550; transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(10, 18, 16, .45); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 420px; background: var(--card); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { margin: 0 0 18px; color: var(--ink-2); }
.modal .btnrow { justify-content: flex-end; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .mainnav a span { display: none; }
  .mainnav a { padding: 9px; }
}
@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: 74px; }
  .topbar { padding: 8px 14px; gap: 10px; backdrop-filter: none; background: var(--card); }
  .brand span:last-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .topright .badge { display: none; }
  .credits small { display: none; }
  .mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
  }
  .mainnav a { flex-direction: column; gap: 2px; padding: 5px 2px; font-size: 10.5px; flex: 1; border-radius: 8px; }
  .mainnav a span { display: block; }
  .mainnav a.on { background: transparent; }
  .mainnav .ico { width: 21px; height: 21px; }
  .mainnav .dot { position: absolute; top: 0; right: calc(50% - 20px); }
  body.kb-open .mainnav { display: none; }
  body.kb-open { padding-bottom: 0; }
  .wrap { padding: 18px 14px 40px; }
  h1 { font-size: 22px; }
  .pagehead { align-items: flex-start; }
  .pagehead .actions { width: 100%; }
  .pagehead .actions .btn { flex: 1; }
  .grid2, .two, .tpl-grid, .upload-grid { grid-template-columns: 1fr; }
  .stats, .stats.small { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat strong { font-size: 24px; }
  .card { padding: 16px; }
  .cust { flex-wrap: wrap; padding: 12px 14px; }
  .cust-main { min-width: 0; flex: 1; }
  .cust-devs { flex-basis: 100%; justify-content: flex-start; padding-left: 52px; }
  .devchip-txt { display: none; }
  .row { flex-wrap: wrap; }
  .card.flush .row { padding: 12px 14px; }
  .row-meta { align-items: flex-start; flex-direction: row; gap: 8px; padding-left: 50px; flex-basis: 100%; }
  .row-actions { padding-left: 50px; flex-basis: 100%; }
  .row-actions .btn { flex: 1; }
  .imp .row select, .two.tight { max-width: none; width: 100%; }
  .callout { flex-direction: column; align-items: stretch; }
  .seg:not(.big) { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .seg:not(.big) label { text-align: center; padding: 8px 4px; font-size: 13px; }
  .seg:not(.big):has(> input:nth-of-type(2):last-of-type) { grid-template-columns: 1fr 1fr; }
  .rows .row-main { flex-basis: 100%; }
  .rows .row-main ~ .badge { margin-left: 50px; }
  .rows .row-main ~ .btn { margin-left: auto; }
  .renew .btn { width: 100%; }
  .btnrow > * { flex: 1 1 calc(50% - 8px); }
  .btnrow > form .btn, .btnrow > .btn { width: 100%; }
  .formfoot .btn.lg { width: 100%; }
  .facts { grid-template-columns: 1fr 1fr; }
}
.note-text { white-space: normal; }
.note-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; max-width: 560px; }
.note-edit .btn { align-self: flex-start; }
.panel-note { display: block; margin-top: 6px; }
.facts dt .iconbtn { margin-left: 2px; }
.seg.lengths input:checked + label.trial-opt { color: var(--violet); }
.seg.lengths input:disabled + label { opacity: .45; cursor: not-allowed; }
.device-title .badge { margin-top: 4px; }
@media (max-width: 760px) {
  .seg.lengths { grid-template-columns: repeat(2, 1fr) !important; }
}
.trial-hours { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.trial-hours span { font-weight: 600; font-size: 14px; }
.trial-hours select { width: auto; min-width: 130px; }
.renew .pack-select { width: auto; max-width: 220px; }
.tests { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.test { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.test.good { border-color: var(--green); background: var(--green-soft); }
.test.cost { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.test-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.test-head .badge { margin-left: auto; }
.test-facts { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.test-facts div { display: contents; }
.test-facts dt { color: var(--muted); }
.test-facts dd { margin: 0; min-width: 0; }
.test-facts code { white-space: pre-wrap; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; max-width: 720px; }
.mode { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.mode:hover { text-decoration: none; border-color: var(--brand); }
.mode.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.mode > .ico { width: 22px; height: 22px; color: var(--brand); }
.mode b { display: block; font-size: 14.5px; }
.mode small { color: var(--muted); }
.paste-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.paste-row > span { font-weight: 600; font-size: 14px; }
.detect { color: var(--brand) !important; font-weight: 600; }
.detect.bad { color: var(--amber) !important; }
.detect:empty { display: none; }
.chips.hours { margin: 2px 0 0; }
.chips.hours input { position: absolute; opacity: 0; pointer-events: none; }
.chips.hours label { cursor: pointer; padding: 9px 15px; font-size: 14.5px; }
.chips.hours input:checked + label { background: var(--violet); border-color: var(--violet); color: #fff; }
.chips.hours input:focus-visible + label { outline: 2px solid var(--brand); }
@media (max-width: 760px) {
  .modes { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode { padding: 10px; gap: 8px; }
  .mode small { display: none; }
  .mode b { font-size: 13.5px; }
  .seg.big.two-kinds { grid-template-columns: 1fr 1fr !important; }
  .chips.hours { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .chips.hours label { text-align: center; padding: 11px 6px; }
  input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea { font-size: 16px; }
}
.btnrow.tight { gap: 6px; }
.scanbox { display: flex; flex-direction: column; gap: 12px; }
.scanbox .pick { cursor: pointer; }
.center { text-align: center; margin: 0; }
#scanpreview { max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); align-self: center; }
.scanstatus { margin: 0; font-weight: 600; color: var(--brand); text-align: center; }
.scanstatus:empty { display: none; }
.scanstatus.busy::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
.scanstatus.bad { color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
#scanresult { display: flex; flex-direction: column; gap: 14px; }
.res { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 12px; background: var(--line-2); }
.res-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.res-small { font-size: 12px; }
.bigcode { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bigcode code { font-size: 22px; font-weight: 700; letter-spacing: .03em; background: var(--card); padding: 6px 10px; }
#mac_qr, #line_qr { margin-top: 6px; }
.appbox { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.appbox .paste-row > span { display: inline-flex; align-items: center; gap: 6px; }
.two.tight2 { gap: 10px; }
.appline { display: block; white-space: nowrap; }
.appline + .appline { margin-top: 4px; }
.appline code { word-break: normal; }

/* player set-up (scan page) */
#setup .field { margin-top: 12px; }
#setup .chips { margin: 8px 0 4px; }
#setup .chip { font-size: 15px; padding: 8px 15px; cursor: pointer; }
#setup #s_open { margin-top: 16px; }
.howsteps { margin: 12px 0 14px; padding-left: 20px; color: var(--ink-2); line-height: 1.5; }
.howsteps li { margin: 3px 0; }
.savebox { margin-top: 16px; }
.howto summary { cursor: pointer; padding: 2px 0; }
.howto p { margin: 10px 0; line-height: 1.5; }
.howto textarea.mono { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 11px; margin: 6px 0 8px; }
.btn.off { opacity: .5; }

/* WhatsApp history on the customer page */
.chatcard .h2 small { font-weight: 400; margin-left: 6px; }
.chatlog { max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px; margin-top: 10px;
  background: var(--bg-2, rgba(127,127,127,.06)); border-radius: 12px; }
.chatday { align-self: center; font-size: 12px; color: var(--muted, #888); background: var(--card, #fff); padding: 2px 10px; border-radius: 10px; margin: 6px 0; }
.bubble { max-width: 78%; padding: 7px 10px 5px; border-radius: 10px; font-size: 14px; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: var(--card, #fff); border: 1px solid rgba(127,127,127,.15); }
.bubble.out { align-self: flex-end; background: #d9fdd3; color: #111; }
.bubble .att { display: block; font-size: 12px; opacity: .75; }
.bubble time { display: block; text-align: right; font-size: 11px; opacity: .55; margin-top: 2px; }
@media (prefers-color-scheme: dark) { .bubble.out { background: #144d37; color: #e9edef; } }

/* WhatsApp API inbox */
.wa-list { padding: 4px 0; }
.wa-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; color: inherit; border-bottom: 1px solid var(--line-2, rgba(127,127,127,.12)); }
.wa-row:last-child { border-bottom: 0; }
.wa-row:hover { background: var(--line-2); text-decoration: none; }
.wa-row .wa-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-row .wa-main > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-row.unread .wa-main > span { color: inherit; font-weight: 600; }
.wa-row .wa-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wa-row .dot { position: static; background: var(--wa); color: #fff; border-radius: 999px; font-size: 11px; min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.wa-open { color: var(--wa); }
.wa-thread .wa-log { max-height: calc(100vh - 330px); min-height: 260px; margin-top: 0; }
.wa-reply { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.wa-reply textarea { flex: 1; resize: vertical; min-height: 46px; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: inherit; }
.wa-window { margin: 6px 2px 0; }
.wa-thread .flash { margin: 12px 0 0; }
.bubble time .read { color: #34b7f1; font-weight: 400; }
.bubble .fail { color: #dc2626; }
.wa-devs { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.wa-dev { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
a.btn.is-busy { opacity: .6; pointer-events: none; }
@media (max-width: 760px) {
  .wa-thread .wa-log { max-height: calc(100vh - 360px); }
  .wa-row { padding: 10px 12px; }
}
.push-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 12px; flex-wrap: wrap; }
.push-card[hidden] { display: none; }
.push-card .push-ico { width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber); flex: none; }
.push-card.on .push-ico { background: var(--green-soft); color: var(--green); }
.push-card .push-txt { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.push-card .push-btns { display: flex; gap: 8px; }
.push-card.on .push-btns .btn { padding: 8px 12px; font-size: 14px; }
.ai-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; margin-bottom: 12px; flex-wrap: wrap; background: var(--green-soft); }
.ai-bar.off { background: var(--amber-soft); }
.hand-btn { font-size: 20px; line-height: 1; padding: 8px 12px; }
.hand-btn.on { background: var(--amber-soft); border-color: var(--amber); }
.bubble .wa-img { display: block; margin: -2px -4px 6px; }
.bubble .wa-img img { display: block; max-width: 240px; max-height: 320px; width: 100%; object-fit: cover; border-radius: 10px; }
.bubble .teach { display: block; margin: 4px 0 0 auto; background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--muted, #6b7280); text-decoration: underline; cursor: pointer; }
.bubble .teach[disabled] { text-decoration: none; color: var(--green); }
.learn-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.learn-list li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.learn-list li .t { flex: 1; min-width: 0; }
.learn-list li form { display: inline; }

/* chat: name bar on top of the thread, reply to a message, delete */
#end { scroll-margin-top: 112px; }
.wa-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.wa-head .wa-head-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-head .wa-head-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-reply { flex-wrap: wrap; }
.wa-reply .reply-to { flex-basis: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-left: 4px solid var(--wa); border-radius: 8px; background: rgba(127,127,127,.1); font-size: 13px; }
.wa-reply .reply-to[hidden] { display: none; }
.wa-reply .reply-to.mine { border-left-color: #53bdeb; }
.wa-reply .reply-to > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-reply .reply-to .rt-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }
.wa-reply .rt-x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; padding: 0 4px; }
.bubble { position: relative; }
.bubble .quote { display: block; margin: 0 -4px 5px; padding: 4px 8px; border-left: 4px solid var(--wa); border-radius: 6px; background: rgba(127,127,127,.12); font-size: 12.5px; opacity: .9; }
.bubble.in .quote { border-left-color: #53bdeb; }
.bubble .quote b { display: block; font-size: 12px; }
.bubble .reply-btn { position: absolute; top: 50%; transform: translateY(-50%); right: -34px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--card, #fff);
  box-shadow: 0 1px 3px rgba(0,0,0,.18); font-size: 15px; line-height: 28px; padding: 0; color: var(--muted, #6b7280); cursor: pointer; opacity: 0; transition: opacity .15s; }
.bubble.out .reply-btn { right: auto; left: -34px; }
.bubble:hover .reply-btn, .bubble .reply-btn:focus { opacity: 1; }
@media (hover: none) { .bubble .reply-btn { opacity: .7; } }
.btn.danger-outline { color: #dc2626; border-color: rgba(220,38,38,.4); }
.pagehead .actions form { display: inline; }
@media (max-width: 760px) { #end { scroll-margin-top: 64px; } .wa-thread .wa-log { max-height: calc(100vh - 380px); } }

/* ---------- Settings: tabs + at a glance ---------- */
.set-tabs { position: sticky; top: 0; z-index: 15; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: -6px -4px 16px; padding: 8px 4px; background: var(--bg, var(--card)); }
.set-tabs::-webkit-scrollbar { display: none; }
.set-tabs button { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.set-tabs button.on { background: var(--ink); border-color: var(--ink); color: var(--card); }
.set-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.set-group > .card { margin: 0; max-width: 720px; width: 100%; }
.set-status { list-style: none; margin: 0; padding: 0; }
.set-status li + li { border-top: 1px solid var(--line); }
.set-status a { display: grid; grid-template-columns: 26px minmax(110px, auto) 1fr 14px; align-items: center; gap: 8px; padding: 11px 2px; color: var(--ink); }
.set-status a:hover { text-decoration: none; background: var(--line-2); }
.set-status .n { font-weight: 600; }
.set-status .t { color: var(--ink-2); font-size: 13.5px; text-align: right; }
.set-status .go { color: var(--ink-3, var(--ink-2)); font-size: 20px; line-height: 1; }
.set-group .btn { white-space: normal; max-width: 100%; height: auto; text-align: center; }
