/* Palm VPN Cabinet */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

:root {
    --bg: #f4f5f7;
    --card: #fff;
    --border: #e5e7eb;
    --border2: #d1d5db;
    --accent: #16a34a;
    --adim: rgba(22, 163, 74, 0.08);
    --ab: rgba(22, 163, 74, 0.25);
    --red: #dc2626;
    --rdim: rgba(220, 38, 38, 0.08);
    --text: #111827;
    --t2: #6b7280;
    --t3: #9ca3af;
    --font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --mono: "JetBrains Mono", monospace;
    --r: 10px;
    --r2: 7px;
    --sh: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --sh2: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --bnav: 60px;
    --hdr: 56px;
    --max: 640px;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 3px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ─── UTILS ─── */
.hidden {
    display: none !important;
}
.mono {
    font-family: var(--mono);
    font-size: 12px;
}
.t2 {
    color: var(--t2);
}
.fs12 {
    font-size: 12px;
}
.mb8 {
    margin-bottom: 8px;
}
.mb12 {
    margin-bottom: 12px;
}
.mb14 {
    margin-bottom: 14px;
}
.spin {
    animation: spinR 1s linear infinite;
    display: inline-block;
}
@keyframes spinR {
    to {
        transform: rotate(360deg);
    }
}

/* ─── LOGIN ─── */
#screen-login {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px 32px;
}
.login-wrap {
    width: 100%;
    max-width: 420px;
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo-icon {
    width: 52px;
    height: 52px;
    background: var(--adim);
    border: 1px solid var(--ab);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: var(--accent);
}
.login-logo-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
}
.login-logo h1 {
    font-size: 20px;
    font-weight: 700;
}
.login-logo p {
    font-size: 13px;
    color: var(--t2);
    margin-top: 3px;
}

/* ─── APP SHELL ─── */
#screen-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── HEADER ─── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    height: var(--hdr);
}
.header-inner {
    max-width: var(--max);
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}
.header-icon {
    width: 32px;
    height: 32px;
    background: var(--adim);
    border: 1px solid var(--ab);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.header-icon svg {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
}
.header-title {
    font-size: 15px;
    font-weight: 700;
}
.header-title span {
    color: var(--accent);
}

/* desktop nav in header */
.header-nav {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
}
.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: none;
    background: none;
    color: var(--t2);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--r2);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
    white-space: nowrap;
}
.nav-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 1.8;
    flex-shrink: 0;
}
.nav-btn:hover {
    background: var(--adim);
    color: var(--text);
}
.nav-btn.active {
    background: var(--adim);
    color: var(--accent);
    font-weight: 600;
}

.btn-logout {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 6px 12px;
    color: var(--t2);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s,
        background 0.15s;
}
.btn-logout svg {
    width: 14px;
    height: 14px;
}
.btn-logout:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--rdim);
}

/* ─── MAIN CONTENT ─── */
.app-main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 20px 16px
        calc(var(--bnav) + 16px + env(safe-area-inset-bottom, 0px));
}
.center-wrap {
    width: 100%;
    max-width: var(--max);
}

/* ─── BOTTOM NAV (mobile) ─── */
.bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav-track {
    position: relative;
    display: flex;
    flex: 1;
}
/* sliding pill indicator */
.bnav-pill {
    position: absolute;
    top: 6px;
    height: calc(100% - 12px);
    background: var(--adim);
    border-radius: 10px;
    transition:
        left 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 0;
}
.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--bnav);
    border: none;
    background: none;
    color: var(--t3);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
    z-index: 1;
}
.bnav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
    transition: transform 0.2s;
}
.bnav-item.active {
    color: var(--accent);
}
.bnav-item.active svg {
    transform: scale(1.12);
}
.bnav-item:active svg {
    transform: scale(0.9);
}

/* ─── PAGES ─── */
.page {
    display: none;
}
.page.active {
    display: block;
}

/* ─── CARD ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--sh);
    margin-bottom: 14px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
}
.card-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
    stroke-width: 2;
    flex-shrink: 0;
}
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-desc {
    font-size: 13px;
    color: var(--t2);
    line-height: 1.55;
    margin-bottom: 12px;
}

/* ─── FIELD ─── */
.field {
    margin-bottom: 12px;
}
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    margin-bottom: 5px;
}
.field input,
.field select {
    width: 100%;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}
.field input::placeholder {
    color: var(--t3);
}
.field select option {
    background: #fff;
}

