/* ProxyManager panel: dark and minimal. No inline styles (strict CSP). */
:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #0e1015;
  --card: #12141a;
  --card-2: #171a21;
  --line: #1f232c;
  --line-2: #2a2f3a;
  --line-3: #3a404e;
  --text: #e7e9ef;
  --muted: #8b91a1;
  --faint: #5d6474;
  --accent: #7c8cff;
  --accent-hi: #98a4ff;
  --accent-ink: #0b0c10;
  --accent-soft: rgba(124, 140, 255, .13);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --side: 240px;
  --sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Cascadia Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
::selection { background: rgba(124, 140, 255, .35); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { color: var(--text); font-weight: 600; }
a.strong:hover { color: var(--accent-hi); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--muted); }
.link:hover { color: var(--text); }
.opt { color: var(--faint); font-size: 12px; font-weight: 500; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* Icons */
.sprite { display: none; }
.ico {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ico.accent { color: var(--accent); }
.ico.xl { width: 32px; height: 32px; stroke-width: 1.4; color: var(--faint); }

/* Shell */
.side {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); z-index: 30;
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px; background: var(--panel); border-right: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px;
  color: var(--text); font-weight: 650; font-size: 15px; letter-spacing: -.01em;
}
.brand:hover { color: var(--text); }
.mark {
  position: relative; flex: none; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #b9a6ff);
}
.mark::after { content: ""; position: absolute; inset: 7px; border-radius: 3px; background: var(--panel); }
.mark.lg { width: 46px; height: 46px; border-radius: 14px; }
.mark.lg::after { inset: 15px; border-radius: 5px; background: var(--bg); }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
}
.menu a:hover { background: var(--card-2); color: var(--text); }
.menu a.on { background: var(--accent-soft); color: var(--text); }
.menu a.on .ico { color: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.side-foot form { margin: 0; }
.side-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted);
  font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.side-link:hover { background: var(--card-2); color: var(--text); }
.main {
  margin-left: var(--side); max-width: calc(1180px + var(--side));
  padding: 32px 40px 72px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 4px; }
