/* DivoVPN user cabinet — Telegram Mini App and web. No inline styles (CSP). */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --line: #e4e7ee;
  --text: #1c2130;
  --muted: #6b7385;
  --primary: #2f5bea;
  --primary-ink: #ffffff;
  --primary-soft: #e6ecfd;
  --dark: #1f2430;
  --green: #22a35a;
  --green-soft: #e7f6ee;
  --red: #d23c3c;
  --red-soft: #fdecec;
  --amber-soft: #fff7df;
  --amber-ink: #7a5300;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(20, 30, 60, .08);
  --tabs-h: 68px;
}
:root[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #181c25;
  --surface-2: #1f2430;
  --line: #2a3040;
  --text: #eef1f7;
  --muted: #9aa3b5;
  --primary: #5b7fff;
  --primary-soft: #23305a;
  --dark: #2b3242;
  --green: #35c071;
  --green-soft: #173626;
  --red: #ef5d5d;
  --red-soft: #3a1d1f;
  --amber-soft: #3a3016;
  --amber-ink: #f3d68a;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #181c25; --surface-2: #1f2430; --line: #2a3040;
    --text: #eef1f7; --muted: #9aa3b5; --primary: #5b7fff; --primary-soft: #23305a;
    --dark: #2b3242; --green: #35c071; --green-soft: #173626; --red: #ef5d5d;
    --red-soft: #3a1d1f; --amber-soft: #3a3016; --amber-ink: #f3d68a; --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--primary); }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); }
.brand {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 18px 16px; background: var(--primary); color: #fff;
  font-weight: 800; font-size: 22px; letter-spacing: .3px;
  border-radius: 0 0 24px 24px;
}
.brand img { border-radius: 10px; background: #fff; }
.view { padding: 16px; display: grid; gap: 14px; }
.loading { text-align: center; color: var(--muted); padding: 48px 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.soft { background: var(--surface-2); box-shadow: none; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.status-value { font-size: 20px; font-weight: 800; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.status-value.ok { color: var(--green); }
.status-value.warn { color: var(--red); }
.dot { width: 18px; height: 18px; border-radius: 50%; background: currentColor; display: inline-grid; place-items: center; }
.dot svg { width: 12px; height: 12px; fill: var(--surface); }

.meter { height: 10px; border-radius: 6px; background: var(--primary-soft); overflow: hidden; margin-top: 10px; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 16px; border: 0; border-radius: 16px;
  font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-ink); width: 100%;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.dark { background: var(--dark); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { min-height: 40px; font-size: 15px; padding: 8px 12px; border-radius: 12px; width: auto; }
.btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 520px; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { border: 0; background: none; border-radius: 14px; display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: 12px; cursor: pointer; }
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.active { background: var(--primary-soft); color: var(--primary); }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 24, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: 24px 24px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 24px; } }
.sheet-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.sheet-head h2 { margin: 0; text-align: center; font-size: 19px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
#sheet-back:not([hidden]) + h2 { grid-column: 2; }
#sheet-back[hidden] + h2 { grid-column: 2; }
.sheet-body { padding: 16px; display: grid; gap: 12px; }

.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); cursor: pointer;
}
.choice:active { background: var(--surface-2); }
.choice .ico { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.choice .ico svg { width: 26px; height: 26px; fill: var(--text); }
.choice b { display: block; font-size: 18px; }
.choice span { color: var(--muted); font-size: 14px; }

.step-badge { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 20px; margin: 4px auto 0; }
.step-badge.done { background: var(--green-soft); color: var(--green); }
.step-badge svg { width: 30px; height: 30px; fill: currentColor; }
.step-title { text-align: center; }
.step-title h3 { margin: 6px 0 2px; font-size: 20px; }
.note { border-radius: 14px; padding: 12px 14px; border: 1px solid transparent; }
.note.info { background: var(--primary-soft); }
.note.warn { background: var(--amber-soft); color: var(--amber-ink); }
.note.ok { background: var(--green-soft); }
.note.bad { background: var(--red-soft); }
.note ol, .note ul { margin: 6px 0 0; padding-left: 20px; }
.note li + li { margin-top: 4px; }

.copy { display: flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.copy code { flex: 1; min-width: 0; padding: 12px; font: 14px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy button { border: 0; background: var(--dark); color: #fff; padding: 0 14px; font-weight: 600; cursor: pointer; }

input[type="text"], input[type="email"], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
textarea { min-height: 120px; resize: vertical; }
.code-input { text-align: center; font-size: 24px !important; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; }

/* Login stays intentionally compact: one surface, one primary action. */
.login-screen { min-height: calc(100vh - 112px); display: grid; align-items: center; padding: 12px 0 32px; }
.login-panel {
  display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.login-copy { text-align: center; }
.login-copy h1 { margin: 0; }
.login-copy p { margin: 6px 0 0; }
.login-code { display: grid; gap: 10px; }
.code-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.code-entry .btn { width: auto; }
.login-help { text-align: center; }
.login-link {
  display: inline-flex; align-items: center; min-height: 44px; border: 0; padding: 0;
  background: none; color: var(--primary); font: inherit; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer; vertical-align: middle;
}
.login-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.login-email h2 { margin: 0 0 2px; text-align: center; font-size: 17px; }
@media (max-width: 420px) {
  .login-panel { padding: 20px; }
  .code-entry { grid-template-columns: 1fr; }
  .code-entry .btn { width: 100%; }
}

.device { display: grid; gap: 10px; }
.device-head { display: flex; align-items: center; gap: 12px; }
.device-head .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; flex: none; }
.device-head .ico svg { width: 22px; height: 22px; fill: var(--primary); }
.device-head b { display: block; }

.plans { display: grid; gap: 10px; }
.plan { text-align: left; display: grid; gap: 2px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.plan.featured { border-color: var(--primary); background: var(--primary-soft); }
.plan b { font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90vw; text-align: center;
}
h1.page { font-size: 22px; margin: 4px 0 0; }
.center { text-align: center; }
.stack { display: grid; gap: 10px; }