/* ─── BUTTONS ─── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 44px;
    padding: 9px 16px;
    border: none;
    border-radius: var(--r2);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s,
        border-color 0.15s;
}
.btn svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    flex-shrink: 0;
}
.btn:active {
    transform: scale(0.98);
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: #15803d;
}
.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--border2);
    background: #f9fafb;
}
.btn-danger {
    background: var(--rdim);
    color: var(--red);
    border: 1px solid rgba(220, 38, 38, 0.2);
}
.btn-danger:hover {
    background: rgba(220, 38, 38, 0.14);
}
.btn-ghost {
    background: none;
    color: var(--t2);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border2);
    background: #f9fafb;
}
.btn-sm {
    width: auto;
    padding: 6px 12px;
    font-size: 13px;
    min-height: 34px;
}
.btn-tg {
    background: #229ed9;
    color: #fff;
}
.btn-tg:hover {
    background: #1d8bc4;
}
.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
}
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--t2);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}
.btn-back svg {
    width: 14px;
    height: 14px;
}
.btn-back:hover {
    color: var(--accent);
}

/* ─── DIVIDER ─── */
.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    color: var(--t3);
    font-size: 12px;
}
.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ─── MSG ─── */
.msg {
    font-size: 13px;
    margin-top: 8px;
    min-height: 18px;
}
.msg.err {
    color: var(--red);
}
.msg.ok {
    color: var(--accent);
}

/* ─── SUBSCRIPTION CARD ─── */
.sub-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}
.sub-label {
    font-size: 12px;
    color: var(--t2);
    margin-bottom: 4px;
}

/* ─── STATS ─── */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.stat-box {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 14px 12px;
}
.stat-box-lbl {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.stat-box-lbl svg {
    width: 13px;
    height: 13px;
    color: var(--accent);
    stroke-width: 2;
}
.stat-box-val {
    font-size: 20px;
    font-weight: 700;
}

/* ─── BADGE ─── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-green {
    background: var(--adim);
    color: var(--accent);
    border: 1px solid var(--ab);
}
.badge svg {
    width: 11px;
    height: 11px;
    stroke-width: 2;
}

/* ─── PBAR ─── */
.pbar-wrap {
    margin-top: 12px;
}
.pbar-track {
    height: 4px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}
.pbar-fill {
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.8s ease;
}
.pbar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 11px;
    color: var(--t3);
    font-family: var(--mono);
}

/* ─── INFO ROWS ─── */
.info-list {
    border-top: 1px solid var(--border);
}
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.info-key {
    color: var(--t2);
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-key svg {
    width: 13px;
    height: 13px;
    color: var(--t3);
    stroke-width: 2;
}
.info-val {
    font-weight: 500;
}
.info-val.mono {
    font-family: var(--mono);
    font-size: 12px;
}

/* ─── URL BOX ─── */
.url-box {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--t2);
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 12px;
}

/* ─── STEPS ─── */
.step {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.step:last-child {
    border-bottom: none;
}
.step-n {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    min-width: 20px;
    padding-top: 1px;
}
.step-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}
.step-desc {
    font-size: 12px;
    color: var(--t2);
    line-height: 1.5;
}
.step-desc strong {
    color: var(--text);
}

.platform-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.platform-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r2);
    border: 1px solid var(--border);
    background: #f9fafb;
    color: var(--t2);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition:
        border-color 0.15s,
        color 0.15s;
}
.platform-link svg {
    width: 13px;
    height: 13px;
    stroke-width: 1.8;
}
.platform-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.platform-link.current {
    border-color: var(--ab);
    color: var(--accent);
    background: var(--adim);
}

/* ─── QR ─── */
.qr-wrap {
    margin-top: 12px;
    text-align: center;
}
.qr-img {
    width: 120px;
    height: 120px;
    border-radius: var(--r2);
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 6px;
}
.qr-lbl {
    font-size: 11px;
    color: var(--t3);
}

/* ─── DEVICES ─── */
.device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.device-row:last-child {
    border-bottom: none;
}
.device-info {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.device-info svg {
    width: 14px;
    height: 14px;
    color: var(--t3);
    stroke-width: 1.8;
    margin-top: 2px;
    flex-shrink: 0;
}
.device-ip {
    font-family: var(--mono);
    font-size: 12px;
}
.device-seen {
    font-size: 11px;
    color: var(--t3);
}
.empty-msg {
    font-size: 13px;
    color: var(--t3);
    padding: 8px 0;
}

/* ─── CHIPS ─── */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 14px;
}
.chip {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #f9fafb;
    color: var(--t2);
    font-size: 13px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s,
        background 0.15s;
}
.chip:hover {
    border-color: var(--border2);
    color: var(--text);
}
.chip.selected {
    border-color: var(--accent);
    background: var(--adim);
    color: var(--accent);
    font-weight: 600;
}

