/* Owner dashboard. No external fonts or scripts; works under a strict CSP. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --text: #1a1d23; --muted: #5b6676; --border: #dfe3ea; --soft: #eef1f5;
  --accent: #0b6b5d; --accent-ink: #ffffff; --good: #137a38; --warn: #a44a07; --bad: #bf2222;
  --good-bg: #e3f4ea; --warn-bg: #fdf0dc; --bad-bg: #fbe4e2; --info-bg: #dff3ee;
  --c0: #0b6b5d; --c1: #c2410c; --c2: #0f766e; --c3: #a21caf; --c4: #64748b;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --text: #e6e9ef; --muted: #9aa5b4; --border: #2a313c; --soft: #1f2530;
    --accent: #4fd1b8; --accent-ink: #06231d; --good: #54c98c; --warn: #f2b45c; --bad: #ff8179;
    --good-bg: #14301f; --warn-bg: #3a2a10; --bad-bg: #3d1a19; --info-bg: #12302a;
    --c0: #4fd1b8; --c1: #fb923c; --c2: #2dd4bf; --c3: #e879f9; --c4: #94a3b8; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --text: #e6e9ef; --muted: #9aa5b4; --border: #2a313c; --soft: #1f2530;
  --accent: #4fd1b8; --accent-ink: #06231d; --good: #54c98c; --warn: #f2b45c; --bad: #ff8179;
  --good-bg: #14301f; --warn-bg: #3a2a10; --bad-bg: #3d1a19; --info-bg: #12302a;
  --c0: #4fd1b8; --c1: #fb923c; --c2: #2dd4bf; --c3: #e879f9; --c4: #94a3b8; --shadow: none;
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
code, .mono { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.05rem; padding: .25rem .6rem 1rem; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border-radius: 8px; color: var(--text); }
.side nav a:hover { background: var(--soft); text-decoration: none; }
.side nav a.active { background: var(--info-bg); color: var(--accent); font-weight: 600; }
.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .6rem .25rem; }
.count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; min-width: 1.3rem; text-align: center; }
.count.zero { display: none; }
.side .foot { margin-top: 1.2rem; padding: .6rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; flex-wrap: wrap; }
.main { padding: 1.4rem 1.6rem 3rem; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: .6rem; }
  .side nav { display: flex; gap: .25rem; overflow-x: auto; }
  .side nav a { white-space: nowrap; }
  .side .group, .side .foot { display: none; }
  .brand { padding-bottom: .4rem; }
  .main { padding: 1rem 1rem 3rem; }
}

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 1rem; }
.grid > .card { margin: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
@media (max-width: 520px) { .grid.two { grid-template-columns: 1fr; } }
.kpis { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.kpi .n { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi.bad .n { color: var(--bad); } .kpi.warn .n { color: var(--warn); } .kpi.good .n { color: var(--good); }
.banner { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.banner.good { background: var(--good-bg); color: var(--good); border: 1px solid var(--good); }
.banner.info { background: var(--info-bg); color: var(--accent); border: 1px solid var(--accent); }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--soft); }
td .detail { color: var(--muted); font-size: .85rem; }

/* badges and buttons */
.badge { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.b-good { background: var(--good-bg); color: var(--good); } .b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); } .b-info { background: var(--info-bg); color: var(--accent); }
.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .4rem .85rem; cursor: pointer; display: inline-block; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.good { border-color: var(--good); color: var(--good); }
.btn.good:hover { background: var(--good-bg); }
.btn.sm { padding: .15rem .55rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .6rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=url], input[type=datetime-local], select, textarea {
  font: inherit; width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; }
textarea { min-height: 5.5rem; resize: vertical; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters > div { min-width: 140px; }
.filters .grow { flex: 1; min-width: 220px; }
.pager { display: flex; gap: .5rem; align-items: center; margin-top: .8rem; color: var(--muted); }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); border-radius: 8px; padding: .7rem .9rem; font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.empty { color: var(--muted); padding: 1.2rem; text-align: center; }

