:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #eef4f7;
    --text: #17212b;
    --muted: #647386;
    --line: #dbe3eb;
    --primary: #106d6f;
    --primary-dark: #0a5457;
    --accent: #d58b2a;
    --danger: #ba3434;
    --success: #1d7a55;
    --shadow: 0 18px 46px rgba(25, 39, 52, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

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

main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 64px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px max(16px, calc((100vw - 1180px) / 2));
    background: rgba(246, 248, 251, .88);
    border-bottom: 1px solid rgba(219, 227, 235, .86);
    backdrop-filter: blur(14px);
}

.brand {
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 20px;
}

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

.nav a {
    color: var(--text);
}

.nav-user {
    color: var(--muted);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
    align-items: stretch;
    padding: 54px 0 32px;
}

.hero-copy {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 44px;
    overflow: hidden;
    border-radius: 8px;
    background:
        linear-gradient(120deg, rgba(16, 109, 111, .92), rgba(19, 63, 93, .92)),
        url("appstore-guide-popup.jpg");
    background-size: cover;
    background-position: center;
    color: #fff;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero .eyebrow {
    color: #ffd38f;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(38px, 7vw, 76px);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 12px;
    font-size: 24px;
}

h3 {
    margin-bottom: 6px;
    font-size: 16px;
}

.lead {
    max-width: 640px;
    margin-bottom: 26px;
    color: rgba(255, 255, 255, .86);
    font-size: 18px;
    line-height: 1.8;
}

.hero-actions,
.inline-actions,
.node-actions,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.button,
.icon-button,
.actions button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    transition: .18s ease;
    white-space: nowrap;
}

.button:hover,
.icon-button:hover,
.actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(25, 39, 52, .10);
}

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

.button.ghost {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-color: rgba(255, 255, 255, .32);
}

.button.slim {
    min-height: 34px;
}

.button.full {
    width: 100%;
}

.status-panel {
    display: flex;
    min-height: 340px;
    flex-direction: column;
    justify-content: center;
    padding: 28px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.status-panel strong {
    display: block;
    margin: 16px 0 8px;
    color: var(--primary);
    font-size: 86px;
    line-height: 1;
}

.split-section,
.redeem-band,
.admin-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 20px 0 28px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.split-section p,
.redeem-band p,
.admin-hero p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.7;
}

.redeem-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
    width: min(540px, 100%);
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 109, 111, .13);
}

.section {
    margin-top: 34px;
}

.section-title,
.table-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-title span,
.table-title span {
    color: var(--muted);
    font-size: 14px;
}

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

.node-card {
    display: flex;
    min-height: 142px;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.node-main {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.flag {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 25px;
}

.node-main h3,
.node-main p {
    overflow-wrap: anywhere;
}

.node-main p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.node-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.icon-button {
    min-width: 0;
    font-size: 13px;
}

.empty-state,
.auth-card,
.admin-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 26px rgba(25, 39, 52, .06);
}

.empty-state {
    padding: 36px;
    text-align: center;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 160px);
    place-items: center;
}

.auth-card {
    width: min(440px, 100%);
    padding: 30px;
}

.auth-card label,
.admin-panel label,
.source-form label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.auth-card h1 {
    color: var(--text);
    font-size: 34px;
}

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

.muted a {
    color: var(--primary);
    font-weight: 800;
}

.form-error,
.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.form-error,
.flash.error {
    border: 1px solid rgba(186, 52, 52, .25);
    background: rgba(186, 52, 52, .08);
    color: var(--danger);
}

.flash.success {
    border: 1px solid rgba(29, 122, 85, .25);
    background: rgba(29, 122, 85, .08);
    color: var(--success);
}

.flash {
    position: sticky;
    top: 76px;
    z-index: 19;
}

.admin-hero h1 {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 42px;
}

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

.admin-panel {
    padding: 22px;
}

.admin-panel.wide {
    margin-bottom: 18px;
}

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

.check-row {
    display: flex !important;
    grid-template-columns: none;
    align-items: center;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

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

td small {
    display: block;
    max-width: 680px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

code {
    padding: 3px 6px;
    border-radius: 6px;
    background: var(--surface-2);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.actions form {
    display: inline-flex;
}

.actions button {
    min-height: 32px;
    padding: 0 10px;
    background: #fff;
    font-size: 12px;
}

.actions button.danger {
    border-color: rgba(186, 52, 52, .34);
    color: var(--danger);
}

.node-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
}

@media (max-width: 880px) {
    main {
        width: min(100% - 24px, 720px);
    }

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

    .nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .hero,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .hero-copy,
    .status-panel {
        min-height: auto;
    }

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

    .split-section,
    .redeem-band,
    .admin-hero,
    .section-title,
    .table-title {
        align-items: stretch;
        flex-direction: column;
    }

    .redeem-form,
    .two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .hero-copy,
    .auth-card,
    .admin-panel,
    .split-section,
    .redeem-band,
    .admin-hero {
        padding: 20px;
    }

    .node-actions {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 42px;
    }
}
