@import url("https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700;800&display=swap");

:root {
    --bg: #f5f5f7;
    --bg-soft: #fbfbfd;
    --bg-band: #f2f2f7;
    --bg-main: #fafafc;
    --bg-elevated: rgba(255, 255, 255, 0.72);
    --bg-card: #ffffff;
    --bg-field: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.12);
    --text: #1d1d1f;
    --text-muted: #6e6e73;
    --text-soft: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-pressed: #0068d1;
    --ok: #0a7f42;
    --ok-bg: #e8f7ee;
    --err: #b42318;
    --err-bg: #fff0ee;
    --radius: 18px;
    --radius-sm: 12px;
    --control-radius: 12px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.03), 0 20px 80px rgba(0, 0, 0, 0.03);
    --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.02), 0 10px 40px rgba(0, 0, 0, 0.02);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Onest", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    background:
        linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 48%, #ffffff 100%);
    /* Sticky footer: short pages still push the footer to the viewport bottom
       so the body background doesn't leak below it. */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container,
main.admin-center,
main.admin-container {
    flex: 1 0 auto;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { color: var(--accent-hover); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    padding: 0 max(24px, calc((100% - 1120px) / 2 + 24px));
}

.brand {
    color: var(--text);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand span { color: var(--accent); }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 980px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-nav a:hover {
    border-color: rgba(0, 113, 227, 0.2);
    color: var(--accent);
    background: rgba(0, 113, 227, 0.04);
}

.container {
    width: 100%;
    margin: 0;
    padding: 62px max(22px, calc((100% - 840px) / 2 + 22px)) 30px;
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(180deg, #ffffff 0%, var(--bg-main) 58%, #f4f4f6 100%);
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.9) inset;
}

.hero {
    max-width: 700px;
    margin: 0 auto 30px;
    text-align: center;
}

.hero h1 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: clamp(34px, 7vw, 58px);
    font-weight: 750;
    line-height: 1.04;
}

.lead {
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(17px, 2.5vw, 21px);
    line-height: 1.42;
}

.card {
    margin-bottom: 20px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-soft);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    opacity: 0;
    transform: translateY(12px);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.04), 0 20px 80px rgba(0, 0, 0, 0.02);
}

.hero {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.04s;
}

.card:nth-of-type(1) { animation-delay: 0.1s; }
.card:nth-of-type(2) { animation-delay: 0.18s; }
.card:nth-of-type(3) { animation-delay: 0.26s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card h2 {
    margin: 0 0 16px;
    color: var(--text);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.guide {
    background: rgba(255, 255, 255, 0.72);
}

.guide ol {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 22px;
}

.guide li {
    color: var(--text-muted);
}

.guide li strong {
    color: var(--text);
    font-weight: 700;
}

code {
    display: inline-block;
    max-width: 100%;
    padding: 2px 7px;
    overflow-wrap: anywhere;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-field);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.form-card {
    padding: 32px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.form-card form,
.card form {
    margin: 0;
}

.form-card textarea,
.card textarea,
.form-card input[type="text"],
.card input[type="text"],
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-field);
    color: var(--text);
    outline: none;
    transition: border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-card input[type="text"],
.card input[type="text"],
.login-card input[type="text"],
.login-card input[type="password"] {
    min-height: 46px;
    padding: 0 14px;
    font-size: 15px;
}

.form-card textarea,
.card textarea {
    min-height: 148px;
    padding: 14px 15px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
}

.form-card textarea:focus,
.card textarea:focus,
.form-card input[type="text"]:focus,
.card input[type="text"]:focus,
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    border-color: var(--accent);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

.form-card textarea::placeholder,
.card textarea::placeholder,
.login-card input::placeholder,
.form-card input::placeholder {
    color: var(--text-soft);
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 16px;
    padding: 0 22px;
    border-radius: 980px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.15);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
}

.btn-primary:active {
    transform: scale(0.97);
    background: var(--accent-pressed);
}

.btn-secondary {
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: rgba(0, 113, 227, 0.34);
    color: var(--accent);
    background: #ffffff;
}

.btn-secondary:active {
    transform: scale(0.97);
}

.form-hint {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.result {
    max-width: 620px;
    margin: 24px auto 16px;
    padding: 38px 28px;
    text-align: center;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    margin: 0 auto 18px;
    border-radius: 50%;
    font-size: 34px;
    font-weight: 700;
}

.result-ok {
    border-color: rgba(10, 127, 66, 0.2);
}

.result-ok .result-icon {
    background: var(--ok-bg);
    color: var(--ok);
}

.result-ok h1 { color: var(--ok); }

.result-error {
    border-color: rgba(180, 35, 24, 0.2);
}

.result-error .result-icon {
    background: var(--err-bg);
    color: var(--err);
}

.result-error h1 { color: var(--err); }

.result h1 {
    margin: 0 0 16px;
    font-size: 32px;
    line-height: 1.12;
}

.result p {
    color: var(--text-muted);
}

.result-message {
    margin: 0 0 22px;
    color: var(--text);
    font-size: 17px;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 28px;
}

/* ---- Promo-for-review callout on success / already-done pages ----
   Green to match the "✓ Подписка уже активирована" headline. Larger
   block so the buyer actually sees the incentive before scrolling
   to the action buttons. */
.promo-nudge {
    position: relative;
    margin: 32px auto 0;
    max-width: 640px;
    padding: 24px 28px 24px 32px;
    border: 1px solid rgba(10, 127, 66, 0.22);
    border-left: 5px solid var(--ok);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(10, 127, 66, 0.08) 0%, rgba(10, 127, 66, 0.025) 100%);
    text-align: left;
}

.promo-nudge-title {
    display: inline-block;
    margin-bottom: 10px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--ok);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    animation: promoPulse 2.4s ease-in-out infinite;
}

