/* ============================================================
   Маяк VPN — личный кабинет (cabinet.mayakvpn.ru)
   Бренд совпадает с лендингом: navy #14213D / голубой #4FC3F7 /
   красный #E63946 / крем #FFFDF7. Светлая тема по умолчанию,
   тёмная — через prefers-color-scheme. Без внешних зависимостей.
   ============================================================ */

:root {
  --navy: #14213D;
  --navy-2: #1A2E5A;
  --blue: #4FC3F7;
  --blue-deep: #2596c9;
  --red: #E63946;
  --cream: #FFFDF7;
  --ink: #14213D;
  --ink-soft: #41506e;
  --line: #e4e2da;
  --white: #ffffff;

  --ok: #1f9d55;
  --ok-bg: rgba(31, 157, 85, .12);
  --warn: #b8860b;
  --warn-bg: rgba(184, 134, 11, .12);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(20, 33, 61, .10);
  --shadow-sm: 0 4px 14px rgba(20, 33, 61, .08);

  --maxw: 1120px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "PT Sans", "Noto Sans", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  font-size: clamp(1rem, .96rem + .3vw, 1.06rem);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { line-height: 1.2; color: var(--navy); margin: 0 0 .5em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); }
h2 { font-size: 1.25rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--blue-deep); }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2rem);
}
.container-narrow { max-width: 760px; }

/* ---------- a11y ---------- */
.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  background: var(--navy);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 3px solid var(--blue-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  font-family: inherit;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: .7rem 1.4rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(230, 57, 70, .28); }
.btn-primary:hover:not(:disabled) { background: #cf2f3c; }

.btn-ghost { background: transparent; color: var(--navy); border-color: rgba(20, 33, 61, .25); }
.btn-ghost:hover:not(:disabled) { border-color: var(--navy); background: rgba(20,33,61,.04); }

.btn-danger { background: transparent; color: var(--red); border-color: rgba(230,57,70,.4); }
.btn-danger:hover:not(:disabled) { background: rgba(230,57,70,.08); border-color: var(--red); }

.btn-lg { padding: .9rem 1.9rem; font-size: 1.05rem; }
.btn-sm { padding: .45rem 1rem; font-size: .92rem; }
.btn-block { width: 100%; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after,
.btn-danger.is-loading::after { border-color: rgba(20,33,61,.35); border-top-color: var(--navy); }

@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--blue-deep);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:disabled { color: var(--ink-soft); cursor: not-allowed; text-decoration: none; }

/* ============================================================
   HEADER / FOOTER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 253, 247, .92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--navy); font-weight: 800; }
.brand-logo { width: 40px; height: 40px; }
.brand-name { font-size: 1.2rem; letter-spacing: -.01em; }

.header-actions { display: flex; align-items: center; gap: .8rem; }
.header-email { color: var(--ink-soft); font-size: .92rem; font-weight: 600; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.site-footer {
  margin-top: auto;
  background: #0f1830;
  color: #b9c7e2;
  padding-block: 1.6rem;
}
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.footer-copy { margin: 0; font-size: .9rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.footer-nav a { color: #c5d2ea; text-decoration: none; font-weight: 600; font-size: .9rem; }
.footer-nav a:hover { color: var(--blue); text-decoration: underline; }

/* ============================================================
   MAIN / VIEWS
   ============================================================ */
.auth-main { flex: 1 0 auto; display: flex; flex-direction: column; }
.view { flex: 1 0 auto; }

/* auth views (register/login/verify/forgot) are centered cards */
#view-register, #view-login, #view-verify, #view-forgot {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3.5rem) 1.1rem;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(79,195,247,.16), transparent 60%),
    linear-gradient(180deg, #fff 0%, var(--cream) 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 4vw, 2.4rem);
}
.auth-head { text-align: center; margin-bottom: 1.6rem; }
.auth-logo { width: 64px; height: 64px; margin: 0 auto .9rem; filter: drop-shadow(0 8px 18px rgba(20,33,61,.18)); }
.auth-sub { color: var(--ink-soft); margin: 0; font-size: .98rem; }
.auth-alt { text-align: center; margin: 1.1rem 0 0; color: var(--ink-soft); font-size: .95rem; }

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 1.1rem; }
.field > label, .label-row label { display: block; font-weight: 700; color: var(--navy); margin-bottom: .35rem; font-size: .95rem; }
.optional { font-weight: 500; color: var(--ink-soft); }