/* ─── STEPPER ─── */
.stepper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 8px;
}
.stepper-info {
    font-size: 13px;
    color: var(--t2);
}
.stepper-info b {
    color: var(--text);
}
.stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    overflow: hidden;
    background: #f9fafb;
}
.stepper-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--t2);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}
.stepper-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}
.stepper-btn:hover:not(:disabled) {
    background: var(--adim);
    color: var(--accent);
}
.stepper-btn:disabled {
    color: var(--t3);
    cursor: default;
}
.stepper-val {
    width: 56px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    height: 44px;
    line-height: 44px;
    font-family: var(--mono);
}
.stepper-hint {
    font-size: 12px;
    color: var(--t3);
    margin-bottom: 8px;
}
.price-summary {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 12px 14px;
    margin: 8px 0 14px;
}
.price-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--t2);
    padding: 3px 0;
}
.price-row.total {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 10px;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
}
.price-row.total b {
    color: var(--accent);
}

/* ─── BUY TOTAL ─── */
.buy-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 12px 0;
}
.buy-total-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

/* ─── RESEND TIMER ─── */
.resend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--t3);
}
.resend-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 600;
    color: var(--accent);
    padding: 0;
    transition: opacity 0.15s;
}
.resend-btn:disabled {
    color: var(--t3);
    cursor: default;
}

/* ─── DEVICE OS BADGE ─── */
.device-os {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--t3);
    margin-top: 2px;
}
.device-os svg {
    width: 11px;
    height: 11px;
    stroke-width: 1.8;
}
.cookie-banner {
    position: fixed;
    bottom: calc(var(--bnav) + 8px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 600px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--sh2);
    z-index: 500;
    padding: 14px 16px;
}
.cookie-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}
.cookie-text {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    font-size: 13px;
    color: var(--t2);
    line-height: 1.55;
}
.cookie-icon {
    width: 16px;
    height: 16px;
    color: #d97706;
    flex-shrink: 0;
    margin-top: 1px;
}
.cookie-btn {
    flex-shrink: 0;
    padding: 8px 18px;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: var(--r2);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.cookie-btn:hover {
    opacity: 0.85;
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

/* ── Tablet / Desktop: hide bottom nav, show header nav ── */
@media (min-width: 700px) {
    :root {
        --bnav: 0px;
        --max: 680px;
        --hdr: 60px;
    }
    .bottomnav {
        display: none !important;
    }
    .header-nav {
        display: flex;
    }
    .app-main {
        padding: 28px 24px;
    }
    .cookie-banner {
        bottom: 16px;
    }
    .btn-logout span {
        display: inline;
    }
    /* vertically center login */
    #screen-login {
        align-items: center;
        padding: 0 24px;
    }
    .login-wrap {
        max-width: 460px;
    }
    .card {
        padding: 22px;
    }
    .stat-box-val {
        font-size: 22px;
    }
}

/* ── Mobile: hide header nav, show bottom nav ── */
@media (max-width: 699px) {
    .header-nav {
        display: none;
    }
    .btn-logout span {
        display: none;
    }
    .btn-logout {
        padding: 6px 9px;
    }
    /* center login content */
    #screen-login {
        padding-top: 40px;
    }
}

/* ── Wider desktop: more breathing room ── */
@media (min-width: 960px) {
    :root {
        --max: 760px;
        --hdr: 64px;
    }
    .header-inner {
        font-size: 15px;
    }
    .nav-btn {
        font-size: 14px;
        padding: 8px 14px;
    }
    .nav-btn svg {
        width: 15px;
        height: 15px;
    }
    .app-main {
        padding-top: 32px;
        padding-bottom: 32px;
    }
    .card {
        padding: 24px;
    }
    .stat-box-val {
        font-size: 24px;
    }
    body {
        font-size: 15px;
    }
}

/* ── Narrow phone ── */
@media (max-width: 360px) {
    .btn-row {
        grid-template-columns: 1fr;
    }
    .stepper-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .cookie-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .cookie-btn {
        width: 100%;
        text-align: center;
    }
}

/* ── Landscape phone ── */
@media (max-height: 480px) and (orientation: landscape) {
    :root {
        --bnav: 50px;
    }
    .bnav-item {
        flex-direction: row;
        gap: 8px;
        font-size: 11px;
        min-height: 50px;
    }
    .bnav-item span {
        display: inline;
    }
}

@media print {
    .app-header,
    .bottomnav,
    .btn-logout,
    .cookie-banner {
        display: none !important;
    }
    .app-main {
        padding: 0;
    }
}
