:root {
  --brand: #1a73e8;
  --brand-dark: #1557b0;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #6b7a90;
  --line: #e3eaf4;
  --green: #00a862;
  --red: #e53935;
  --orange: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { border: 0; border-radius: 10px; padding: 9px 16px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.light { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--text); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 28px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, #1a73e8, #0b1426); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; margin: 0 auto 12px; }
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.login-card .btn { width: 100%; padding: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100%; }
.sidebar { width: 230px; background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 16px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; margin: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-weight: 700; }
.nav .ico { width: 18px; text-align: center; }
.sidebar .foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar .foot b { color: var(--text); display: block; font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.topbar { display: none; }
h2.page { margin: 0 0 4px; font-size: 22px; }
p.page-sub { margin: 0 0 20px; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 320px 1fr; align-items: start; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.brand { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; }
.stat.brand .l { color: rgba(255, 255, 255, .85); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.actions { text-align: right; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.active { background: #e6f6ee; color: var(--green); }
.pill.expired { background: #fff4e5; color: #b26a00; }
.pill.blocked { background: #fdecec; color: var(--red); }
.uname { font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 13px; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.red:hover { border-color: var(--red); color: var(--red); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: 18px; width: 100%; max-width: 420px; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2433; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 60; max-width: 90%; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }
.copybox { display: flex; gap: 8px; }
.copybox .input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.log-list div { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.log-list div:last-child { border-bottom: 0; }
.tag { font-size: 12px; background: var(--bg); padding: 1px 8px; border-radius: 6px; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; font-weight: 800; }
  .layout { flex-direction: column; }
  .main { padding: 16px 14px 60px; }
  th.hide-sm, td.hide-sm { display: none; }
}
.mb12 { margin-bottom: 12px; }
.mt12 { margin-top: 12px; }
.small { font-size: 12px; }
.w-auto { width: auto; }
.grid > * { min-width: 0; }
@media (max-width: 720px) {
  /* Accounts table becomes stacked rows: name/status/expiry on top, buttons underneath */
  table.acc thead { display: none; }
  table.acc tbody tr { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.acc td { border: 0; padding: 0; }
  table.acc td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; padding-top: 6px; }
  table.acc td.actions .icon-btn { margin: 0 4px 4px 0; padding: 7px 11px; }
}
.credits { margin: 8px 0 4px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-size: 13px; }
.credits b { display: inline; color: var(--brand); }
.pill.trial { background: #efe9ff; color: #6d28d9; }
.dot-on { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 4px; }
.hint { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.pill.online { background: #e6f6ee; color: var(--green); }
.pill.offline { background: #fdecec; color: var(--red); }
.pill.waiting { background: #fff4e5; color: #b26a00; }
.cmd { width: 100%; min-height: 84px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.steps { margin: 6px 0 0 18px; padding: 0; font-size: 13px; }
.steps li { margin: 4px 0; }
a.icon-btn { display: inline-block; text-decoration: none; color: inherit; }
.row.between { justify-content: space-between; align-items: center; }
.field.w-port { width: 96px; flex: 0 0 96px; }
.pill.proto { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.log-box { background: #0b1426; color: #cfe3ff; border-radius: 10px; padding: 10px 12px; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 8px; }
.modal { max-height: 92vh; overflow: auto; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.feat { display: grid; gap: 2px; }
.feat .check { margin: 2px 0; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.shade { display: none; }
@media (max-width: 720px) {
  .shade.show { display: block; position: fixed; inset: 0; background: rgba(11, 20, 38, .45); z-index: 35; }
  .sidebar { overflow-y: auto; }
}

/* logout always reachable (top bar on phones, menu item everywhere) */
.top-logout { margin-left: auto; }
.nav a.nav-logout { color: #dc2626; margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.nav a.nav-logout:hover { background: #fef2f2; }

/* ---------- v2.8: dashboard map, free access, branding ---------- */
.logo { background: linear-gradient(135deg, var(--brand), #0b1426); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; margin-bottom: 16px; }
h3.section { margin: 8px 0 12px; font-size: 15px; color: var(--muted); }
.map-wrap { display: grid; grid-template-columns: minmax(0, 820px) 1fr; gap: 12px; align-items: start; }
.map { position: relative; width: 100%; padding-top: 50.6%; overflow: hidden; border-radius: 12px; background: #eef2f7; border: 1px solid var(--line); }
.map-inner { position: absolute; left: 0; width: 100%; }
.map-tile { position: absolute; display: block; user-select: none; pointer-events: none; }
.map-pin { position: absolute; transform: translate(-50%, -50%); min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 4px rgba(0, 0, 0, .08); }
.map-pin.off { background: var(--red); }
.map-attr { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: var(--muted); background: rgba(255, 255, 255, .8); padding: 0 4px; border-radius: 4px; }
.map-list { max-height: 330px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.map-row { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.map-row .flag { font-size: 20px; }
.grow { flex: 1; min-width: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.input.w-name { width: 130px; flex: 0 0 130px; }
textarea.input { resize: vertical; font: inherit; }
.ok-text { color: var(--green); }
.bad-text { color: var(--red); }
.maint { background: #fff4e5; color: #8a5300; border-bottom: 1px solid #ffd9a8; padding: 10px 16px; font-weight: 600; }
.login-msg { white-space: pre-line; text-align: center; color: var(--text); background: var(--bg); border-radius: 12px; padding: 10px 12px; margin-top: 16px; font-size: 13px; }
.app-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.app-links a { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 13px; }
@media (max-width: 900px) { .map-wrap { grid-template-columns: 1fr; } }
.row.gap8 { gap: 8px; }
.row.gap4 { gap: 4px; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.hint.hint-bad { border-color: #fca5a5; background: #fef2f2; }
.login-card p.sub.sub-link { margin: 14px 0 0; text-align: center; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 12px 6px; }
.card.inner { box-shadow: none; border: 1px solid var(--line); margin: 0; }
.map-tile { filter: saturate(.6) brightness(1.04); }
