:root {
  --ground: #f3f5f3;
  --surface: #ffffff;
  --sunk: #f7f9f8;
  --ink: #17201c;
  --muted: #5c6a64;
  --line: #d9e0dc;
  --accent: #146c5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --ok: #1f7a3f;
  --ok-soft: #e4f3e8;
  --warn: #a35708;
  --warn-soft: #fbefdf;
  --danger: #b42318;
  --danger-soft: #fce8e6;
  --info: #1d5fa8;
  --info-soft: #e5eefa;
  --idle-soft: #eceff0;
  --focus: #1d5fa8;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0e1311;
    --surface: #151c19;
    --sunk: #111815;
    --ink: #e4ebe7;
    --muted: #97a59f;
    --line: #26312c;
    --accent: #3aae93;
    --accent-ink: #06130f;
    --accent-soft: #15302a;
    --ok: #57c17d;
    --ok-soft: #14301f;
    --warn: #e0a152;
    --warn-soft: #33260f;
    --danger: #f07a6e;
    --danger-soft: #3a1714;
    --info: #7fb2ec;
    --info-soft: #152538;
    --idle-soft: #1d2522;
    --focus: #7fb2ec;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #0e1311;
  --surface: #151c19;
  --sunk: #111815;
  --ink: #e4ebe7;
  --muted: #97a59f;
  --line: #26312c;
  --accent: #3aae93;
  --accent-ink: #06130f;
  --accent-soft: #15302a;
  --ok: #57c17d;
  --ok-soft: #14301f;
  --warn: #e0a152;
  --warn-soft: #33260f;
  --danger: #f07a6e;
  --danger-soft: #3a1714;
  --info: #7fb2ec;
  --info-soft: #152538;
  --idle-soft: #1d2522;
  --focus: #7fb2ec;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 24px; }
h2 { font-size: 17px; letter-spacing: -0.01em; }
h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13.5px; }
.fine { color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 8px 14px; font-weight: 600; font-size: 14px; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button[aria-busy="true"] { cursor: progress; }
button[aria-busy="true"]::after {
  content: ""; display: inline-block; width: 0.75em; height: 0.75em; margin-left: 0.5em; vertical-align: -0.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { button[aria-busy="true"]::after { animation: none; } }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.primary { background: var(--accent); color: var(--accent-ink); }
.primary:not(:disabled):hover { filter: brightness(1.08); }
.secondary { background: var(--surface); border-color: var(--line); }
.secondary:not(:disabled):hover { background: var(--sunk); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { color: var(--ink); }
.danger { background: var(--danger); color: #fff; }
.danger-text { background: transparent; color: var(--danger); border-color: var(--line); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.small { padding: 5px 10px; font-size: 13px; }
.big { padding: 12px 22px; font-size: 16px; }

textarea, input[type="password"], input[type="number"] {
  width: 100%;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 96px; }
textarea:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.boot { padding: 40px; text-align: center; color: var(--muted); }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-card label { font-weight: 600; font-size: 13.5px; margin-top: 4px; }
.login-card .primary { padding: 11px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.error { color: var(--danger); font-size: 13.5px; }

/* app */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.net-note { color: var(--warn); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 20px;
  padding: 20px 24px 48px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); padding: 14px; } .top { padding: 10px 14px; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  display: grid;
  gap: 14px;
}

.step { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 4px; }
.step .n {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.push { margin-left: auto; }

.file { position: relative; display: inline-flex; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file span {
  display: inline-block; padding: 7px 12px; border-radius: 8px;
  border: 1px dashed var(--line); background: var(--sunk); font-weight: 600; font-size: 13px;
}
.file:hover span { border-color: var(--accent); }
.file input:disabled { cursor: not-allowed; }
.file:has(input:disabled) span { opacity: 0.5; }
.file input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picked {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 8px;
  background: var(--accent-soft); color: var(--ink); font-size: 14px;
}

.choose { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px;
  cursor: pointer;
}
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice small { display: block; color: var(--muted); font-size: 12px; }
.choice.off { opacity: 0.55; cursor: not-allowed; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.capacity { font-size: 13.5px; color: var(--muted); }
.capacity.short { color: var(--warn); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: 10px; font-size: 14px;
  background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
}
.banner.stopped { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }

.sending {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 10px;
  background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 30%, var(--line));
}
.sending-body { flex: 1; min-width: 0; }
.sending-body p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--info); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* numbers */
.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.number {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; display: grid; gap: 9px; align-content: start;
  background: var(--surface);
}
.num-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.num-label { font-weight: 700; font-size: 14px; }
.phone { font-size: 14px; font-variant-numeric: tabular-nums; min-height: 21px; }
.reason { font-size: 12.5px; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--idle-soft); color: var(--muted);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }

.limit-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.limit-row label { color: var(--muted); white-space: nowrap; }
.limit-row input { width: 90px; padding: 6px 8px; }
.used { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 4px; background: var(--idle-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.qr { display: grid; gap: 8px; justify-items: center; padding: 10px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.qr p { color: #3c4843; font-size: 12.5px; text-align: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  background: var(--ink); color: var(--surface);
  padding: 11px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); z-index: 20;
}
.toast.bad { background: var(--danger); color: #fff; }
