:root {
    color-scheme: light;
    --ink: #0e1718;
    --muted: #586764;
    --bg: #f3efe3;
    --panel: rgba(255, 251, 239, 0.88);
    --panel-solid: #fffaf0;
    --field: #fffdf8;
    --line: rgba(28, 63, 69, 0.22);
    --grid-line: rgba(18, 97, 75, 0.16);
    --grid-strong: rgba(18, 97, 75, 0.3);
    --green: #12614b;
    --green-dark: #083f31;
    --sand: #e6c98e;
    --orange: #ba6b20;
    --red: #aa3d2d;
    --glow: rgba(51, 123, 153, 0.22);
    --shadow: 0 24px 70px rgba(43, 35, 24, 0.16);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #eef7ff;
    --muted: #a8b8c7;
    --bg: #04070d;
    --panel: rgba(7, 13, 24, 0.78);
    --panel-solid: #07101d;
    --field: rgba(2, 8, 16, 0.88);
    --line: rgba(105, 152, 190, 0.34);
    --grid-line: rgba(68, 126, 178, 0.18);
    --grid-strong: rgba(124, 176, 219, 0.45);
    --green: #74d0ff;
    --green-dark: #e8f5ff;
    --sand: #d1a955;
    --orange: #f0a64a;
    --red: #ff735f;
    --glow: rgba(89, 176, 255, 0.35);
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 10%, var(--glow), transparent 30rem),
        radial-gradient(circle at 88% 18%, rgba(186, 107, 32, 0.18), transparent 28rem),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
        linear-gradient(135deg, var(--bg) 0%, var(--panel-solid) 52%, var(--bg) 100%);
    background-attachment: fixed;
    background-size: auto, auto, 28px 28px, 28px 28px, auto;
}

body::before {
    content: "";
    position: fixed;
    inset: 42vh -12vw -18vh;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(var(--grid-strong) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, transparent, #000 16%, transparent 82%);
    opacity: 0.64;
    transform: perspective(900px) rotateX(64deg);
    transform-origin: top center;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 78% 42%, var(--glow), transparent 18rem),
        linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0.7;
}

html[data-theme="dark"] body::after {
    background:
        linear-gradient(to bottom, rgba(4, 7, 13, 0.08), rgba(4, 7, 13, 0.84)),
        url("/client/static/grid-reference.png") center bottom / cover no-repeat;
    opacity: 0.58;
}

.site-header,
main,
.toast {
    position: relative;
    z-index: 1;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    border-radius: 2px;
    padding: 12px 17px;
    cursor: pointer;
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 12px 13px;
    color: var(--ink);
    background: var(--field);
    outline: none;
}

textarea,
pre {
    white-space: pre-wrap;
    font-family: "Cascadia Mono", "Courier New", monospace;
}

pre {
    line-height: 1.55;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 800;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hidden {
    display: none !important;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px clamp(18px, 5vw, 60px);
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel-solid) 76%, transparent);
    backdrop-filter: blur(16px);
}

.logo {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 2px;
    color: #fff;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    font-weight: 1000;
    letter-spacing: -0.08em;
    text-decoration: none;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.site-header a,
.text-link {
    color: var(--green-dark);
    font-weight: 900;
    text-decoration: none;
}

.theme-toggle {
    color: var(--green-dark);
    background: var(--field);
    border: 1px solid var(--line);
}

.hero,
.section,
.client-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 28px;
    align-items: center;
    min-height: 620px;
    padding: 60px 0;
}

.hero h1,
.client-shell h1 {
    margin: 0;
    font-size: clamp(42px, 8vw, 86px);
    line-height: 0.92;
    letter-spacing: -0.07em;
}

.lead {
    max-width: 720px;
    color: var(--muted);
    font-size: 20px;
    line-height: 1.55;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--orange);
    font-size: 12px;
    font-weight: 1000;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hero-actions,
