:root {
    --bg-a: #e6f1ff;
    --bg-b: #d8e8ff;
    --bg-c: #c7dcff;
    --card: rgba(255, 255, 255, 0.86);
    --card-strong: rgba(255, 255, 255, 0.95);
    --line: rgba(21, 87, 188, 0.16);
    --ink: #0f1d35;
    --muted: #4f658c;
    --primary: #1463df;
    --primary-deep: #0e49a6;
    --ok: #0f9f68;
    --bad: #ce3c57;
    --warn: #d38a15;
    --shadow: 0 10px 24px rgba(11, 63, 146, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    color: var(--ink);
    font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    line-height: 1.34;
    background:
        radial-gradient(900px 560px at 12% 14%, rgba(69, 143, 255, 0.22), transparent 62%),
        radial-gradient(900px 560px at 85% 90%, rgba(16, 103, 220, 0.18), transparent 65%),
        linear-gradient(145deg, var(--bg-a) 0%, var(--bg-b) 48%, var(--bg-c) 100%);
}

.page-shell {
    max-width: 840px;
    margin: 0 auto;
    padding: 10px 8px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 6px;
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 560px;
    text-align: right;
}

.content {
    display: grid;
    gap: 6px;
    flex: 1;
}

.grid {
    display: grid;
    gap: 6px;
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card,
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(9px);
}

.cabinet-page {
    display: grid;
    gap: 6px;
}

.hero-card {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(130deg, rgba(20, 99, 223, 0.05), rgba(20, 99, 223, 0.01)),
        var(--card-strong);
}

.hero-card::after {
    content: none;
}

.hero-top {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.hero-status {
    min-width: 180px;
    text-align: right;
}

.hero-date {
    margin: 2px 0;
    font-weight: 700;
    font-size: 13px;
}

.hero-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 6px;
}

.action-card {
    display: grid;
    align-content: start;
    gap: 4px;
}

.auth-card {
    max-width: 540px;
    margin: 0 auto;
}

.auth-hint {
    margin: 2px 0 0;
}

.action-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.setup-card h2,
.config-card h2,
.panel h1,
.panel h2 {
    margin: 0 0 2px;
}

.setup-steps {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.step-tile {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    padding: 12px 14px;
}

.step-index {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--primary), var(--primary-deep));
    color: #fff;
    font-weight: 800;
    flex-shrink: 0;
}

.step-title {
    margin: 0;
    font-weight: 800;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 11px;
    color: var(--primary-deep);
    font-weight: 700;
}

h1 {
    font-size: clamp(18px, 2.4vw, 24px);
    margin: 0;
    line-height: 1.05;
}

.muted,
.hint,
.subtitle {
    color: var(--muted);
}

input,
textarea,
select,
button {
    width: 100%;
    min-height: 34px;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
}

input,
textarea {
    border: 1px solid var(--line);
    padding: 7px 9px;
    background: rgba(247, 252, 255, 0.94);
    color: var(--ink);
}

select {
    border: 1px solid var(--line);
    padding: 7px 9px;
    background: rgba(247, 252, 255, 0.94);
    color: var(--ink);
}

textarea {
    resize: vertical;
    min-height: 46px;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.38;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

button {
    border: 0;
    padding: 7px 9px;
    cursor: pointer;
    color: #f6fbff;
    font-weight: 700;
    background: linear-gradient(145deg, var(--primary), var(--primary-deep));
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(20, 99, 223, 0.28);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ghost-link,
.pay-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 7px 9px;
    color: #f6fbff;
    background: linear-gradient(145deg, var(--primary), var(--primary-deep));
    font-weight: 700;
}

.ghost-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    color: var(--primary-deep);
}

.pay-link.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.payment-addon {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 4px;
}

.payment-addon-form {
    margin-top: 2px;
}

.status-chip {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
}

.status-active {
    color: var(--ok);
    background: rgba(15, 159, 104, 0.15);
}

.status-inactive {
    color: var(--bad);
    background: rgba(206, 60, 87, 0.16);
}

.link-details {
    margin-top: 6px;
}

.link-details summary {
    cursor: pointer;
    color: var(--primary-deep);
    font-weight: 700;
}

.link-details code {
    display: block;
    margin-top: 6px;
    padding: 7px 9px;
    border-radius: 10px;
    background: rgba(249, 252, 255, 0.95);
    border: 1px solid var(--line);
    overflow-wrap: anywhere;
}

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

.compact {
    margin-top: 4px;
}

label span {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

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

.facts div {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.74);
}

.facts dt {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 13px;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.device-form {
    margin-top: 6px;
}

.device-list {
    margin-top: 6px;
    display: grid;
    gap: 6px;
}

.device-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
    padding: 7px;
    display: grid;
    gap: 6px;
}

.device-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.device-name {
    margin: 0;
    font-weight: 800;
    font-size: 13px;
}

.device-qr-wrap {
    display: grid;
    justify-items: start;
    gap: 3px;
}

.device-qr {
    width: 108px;
    height: 108px;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 5px;
}

.device-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.device-actions .ghost-btn {
    width: auto;
}

.device-row-actions {
    display: grid;
    gap: 5px;
}

.inline-rename {
    display: grid;
    gap: 5px;
    grid-template-columns: 1fr auto;
}

.inline-delete {
    display: grid;
}

.danger-btn {
    background: linear-gradient(145deg, #d54857, #a42536);
}

.danger-btn:hover {
    box-shadow: 0 10px 24px rgba(164, 37, 54, 0.36);
}

.alert {
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 7px 9px;
    font-weight: 600;
}

.alert-success {
    background: rgba(15, 159, 104, 0.12);
    color: var(--ok);
}

.alert-error {
    background: rgba(206, 60, 87, 0.14);
    color: var(--bad);
}

code {
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

.inline-link {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.meta-inline {
    margin: 1px 0 0;
    font-size: 11px;
}

.panel-head-compact {
    align-items: center;
}

.device-form-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 5px;
    margin-top: 4px;
}

.compact-disclosure {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 5px 7px;
    background: rgba(255, 255, 255, 0.78);
}

.compact-disclosure summary {
    cursor: pointer;
    color: var(--primary-deep);
    font-weight: 700;
}

.compact-disclosure textarea {
    margin-top: 5px;
}

.compact-disclosure form,
.compact-disclosure .device-row-actions {
    margin-top: 5px;
}

.is-hidden {
    display: none;
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 6px 2px 0;
    color: var(--muted);
    font-size: 10px;
    opacity: 0.9;
}

.site-footer a {
    color: var(--primary-deep);
    text-decoration: none;
    font-weight: 700;
}

.site-footer a:hover {
    text-decoration: underline;
}

.site-footer-sep {
    color: rgba(79, 101, 140, 0.7);
}

@media (max-width: 860px) {
    .two-columns,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .subtitle {
        text-align: left;
    }
}

@media (max-width: 760px) {
    .page-shell {
        padding: 8px 6px 16px;
    }

    .brand {
        font-size: 20px;
    }

    .hero-top {
        display: grid;
        gap: 4px;
    }

    .hero-status {
        min-width: 0;
        text-align: left;
    }

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

    .ghost-link,
    .pay-link,
    .ghost-btn {
        width: 100%;
    }

    .device-actions .ghost-btn {
        width: auto;
    }

    .inline-rename {
        grid-template-columns: 1fr;
    }

    .device-head {
        display: grid;
    }

    .device-form-inline {
        grid-template-columns: 1fr;
    }
}