.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.label-link { font-size: .85rem; font-weight: 600; }

input[type="email"],
input[type="tel"],
input[type="text"],
input[type="password"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem .85rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #9aa3b5; }
input:focus { outline: none; border-color: var(--blue-deep); box-shadow: 0 0 0 3px rgba(79,195,247,.22); }
input[aria-invalid="true"] { border-color: var(--red); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(230,57,70,.2); }

.field-hint { margin: .35rem 0 0; font-size: .84rem; color: var(--ink-soft); }
.field-error { margin: .35rem 0 0; font-size: .86rem; color: var(--red); font-weight: 600; }

.code-input {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: .5em;
  font-weight: 700;
  padding-inline: .85rem .35rem;
}

/* password show/hide */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.4rem; }
.pw-toggle {
  position: absolute;
  right: .5rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: 0;
  font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--blue-deep);
  cursor: pointer;
  padding: .3rem .4rem;
}

/* password strength */
.pw-strength { margin-top: .5rem; }
.pw-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.pw-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--red); transition: width .25s ease, background .25s ease; }
.pw-bar span.s1 { width: 25%; background: #e0463a; }
.pw-bar span.s2 { width: 50%; background: #d98324; }
.pw-bar span.s3 { width: 75%; background: #c8b41f; }
.pw-bar span.s4 { width: 100%; background: var(--ok); }
.pw-label { display: block; margin-top: .3rem; font-size: .82rem; color: var(--ink-soft); }

/* consent checkbox */
.checkbox { display: flex; align-items: flex-start; gap: .6rem; font-weight: 500; color: var(--ink-soft); font-size: .92rem; cursor: pointer; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; accent-color: var(--blue-deep); flex: 0 0 auto; }
.consent a { font-weight: 600; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  z-index: 300;
  max-width: min(92vw, 460px);
  padding: .8rem 1.1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: .94rem;
  color: #fff;
  background: var(--navy);
}
.toast.toast-error { background: var(--red); }
.toast.toast-ok { background: var(--ok); }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard { padding-block: clamp(1.5rem, 4vw, 2.6rem); }
.dash-container { max-width: var(--maxw); }
.dash-title { margin-bottom: 1.4rem; }

.dash-loading { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); padding: 2rem 0; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--line); border-top-color: var(--blue-deep); border-radius: 50%; animation: spin .7s linear infinite; }

.dash-error {
  background: rgba(230,57,70,.08);
  border: 1px solid rgba(230,57,70,.35);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
}
.dash-error p { margin: 0; color: var(--red); font-weight: 600; }

.dash-grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: 1fr;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.4rem 1.5rem;
}
.panel-h { font-size: 1.15rem; margin-bottom: 1rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; }
.panel-head .panel-h { margin-bottom: 0; }