.promo-nudge p {
    margin: 0;
    color: var(--text);
    font-size: 16px;
    line-height: 1.55;
}

.promo-nudge strong {
    color: var(--ok);
    font-weight: 650;
}

@keyframes promoPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(10, 127, 66, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(10, 127, 66, 0); }
}

.kozyvpn {
    width: 100%;
    margin: 0;
    padding: 34px max(22px, calc((100% - 840px) / 2 + 22px));
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(180deg, #f4f4f6 0%, var(--bg-band) 100%);
}

.kozyvpn-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 22px 24px;
    max-width: 796px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.kozyvpn-text { flex: 1; }

.kozyvpn-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin-bottom: 9px;
    padding: 0 10px;
    border-radius: var(--control-radius);
    background: #f2f2f7;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

.kozyvpn h3 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 18px;
    line-height: 1.25;
}

.kozyvpn p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.45;
}

.kozyvpn-cta {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--control-radius);
    background: var(--text);
    color: #ffffff;
    font-size: 14px;
    font-weight: 650;
}

.kozyvpn-cta:hover {
    background: #000000;
    color: #ffffff;
}

.footer {
    width: 100%;
    margin: 0;
    padding: 48px max(24px, calc((100% - 840px) / 2 + 24px)) 64px;
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.6;
    border-top: 1px solid var(--border);
}

.footer-inner {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.footer-disclaimer {
    color: var(--text-soft);
    margin-bottom: 20px;
    font-size: 11px;
    line-height: 1.5;
}

.footer-divider {
    border: 0;
    height: 1px;
    background-color: var(--border);
    margin: 20px 0;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-links {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.footer-links a:hover {
    color: var(--accent);
}

.copyright {
    color: var(--text-soft);
}

.admin-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.9), transparent 42%),
        linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 100%);
}

.admin-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
}

.admin-container {
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 42px 22px 64px;
}

.login-card {
    width: 100%;
    max-width: 390px;
    margin: 0;
    padding: 28px;
    text-align: center;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 20px;
    font-size: 28px;
    line-height: 1.1;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    min-height: 46px;
    margin-bottom: 10px;
    padding: 0 14px;
    font-size: 15px;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 8px;
}

.login-error {
    margin-bottom: 14px;
    padding: 11px 14px;
    border: 1px solid rgba(180, 35, 24, 0.18);
    border-radius: var(--radius-sm);
    background: var(--err-bg);
    color: var(--err);
    font-size: 14px;
}

.admin-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    text-align: left;
}

.admin-hero h1 {
    margin: 0 0 5px;
    font-size: 34px;
    line-height: 1.08;
}

.admin-hero .lead {
    color: var(--text-muted);
    font-size: 16px;
}

.logout-form { margin: 0; }

.admin-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-actions .btn-secondary {
    min-height: 38px;
    margin-top: 0;
    padding: 0 16px;
    font-size: 14px;
}