.sub { color: var(--muted); margin-top: 4px; }
.crumbs { display: flex; gap: 6px; color: var(--faint); font-size: 12.5px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.head-state { display: flex; }

/* Quick guides */
.guide { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.guide > summary {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  color: var(--muted); font-weight: 500; cursor: pointer; list-style: none; user-select: none;
}
.guide > summary::-webkit-details-marker { display: none; }
.guide > summary > .ico:first-child { color: var(--accent); }
.guide > summary:hover { color: var(--text); }
.guide[open] > summary { border-bottom: 1px solid var(--line); }
.chev { margin-left: auto; color: var(--faint); transition: transform .15s; }
details[open] > summary .chev { transform: rotate(180deg); }
.guide-list { margin: 0; padding: 14px 18px 4px 34px; display: grid; gap: 7px; color: var(--muted); }
.guide-list:last-child { padding-bottom: 16px; }
.guide-list b { color: var(--text); font-weight: 600; }
ul.guide-list li::marker { color: var(--faint); }
ol.guide-list { list-style: none; padding-left: 18px; counter-reset: guide; }
ol.guide-list li { counter-increment: guide; position: relative; padding-left: 32px; }
ol.guide-list li::before {
  content: counter(guide); position: absolute; left: 0; top: 0;
  width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700;
}
.guide-note { padding: 6px 18px 16px; color: var(--muted); font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head.pad { padding: 16px 20px 0; margin-bottom: 8px; }
.card-head:last-child { margin-bottom: 0; }
.stack > .card-head { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.danger-zone { border-color: rgba(248, 113, 113, .22); }
.danger-zone > p { margin-bottom: 14px; }

/* First steps */
.onboarding {
  border-color: rgba(124, 140, 255, .32);
  background: linear-gradient(180deg, rgba(124, 140, 255, .07), rgba(124, 140, 255, 0) 70%), var(--card);
}
.progress {
  display: block; width: 100%; height: 4px; margin-bottom: 12px;
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 4px; overflow: hidden; background: var(--line);
}
.progress::-webkit-progress-bar { background: var(--line); border-radius: 4px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.setup { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.setup li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--radius-sm); }
.setup li:hover { background: rgba(255, 255, 255, .02); }
.tick {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--line-3); color: var(--muted); font-size: 12px; font-weight: 600;
}
.setup li.done .tick { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.setup li.done .setup-text b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.setup-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.setup-text b { font-weight: 600; }
.setup .btn .ico { transform: rotate(-90deg); }

/* Numbers */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
a.kpi:hover { color: var(--text); border-color: var(--line-2); background: var(--card-2); }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--faint); margin-left: 4px; }
.kpi-value.speed { font-size: 20px; white-space: nowrap; }
.kpi-value.speed small { display: block; margin: 2px 0 0; }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.bad .kpi-value { color: var(--bad); }
.kpi .progress { margin: 2px 0 0; }

/* A proxy's page: what the customer gets on the left, the rest on the right */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 16px; min-width: 0; }
.exit-country { margin-top: 14px; display: grid; gap: 6px; }
.exit-row { display: flex; align-items: flex-end; gap: 8px; }
.exit-row .field { flex: 1; min-width: 0; }
.edit-origins { margin-top: 14px; }
.detail-main .formats li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.detail-main .fmt-label { grid-column: 1 / -1; }
.feed.compact li { grid-template-columns: auto minmax(0, 1fr); }
.feed.compact time { grid-column: 2; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  font: inherit; font-weight: 550; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { color: var(--text); background: #1c2029; border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card-2); color: var(--text); }
.btn.danger { background: transparent; border-color: rgba(248, 113, 113, .35); color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.danger-text { color: var(--muted); }
.btn.danger-text:hover { color: var(--bad); background: var(--bad-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.sm .ico { width: 14px; height: 14px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.done { border-color: var(--ok); color: var(--ok); }
.btn.primary.done { background: var(--ok); border-color: var(--ok); color: var(--accent-ink); }
a:focus-visible, .btn:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span2 { grid-column: 1 / -1; }
.field { display: block; font-size: 13px; font-weight: 500; }
.field > input, .field > select, .field > textarea, .field > .pills, .field > .hint { margin-top: 6px; }
.hint { display: block; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
.hint a { color: var(--accent); }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--line-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b91a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select option { background: var(--card); color: var(--text); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: 13px; }
input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px; margin: 0; padding: 0; flex: none; accent-color: var(--accent); cursor: pointer;
}
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check input { margin-top: 2px; }
.check > span { display: flex; flex-direction: column; gap: 2px; }
.check b { font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form select, .inline-form input:not([type=checkbox]) { width: auto; flex: 1 1 160px; }
.inline-form .check { flex: none; }
.renew-custom { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.custom-duration { margin-top: 10px; }
.custom-duration input { flex: 0 1 140px; }
.custom-duration select { flex: 0 1 160px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 190px; }
.filters .grow { flex: 1 1 240px; }

/* Duration pills */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; display: inline-flex; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--card-2);
  color: var(--muted); font-weight: 550; cursor: pointer; transition: all .12s;
}
.pill span:hover { color: var(--text); border-color: var(--line-3); }
.pill input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* New proxy steps */
.wizard { display: flex; flex-direction: column; gap: 16px; }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.step-head > span:nth-child(2) { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.step-n {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}
.step .pills + .form-grid, .step .form-grid + .check, .step .choices + .check, .step .rotation + .check { margin-top: 16px; }
details.advanced > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced[open] > summary { margin-bottom: 16px; }
.choices { display: grid; gap: 10px; }
.choice {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(170px, 260px); align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice:has(input[name=upstream_mode]:checked),
.choice:has(input[name=address_mode]:checked) { border-color: rgba(124, 140, 255, .55); background: var(--accent-soft); }
.choice.address:not(:has(input[name=address_mode]:checked)) input[name=proxy_host] { opacity: .5; }
.address-extra { margin-top: 14px; }

/* Internet access card */
.access { display: grid; gap: 14px; }
.access .card-head { margin-bottom: 0; }
.access .guide-list { padding: 0 0 0 20px; }
.howto { border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 13.5px; }
.howto > summary { cursor: pointer; color: var(--text); font-weight: 500; }
.howto p { margin: 10px 0 6px; }
.choice:not(:has(input[name=upstream_mode]:checked)) select,
.choice:not(:has(input[name=upstream_mode]:checked)) .pick-list { opacity: .5; }
.choice-pick { display: block; }
.choice-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.choice-head > span { display: flex; flex-direction: column; gap: 2px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0 28px; }
.pick {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg); font-size: 13px;
}
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick > span { display: flex; flex-direction: column; gap: 1px; }
.pick small { font-size: 12px; }
.rotation { margin-top: 14px; }
form:not(:has(input[name=upstream_mode][value^=pool]:checked)) .rotation { opacity: .45; }
.every { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.every input { width: 80px; padding: 6px 8px; }
.origin-summary { margin-bottom: 10px; }
.origin-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.origin-list li {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.edit-origins > summary { list-style: none; display: inline-flex; }
.edit-origins > summary::-webkit-details-marker { display: none; }
.edit-origins[open] > summary { margin-bottom: 14px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line);
  color: var(--faint); font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, .018); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { display: inline-flex; vertical-align: middle; margin-left: 6px; }
.row-actions form { margin: 0; }
tr.off td { opacity: .5; }
.table-foot { padding: 10px 20px; border-top: 1px solid var(--line); }

/* States and tags */
.state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); white-space: nowrap; }
.state::before {
  content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint); box-shadow: 0 0 0 3px rgba(255, 255, 255, .04);
}
.state.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.state.warn::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.state.bad::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.state.info::before { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.state.lg { font-size: 14px; padding: 7px 14px; background: var(--card); border: 1px solid var(--line-2); border-radius: 999px; }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px;
  background: var(--card-2); color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }

/* Lists */
.rows, .feed, .formats { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows li:first-child { padding-top: 0; }
.rows li > .grow { min-width: fit-content; }
.rows li:last-child { border-bottom: 0; padding-bottom: 0; }
.feed li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.feed li:first-child { padding-top: 0; }
.feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.feed time { white-space: nowrap; }
.feed-msg { overflow-wrap: anywhere; }
.formats { display: grid; gap: 8px; }
.formats li { display: grid; grid-template-columns: 230px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.fmt-label { color: var(--muted); font-size: 12.5px; }
.code-line {
  display: block; padding: 8px 12px; overflow-x: auto; white-space: nowrap;
  background: var(--bg); border-color: var(--line); color: var(--text); font-size: 13px;
}
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 20px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.origin { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.origin + .mono { display: block; margin-bottom: 14px; }
.card > .hint, .inline-form + .hint { margin-top: 10px; }

/* Copy block */
.copy-block { display: flex; align-items: flex-start; gap: 12px; }
.portal-msg { margin: 14px 0; }
textarea.code {
  flex: 1; min-height: 46px; padding: 11px 13px; overflow-x: auto; white-space: pre;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7; resize: vertical;
}

/* Empty states */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty > p:first-of-type { color: var(--text); font-weight: 500; }
.empty .btn { margin-top: 8px; }
.empty.sm { align-items: flex-start; padding: 6px 0 0; text-align: left; }
.empty.sm > p:first-of-type { color: var(--muted); font-weight: 400; }

/* Alerts and toasts */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid; border-radius: var(--radius-sm); font-size: 13.5px;
}
.alert .ico { margin-top: 2px; }
.alert a { color: inherit; text-decoration: underline; }
.alert.err { background: var(--bad-soft); border-color: rgba(248, 113, 113, .3); color: #fecaca; }
.alert.warn { background: var(--warn-soft); border-color: rgba(251, 191, 36, .3); color: #fde68a; }
.alert.ok { background: var(--ok-soft); border-color: rgba(52, 211, 153, .3); color: #a7f3d0; }
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
  background: #191c24; border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  animation: toast-in .2s ease-out;
}
.toast > .ico { margin-top: 2px; }
.toast.ok { border-left-color: var(--ok); }
.toast.ok > .ico { color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
.toast.err > .ico { color: var(--bad); }
.toast p { flex: 1; font-size: 13.5px; white-space: pre-line; }
.toast-x { display: grid; place-items: center; padding: 2px; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; }
.toast-x:hover { color: var(--text); background: var(--card-2); }
.toast.hide { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

/* Edit menu on the origin list */
details.dropdown { position: relative; }
details.dropdown > summary { list-style: none; }
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown .pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px;
  display: flex; flex-direction: column; gap: 16px; padding: 14px;
  text-align: left; white-space: normal;
  background: #171a21; border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.table-wrap:has(details.dropdown[open]) { overflow: visible; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-brand h1 { justify-content: center; }
.login .card { padding: 22px; }
.login-help { color: var(--faint); font-size: 12.5px; line-height: 1.6; text-align: center; }

/* Customer panel: a top bar instead of the side menu */
.portal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px;
  border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5;
}
.portal-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 16px; }
.portal-card { display: grid; gap: 16px; }
.portal-card .card-head { margin-bottom: 0; }
.portal-card .kpi { background: var(--bg); }
.portal-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.portal-grid h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.portal-grid .formats li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.portal-grid .fmt-label { grid-column: 1 / -1; }
.ip-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.ip-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Small screens: the side menu becomes a top bar */
@media (max-width: 1100px) {
  .main { padding: 28px 28px 64px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .portal-bar { padding: 10px 16px; }
  .portal-main { padding: 20px 16px 48px; }
  .portal-grid { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; bottom: auto; width: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .menu { order: 3; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .menu a { white-space: nowrap; padding: 7px 10px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; }
  .side-foot .btn { display: none; }
  .side-link span { display: none; }
  .setup li { flex-wrap: wrap; }
  .setup li .btn { margin-left: 38px; }
  .setup-text { flex: 1 1 calc(100% - 40px); }
  .main { margin-left: 0; padding: 20px 16px 48px; }
  .form-grid, .grid2 { grid-template-columns: minmax(0, 1fr); }
  .choice { grid-template-columns: auto minmax(0, 1fr); }
  .choice select, .choice input[name=proxy_host] { grid-column: 1 / -1; }
  .pick-list { margin-left: 0; }
  .formats li { grid-template-columns: minmax(0, 1fr) auto; }
  .fmt-label { grid-column: 1 / -1; }
  .copy-block { flex-direction: column; align-items: stretch; }
  .feed li { grid-template-columns: auto minmax(0, 1fr); }
  .feed time { grid-column: 2; }
  details.dropdown .pop { position: static; width: auto; margin-top: 8px; box-shadow: none; }
}
