/*
 * The cabinet's design system, taken from the approved mockups (tasks/design/mvp-mockups.html).
 * Layers: fonts → tokens (light, then dark) → classless base → layout → components → utilities.
 * Everything works without JavaScript; `.js-only` elements appear once a Stimulus controller marks the page.
 * One file on purpose: the order of the layers is the cascade, and Propshaft has no import step.
 */

/* ---------- fonts (self-hosted, SIL OFL: see OFL-*.txt next to them) ---------- */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/assets/onest-cyrillic-cade0a1b.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/assets/onest-latin-ext-59c69f90.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/assets/onest-latin-3d436d4d.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("/assets/unbounded-cyrillic-bc4f33be.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("/assets/unbounded-latin-ext-648df949.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("/assets/unbounded-latin-9c83474d.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f1f4f2;
  --fg: #131a16;
  --muted: #5a665f;
  --faint: #8a958f;
  --border: #dbe2de;
  --border-strong: #c3ccc7;
  /* accent: deep emerald, "the money has arrived" */
  --accent: #0b7a55;
  --accent-hover: #086447;
  --accent-fg: #ffffff;
  --accent-soft: #e0f1e9;
  --accent-line: #9fd3bb;
  --focus: #0b7a55;
  /* states: separate from the accent */
  --ok: #17784a;   --ok-bg: #e3f3ea;
  --wait: #56626b; --wait-bg: #e9edf0;
  --info: #2459b8; --info-bg: #e5edfb;
  --warn: #8a5900; --warn-bg: #fbefd2;
  --bad: #b8312b;  --bad-bg: #fbe7e5;
  --knob-shadow: 0 1px 2px rgb(0 0 0 / .2);
  /* Telegram previews (light iOS theme) */
  --tg-wall-a: #d7dcb3;
  --tg-wall-b: #8fbe98;
  --tg-wall-dot: rgb(255 255 255 / .22);
  --tg-in: #ffffff;
  --tg-text: #000000;
  --tg-meta: #93a093;
  --tg-key: rgb(42 74 50 / .34);
  --tg-key-fg: #ffffff;
  --tg-card: rgb(255 255 255 / .86);
  --tg-shadow: 0 1px 1px rgb(0 0 0 / .12);

  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-tg: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px;
  --r-s: 10px;
  --tap: 44px;
  --container: 1180px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101512;
    --surface: #171d1a;
    --surface-2: #1d2420;
    --fg: #e5ebe7;
    --muted: #9aa6a0;
    --faint: #6f7b75;
    --border: #27302b;
    --border-strong: #36413b;
    --accent: #3cc98a;
    --accent-hover: #5cd9a0;
    --accent-fg: #04150d;
    --accent-soft: #133024;
    --accent-line: #2a6b4d;
    --focus: #3cc98a;
    --ok: #4cc884;   --ok-bg: #132a1e;
    --wait: #a2adb5; --wait-bg: #222a2f;
    --info: #79a8f5; --info-bg: #15233a;
    --warn: #e2b04a; --warn-bg: #2d2412;
    --bad: #f07b72;  --bad-bg: #321816;
    --tg-wall-a: #1b2a35;
    --tg-wall-b: #0e1923;
    --tg-wall-dot: rgb(255 255 255 / .035);
    --tg-in: #182533;
    --tg-text: #f5f5f5;
    --tg-meta: #6d7f8f;
    --tg-key: rgb(57 82 105 / .62);
    --tg-key-fg: #ffffff;
    --tg-card: rgb(24 37 51 / .9);
    --tg-shadow: none;
  }
}

/* ---------- base (classless: plain markup already looks right) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 15px/1.45 var(--font); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; text-wrap: balance; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; margin-top: 1.2em; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .75em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
small { font-size: 13px; }
code, kbd, pre { font-family: var(--mono); font-size: 13px; }
code { background: var(--surface-2); border-radius: 6px; padding: 1px 5px; }
pre { overflow-x: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-s); background: var(--surface-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

label { font-size: 14px; }
/* :where keeps the base at zero specificity: any component class overrides it */
:where(input:not([type=checkbox], [type=radio], [type=hidden], [type=submit], [type=button]), select, textarea) {
  width: 100%; max-width: 100%; min-height: var(--tap); border-radius: var(--r-s); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg); font: 400 16px/1.4 var(--font); padding: 10px 12px;
}
textarea { display: block; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; vertical-align: middle; }
input[readonly] { background: var(--surface-2); }
::placeholder { color: var(--faint); }