/* charts */
svg.chart { width: 100%; height: auto; max-width: 640px; display: block; }
svg.chart .bar { fill: var(--c0); } svg.chart .lbl, svg.chart .val { fill: var(--text); font-size: 12.5px; }
svg.chart .tick { fill: var(--muted); font-size: 11px; } svg.chart .axis { stroke: var(--border); stroke-width: 1; }
svg.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { stroke: none; }
.c0.line, .c0.dot { stroke: var(--c0); fill: var(--c0); } .c1.line, .c1.dot { stroke: var(--c1); fill: var(--c1); }
.c2.line, .c2.dot { stroke: var(--c2); fill: var(--c2); } .c3.line, .c3.dot { stroke: var(--c3); fill: var(--c3); }
.c4.line, .c4.dot { stroke: var(--c4); fill: var(--c4); } svg.chart .line { fill: none; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; margin: .4rem 0 0; }
.key::before { content: ""; display: inline-block; width: .8rem; height: 3px; margin-right: .4rem; vertical-align: middle; background: currentColor; }
.key.c0 { color: var(--c0); } .key.c1 { color: var(--c1); } .key.c2 { color: var(--c2); } .key.c3 { color: var(--c3); } .key.c4 { color: var(--c4); }
meter, progress { width: 100%; height: .6rem; }

/* video approval */
.videos { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.vcard { display: grid; grid-template-columns: 150px 1fr; gap: .9rem; }
.vcard video, .vcard .thumb { width: 150px; aspect-ratio: 9 / 16; background: #000; border-radius: 8px; object-fit: cover; }
.vplayer { max-width: 280px; width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 10px; }
@media (max-width: 520px) { .vcard { grid-template-columns: 1fr; } .vcard video { width: 100%; max-height: 60vh; } }

/* toast and dialog */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; }
.toast { background: var(--text); color: var(--bg); border-radius: 8px; padding: .6rem .9rem; max-width: 26rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 1.2rem; max-width: 28rem; width: calc(100% - 2rem); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form > * + * { margin-top: .8rem; }
.login { max-width: 22rem; margin: 14vh auto; }
.login .card { padding: 1.4rem; }

/* approvals */
.appr { display: grid; grid-template-columns: minmax(200px, 290px) minmax(0, 1fr); gap: 1.3rem; }
@media (max-width: 720px) { .appr { grid-template-columns: 1fr; } }
.gates { display: flex; gap: .4rem; flex-wrap: wrap; }
details > summary { cursor: pointer; color: var(--accent); }

/* Leads: contact summary and contact columns */
.contact-sum { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.contact-sum .cs-item { padding: .45rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; }
.contact-sum .cs-item b { font-size: 1.05rem; margin-right: .2rem; }
.contact-sum .cs-item.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
table.leads td { vertical-align: top; }
table.leads .contact { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; }
.hidden-note { margin-top: .75rem; }

/* sidebar: collapsible "Settings & tools" */
.side details.tools { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.side details.tools > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border-radius: 8px; color: var(--muted); font-size: .85rem; }
.side details.tools > summary::-webkit-details-marker { display: none; }
.side details.tools > summary::after { content: "▸"; margin-left: auto; padding-left: .5rem; }
.side details.tools[open] > summary::after { content: "▾"; }
.side details.tools > summary:hover { background: var(--soft); }
.side details.tools a { font-size: .9rem; padding: .35rem .6rem .35rem 1rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 .8rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .87rem; white-space: nowrap; }
a.chip:hover { text-decoration: none; background: var(--soft); }
.chip b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on b { color: var(--accent-ink); opacity: .85; }
.chip.static { padding: .1rem .55rem; font-size: .8rem; }
.chip.static.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.static.soft { background: var(--soft); border-color: transparent; color: var(--muted); }
.sector-chips { margin-bottom: .5rem; }

/* website-fit dots */
.fit { display: inline-flex; gap: 2px; vertical-align: middle; }
.fit i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); display: inline-block; }
.fit i.on { background: var(--good); }
.fit-medium i.on { background: var(--warn); }
.fit-low i.on { background: var(--muted); }
.chip.on .fit i { background: rgba(255, 255, 255, .35); } .chip.on .fit i.on { background: var(--accent-ink); }

/* contact cells and copy buttons */
.cline { display: flex; align-items: center; gap: .3rem; }
.copy { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 .2rem; font-size: .9rem; line-height: 1; }
.copy:hover { color: var(--accent); }
.copy.done { color: var(--good); }
.copy .ic { width: 16px; height: 16px; vertical-align: -3px; }
table.leads .biz { font-weight: 600; }
.contact-cell { min-width: 14rem; }

/* home: the two flows */
.flows { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); margin-bottom: 1rem; }
.flow-head { display: flex; justify-content: space-between; align-items: center; }
.flow-head h2 { margin: 0; font-size: 1.2rem; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .8rem 0; }
.mini-kpis a { display: block; background: var(--soft); border-radius: 8px; padding: .55rem .6rem; color: var(--text); }
.mini-kpis a:hover { text-decoration: none; outline: 1px solid var(--accent); }
.mini-kpis b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.mini-kpis span { color: var(--muted); font-size: .78rem; }
.req-line { display: flex; gap: .7rem; align-items: center; padding: .45rem .2rem; border-top: 1px solid var(--border); color: var(--text); }
.req-line:hover { text-decoration: none; background: var(--soft); }
.req-text { display: block; min-width: 0; }
.req-text .detail { display: block; }
.fit-num { flex: none; width: 2.2rem; text-align: center; border-radius: 6px; font-weight: 700; font-size: .85rem; padding: .15rem 0; background: var(--soft); color: var(--muted); }
.fit-num.hi, .req-fit.hi { background: var(--good-bg); color: var(--good); }
.fit-num.mid, .req-fit.mid { background: var(--warn-bg); color: var(--warn); }