.actions-row,
.inline-form {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.primary {
    color: #fff;
    background: var(--green);
}

.secondary {
    color: var(--ink);
    background: var(--sand);
}

.outline {
    color: var(--green-dark);
    background: transparent;
    border: 1px solid var(--green);
}

.status-card,
.panel,
.auth-card,
.plan-card {
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.status-card {
    padding: 28px;
    transform: rotate(1.5deg);
}

.status-card span,
.muted {
    color: var(--muted);
}

.status-card strong {
    display: block;
    margin: 12px 0;
    font-size: 40px;
    letter-spacing: -0.06em;
}

.section {
    padding: 42px 0;
}

.section-title {
    margin-bottom: 18px;
}

.section-title h2,
.panel h2,
.auth-card h1 {
    margin: 0;
    letter-spacing: -0.04em;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.plan-card {
    padding: 22px;
}

.plan-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 28px;
}

.plan-card .price {
    margin: 12px 0 16px;
    font-size: 24px;
    font-weight: 1000;
}

.plan-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.plan-actions button {
    flex: 1 1 120px;
}

.split,
.dashboard-grid,
.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.client-shell {
    padding: 38px 0 60px;
}

.instructions-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 52px 0 70px;
}

.instruction-hero {
    max-width: 780px;
    margin-bottom: 28px;
}

.instruction-hero h1 {
    margin: 0;
    font-size: clamp(40px, 7vw, 78px);
    line-height: 0.96;
    letter-spacing: -0.07em;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.notebook-panel {
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
        var(--panel);
    background-size: 22px 22px, 22px 22px, auto;
}

.instruction-steps {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.instruction-steps div {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    background: var(--field);
}

.instruction-steps strong {
    color: var(--orange);
    font-size: 20px;
}

.auth-card,
.panel {
    padding: 22px;
}

.telegram-auth-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
    gap: 16px;
    align-items: center;
}

.telegram-auth-card h1 {
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1;
}

.telegram-login-widget {
    display: flex;
    min-height: 48px;
    align-items: center;
}

.telegram-auth-card .muted {
    margin: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

.cabinet-top,
.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.cabinet-top {
    align-items: center;
}

.dashboard-grid {
    margin-bottom: 18px;
}

.key-panel textarea {
    min-height: 96px;
}

.qr-box {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--line);
    background: var(--field);
}

.qr-code {
    display: grid;
    width: 180px;
    min-height: 180px;
    place-items: center;
    background: #fff;
    border: 1px solid var(--line);
}

.qr-code svg {
    display: block;
    width: 180px;
    height: 180px;
}

.status-list {
    display: grid;
    gap: 10px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border-radius: 2px;
    border: 1px solid var(--line);
    background: var(--field);
}

.status-row span {
    color: var(--muted);
}

.pill {
    display: inline-flex;
    padding: 5px 10px;
    border-radius: 2px;
    color: var(--green-dark);
    background: color-mix(in srgb, var(--green) 16%, transparent);
    font-weight: 900;
}

.pill.bad {
    color: var(--red);
    background: color-mix(in srgb, var(--red) 16%, transparent);
}

.table-wrap {
    overflow-x: auto;
}

.error-text {
    min-height: 22px;
    color: var(--red);
    font-weight: 900;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 2px;
    color: #fff;
    background: var(--green-dark);
    box-shadow: var(--shadow);
}

@media (max-width: 860px) {
    .hero,
    .split,
    .dashboard-grid,
    .auth-grid,
    .telegram-auth-card,
    .plans-grid,
    .instruction-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
    }

    .cabinet-top,
    .panel-title {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero,
    .section,
    .client-shell,
    .instructions-shell {
        width: min(100% - 24px, 1180px);
    }

    .hero h1,
    .client-shell h1,
    .instruction-hero h1 {
        font-size: 42px;
    }

    .hero-actions,
    .actions-row,
    .inline-form,
    .qr-box {
        align-items: stretch;
        flex-direction: column;
    }

    .qr-box {
        display: grid;
        grid-template-columns: 1fr;
    }

    button,
    .text-link {
        width: 100%;
        text-align: center;
    }
}