button, input[type=submit], input[type=button], .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px;
  border-radius: var(--r-s); border: 1px solid transparent; background: var(--accent); color: var(--accent-fg);
  font: 600 15px var(--font); text-decoration: none; cursor: pointer; text-align: center; max-width: 100%;
}
button:hover, input[type=submit]:hover, .btn:hover { background: var(--accent-hover); color: var(--accent-fg); }
button:disabled, input[type=submit]:disabled, .btn[aria-disabled=true] {
  background: var(--surface-2); color: var(--faint); border-color: var(--border); cursor: not-allowed;
}
form.button_to, form.inline { display: inline-block; margin: 0; }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; min-height: var(--tap); display: flex; align-items: center; }
details[open] > summary { margin-bottom: 8px; }

dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 12px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
ul, ol { padding-left: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 0 12px 8px 0; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

/* ---------- layout ---------- */
.page { max-width: var(--container); margin: 0 auto; padding-inline: 16px; padding-block: 0 48px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.app-header nav { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; }
.app-header nav a { color: var(--fg); text-decoration: none; font-weight: 500; }
.app-header nav a:hover { color: var(--accent); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: var(--fg); text-decoration: none; }
.mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; }
.app-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.app-main > * { margin-block: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; } }
/* a phone shows the working bot in the order of the mockup (screen 2): money, the link to sell with, payments, health */
@media (max-width: 899px) {
  .grid-2 { gap: 12px; }
  .grid-2 > .stack { display: contents; }
  .grid-2 #bot-link { order: 1; }
  .grid-2 #recent-payments { order: 2; }
  .grid-2 #health { order: 3; }
}

/* the owner's menu (a <details>, works without JavaScript) */
.menu { position: relative; }
.menu > summary { list-style: none; min-height: var(--tap); }
.menu > summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 220px; display: grid; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 12px 32px -12px rgb(0 0 0 / .25); }
.menu-body p { margin: 0; font-weight: 600; }