/* requirements list */
.req-list { display: grid; gap: .8rem; }
.req-list .card + .card { margin-top: 0; }
.req { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); gap: 1rem; }
.req-fit { width: 3.2rem; height: 3.2rem; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; background: var(--soft); color: var(--muted); }
.req-fit.big { width: 4rem; height: 4rem; font-size: 1.5rem; flex: none; }
.req h2 { font-size: 1rem; margin: 0 0 .25rem; line-height: 1.35; }
.req h2 a { color: var(--text); }
.req .chips { margin: .45rem 0; }
.req-meta { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .85rem; }
.req-actions { margin-top: .6rem; flex-wrap: wrap; }
.post-body { max-height: 32rem; overflow-y: auto; font-family: inherit; font-size: .93rem; }

/* summary card (lead and post pages) */
.summary .summary-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .6rem; }
.summary .sub { color: var(--muted); margin-top: .25rem; }
.badge.big { font-size: .9rem; padding: .25rem .8rem; }
.contact-cards { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: .8rem 0 1rem; }
.cc { background: var(--soft); border-radius: 8px; padding: .55rem .75rem; overflow-wrap: anywhere; }
details.tech { margin-top: 1rem; }
details.tech > summary { display: flex; gap: .7rem; align-items: baseline; color: var(--text); }
details.tech > summary h2 { margin: 0; display: inline; }