/* profile key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1rem; margin: 0; }
.kv dt { color: var(--ink-soft); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; color: var(--navy); display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; word-break: break-word; }

.badge {
  display: inline-block;
  font-size: .74rem;
  font-weight: 700;
  padding: .12rem .5rem;
  border-radius: 999px;
  letter-spacing: .01em;
}
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }

/* plan */
.plan-now { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.plan-name { font-size: 1.3rem; font-weight: 800; color: var(--navy); }
.plan-code { color: var(--ink-soft); font-size: .85rem; margin-left: .4rem; }
.plan-until { font-size: .9rem; color: var(--ink-soft); }
.plan-until strong { color: var(--navy); }

.usage { margin-bottom: 1.3rem; }
.usage-row { display: flex; justify-content: space-between; font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.usage-row span:last-child { color: var(--navy); }
.usage-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.usage-bar span { display: block; height: 100%; width: 0; background: var(--blue-deep); border-radius: 999px; transition: width .3s ease; }
.usage-bar span.full { background: var(--red); }

.tariffs { border-top: 1px solid var(--line); padding-top: 1.1rem; }
.tariffs-lead { font-weight: 700; color: var(--navy); margin: 0 0 .6rem; font-size: .95rem; }
.tariff-list { list-style: none; margin: 0 0 .9rem; padding: 0; display: grid; gap: .45rem; }
.tariff-list li { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; align-items: baseline; font-size: .92rem; padding: .45rem .6rem; background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.t-name { font-weight: 700; color: var(--navy); }
.t-dev { color: var(--ink-soft); font-size: .85rem; }
.t-price { font-weight: 700; color: var(--blue-deep); }
.tariffs-note { font-size: .82rem; color: var(--ink-soft); margin: .6rem 0 0; text-align: center; }

/* devices */
.dev-count { font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.dev-help { color: var(--ink-soft); font-size: .9rem; margin: 0 0 1rem; }
.dev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.dev-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  background: var(--cream);
}
.dev-main { min-width: 0; }
.dev-label { font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dev-meta { font-size: .82rem; color: var(--ink-soft); margin-top: .2rem; }
.dev-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: var(--ink-soft); }
.dot { color: var(--line); }
.dev-online { color: var(--ok); font-weight: 700; font-size: .78rem; }

.dev-empty, .dev-limit-msg { color: var(--ink-soft); font-size: .92rem; padding: .8rem 0 0; }
.dev-limit-msg { color: var(--warn); font-weight: 600; }

/* ============================================================
   LEGAL
   ============================================================ */
.legal { padding-block: clamp(1.5rem, 4vw, 3rem); }
.legal-inner h1 { margin-bottom: .8rem; }
.legal-inner h2 { margin-top: 1.8rem; font-size: 1.15rem; }
.legal-inner ul { color: var(--ink-soft); padding-left: 1.2rem; }
.legal-inner li { margin-bottom: .4rem; }
.legal-inner p { color: var(--ink-soft); }
.back-link { display: inline-block; margin-bottom: 1rem; font-weight: 600; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.legal-stub {
  background: rgba(230,57,70,.06);
  border: 1px dashed rgba(230,57,70,.45);
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  color: var(--ink-soft);
}
.placeholder-tag {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--red);
  background: rgba(230,57,70,.1);
  border: 1px dashed rgba(230,57,70,.5);
  border-radius: 6px;
  padding: .05rem .45rem;
  margin-left: .25rem;
  vertical-align: middle;
}

.cooldown { color: var(--ink-soft); font-size: .9rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 760px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .panel-wide { grid-column: 1 / -1; }
}

/* ============================================================
   DARK THEME
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --cream: #0e1626;
    --white: #131f36;
    --ink: #e7edf7;
    --ink-soft: #a9b6d0;
    --line: #243352;
    --navy: #cfe6fb;
    --ok: #4ade80;
    --ok-bg: rgba(74, 222, 128, .14);
    --warn: #e7c14b;
    --warn-bg: rgba(231, 193, 75, .14);
  }
  body { background: #0e1626; }
  .site-header { background: rgba(14,22,38,.9); }
  .brand, .brand-name { color: #e7edf7; }
  #view-register, #view-login, #view-verify, #view-forgot {
    background:
      radial-gradient(1000px 500px at 80% -10%, rgba(79,195,247,.14), transparent 60%),
      linear-gradient(180deg, #121d33 0%, #0e1626 100%);
  }
  input { background: #0e1626; color: #e7edf7; }
  .btn-ghost { color: #e7edf7; border-color: rgba(231,237,247,.3); }
  .panel, .auth-card { background: var(--white); }
  .dev-item, .tariff-list li { background: #0f1830; }
  .skip-link { background: var(--blue-deep); }
}