/* desktop: the owner's bots on the left (mockups, screen 8) */
.side { display: none; }
@media (min-width: 900px) {
  .page.with-side { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0 28px; max-width: calc(var(--container) + 260px); }
  .with-side .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; align-self: start; min-height: 100vh;
    padding: 18px 14px; margin-left: -16px; background: var(--surface); border-right: 1px solid var(--border); }
  .with-side .app-header { display: none; }
  .with-side .page-main { padding-top: 20px; min-width: 0; }
}
.side .brand { padding: 0 6px 16px; }
.side-label { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 10px 8px 6px; }
.side-bots { display: grid; gap: 2px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; color: var(--fg); text-decoration: none; font-size: 14px; }
.side a:hover, .side a.on { background: var(--accent-soft); color: var(--fg); }
.side .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .mini { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted); flex: none; }
.side a.on .mini { background: var(--accent); color: var(--accent-fg); }
.side .mini.add { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--accent); }
.side a.add-bot { color: var(--accent); }
.dotm { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.dotm.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.side-owner { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 16px 8px 0; font-size: 14px; }

/* the head of a bot's pages */
.bothead { display: grid; gap: 10px; }
.crumb { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; text-decoration: none; justify-self: start; }
.crumb:hover { color: var(--accent); }
.bothead-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.bothead-row .grow { flex: 1; min-width: 0; }
.bothead h1 { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.bothead .sub { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions { display: none; gap: 8px; }
@media (min-width: 900px) { .head-actions { display: flex; } .bothead h1 { font-size: 22px; } .crumb { display: none; } }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin: 4px -4px 0; padding: 0 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 8px 11px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; position: relative; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current] { color: var(--fg); font-weight: 600; }
.tabs a[aria-current]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

/* ---------- components ---------- */
/* buttons */
.btn.block, button.block, input[type=submit].block { width: 100%; }
.btn.secondary, button.secondary, input[type=submit].secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn.secondary:hover, button.secondary:hover { border-color: var(--accent); background: var(--surface); color: var(--fg); }
.btn.soft, button.soft { background: var(--accent-soft); color: var(--accent); }
.btn.soft:hover, button.soft:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn.ghost, button.ghost { background: transparent; color: var(--accent); padding: 0 4px; min-height: 32px; }
.btn.ghost:hover, button.ghost:hover { background: transparent; color: var(--accent-hover); }
.btn.danger, button.danger, input[type=submit].danger { background: transparent; color: var(--bad); border-color: var(--border-strong); }
.btn.danger:hover, button.danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn.sm, button.sm { min-height: 36px; font-size: 14px; padding: 0 12px; }
.btn-row, .controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* badges and states: a symbol and a word, colour never alone */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: 999px; white-space: nowrap; line-height: 1.3; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.wait { color: var(--wait); background: var(--wait-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.you { color: var(--accent); background: var(--accent-soft); }
.badge.plain { color: var(--muted); background: transparent; padding-inline: 0; font-weight: 500; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 9px 3px 8px; border-radius: 999px; color: var(--wait); background: var(--wait-bg); }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.draft::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.state.live { color: var(--ok); background: var(--ok-bg); }
.state.paused { color: var(--warn); background: var(--warn-bg); }
.state.suspended { color: var(--bad); background: var(--bad-bg); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card > h2:first-child, .card-head h2 { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head > * { margin: 0; }
.hint { color: var(--muted); font-size: 13px; }
.lead { color: var(--muted); font-size: 14px; }
.kicker { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin: 8px 2px 0; }

/* flash and callouts: what happened, and what next */
.flash { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r-s); font-size: 14px; margin: 0; }
.flash.notice { color: var(--ok); background: var(--ok-bg); }
.flash.alert { color: var(--bad); background: var(--bad-bg); }
.flash.info { color: var(--info); background: var(--info-bg); }
.flash.warn { color: var(--warn); background: var(--warn-bg); }
.flash a { color: inherit; font-weight: 600; }
.flash > * { margin: 0; }
.flash.stacked { flex-direction: column; }

/* figures */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 14px 16px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font: 600 22px/1.15 var(--font-display); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat.wide { grid-column: 1 / -1; }
.stat.wide .value { font-size: 28px; }
.num, .money { font-variant-numeric: tabular-nums; }

/* setup steps */
.segs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-top: 12px; }
.segs i { height: 6px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.segs i.on { background: var(--accent); box-shadow: none; }
.segs i.wait { background: repeating-linear-gradient(-45deg, var(--wait-bg) 0 4px, var(--border-strong) 4px 6px); box-shadow: none; }
.steps { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 16px; }
.step + .step { border-top: 1px solid var(--border); }
.step-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.step.done .step-mark { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
.step.admin .step-mark { background: var(--wait-bg); color: var(--wait); box-shadow: none; }
.step.failed .step-mark { background: var(--bad-bg); color: var(--bad); box-shadow: none; }
.step.current .step-mark { box-shadow: inset 0 0 0 2px var(--accent); }
.step.current .step-mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.step.current { background: linear-gradient(var(--accent-soft), var(--accent-soft)) left / 3px 100% no-repeat; }
.step-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; flex-wrap: wrap; }
.step-top b { font-weight: 600; font-size: 15px; }
.step.done .step-top b { color: var(--muted); font-weight: 500; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.step .problem { color: var(--bad); }
.step-body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.step-body.btn-row { flex-direction: row; align-items: center; }
.step .btn.ghost { padding: 0; margin-top: 6px; justify-content: flex-start; }
.step .step-body .btn.ghost { margin-top: 0; }

/* the launch card and the progress of the setup */
.progress-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.progress-title strong { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.progress-title span { color: var(--muted); font-size: 13px; }
form.block { display: block; }
.launch-left { margin: 10px 0 0; font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; }
.launch-left svg { color: var(--warn); margin-top: 2px; }
.launch-left b { font-weight: 600; }
.launch-after { margin: 6px 0 0 24px; }

/* settings (mockups, screen 6) */
.setting-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 6px 0; cursor: pointer; }
.setting-row > span { display: grid; gap: 2px; }
.setting-row b { font-weight: 500; font-size: 15px; }
input[type=checkbox].switch { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; }
input[type=checkbox].switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: var(--knob-shadow); transition: left .15s; }
input[type=checkbox].switch:checked { background: var(--accent); }
input[type=checkbox].switch:checked::after { left: 21px; }
.token { font: 500 14px var(--mono); color: var(--muted); padding: 10px 12px; border-radius: var(--r-s); background: var(--surface-2); letter-spacing: .02em; }
#token-replace[open] { display: grid; gap: 10px; }

/* the chosen chat and the picker of another one (settings, mockups screen 6) */
.chat-pick { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r-s); background: var(--surface-2); margin: 0 0 12px; }
.chat-pick .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
.chat-pick b { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.chat-pick span { color: var(--muted); font-size: 12.5px; }
.chat-pick .problem { color: var(--bad); }
.lock { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.picker { margin-top: 8px; }
.picker[open] { display: grid; gap: 12px; }
.add-to-chat { display: grid; gap: 8px; }
.add-to-chat .hint { margin: 0; }

/* copy a value */
.copy { display: flex; flex-wrap: wrap; gap: 8px; }
.copy input { flex: 999 1 170px; width: auto; min-width: 0; }
.copy .btn, .copy button { flex: 1 0 auto; }

/* lists of people and payments */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.rows li + li { border-top: 1px solid var(--border); }
.rows .who { flex: 1; min-width: 0; }
.rows .who b { font-weight: 500; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .who span { color: var(--muted); font-size: 12.5px; }
.rows .amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; }
.ini { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; background: var(--surface-2); color: var(--muted); }
.ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; border: 1px solid var(--border); flex: none; }
.ava.lg { width: 44px; height: 44px; border-radius: 13px; font-size: 15px; background: var(--accent-soft); color: var(--accent); border: 0; }
.health { display: grid; gap: 8px; }
.health > div { display: flex; gap: 8px; font-size: 13.5px; align-items: center; }
.health svg { color: var(--ok); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .error, .field-error { color: var(--bad); font-size: 13px; }
.check, .radio { display: flex; gap: 10px; align-items: center; font-size: 15px; min-height: 40px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font: 500 13px var(--mono); color: var(--fg); }
.counter { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.over-limit { color: var(--bad); font-weight: 600; }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.filters::-webkit-scrollbar { display: none; }
.filters a, .filters span { flex: none; min-height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; font-weight: 500; color: var(--muted); text-decoration: none; }
.filters a.current, .filters a[aria-current], .filters span.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.filters small { font-size: 12px; opacity: .7; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.save-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 30%); z-index: 1; }

/* the danger zone stays folded */
.danger-zone { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 0 16px; }
.danger-zone > summary { color: var(--bad); font-weight: 600; min-height: 52px; }
.danger-zone[open] { padding-bottom: 16px; }

/* tables that turn into cards on a phone: every cell says what it is (data-label) */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 16px; overflow-x: auto; }
@media (max-width: 640px) {
  .table-wrap { background: transparent; border: 0; padding: 0; overflow: visible; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 14px; margin-bottom: 8px; }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); text-align: right; }
  table.cards td > * { min-width: 0; overflow-wrap: anywhere; }
  table.cards td form.button_to, table.cards td form.button_to button { max-width: 100%; }
  table.cards tr td:last-child { border-bottom: 0; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  table.cards td[data-label=""]::before { content: none; }
}

/* statuses of payments (legacy class names in views) */
.status-paid { color: var(--ok); font-weight: 600; }
.status-cancelled, .status-refunded, .status-expired, .status-revoked { color: var(--bad); }
tr.refund td { background: var(--warn-bg); }

/* Telegram previews: what the customer will see */
.tg { font-family: var(--font-tg); color: var(--tg-text); }
.tg-chat { border-radius: var(--r-s); padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
  background: radial-gradient(var(--tg-wall-dot) 1px, transparent 1.5px) 0 0 / 14px 14px, linear-gradient(160deg, var(--tg-wall-a), var(--tg-wall-b)); }
.tg-label { font: 600 11.5px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 0 0 6px; }
.bubble, .telegram-bubble { background: var(--tg-in); color: var(--tg-text); border-radius: 17px 17px 17px 6px; padding: 7px 12px; font: 15.5px/1.32 var(--font-tg);
  max-width: 100%; box-shadow: var(--tg-shadow); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; align-self: flex-start; }
.keys, .telegram-keyboard { display: grid; gap: 4px; align-self: stretch; }
.key, .telegram-keyboard > span { min-height: 38px; display: grid; place-items: center; padding: 6px 18px; border-radius: 10px; background: var(--tg-key); color: var(--tg-key-fg);
  font: 500 14.5px var(--font-tg); text-align: center; }
.tg-card { background: var(--tg-card); color: var(--tg-text); border-radius: 20px; padding: 14px 16px; max-width: 290px; box-shadow: var(--tg-shadow); }
.tg-card b { display: block; font-size: 15px; margin-bottom: 6px; }
.tg-card p { margin: 0; font-size: 14px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-empty-chat { display: grid; place-items: center; padding: 18px 16px; }
.field > .counter { align-self: flex-end; }
mark.unknown-placeholder { background: var(--bad-bg); color: inherit; border-bottom: 1px dashed var(--bad); cursor: help; }

/* payments as cards (mockups, screen 5) */
.summary { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin: 0; }
.summary b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
a.pay { color: var(--fg); text-decoration: none; }
a.pay:hover { border-color: var(--accent-line); color: var(--fg); }
.pay { display: grid; gap: 10px; }
.pay-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pay-top > span:first-child { display: grid; gap: 2px; min-width: 0; }
.pay-sum { font: 600 19px/1.2 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pay-sum.big { font-size: 28px; }
.pay-plan { color: var(--muted); font-size: 13px; }
.pay-plan-name { font-weight: 600; font-size: 16px; }
.rows li form.button_to { flex: none; }
.pay-who { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.pay-who .grow { flex: 1; min-width: 0; display: grid; }
.pay-who b { font-weight: 500; overflow-wrap: anywhere; }
.pay-who .grow span { color: var(--muted); }
.pay-date { color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.pay.muted .pay-sum { color: var(--muted); }
.pay-note { font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 6px 10px; margin: 0; }
details.card > summary { margin: -4px 0; }

/* the list of bots */
.bot-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.bot-card { display: flex; gap: 12px; align-items: center; color: var(--fg); text-decoration: none; }
.bot-card:hover { border-color: var(--accent-line); color: var(--fg); }
.bot-card .grow { flex: 1; min-width: 0; display: grid; gap: 4px; }
.bot-card b { font-size: 15px; overflow-wrap: anywhere; }
.bot-card .sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.bot-card > svg { color: var(--faint); }

/* the texts: one folded item per message (mockups, screen 4) */
.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.acc-item + .acc-item { border-top: 1px solid var(--border); }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 52px; font-size: 15px; font-weight: 500; color: var(--fg); list-style: none; }
.acc-row::-webkit-details-marker { display: none; }
.acc-row .grow { flex: 1; }
.acc-row > svg { color: var(--faint); transition: transform .15s; }
.acc-item[open] > .acc-row { font-weight: 600; margin-bottom: 0; }
.acc-item[open] > .acc-row > svg { transform: rotate(180deg); }
.acc-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.acc-body .hint, .acc-body .tg-label { margin: 0; }
.meta-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.acc-body .reset { justify-self: start; padding: 0; color: var(--muted); }

/* sign-in: one card in the middle */
.login { max-width: 460px; width: 100%; margin: 24px auto 0; display: grid; gap: 12px; justify-items: center; text-align: center; }
.login form { display: grid; gap: 10px; width: 100%; text-align: left; }
.login-mark { width: 44px; height: 44px; border-radius: 13px; }

/* empty states */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty h2, .empty h3 { color: var(--fg); margin-top: 0; }

/* ---------- utilities ---------- */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.js-only { display: none !important; }
.js-enabled .js-only { display: inline-flex !important; }
.js-enabled .no-js-only { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the plan editor (mockups, screen 3) ---------- */
.plan { padding: 0; overflow: hidden; }
.plan.invalid { border-color: var(--bad); }
.plan-top { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.plan-top b { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-top .n { color: var(--faint); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 1ch; }
.iconbtn { width: var(--tap); min-height: 36px; padding: 0; border-radius: 8px; color: var(--muted); border: 1px solid var(--border); background: var(--surface); }
.iconbtn:hover { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.iconbtn:disabled { color: var(--border-strong); background: var(--surface); }
.plan-body { padding: 14px 16px 12px; display: grid; gap: 12px; }
.plan-grid { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; }
fieldset.term { border: 0; padding: 0; margin: 0; display: grid; gap: 2px; min-width: 0; }
fieldset.term legend { font-size: 13px; font-weight: 500; color: var(--muted); padding: 0; margin-bottom: 4px; }
input.days { flex: none; width: 76px; min-height: 36px; padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.plan-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: 6px; }
.check.remove { color: var(--muted); }
button.add { background: transparent; color: var(--accent); border: 1.5px dashed var(--border-strong); }
button.add:hover { background: var(--accent-soft); color: var(--accent); }
.row-errors { color: var(--bad); margin: 0; padding-left: 18px; font-size: 13px; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