/* phones */
@media (max-width: 860px) {
  .side details.tools { margin: 0; border: 0; padding: 0; }
  .side details.tools:not([open]) a { display: none; }
  .side nav { flex-wrap: wrap; overflow: visible; }
  .side details.tools[open] { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .25rem; }
  .side details.tools[open] > summary { flex-basis: 100%; }
  .side details.tools a { padding: .35rem .6rem; }
  .flows { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .mini-kpis { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  .filters > div { min-width: calc(50% - .3rem); flex: 1; }
  .filters .grow { min-width: 100%; }
  .req { grid-template-columns: 1fr; }
  .req-fit { width: auto; height: auto; padding: .2rem .6rem; justify-self: start; font-size: .95rem; }
  table.leads thead { display: none; }
  table.leads tr { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
  table.leads td { border: 0; padding: 0; }
  table.leads td:first-child, table.leads td.contact-cell { grid-column: 1 / -1; }
  .contact-cell { min-width: 0; }
}
.offscreen { position: fixed; left: -9999px; top: 0; }

/* ================================================================ phone shell (the same block in both dashboards)
   Wide screens keep the sidebar layout above. At 860 px and below: a top bar, a bottom tab bar, a More sheet,
   filter sheets, tables as cards, sticky action bars and 44 px touch targets. */
.topbar, .tabbar, .scrim, .fbtn, .chart-narrow, .only-phone, .sheet-title, .actionbar, .fab { display: none; }
.chart-wide { display: block; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ic { width: 18px; height: 18px; vertical-align: -4px; }
.btn.icon-btn { display: inline-grid; place-items: center; padding: .35rem; line-height: 0; }
.btn.block { display: flex; width: 100%; justify-content: center; align-items: center; gap: .4rem; }
.clamp2, .clamp3, .clamp6 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.clamp2 { -webkit-line-clamp: 2; } .clamp3 { -webkit-line-clamp: 3; } .clamp6 { -webkit-line-clamp: 6; }
.clamp2.open, .clamp3.open, .clamp6.open { -webkit-line-clamp: unset; display: block; cursor: auto; }
dialog.sheet { max-width: 26rem; padding: .6rem 1rem 1rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem 0 .4rem; }
.more-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .4rem .3rem; }
.more-item { display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 48px; padding: .35rem .5rem; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.more-item:hover { background: var(--soft); text-decoration: none; }
.more-item.on { background: var(--info-bg); color: var(--accent); font-weight: 600; }
.more-item .count { margin-left: auto; }
.needs { display: grid; gap: .5rem; margin-bottom: 1rem; }
.need { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); min-height: 52px; }
.need:hover { text-decoration: none; background: var(--soft); }
.need b { font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 1.6rem; }
.need .go { margin-left: auto; color: var(--muted); }
.need.warn { border-color: var(--warn); } .need.warn b { color: var(--warn); }
.need.bad { border-color: var(--bad); } .need.bad b { color: var(--bad); }
.need.good { border-color: var(--good); color: var(--good); }
.fchips { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.4rem 0 .9rem; }
.fchip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .4rem .2rem .7rem; border-radius: 999px; background: var(--info-bg); color: var(--accent); font-size: .85rem; white-space: nowrap; }
.fchip:hover { text-decoration: none; filter: brightness(.97); }
.fchip .ic { width: 16px; height: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg label { margin: 0; display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; color: var(--text); cursor: pointer; font-size: .9rem; }
.seg label + label { border-left: 1px solid var(--border); }
.seg input { accent-color: var(--accent); }
.seg label:has(input:checked) { background: var(--info-bg); color: var(--accent); font-weight: 600; }
.card.danger-zone { border-color: var(--bad); }
.card.danger-zone h2 { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .6rem 0; }
.stat { background: var(--soft); border-radius: 8px; padding: .45rem .6rem; }
.stat b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .78rem; }
.thumb-row { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: .75rem; align-items: start; }
.thumb-row img, .thumb-row .nothumb { width: 54px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: var(--soft); display: block; }
textarea { field-sizing: content; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

@media (max-width: 860px) {
  :root { --tabbar-h: 58px; --topbar-h: 52px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
  body.sheet-open { overflow: hidden; }
  .side { display: none; }
  .shell { display: block; min-height: 0; }
  .main { padding: .9rem max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + var(--safe-b) + 1.5rem) max(16px, env(safe-area-inset-left)); max-width: none; }
  .hide-phone { display: none !important; }
  .only-phone { display: block; }
  .only-phone.row { display: flex; } span.only-phone, a.only-phone { display: inline; } button.only-phone, .btn.only-phone { display: inline-flex; }
  .chart-wide { display: none; } .chart-narrow { display: block; }

  /* top bar */
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: .55rem;
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
    background: var(--surface); border-bottom: 1px solid var(--border); }
  .tb-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-back { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -6px; border-radius: 10px; color: var(--text); }
  .tb-back:hover { background: var(--soft); text-decoration: none; }
  .tb-brand { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .95rem; }
  .tb-act { display: flex; gap: .4rem; flex: none; align-items: center; }
  .tb-act .btn { min-height: 38px; padding: .3rem .75rem; font-size: .9rem; display: inline-flex; align-items: center; gap: .3rem; }
  .page-head { margin-bottom: .8rem; }
  .page-head h1 { display: none; }
  .page-head .sub { font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .summary h1, .keep-h1 h1 { display: block; font-size: 1.25rem; }

  /* bottom tabs */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 env(safe-area-inset-right) var(--safe-b) env(safe-area-inset-left);
    background: var(--surface); border-top: 1px solid var(--border); }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    color: var(--muted); font-size: .7rem; font-weight: 600; text-decoration: none; }
  .tabbar a .tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .count { position: absolute; top: 5px; left: calc(50% + 5px); font-size: .66rem; min-width: 1.15rem; line-height: 1.15rem; padding: 0 .3rem; }

  /* sheets: More, confirm/prompt, filters */
  dialog.sheet, #dlg { inset: 0; margin: auto 0 0; width: 100%; max-width: none; max-height: 86svh; height: fit-content; overflow-y: auto;
    border: 0; border-radius: 16px 16px 0 0; padding: .5rem 16px calc(16px + var(--safe-b)); animation: sheet-up .18s ease-out; }
  dialog.sheet::before, #dlg::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto .5rem; }
  .sheet-head { position: sticky; top: -.5rem; background: var(--surface); z-index: 1; }
  #dlg .row { flex-direction: column-reverse; align-items: stretch; }
  #dlg .row .btn { width: 100%; }
  #dlg p[data-msg] { font-size: 1.02rem; margin-top: 0; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }

  .fbtn { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
  .fbtn b { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .75rem; min-width: 1.25rem; padding: 0 .35rem; text-align: center; }
  form.filters.fsheet { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: end; }
  form.filters.fsheet > * { display: none; }
  form.filters.fsheet > .grow { display: block; min-width: 0; }
  form.filters.fsheet > .grow label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  form.filters.fsheet > .fbtn { display: inline-flex; justify-self: start; }
  form.filters.fsheet > .grow + .fbtn { justify-self: end; }
  form.filters.fsheet.open { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; display: flex; flex-direction: column; align-items: stretch; gap: .75rem;
    margin: 0; max-height: 86svh; overflow-y: auto; background: var(--surface); border-radius: 16px 16px 0 0;
    padding: 1rem 16px calc(1rem + var(--safe-b)); animation: sheet-up .18s ease-out; }
  form.filters.fsheet.open > * { display: block; min-width: 0 !important; }
  form.filters.fsheet.open > input[type=hidden] { display: none; }
  form.filters.fsheet.open > .grow label { position: static; width: auto; height: auto; clip-path: none; }
  form.filters.fsheet.open > .fbtn { display: none; }
  form.filters.fsheet.open > .sheet-title { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 1.05rem; }
  form.filters.fsheet.open > .row { display: flex; position: sticky; bottom: calc(-1rem - var(--safe-b)); background: var(--surface); padding: .5rem 0 0; }
  form.filters.fsheet.open > .row .btn { flex: 1; text-align: center; }

  /* touch targets and typing */
  .btn { min-height: 44px; padding: .5rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; text-align: center; }
  .btn.sm { min-height: 44px; padding: .4rem .8rem; font-size: .9rem; }
  input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=url], input[type=datetime-local], select, textarea { font-size: 16px; min-height: 44px; }
  textarea { min-height: 5.5rem; }
  .row { gap: .5rem; }
  .row.stretch > .btn, .row.stretch > form, .row.stretch > a.btn { flex: 1 1 0; }
  .row.stretch > .btn.primary { flex-basis: 100%; }
  .copy { min-width: 40px; min-height: 40px; }

  /* tabs and page-level chip rows scroll sideways in one line */
  .tabs, .chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 2px; scroll-padding: 0 16px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .tabs::-webkit-scrollbar, .chips.scroll::-webkit-scrollbar { display: none; }
  .tabs a, .chips.scroll .chip { flex: none; min-height: 40px; display: inline-flex; align-items: center; }
  .tabs a:last-child, .chips.scroll > :last-child { margin-right: 24px; }

  /* surfaces */
  .card { padding: .9rem 1rem; }
  .grid, .grid.two, .flows { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .65rem .8rem; } .kpi .n { font-size: 1.35rem; } .kpi .l { font-size: .8rem; line-height: 1.3; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.kv dt { font-size: .8rem; margin-top: .5rem; } dl.kv dt:first-child { margin-top: 0; }
  .pre { font-size: 13px; }
  .pager { justify-content: space-between; flex-wrap: wrap; }
  .pager span { order: -1; flex-basis: 100%; text-align: center; font-size: .85rem; }
  .pager .btn { flex: 1; }
  #toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
  .toast { max-width: none; }
  .fab { position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 25; border-radius: 999px; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); }

  /* sticky action bar at the end of a detail page: always in reach above the tabs */
  .actionbar { display: flex; position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 20; gap: .5rem; margin: 1rem -4px 0; padding: .5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 6px 22px rgba(0, 0, 0, .14); }
  .actionbar > .btn, .actionbar > a.btn { flex: 1 1 0; }

  /* list tables become cards: first cell is the title, the rest are label/value lines */
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { padding: .75rem 0; border-bottom: 1px solid var(--border); }
  table.rt tr:last-child { border-bottom: 0; }
  table.rt tr:hover td { background: none; }
  table.rt td { border: 0; padding: .1rem 0; text-align: left; }
  table.rt td[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: right; }
  table.rt td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .82rem; text-align: left; flex: none; }
  table.rt td[data-label=""] { display: block; text-align: left; }
  table.rt td[data-label=""]::before { content: none; }
  table.rt td.rt-main { font-weight: 600; padding-bottom: .25rem; }
  table.rt td.rt-main .detail { font-weight: 400; }
  table.rt td.rt-act { display: flex; gap: .5rem; padding-top: .5rem; text-align: left; }
  table.rt td.rt-act:empty { display: none; }
  table.rt td.rt-act .btn { flex: 1; }
  table.rt td.empty { text-align: center; }
  table.rt td .detail { overflow-wrap: anywhere; }
  .tablewrap { overflow-x: visible; }
  .tablewrap.keep { overflow-x: auto; }

  .pclamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 10; overflow: hidden; cursor: pointer; max-height: none; }
  .pclamp.open { display: block; -webkit-line-clamp: unset; cursor: auto; }
  .btn.block-phone { display: flex; width: 100%; }
  .row.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.rt tr:has(+ tr.rt-sub) { border-bottom: 0; padding-bottom: .2rem; }
  table.rt tr.rt-sub { padding-top: 0; }
  form .actionbar { justify-content: space-between; align-items: center; padding-left: 1rem; }
  form .actionbar > .btn { flex: 0 1 auto; min-width: 50%; }

  /* video */
  .vplayer { height: 62svh; width: auto; max-width: 100%; margin: 0 auto; display: block; }
  .appr { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  dialog.sheet, #dlg, form.filters.fsheet.open { animation: none; }
}