.logout-form .btn-secondary {
    min-height: 38px;
    margin-top: 0;
    padding: 0 16px;
    font-size: 14px;
}

.stats-page-hero .admin-actions .btn-primary {
    min-height: 38px;
    margin-top: 0;
    padding: 0 16px;
    font-size: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.stat {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--bg-field);
    text-align: center;
}

.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
}

.stat-value {
    margin-top: 4px;
    color: var(--text);
    font-size: 34px;
    font-weight: 750;
    line-height: 1;
}

.stat-ok { color: var(--ok); }
.stat-used { color: var(--text-muted); }

.admin-stats-page {
    width: min(100%, 1120px);
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stats-metric {
    min-height: 128px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.stats-metric-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.stats-metric-value {
    margin-top: 8px;
    color: var(--text);
    font-size: 34px;
    font-weight: 760;
    line-height: 1;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-metric-hint {
    margin-top: 9px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.35;
}

.stats-metric.stats-ok .stats-metric-value { color: var(--ok); }
.stats-metric.stats-danger .stats-metric-value { color: var(--err); }
.stats-metric.stats-muted .stats-metric-value { color: var(--text-muted); }

.stats-chart-card {
    padding: 30px 32px;
    border-radius: 22px;
}

.stats-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.stats-chart-head h2 {
    margin-bottom: 4px;
}

.chart-periods,
.summary-filters {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-field);
}

.chart-period-tab,
.summary-filter {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.chart-period-tab:hover,
.summary-filter:hover {
    color: var(--text);
}

.chart-period-tab.active,
.summary-filter.active {
    background: var(--bg-card);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16), 0 6px 16px rgba(0, 0, 0, 0.12);
}

.chart-wrap {
    position: relative;
    min-height: 220px;
}

.chart-svg {
    display: block;
    width: 100%;
    height: 260px;
}

.chart-grid-line {
    stroke: var(--border);
    stroke-width: 0.7;
    stroke-dasharray: 3 4;
}

.chart-area {
    fill: url(#stats-chart-gradient);
}

.chart-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-dot {
    fill: #ffffff;
    stroke: var(--accent);
    stroke-width: 1.8;
}

.chart-hit {
    fill: transparent;
    cursor: default;
}

.chart-tooltip {
    pointer-events: none;
    opacity: 0;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 5px;
    stroke-linejoin: round;
    fill: var(--text);
    font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 11px;
    font-weight: 700;
    transition: opacity .12s ease;
}

.chart-point:hover .chart-tooltip,
.chart-point:focus .chart-tooltip {
    opacity: 1;
}

.chart-point:hover .chart-dot,
.chart-point:focus .chart-dot {
    r: 4.5;
}

.chart-axis-text {
    fill: var(--text-soft);
    font-size: 10px;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.chart-empty {
    display: grid;
    min-height: 220px;
    place-items: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-field);
    color: var(--text-muted);
    font-size: 14px;
}

.chart-point-list {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.admin-stats-page {
    width: min(100%, 1280px);
}

.stats-page-hero {
    margin-bottom: 18px;
}

.stats-chart-title {
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.stats-chart-card {
    background: #ffffff;
}

.stats-chart-card .form-hint {
    margin-top: 4px;
}

.stats-chart-card .chart-svg {
    height: 300px;
}

.stats-key-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.stats-key-strip div {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
}

.stats-key-strip span {
    display: block;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stats-key-strip strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 26px;
    line-height: 1;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-revenue-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.stats-revenue-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid rgba(0, 113, 227, 0.12);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(0, 113, 227, 0.06), rgba(255, 255, 255, 0.9));
    box-shadow: var(--shadow-soft);
}

.stats-revenue-card span,
.stats-revenue-card small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
}

.stats-revenue-card span {
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-revenue-card strong {
    display: block;
    margin-top: 10px;
    color: var(--text);
    font-size: 28px;
    font-weight: 780;
    line-height: 1;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-revenue-card small {
    margin-top: 8px;
}

.stats-period-panel {
    margin-top: 24px;
    padding: 30px 32px;
    border-radius: 22px;
    background: #ffffff;
}

.stats-period-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.stats-period-summary {
    display: grid;
    grid-template-columns: 1.2fr repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.stats-period-summary div {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-card);
}

.stats-period-summary span {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stats-period-summary strong {
    display: block;
    margin-top: 10px;
    color: var(--text);
    font-size: 34px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.01em;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-period-summary div:nth-child(3) strong {
    color: var(--ok);
}

.stats-period-card {
    min-width: 0;
}

.stats-period-label {
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stats-period-count {
    margin-top: 14px;
    color: var(--text);
    font-size: 24px;
    font-weight: 750;
    line-height: 1;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-period-count span {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stats-period-revenue {
    margin-top: 10px;
    color: var(--ok);
    font-size: 32px;
    font-weight: 780;
    line-height: 1;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stats-status-table {
    width: 100%;
    margin-top: 28px;
    border-collapse: collapse;
    color: var(--text);
    font-size: 14px;
}

.stats-status-table th,
.stats-status-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.stats-status-table th:last-child,
.stats-status-table .mono {
    text-align: right;
}

.stats-status-table th {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stats-status-table tr:last-child td {
    border-bottom: 0;
}

.stats-status-table .muted-row td {
    color: var(--text-soft);
}

.stats-status-table .mono {
    font-family: inherit;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.keys-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.015);
}

.filter-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    align-self: flex-start;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.filter-tab:hover {
    color: var(--text);
}

.filter-tab.active {
    background: var(--accent);
    color: #ffffff;
}

.filter-tab.active:hover {
    color: #ffffff;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-search-row {
    margin: 0;
}

.filter-search {
    flex: 1;
    min-width: 200px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.filter-search:focus {
    border-color: rgba(0, 113, 227, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.13);
}

.btn-sm {
    min-height: 32px;
    padding: 0 16px;
    font-size: 13px;
}

/* ---- Sortable column headers ---- */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: inherit;
}

.sort-link:hover {
    color: var(--accent);
}

.sort-link.sort-active {
    color: var(--text);
}

.sort-arrow {
    display: inline-block;
    font-size: 11px;
    color: var(--accent);
}

.keys-header h2 {
    margin: 0;
}

.keys-counter {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.keys-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 13px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.pagination-btn:hover {
    border-color: rgba(0, 113, 227, 0.34);
    color: var(--accent);
}

.pagination-btn.disabled {
    color: var(--text-soft);
    background: transparent;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.55;
}

.keys-table th,
.keys-table td {
    padding: 10px 11px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.keys-table th {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
}

.keys-table tbody tr:hover td {
    background: rgba(0, 113, 227, 0.035);
}

.cell-key {
    max-width: 320px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cell-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.cell-actions form {
    display: inline-block;
    margin: 0;
}

.key-edit-form {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 0;
}

.key-edit-form input {
    flex: 1;
    min-width: 0;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-field);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    outline: none;
    transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}

.key-edit-form input:focus {
    border-color: rgba(0, 113, 227, 0.6);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.13);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.btn-icon:hover {
    border-color: rgba(0, 113, 227, 0.34);
    color: var(--accent);
}

.btn-icon-danger:hover {
    border-color: rgba(180, 35, 24, 0.34);
    color: var(--err);
    background: var(--err-bg);
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: var(--control-radius);
    font-size: 11px;
    font-weight: 700;
}

.pill-available {
    background: var(--ok-bg);
    color: var(--ok);
}

.pill-used {
    background: var(--bg-field);
    color: var(--text-muted);
}

/* Dead-card flag (e.g. CARD_ALREADY_USED): card stays in the pool, this is just
   an operator alert surfaced in /admin. Amber to distinguish from delete (red). */
.stat-flagged { color: #b54708; }

.flag-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    padding: 0 8px;
    min-height: 22px;
    border-radius: var(--control-radius);
    background: #fff4e5;
    color: #b54708;
    font-size: 11px;
    font-weight: 700;
    cursor: help;
}

.row-flagged { background: rgba(181, 71, 8, 0.05); }

.cell-actions .inline-form + .inline-form { margin-left: 4px; }

.muted {
    padding: 24px 0;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 700px) {
    .topbar {
        min-height: 58px;
        padding: 12px 18px;
    }

    .container {
        padding: 38px 16px 24px;
    }

    .hero {
        margin-bottom: 24px;
        text-align: left;
    }

    .card,
    .form-card,
    .login-card {
        padding: 18px;
    }

    .kozyvpn {
        padding: 24px 16px;
    }

    .kozyvpn-inner {
        flex-direction: column;
        align-items: stretch;
        padding: 18px;
    }

    .kozyvpn-cta {
        width: 100%;
    }

    .footer {
        padding: 32px 16px 40px;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .footer-links {
        gap: 12px;
    }

    .admin-container {
        padding: 30px 16px 48px;
    }

    .admin-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .stats-overview {
        grid-template-columns: 1fr;
    }

    .stats-chart-head {
        flex-direction: column;
    }

    .chart-periods {
        width: 100%;
    }

    .chart-period-tab {
        flex: 1;
        justify-content: center;
    }

    .stats-chart-card {
        padding: 20px 14px;
    }

    .stats-chart-card .chart-svg,
    .stats-chart-card .chart-empty {
        height: 240px;
        min-height: 240px;
    }

    .stats-key-strip,
    .stats-revenue-grid,
    .stats-period-summary {
        grid-template-columns: 1fr;
    }

    .stats-period-head {
        flex-direction: column;
    }

    .summary-filters {
        width: 100%;
        justify-content: stretch;
    }

    .summary-filter {
        flex: 1;
        justify-content: center;
    }

    .keys-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ---- 2K / large desktop tuning -----------------------------------------
   Text width capped on purpose (reading > ~80ch is bad for UX), but base
   font, padding, and card widths scale up so the page doesn't look lost
   in the middle of a 2560 / 1440-line monitor.
*/
@media (min-width: 1600px) {
    html, body {
        font-size: 18px;
    }

    .topbar {
        padding: 0;
    }

    .topbar-inner {
        min-height: 64px;
        padding: 0 max(32px, calc((100% - 1280px) / 2 + 32px));
    }

    .container {
        padding: 88px max(32px, calc((100% - 960px) / 2 + 32px)) 56px;
    }

    .hero {
        max-width: 820px;
        margin-bottom: 44px;
    }

    .card {
        padding: 32px;
    }

    .form-card {
        padding: 36px;
    }

    .result {
        max-width: 720px;
        padding: 52px 40px;
    }

    .kozyvpn {
        padding: 56px max(32px, calc((100% - 960px) / 2 + 32px));
    }

    .kozyvpn-inner {
        max-width: 920px;
        padding: 28px 32px;
    }

    .footer {
        padding: 28px max(32px, calc((100% - 960px) / 2 + 32px)) 48px;
    }

    .admin-container {
        max-width: 1180px;
        padding: 56px 32px 80px;
    }
}

@media (min-width: 2200px) {
    /* True 2K+ — push base font and gutters a bit further. */
    html, body {
        font-size: 19px;
    }

    .container {
        padding: 112px max(48px, calc((100% - 1040px) / 2 + 48px)) 72px;
    }

    .hero {
        max-width: 900px;
    }

    .admin-container {
        max-width: 1320px;
    }
}

/* ---- Admin control room theme ------------------------------------------ */
html[data-theme="dark"] {
    --admin-bg: #090b0f;
    --admin-bg-soft: #0f131a;
    --admin-bg-panel: rgba(18, 23, 31, 0.88);
    --admin-bg-panel-solid: #121720;
    --admin-bg-field: rgba(255, 255, 255, 0.055);
    --admin-bg-hover: rgba(83, 168, 255, 0.11);
    --admin-border: rgba(255, 255, 255, 0.105);
    --admin-border-strong: rgba(255, 255, 255, 0.18);
    --admin-text: #eef3f8;
    --admin-muted: #a3adba;
    --admin-soft: #788393;
    --admin-accent: #53a8ff;
    --admin-accent-strong: #79bdff;
    --admin-ok: #45d483;
    --admin-ok-bg: rgba(69, 212, 131, 0.13);
    --admin-err: #ff6b6b;
    --admin-err-bg: rgba(255, 107, 107, 0.13);
    --admin-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

html[data-theme="light"] {
    --admin-bg: #f3f5f8;
    --admin-bg-soft: #ffffff;
    --admin-bg-panel: rgba(255, 255, 255, 0.9);
    --admin-bg-panel-solid: #ffffff;
    --admin-bg-field: rgba(13, 19, 31, 0.045);
    --admin-bg-hover: rgba(26, 112, 214, 0.07);
    --admin-border: rgba(13, 19, 31, 0.095);
    --admin-border-strong: rgba(13, 19, 31, 0.16);
    --admin-text: #141922;
    --admin-muted: #596477;
    --admin-soft: #7b8494;
    --admin-accent: #1769d3;
    --admin-accent-strong: #0d55b7;
    --admin-ok: #087a45;
    --admin-ok-bg: rgba(8, 122, 69, 0.11);
    --admin-err: #b42318;
    --admin-err-bg: rgba(180, 35, 24, 0.1);
    --admin-shadow: 0 18px 55px rgba(30, 41, 59, 0.11);
}

html[data-theme] .admin-body {
    --bg: var(--admin-bg);
    --bg-soft: var(--admin-bg-soft);
    --bg-card: var(--admin-bg-panel-solid);
    --bg-elevated: var(--admin-bg-panel);
    --bg-field: var(--admin-bg-field);
    --border: var(--admin-border);
    --border-strong: var(--admin-border-strong);
    --text: var(--admin-text);
    --text-muted: var(--admin-muted);
    --text-soft: var(--admin-soft);
    --accent: var(--admin-accent);
    --accent-hover: var(--admin-accent-strong);
    --accent-pressed: var(--admin-accent-strong);
    --ok: var(--admin-ok);
    --ok-bg: var(--admin-ok-bg);
    --err: var(--admin-err);
    --err-bg: var(--admin-err-bg);
    --radius: 8px;
    --radius-sm: 8px;
    --control-radius: 7px;
    --shadow: var(--admin-shadow);
    --shadow-soft: var(--admin-shadow);
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(83, 168, 255, 0.14), transparent 34%),
        linear-gradient(180deg, var(--admin-bg) 0%, var(--admin-bg-soft) 100%);
    color: var(--admin-text);
}

html[data-theme="light"] .admin-body {
    background:
        linear-gradient(120deg, rgba(23, 105, 211, 0.1), transparent 36%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.theme-toggle {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 120;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--admin-border-strong);
    border-radius: 999px;
    background: var(--admin-bg-panel);
    color: var(--admin-text);
    box-shadow: var(--admin-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.theme-toggle:hover {
    border-color: rgba(83, 168, 255, 0.42);
    color: var(--admin-accent);
}

.theme-toggle-icon {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--admin-accent);
    box-shadow: 0 0 0 4px rgba(83, 168, 255, 0.14);
}

html[data-theme="light"] .theme-toggle-icon {
    background: #f6b73c;
    box-shadow: 0 0 0 4px rgba(246, 183, 60, 0.18);
}

html[data-theme] .admin-container {
    width: min(100%, 1180px);
    padding-top: 64px;
}

html[data-theme] .admin-stats-page {
    width: min(100%, 1280px);
}

html[data-theme] .admin-hero {
    align-items: flex-end;
    padding: 20px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: linear-gradient(135deg, var(--admin-bg-panel), rgba(83, 168, 255, 0.055));
    box-shadow: var(--admin-shadow);
}

html[data-theme] .admin-hero h1 {
    font-size: clamp(30px, 3.8vw, 46px);
    font-weight: 800;
}

html[data-theme] .admin-hero .lead {
    max-width: 620px;
}

html[data-theme] .stats-page-hero {
    padding: 4px 2px 0;
    border: 0;
    background: none;
    box-shadow: none;
}

html[data-theme] .stats-page-hero h1 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

html[data-theme] .admin-actions .btn-secondary,
html[data-theme] .logout-form .btn-secondary {
    background: var(--admin-bg-field);
    color: var(--admin-text);
}

html[data-theme] .card {
    border-color: var(--admin-border);
    background: var(--admin-bg-panel);
    box-shadow: var(--admin-shadow);
}

html[data-theme] .card:hover {
    transform: translateY(-1px);
}

html[data-theme] .admin-stats-page .card:hover {
    transform: none;
}

html[data-theme] .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

html[data-theme] .stat,
html[data-theme] .stats-period-summary div,
html[data-theme] .stats-metric,
html[data-theme] .stats-key-strip div {
    border: 1px solid var(--admin-border);
    background: linear-gradient(180deg, var(--admin-bg-field), transparent);
    text-align: left;
}

html[data-theme] .stats-period-summary div {
    background: var(--admin-bg-field);
    border-color: var(--admin-border);
}

html[data-theme] .stat-value,
html[data-theme] .stats-period-summary strong,
html[data-theme] .stats-metric-value,
html[data-theme] .stats-key-strip strong {
    letter-spacing: 0;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

html[data-theme] .filter-bar,
html[data-theme] .chart-periods,
html[data-theme] .summary-filters,
html[data-theme] .filter-tabs {
    border-color: var(--admin-border);
    background: var(--admin-bg-field);
}

html[data-theme] .filter-tab.active,
html[data-theme] .chart-period-tab.active {
    background: var(--admin-accent);
    color: #07111f;
}

html[data-theme="light"] .filter-tab.active,
html[data-theme="light"] .chart-period-tab.active {
    color: #ffffff;
}

html[data-theme] .summary-filter:hover,
html[data-theme] .summary-filter.active {
    background: var(--admin-bg-panel-solid);
    color: var(--admin-text);
    box-shadow: none;
}

html[data-theme] .stats-chart-card,
html[data-theme] .stats-period-panel,
html[data-theme] .login-card {
    background: var(--admin-bg-panel);
}

html[data-theme] .chart-grid-line {
    stroke: var(--admin-border);
}

html[data-theme] .chart-dot {
    fill: var(--admin-bg-panel-solid);
}

html[data-theme] .chart-tooltip {
    stroke: var(--admin-bg-panel-solid);
}

html[data-theme] .chart-wrap {
    min-height: 260px;
    padding: 8px 0 0;
    border: 0;
    background: none;
    border-radius: 0;
}

html[data-theme] .keys-table {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    overflow: hidden;
}

html[data-theme] .keys-table th {
    background: var(--admin-bg-field);
    color: var(--admin-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

html[data-theme] .keys-table tbody tr:hover td {
    background: var(--admin-bg-hover);
}

html[data-theme] .key-edit-form input,
html[data-theme] .filter-search,
html[data-theme] .card textarea,
html[data-theme] .card input[type="text"],
html[data-theme] .login-card input[type="text"],
html[data-theme] .login-card input[type="password"] {
    border-color: var(--admin-border);
    background: var(--admin-bg-field);
    color: var(--admin-text);
}

html[data-theme] .key-edit-form input:focus,
html[data-theme] .filter-search:focus,
html[data-theme] .card textarea:focus,
html[data-theme] .card input[type="text"]:focus,
html[data-theme] .login-card input[type="text"]:focus,
html[data-theme] .login-card input[type="password"]:focus {
    background: var(--admin-bg-panel-solid);
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 3px rgba(83, 168, 255, 0.18);
}

html[data-theme] .btn-secondary,
html[data-theme] .btn-icon,
html[data-theme] .pagination-btn {
    border-color: var(--admin-border);
    background: var(--admin-bg-field);
    color: var(--admin-text);
}

html[data-theme] .btn-primary {
    border-color: var(--admin-accent);
    background: var(--admin-accent);
    color: #07111f;
    box-shadow: 0 10px 26px rgba(83, 168, 255, 0.18);
}

html[data-theme="light"] .btn-primary {
    color: #ffffff;
}

html[data-theme] .btn-secondary:hover,
html[data-theme] .btn-icon:hover,
html[data-theme] .pagination-btn:hover {
    border-color: rgba(83, 168, 255, 0.42);
    background: var(--admin-bg-hover);
    color: var(--admin-accent);
}

html[data-theme] .pill {
    border: 1px solid transparent;
}

html[data-theme] .pill-available {
    border-color: rgba(69, 212, 131, 0.26);
}

html[data-theme] .pill-used {
    border-color: var(--admin-border);
    background: var(--admin-bg-field);
}

html[data-theme] .admin-stats-page .chart-period-tab.active,
html[data-theme] .admin-stats-page .summary-filter.active {
    background: var(--admin-bg-panel-solid);
    color: var(--admin-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 6px 16px rgba(0, 0, 0, 0.22);
}

html[data-theme] .flag-badge {
    background: rgba(240, 168, 104, 0.14);
    color: #f0b274;
    border: 1px solid rgba(240, 168, 104, 0.28);
}

html[data-theme] .row-flagged { background: rgba(240, 168, 104, 0.06); }

@media (max-width: 700px) {
    .theme-toggle {
        top: 12px;
        right: 12px;
    }

    .theme-toggle-text {
        display: none;
    }

    html[data-theme] .admin-container {
        padding-top: 58px;
    }

    html[data-theme] .admin-hero {
        align-items: flex-start;
        padding: 16px;
    }

    html[data-theme] .stats {
        grid-template-columns: 1fr;
    }

    html[data-theme] .chart-wrap {
        min-height: 240px;
    }
}
