/* ============================================================
   UNIDENTIFIED VPN — Account portal (site)
   Loaded AFTER styles.css — reuses its tokens, fonts, buttons,
   .copy-line, .chip, .loader, scanlines/halftone, platform glyphs.
   ============================================================ */

/* portal uses normal viewport media queries (real responsive site) */
.portal { position: relative; z-index: 1; min-height: 100vh; }

/* ---- shared field ---- */
.field {
  width: 100%; background: var(--black-1); border: 1px solid var(--line-2);
  color: var(--ghost); font-family: var(--f-mono); font-size: 14px; padding: 15px 16px;
}
.field::placeholder { color: var(--ghost-dim); }
.field:focus { outline: none; border-color: var(--accent); background: #0c0c0c; }

/* corner-bracket accent for cards */
.brk { position: relative; }
.brk::before, .brk::after { content:""; position:absolute; width:12px; height:12px; pointer-events:none; }
.brk::before { top:-1px; left:-1px; border-top:1px solid var(--accent); border-left:1px solid var(--accent); }
.brk::after  { bottom:-1px; right:-1px; border-bottom:1px solid var(--accent); border-right:1px solid var(--accent); }

/* ============================================================
   AUTH SCREENS (login / email)
   ============================================================ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 28px; position: relative; z-index: 1; }
.auth-inner { width: min(440px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }
.auth-brand img { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(var(--accent-rgb),0.3)); }
.auth-brand .wm { font-family: var(--f-display); font-weight: 800; font-size: 24px; letter-spacing: 0.01em; text-transform: uppercase; line-height: 0.9; }
.auth-brand .wm .vpn { color: var(--accent); }

.auth-card { position: relative; background: var(--black-2); border: 1px solid var(--line); padding: 34px 30px; }
.auth-kicker { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--accent); }
.auth-card h1 { font-family: var(--f-display); font-weight: 800; font-size: 40px; line-height: 0.9; text-transform: uppercase; margin: 12px 0 10px; }
.auth-card .lead { color: var(--ghost-fade); font-size: 14px; margin-bottom: 26px; }
.auth-foot { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--ghost-dim); margin-top: 22px; line-height: 1.7; text-align: center; }
.auth-steps { display: flex; gap: 6px; justify-content: center; margin-top: 22px; }
.auth-steps i { width: 22px; height: 3px; background: var(--line-2); }
.auth-steps i.on { background: var(--accent); }

/* Telegram login button */
.tg-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: #229ED9; color: #fff; border: none; padding: 16px 20px; cursor: pointer;
  font-family: var(--f-mono); font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  border-radius: 8px; transition: filter .15s, transform .05s;
}
.tg-btn:hover { filter: brightness(1.07); }
.tg-btn:active { transform: translateY(1px); }
.tg-btn svg { width: 22px; height: 22px; }

/* Official Telegram Login Widget (iframe) — we can't restyle the iframe itself,
   so we frame and center it to sit cleanly inside the auth card. */
.tg-widget-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.tg-widget { min-height: 48px; display: flex; justify-content: center; align-items: center; }
.tg-widget.busy { opacity: 0.45; pointer-events: none; }
.auth-busy { display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--accent); }
.auth-busy svg { width: 16px; height: 16px; }
.auth-error { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.02em;
  color: var(--accent-2); line-height: 1.5; text-align: center; }