/* ================================================================ phone screens (leads) */
@media (max-width: 860px) {
  .banner { padding: .5rem .8rem; font-size: .88rem; margin-bottom: .8rem; }
  .copy { display: inline-grid; place-items: center; }
  .fit-chips .muted { flex: none; align-self: center; }
  .contact-cards { grid-template-columns: minmax(0, 1fr); }
  .cc .cline a.contact { font-size: 1rem; }
  .req-line { padding: .6rem .2rem; }
}


/* ================================================================ site watch */
.st { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; font-weight: 600; font-size: .85rem; }
.st::before { content: ""; width: .65rem; height: .65rem; border-radius: 50%; background: var(--muted); flex: none; }
.st-up::before { background: var(--good); } .st-down::before { background: var(--bad); border-radius: 2px; }
.st-warn::before, .st-suspect::before { background: var(--warn); }
.st-down { color: var(--bad); } .st-warn, .st-suspect { color: var(--warn); } .st-up { color: var(--good); } .st-new, .st-off { color: var(--muted); }
.bars { display: flex; gap: 2px; height: 26px; margin: .5rem 0 .2rem; }
.bars i { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--soft); border: 1px solid var(--border); }
.bars i.ok { background: var(--good); border-color: var(--good); opacity: .75; }
.bars i.short { background: var(--warn); border-color: var(--warn); } .bars i.down { background: var(--bad); border-color: var(--bad); }
.needs { display: grid; gap: .5rem; margin-bottom: 1rem; }
.clients { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 1rem; }
.ccard { display: block; color: var(--text); margin: 0; }
.ccard:hover { text-decoration: none; border-color: var(--accent); }
.ccard .top { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.ccard .top strong { overflow-wrap: anywhere; }
.compose textarea { min-height: 9rem; }
.compose .row { margin-top: .6rem; }
.form2 { display: grid; gap: .7rem 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form2 .wide { grid-column: 1 / -1; }
.form2 label.tick { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .95rem; margin: 0; }
.todo { list-style: none; padding: 0; margin: 0; } .todo li { padding: .3rem 0 .3rem 1.7rem; position: relative; }
.todo li::before { content: "○"; position: absolute; left: .2rem; color: var(--warn); font-weight: 700; }
.todo li.done::before { content: "✓"; color: var(--good); } .todo li.done { color: var(--muted); }
.evid { margin: 0; padding-left: 1.1rem; } .evid li { overflow-wrap: anywhere; margin-bottom: .25rem; }
[hidden] { display: none !important; }
a.back-link { font-size: .85rem; }
@media (max-width: 860px) {
  .clients { grid-template-columns: minmax(0, 1fr); }
  .compose .row > .btn, .compose .row > a.btn { flex: 1 1 40%; }
  .compose .row > .btn.primary { flex-basis: 100%; }
  .form2 { grid-template-columns: minmax(0, 1fr); }
  .form2 label.tick { min-height: 44px; }
  .form2 input[type=checkbox] { width: 22px; height: 22px; }
  .bars { gap: 1px; }
  details > summary { min-height: 44px; display: flex; align-items: center; }
}

.card + .grid, .clients + .card, .kpis + .clients { margin-top: 1rem; }
.clients > .card + .card { margin-top: 0; }
form > .card + .row, form > .row:last-child { margin-top: 1rem; }
dl.kv + .row, .summary .row { margin-top: .6rem; }
