/*
 * Boop VPN web design. Built on the ideas of GitLab's Pajamas design system:
 * neutral grays, one blue for actions, Inter type, a 4 px grid, 4 px corners on
 * controls and 8 px on panels, 1 px borders, no shadows, no gradients.
 * Layout rules: every row of tiles is full (see evenCols() in app.js), tiles in a row
 * share one height, controls in a row share one height, edges line up on the container.
 */
:root {
  --bg: #fbfafd; --surface: #ffffff; --subtle: #f6f6f8;
  --text: #333238; --heading: #1f1e24; --muted: #626168; --faint: #89888d;
  --border: #dcdcde; --border-strong: #bfbfc3; --row: #ececef;
  --primary: #1f75cb; --primary-hover: #1068bf; --primary-active: #0b5cad; --primary-tint: #e9f3fc; --focus: #428fdc;
  --success: #108548; --success-tint: #ecf4ee; --success-text: #24663b;
  --warning: #ab6100; --warning-tint: #fdf1dd; --warning-text: #8f4700;
  --danger: #dd2b0e; --danger-tint: #fcf1ef; --danger-text: #ae1800;
  --neutral-tint: #ececef; --neutral-text: #535158;
  --r-ctl: 4px; --r-panel: 8px; --ctl: 32px; --gap: 16px; --page: 1080px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/20px Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--heading); font-weight: 600; letter-spacing: 0; }
h1 { font-size: 24px; line-height: 32px; margin: 0; }
h2 { font-size: 18px; line-height: 24px; margin: 32px 0 16px; }
h3 { font-size: 16px; line-height: 24px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 16px; }
.mono { font-family: var(--mono); font-size: 13px; }
.center { text-align: center; }
.warn { color: var(--danger-text); }
.warn:empty { display: none; }
:focus-visible { outline: none; box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--focus); }

/* ---------- top bar ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-in { max-width: var(--page); margin: 0 auto; padding: 0 16px; height: 48px; display: flex; align-items: center; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--heading); }
.logo:hover { text-decoration: none; }
.logo img { width: 24px; height: 24px; display: block; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a.item { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: var(--r-ctl); color: var(--text); font-weight: 500; }
.nav a.item:hover { background: var(--row); text-decoration: none; }
.nav a.item.on { background: var(--row); color: var(--heading); }
.nav .menu-btn { display: none; }
.menu { display: none; }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }

/* language switch: a small segmented control */
.langs { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); overflow: hidden; }
.langs a, .langs button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 30px; font: 500 12px/1 Inter, sans-serif; color: var(--muted);
  background: var(--surface); border: 0; border-left: 1px solid var(--border-strong); cursor: pointer; text-decoration: none; }
.langs > :first-child { border-left: 0; }
.langs .on { background: var(--row); color: var(--heading); }

main { max-width: var(--page); margin: 0 auto; padding: 0 16px 64px; }
main.narrow { max-width: 640px; }
.spinner { color: var(--muted); padding: 48px 0; text-align: center; }

/* page heading: title on the left, actions on the right, one line */
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 0 16px; }
.head p { margin: 4px 0 0; }
.h2row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; margin: 32px 0 16px; }
.h2row h2 { margin: 0; }
.h2row + p { margin-top: -8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- panels ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel); padding: 16px; }
.card > :last-child { margin-bottom: 0; }
.card + .card { margin-top: var(--gap); }
.cards > .card + .card, .grid2 > .card + .card { margin-top: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; margin-bottom: 12px; }
.card-h h3 { margin: 0; }