/* fallback email-recovery panel on the login screen */
.auth-recover { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.auth-recover-kicker { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.auth-recover-lead { font-family: var(--f-mono); font-size: 12px; color: var(--ghost-fade);
  line-height: 1.6; margin-bottom: 12px; }
.auth-recover-ok { font-family: var(--f-mono); font-size: 12.5px; color: var(--ghost-fade);
  line-height: 1.65; text-align: left; }

.auth-row { display: flex; gap: 12px; }
.auth-row .btn { flex: 1; }
/* strip the Happ "H" watermark from auth-screen primary buttons (it belongs only on the real "Add to HAPP" CTA) */
.auth .btn-primary { background-image: none; }
/* "+ Добавить устройство" is an outline-accent button but must NOT carry the Karing watermark */
.devhead .btn-outline-accent { background-image: none; }
/* TG-proxy page: its primary buttons are Telegram/renew actions — no Happ "H" watermark */
.tgproxy .btn-primary { background-image: none; }
.linkbtn { background: none; border: none; color: var(--ghost-dim); font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; padding: 12px; text-align: center; width: 100%; }
.linkbtn:hover { color: var(--accent); }

/* ============================================================
   APP SHELL (sidebar + main + mobile nav)
   ============================================================ */
.app { min-height: 100vh; display: flex; position: relative; z-index: 1; }

.sidebar {
  width: 248px; flex: none; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .s-logo { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.sidebar .s-logo img { width: 30px; height: 30px; object-fit: contain; }
.sidebar .s-logo .wm { font-family: var(--f-display); font-weight: 800; font-size: 17px; text-transform: uppercase; line-height: 0.9; }
.sidebar .s-logo .wm .vpn { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 12px; padding: 13px 12px; background: none; border: none; cursor: pointer;
  font-family: var(--f-mono); font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ghost-dim);
  text-decoration: none; text-align: left; width: 100%; border-left: 2px solid transparent; transition: color .15s, background .15s;
}
.nav a:hover, .nav button:hover { color: var(--ghost); background: var(--black-2); }
.nav a.on, .nav button.on { color: var(--ghost); border-left-color: var(--accent); background: linear-gradient(90deg, rgba(var(--accent-rgb),0.08), transparent); }
.nav .ic { width: 16px; height: 16px; flex: none; }
.nav .ic svg { width: 100%; height: 100%; }

.sidebar .spacer { flex: 1; }
.acct { display: flex; align-items: center; gap: 11px; padding: 12px 10px; border: 1px solid var(--line); }
.acct .av { width: 38px; height: 38px; flex: none; border: 1px solid var(--line-2); background: var(--black-1); display: grid; place-items: center; overflow: hidden; }
.acct .av img { width: 100%; height: 100%; object-fit: cover; }
.acct .who { min-width: 0; flex: 1; }
.acct .who .h { font-family: var(--f-mono); font-size: 12.5px; color: var(--ghost); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .who .e { font-family: var(--f-mono); font-size: 10px; color: var(--ghost-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .out { background: none; border: none; cursor: pointer; color: var(--ghost-dim); padding: 6px; flex: none; }
.acct .out:hover { color: var(--magenta); }
.acct .out svg { width: 16px; height: 16px; display: block; }

/* main */
.app-main { flex: 1; min-width: 0; padding: 26px 32px 64px; max-width: 1120px; }
.app-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.app-head .ttl { display: flex; align-items: baseline; gap: 12px; }
.app-head .ttl .num { font-family: var(--f-display); font-weight: 800; font-size: 30px; color: var(--accent); line-height: 0.8; }
.app-head .ttl .sl { font-family: var(--f-display); font-weight: 700; font-size: 26px; color: var(--accent-2); line-height: 0.8; }
.app-head h1 { font-family: var(--f-display); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 0.82; }
.app-head .sub { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ghost-dim); }

/* status label */
.slabel { display: inline-flex; align-items: center; gap: 9px; font-family: var(--f-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; border: 1px solid rgba(43,224,139,0.5); color: var(--green); padding: 8px 13px; }
.slabel .d { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ---- card grid ---- */
.grid2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }

.pcard { position: relative; background: var(--black-2); border: 1px solid var(--line); padding: 22px; }
.pcard .clabel { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ghost-dim); margin-bottom: 16px; }
.pcard .clabel .a { color: var(--accent); }

/* status stats */
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 0; }
.stats .st { padding: 4px 18px; border-left: 1px solid var(--line); }
.stats .st:first-child { border-left: none; padding-left: 0; }
.stats .st .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ghost-dim); }
.stats .st .big { font-family: var(--f-display); font-weight: 800; font-size: 44px; line-height: 0.9; margin-top: 8px; }
.stats .st .big .u { font-family: var(--f-mono); font-size: 12px; color: var(--ghost-dim); letter-spacing: 0.04em; margin-left: 5px; }
.stats .st .bar { height: 5px; background: var(--black-3); border: 1px solid var(--line); margin-top: 12px; position: relative; overflow: hidden; }
.stats .st .bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.stats .st .bar.seg > span { background: repeating-linear-gradient(90deg, var(--accent) 0 12px, transparent 12px 16px); }

/* key field */
.keyrow { display: flex; align-items: stretch; border: 1px solid var(--line-2); background: var(--black-1); }
.keyrow .kv { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: 13px; color: var(--ghost-fade); padding: 0 16px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em; }
.keyrow .kbtn { flex: none; border: none; border-left: 1px solid var(--line-2); background: var(--black-2); color: var(--ghost); font-family: var(--f-mono); font-weight: 700; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; padding: 0 16px; cursor: pointer; transition: background .15s, color .15s; }
.keyrow .kbtn:hover { background: var(--accent); color: #0a0a0a; }
.keyrow .kbtn.done { background: var(--accent-2); color: #0a0a0a; }
.keyactions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.keyactions .mini { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ghost-dim); background: none; border: 1px solid var(--line-2); padding: 9px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: border-color .15s, color .15s; }
.keyactions .mini:hover { color: var(--ghost); border-color: var(--accent); }
.keyactions .mini.warn:hover { color: var(--magenta); border-color: var(--magenta); }

/* connect buttons in dashboard */
.connect2 { display: grid; gap: 12px; }

/* account card */
.acc-line { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px dashed var(--line); }
.acc-line + .acc-line { }
.acc-ic { width: 20px; height: 20px; flex: none; color: var(--accent); }
.acc-ic svg { width: 100%; height: 100%; display: block; }
.acc-meta { min-width: 0; flex: 1; }
.acc-meta .acc-k { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ghost-dim); }
.acc-meta .acc-v { font-family: 'IBM Plex Mono', monospace; font-size: 13.5px; color: var(--ghost); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-meta .acc-v.dim { color: var(--ghost-dim); }
.acc-badge { flex: none; font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; padding: 4px 8px; border: 1px solid var(--line-2); }
.acc-badge.ok { color: var(--green); border-color: rgba(43,224,139,0.45); }
.acc-badge.off { color: var(--ghost-dim); }
.acc-edit { margin-top: 14px; }
.acc-edit .kv-input { flex: 1; min-width: 0; background: transparent; border: none; color: var(--ghost); font-family: 'IBM Plex Mono', monospace; font-size: 13px; padding: 15px 16px; }
.acc-edit .kv-input:focus { outline: none; }
.acc-edit .kv-input::placeholder { color: var(--ghost-dim); }

/* QR card */
.qrwrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.qrbox { position: relative; padding: 14px; background: var(--black-1); border: 1px solid var(--line-2); width: 190px; height: 190px; }
.qrbox::before, .qrbox::after { content:""; position:absolute; width:18px; height:18px; }
.qrbox::before { top:-1px; left:-1px; border-top:2px solid var(--accent); border-left:2px solid var(--accent); }
.qrbox::after { bottom:-1px; right:-1px; border-bottom:2px solid var(--accent); border-right:2px solid var(--accent); }
.qrbox svg { width: 100%; height: 100%; display: block; }
.qrbox .scan { position:absolute; left:8px; right:8px; height:2px; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); top:14px; animation: qrscan 2.6s ease-in-out infinite; }
@keyframes qrscan { 0%,100%{top:14px} 50%{top:calc(100% - 14px)} }

/* install rows */
.plist { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.prow { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--black-2); text-decoration: none; color: var(--ghost); transition: background .15s; }
.prow:hover { background: var(--black-3); }
.prow .g { width: 26px; height: 26px; flex: none; display: grid; place-items: center; }
.prow .g svg { width: 24px; height: 24px; }
.prow .nm { font-family: var(--f-display); font-weight: 800; font-size: 18px; text-transform: uppercase; line-height: 1; }
.prow .st2 { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ghost-dim); margin-top: 2px; }
.prow .dl { margin-left: auto; font-family: var(--f-mono); font-size: 11px; color: var(--accent); white-space: nowrap; }

/* support links */
.suprow { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px dashed var(--line); text-decoration: none; color: var(--ghost); }
.suprow:last-child { border-bottom: none; }
.suprow .sg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.suprow .sg svg { width: 100%; height: 100%; }
.suprow .st { font-family: var(--f-mono); font-size: 13px; }
.suprow .tg { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--accent); }