/* Tiles in rows that are always full: --n columns (from evenCols), a short last row centered. */
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); }
.cards > * { flex: 0 0 calc((100% - (var(--n) - 1) * var(--gap)) / var(--n)); min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.section { margin-top: var(--gap); }
.grid2 > .section, .cards > .section { margin-top: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--ctl); padding: 0 12px; border-radius: var(--r-ctl);
  border: 1px solid var(--primary); background: var(--primary); color: #fff; font: 500 14px/1 Inter, sans-serif; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:active { background: var(--primary-active); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--subtle); border-color: var(--faint); }
.btn.danger { background: var(--surface); color: var(--danger-text); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.btn.small { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.large { height: 40px; padding: 0 16px; font-size: 16px; }
.btn[disabled], .btn[disabled]:hover { background: var(--subtle); border-color: var(--border); color: var(--faint); cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; }
.warnlink { color: var(--danger-text); }
.actionsrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.keyactions { display: flex; flex-wrap: wrap; gap: 8px; }
.linkbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- badges, alerts ---------- */
.badge, .status { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font: 500 12px/1 Inter, sans-serif;
  background: var(--neutral-tint); color: var(--neutral-text); white-space: nowrap; vertical-align: middle; }
.badge.test { background: var(--warning-tint); color: var(--warning-text); }
.badge.best { background: var(--primary-tint); color: var(--primary-active); }
.status.active { background: var(--success-tint); color: var(--success-text); }
.status.lapsed { background: var(--warning-tint); color: var(--warning-text); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-ctl); margin: 0 0 16px; background: var(--primary-tint); color: var(--heading); }
.notice::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.notice.ok { background: var(--success-tint); } .notice.ok::before { background: var(--success); }
.notice.bad { background: var(--warning-tint); } .notice.bad::before { background: var(--warning); }
.notice.danger { background: var(--danger-tint); } .notice.danger::before { background: var(--danger); }
.notice .grow { flex: 1; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; line-height: 20px; margin: 0 0 8px; color: var(--heading); }
input, select, textarea { width: 100%; height: var(--ctl); border: 1px solid var(--faint); border-radius: var(--r-ctl); padding: 0 12px;
  font: 14px Inter, sans-serif; background: var(--surface); color: var(--text); }
textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 20px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input.code { font: 500 20px var(--mono); letter-spacing: .3em; text-align: center; height: 40px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 8px 0 0; }
.formrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: end; }
.formrow.two { grid-template-columns: 1fr auto; }
.adminform + .adminform { margin-top: var(--gap); }
.adminform > p.muted { margin-bottom: 16px; }
.adminform > p.hint { margin: 8px 0 0; }
.adminform h4 { margin: 24px 0 0; font-size: 14px; line-height: 20px; }
.fields .wide { grid-column: 1 / -1; }
.card.installcard { margin: 0 0 16px; }
pre.log { margin: 12px 0 0; max-height: 320px; overflow: auto; padding: 12px; background: var(--neutral-tint); border-radius: var(--r-ctl);
  font: 12px/16px var(--mono); white-space: pre-wrap; word-break: break-word; }
.stack > * + * { margin-top: 16px; }
label.gap { margin-top: 16px; }
.gap-s { margin-top: 8px; }
.result { margin: 12px 0 0; }
.result:empty { display: none; }
.result.ok { color: var(--success-text); }
.result.warn { color: var(--danger-text); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.toggle { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; margin: 16px 0 4px; cursor: pointer; }
.danger-text { color: var(--muted); margin: 0 0 8px 24px; }

/* ---------- tables ---------- */
.tablewrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--heading); }
th, td { padding: 12px; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
th, td { border-bottom: 1px solid var(--row); vertical-align: top; }
thead th { background: var(--subtle); border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
thead tr:first-child th:first-child { border-top-left-radius: var(--r-panel); }
thead tr:first-child th:last-child { border-top-right-radius: var(--r-panel); }
table.data td { white-space: nowrap; }
table.data td.wrap, table.data.alerts td:nth-child(2) { white-space: normal; min-width: 200px; }
td.actions { text-align: right; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--heading); font-weight: 500; margin-top: 4px; }

/* ---------- landing ---------- */
.hero { text-align: center; padding: 72px 0 56px; max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 40px; line-height: 48px; }
.hero p { font-size: 18px; line-height: 28px; color: var(--muted); margin: 16px 0 0; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 32px; }
.facts { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 32px 0; }
.fact { text-align: center; padding: 0 16px; }
.fact svg { width: 24px; height: 24px; color: var(--primary); display: block; margin: 0 auto 12px; }
.fact h3 { margin-bottom: 4px; }
.fact p { color: var(--muted); margin: 0; }
.section-h { text-align: center; margin: 56px 0 24px; }
.section-h h2 { margin: 0; font-size: 24px; line-height: 32px; }
.section-h p { color: var(--muted); margin: 8px 0 0; }
.section-h .badge { margin-top: 12px; }
.plan { display: flex; flex-direction: column; padding: 24px; }
.plan.best { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.plan .badge-slot { height: 20px; margin-bottom: 12px; }
.plan h3 { margin: 0; }
.price { font-size: 32px; line-height: 40px; font-weight: 600; color: var(--heading); margin: 8px 0 16px; }
.plan ul { list-style: none; padding: 16px 0 0; margin: 0 0 24px; border-top: 1px solid var(--row); flex: 1; }
.plan li { padding: 4px 0 4px 24px; position: relative; }
.plan li::before { content: ""; position: absolute; left: 3px; top: 10px; width: 9px; height: 4px; border-left: 2px solid var(--success); border-bottom: 2px solid var(--success); transform: rotate(-45deg); }
.plan .btn { width: 100%; }
.app-card { display: flex; flex-direction: column; text-align: center; padding: 24px; }
.app-card p { flex: 1; color: var(--muted); }
.app-card .btn { width: 100%; }
footer { width: calc(100% - 32px); max-width: calc(var(--page) - 32px); margin: 0 auto; padding: 24px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
footer nav { display: flex; gap: 16px; }

/* ---------- sign in ---------- */
.signbox { max-width: 400px; margin: 48px auto; padding: 24px; }
.signbox h1 { margin-bottom: 8px; }
.signbox form label { margin-top: 16px; }
.signbox .btn, .alt .btn { width: 100%; margin-top: 16px; }
.alt p { margin: 8px 0 0; text-align: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 24px 0 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------- account ---------- */
.buyrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--row); }
.buyrow:first-of-type { border-top: 0; padding-top: 0; }
.buyrow .price-s { font-weight: 600; color: var(--heading); text-align: right; }
.paynote { margin: 12px 0 0; color: var(--muted); }
.keys { display: grid; gap: var(--gap); }
.keycard { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 24px; align-items: center; }
.keycard .qr { width: 160px; height: 160px; border: 1px solid var(--row); border-radius: var(--r-ctl); image-rendering: pixelated; background: #fff; display: block; }
.keycard h3 { margin-bottom: 4px; }
main.narrow .keycard { grid-template-columns: 1fr; justify-items: center; text-align: center; }
main.narrow .keycard .qr { width: 240px; height: 240px; }
main.narrow .keyactions { justify-content: center; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 12px; }
.code-big { font: 600 28px/36px var(--mono); letter-spacing: .2em; color: var(--heading); }
.big { font-size: 40px; line-height: 48px; color: var(--success); }
.tag { display: inline-flex; height: 20px; align-items: center; padding: 0 8px; border-radius: 999px; background: var(--warning-tint); color: var(--warning-text); font-size: 12px; margin-bottom: 16px; }

/* ---------- tabs and segmented controls ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin: 0 0 24px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; color: var(--text); white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.tabs a:hover { text-decoration: none; box-shadow: inset 0 -2px 0 var(--border-strong); }
.tabs a.on { color: var(--heading); font-weight: 600; box-shadow: inset 0 -2px 0 var(--primary); }
.chips { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); overflow: hidden; }
.chip { display: inline-flex; align-items: center; justify-content: center; height: calc(var(--ctl) - 2px); padding: 0 12px; background: var(--surface); color: var(--text); border-left: 1px solid var(--border-strong); white-space: nowrap; }
.chip:first-child { border-left: 0; }
.chip:hover { background: var(--subtle); text-decoration: none; }
.chip.on { background: var(--row); color: var(--heading); font-weight: 600; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; }

/* ---------- numbers and charts ---------- */
.kpi { display: flex; flex-direction: column; }
.kpi-v { font-size: 24px; line-height: 32px; font-weight: 600; color: var(--heading); margin-top: 4px; overflow-wrap: anywhere; }
.kpi-n { margin-top: 4px; font-size: 12px; line-height: 16px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart .grid { stroke: var(--row); stroke-width: 1; }
.chart .base { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { font: 12px Inter, sans-serif; fill: var(--muted); }
.chart .hit { fill: transparent; }
.chart .col:hover .hit { fill: rgba(31, 30, 36, .04); }
.chart .tip { position: absolute; top: 48px; min-width: 160px; background: var(--heading); color: #fff; border-radius: var(--r-ctl); padding: 8px 12px; font-size: 12px; line-height: 16px; pointer-events: none; white-space: nowrap; }
.chart.line .xh { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0; }
.chart.line .dot { stroke: var(--surface); stroke-width: 2; opacity: 0; }
.chart.line .col:hover .xh, .chart.line .col:hover .dot { opacity: 1; }
.chart.line .col:hover .hit { fill: transparent; }
.legend { display: flex; gap: 16px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 2px; margin-right: 8px; vertical-align: middle; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 12px; }
.hbar b { font-weight: 600; color: var(--heading); }
.hbar .track { grid-column: 1 / -1; height: 4px; background: var(--row); border-radius: 2px; overflow: hidden; }
.hbar .track div { height: 100%; background: var(--primary); }
.meter { height: 4px; background: var(--row); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.meter div { height: 100%; background: var(--primary); }
.meter div.hot { background: var(--danger); }

/* ---------- server status ---------- */
.lvl { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--heading); }
.lvl i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.lvl.ok i { background: var(--success); } .lvl.warning i { background: var(--warning); } .lvl.critical i { background: var(--danger); }
.notify .nrow { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-top: 1px solid var(--row); overflow-wrap: anywhere; }
.notify .nrow:first-of-type { border-top: 0; padding-top: 0; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  :root { --ctl: 40px; }
  .btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
  .nav a.item, .nav .sep { display: none; }
  .nav .menu-btn { display: inline-flex; width: var(--ctl); padding: 0; }
  .menu.open { display: grid; gap: 4px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px; }
  .menu a { display: flex; align-items: center; height: 40px; padding: 0 12px; border-radius: var(--r-ctl); color: var(--text); font-weight: 500; }
  .menu a:hover { text-decoration: none; background: var(--row); }
  .menu a.on { background: var(--row); color: var(--heading); }
  .langs a, .langs button { height: 38px; width: 40px; }
  .hero { padding: 40px 0 32px; }
  .hero h1 { font-size: 30px; line-height: 36px; }
  .hero p { font-size: 16px; line-height: 24px; }
  .cta .btn { width: 100%; }
  .cards > * { flex-basis: 100%; }
  .cards.kpis[data-even="true"] > * { flex-basis: calc((100% - var(--gap)) / 2); }
  .grid2, .fields, .formrow, .formrow.two, .kv { grid-template-columns: 1fr; }
  .formrow .btn, .actionsrow .btn { width: 100%; }
  .keycard { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .keycard .keyactions .btn { flex: 1 1 100%; }
  .chart .card-h { flex-direction: column; align-items: flex-start; gap: 4px; }
  .buyrow { grid-template-columns: minmax(0, 1fr) auto; }
  .buyrow .btn { grid-column: 1 / -1; width: 100%; }
  .notify .nrow { grid-template-columns: 1fr; gap: 4px; }
  .head .chips, .toolbar .chips { width: 100%; }
  .head .chips .chip, .toolbar .chips .chip { flex: 1; }
  .head > .btn { width: 100%; }
  footer { flex-direction: column; align-items: center; text-align: center; }
}