/* ---- devices ---- */
.devhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.devhead .cnt { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ghost-dim); }
.devhead .cnt b { color: var(--accent); font-weight: 700; }
.devlist { display: grid; gap: 12px; }
.devrow { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border: 1px solid var(--line); background: var(--black-2); }
.devrow .dg { width: 30px; height: 30px; flex: none; display: grid; place-items: center; color: var(--ghost); }
.devrow .dg svg { width: 26px; height: 26px; }
.devrow .di { min-width: 0; flex: 1; }
.devrow .di .n { font-family: var(--f-mono); font-size: 14px; color: var(--ghost); display: flex; align-items: center; gap: 9px; }
.devrow .di .n .cur { font-size: 9px; letter-spacing: 0.14em; color: var(--accent); border: 1px solid var(--line-2); padding: 2px 6px; }
.devrow .di .m { font-family: var(--f-mono); font-size: 11px; color: var(--ghost-dim); margin-top: 4px; }
.devrow .dd { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.devrow .dd.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.devrow .dd.off { background: var(--gray); }
.devrow .unlink { background: none; border: 1px solid var(--line-2); color: var(--ghost-dim); font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; padding: 8px 12px; cursor: pointer; flex: none; transition: border-color .15s, color .15s; }
.devrow .unlink:hover { border-color: var(--magenta); color: var(--magenta); }
.devslot { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 1px dashed var(--line-2); color: var(--ghost-dim); font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---- mobile chrome ---- */
.m-topbar { display: none; }
.bottomnav { display: none; }

@media (max-width: 880px) {
  .sidebar { display: none; }
  .app-main { padding: 0 18px 110px; max-width: 100%; }
  .m-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 40; padding: 14px 0 12px; margin-bottom: 10px;
    background: linear-gradient(180deg, var(--black) 72%, transparent);
  }
  .m-topbar .s-logo { display: flex; align-items: center; gap: 9px; }
  .m-topbar .s-logo img { width: 28px; height: 28px; }
  .m-topbar .s-logo .wm { font-family: var(--f-display); font-weight: 800; font-size: 16px; text-transform: uppercase; }
  .m-topbar .s-logo .wm .vpn { color: var(--accent); }
  .m-topbar .av { width: 34px; height: 34px; border: 1px solid var(--line-2); background: var(--black-1); display: grid; place-items: center; overflow: hidden; }
  .m-topbar .av img { width: 100%; height: 100%; object-fit: cover; }

  .app-head { margin: 16px 0 20px; }
  .app-head h1 { font-size: 30px; }
  .grid2 { grid-template-columns: 1fr; }
  .stats .st { padding: 4px 12px; }
  .stats .st .big { font-size: 38px; }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(13,13,13,0.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .bottomnav button {
    flex: 1; background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 8px 4px; color: var(--ghost-dim); font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  }
  .bottomnav button.on { color: var(--accent); }
  .bottomnav button .ic { width: 20px; height: 20px; }
  .bottomnav button .ic svg { width: 100%; height: 100%; }
}

@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr; gap: 14px; }
  .stats .st { border-left: none; padding: 0; border-top: 1px solid var(--line); padding-top: 14px; }
  .stats .st:first-child { border-top: none; padding-top: 0; }
  .auth-card { padding: 26px 20px; }
  .auth-card h1 { font-size: 34px; }
}
