:root {
    --blue: #b67a0e;
    --ink: #3f2c10;
    --muted: #7a6749;
    --line: #ddc389;
    --soft: #f6efdd;
    --danger: #b13a24;
    --gold-strong: #8b5b06;
    --gold-surface: #fffaf0;
    --gold-shadow: rgba(129, 88, 13, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    background:
        radial-gradient(circle at top, rgba(214, 168, 60, 0.18), transparent 32%),
        linear-gradient(180deg, #fbf7ee 0%, #f4ecd9 100%);
}

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

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 230px;
    padding: 24px 18px;
    color: #fff6db;
    background: linear-gradient(180deg, #6b4606 0%, #b8861c 38%, #805407 100%);
    border-right: 1px solid rgba(255, 234, 179, 0.34);
    box-shadow: 8px 0 26px rgba(104, 70, 8, 0.18);
    overflow-y: auto;
}

.admin-sidebar h1 {
    margin: 0 0 22px;
    color: #fff4cf;
    font-size: 21px;
    text-shadow: 0 2px 6px rgba(87, 54, 3, 0.34);
}

.admin-sidebar a {
    display: block;
    margin: 6px 0;
    padding: 10px 12px;
    color: rgba(255, 248, 221, 0.88);
    border: 1px solid transparent;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.admin-sidebar a:hover {
    color: #fffdf5;
    border-color: rgba(255, 227, 153, 0.4);
    background: rgba(255, 249, 224, 0.14);
}

.admin-sidebar a.sidebar-emphasis {
    color: #ff2a2a;
    font-weight: 800;
    background: rgba(255, 244, 244, 0.86);
    border-color: rgba(255, 111, 111, 0.4);
    box-shadow: inset 0 0 0 1px rgba(255, 226, 226, 0.55);
}

.admin-sidebar a.sidebar-emphasis:hover {
    color: #ff0000;
    border-color: rgba(255, 69, 69, 0.55);
    background: rgba(255, 239, 239, 0.96);
}

.admin-main {
    max-width: 1180px;
    margin-left: 230px;
    padding: 34px;
}

h2 {
    margin: 0 0 20px;
    color: var(--gold-strong);
    font-size: 28px;
}

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

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

.stat-grid div,
.admin-form,
table,
.hint,
.alert,
.login-card {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fffdf7 0%, #fff8ec 100%);
    border-radius: 18px;
    box-shadow: 0 14px 34px var(--gold-shadow);
}

.stat-grid div {
    padding: 22px;
}

.stat-grid strong {
    display: block;
    color: var(--gold-strong);
    font-size: 34px;
}

.stat-grid strong.status-open {
    color: #16a34a;
}

.stat-grid strong.status-closed {
    color: var(--danger);
}

.stat-grid span,
.hint,
.login-card p {
    color: var(--muted);
}

.hint {
    padding: 16px 18px;
}

.admin-form {
    display: grid;
    gap: 16px;
    max-width: 760px;
    padding: 22px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(182, 122, 14, 0.14);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check input {
    width: auto;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 42px;
    padding: 0 18px;
    color: #fff9ea;
    font-weight: 700;
    background: linear-gradient(180deg, #d5a12c 0%, #b57a08 52%, #8a5a00 100%);
    border: 1px solid #8a5a00;
    border-radius: 12px;
    box-shadow: 0 10px 18px rgba(139, 91, 6, 0.18);
    cursor: pointer;
}

button:hover,
.button:hover {
    filter: saturate(1.05);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.danger {
    margin-top: 14px;
    background: linear-gradient(180deg, #d86047 0%, #b63d29 100%);
    border-color: #a93724;
}

.site-switch-card {
    display: grid;
    gap: 18px;
    max-width: 760px;
    padding: 22px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 14px 34px rgba(20, 36, 60, 0.06);
}

.site-switch-state {
    display: grid;
    gap: 8px;
    padding: 18px;
    border-radius: 14px;
}

.site-switch-state strong {
    font-size: 24px;
}

.site-switch-state span {
    color: var(--muted);
}

.site-switch-state.open {
    background: #eef8f1;
}

.site-switch-state.open strong {
    color: #137333;
}

.site-switch-state.closed {
    background: #fff2f0;
}

.site-switch-state.closed strong {
    color: var(--danger);
}

.site-switch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.site-switch-actions form {
    margin: 0;
}

.site-switch-actions .danger {
    margin-top: 0;
}

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

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

th {
    color: #7b6133;
    font-size: 13px;
    background: linear-gradient(180deg, #fff3cc 0%, #f5deb0 100%);
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
}

.alert.success {
    color: #6f4b06;
    background: linear-gradient(180deg, #fff8df 0%, #f7e5ba 100%);
}

.alert.error {
    color: var(--danger);
    background: linear-gradient(180deg, #fff4ee 0%, #ffe6dc 100%);
}

.admin-login {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background:
        radial-gradient(circle at 20% 0, rgba(213, 161, 44, 0.24), transparent 30%),
        linear-gradient(135deg, #f9f3e4, #efe1bf);
}

.login-card {
    display: grid;
    gap: 16px;
    width: min(92vw, 420px);
    padding: 32px;
}

.login-card h1 {
    margin: 0;
}

.login-card button {
    width: 100%;
}

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

.frame-admin-card {
    display: grid;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fffdf7 0%, #fff8ec 100%);
    border-radius: 18px;
    box-shadow: 0 14px 34px var(--gold-shadow);
}

.frame-admin-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.frame-admin-card-head h3 {
    margin: 0 0 6px;
    color: var(--gold-strong);
    font-size: 20px;
}

.frame-admin-card-head p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.frame-admin-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    color: #fff8ea;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    background: linear-gradient(180deg, #d5a12c 0%, #b57a08 52%, #8a5a00 100%);
    border: 1px solid #8a5a00;
}

.frame-admin-badge.is-default {
    color: var(--gold-strong);
    background: linear-gradient(180deg, #fff6db 0%, #f1e1b4 100%);
    border-color: rgba(139, 91, 6, 0.22);
}

.frame-admin-preview-shell {
    overflow: hidden;
    border: 1px solid rgba(221, 195, 137, 0.9);
    border-radius: 16px;
    background: linear-gradient(180deg, #fffaf0 0%, #f5e2b5 100%);
}

.frame-admin-preview-image {
    display: block;
    width: 100%;
    height: 260px;
    object-fit: cover;
    background: #f6efdd;
}

.frame-admin-meta {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 13px;
    border: 1px dashed rgba(221, 195, 137, 0.92);
    border-radius: 14px;
    background: rgba(255, 250, 240, 0.8);
}

.frame-admin-meta strong {
    color: var(--ink);
    font-size: 14px;
    word-break: break-all;
}

.frame-admin-form {
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.admin-form-section {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px dashed rgba(221, 195, 137, 0.92);
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.82);
}

.admin-form-section-head h3 {
    margin: 0 0 6px;
    color: var(--gold-strong);
    font-size: 18px;
}

.admin-form-section-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

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

.admin-form-section-wide {
    grid-column: 1 / -1;
}

.frame-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-head-description {
    margin: -12px 0 18px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.history-admin-page-form {
    max-width: none;
    margin-bottom: 20px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.history-admin-page-form button {
    margin-bottom: 1px;
}

.history-admin-grid {
    display: grid;
    gap: 20px;
}

.history-admin-card {
    display: grid;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, #fffdf7 0%, #fff8ec 100%);
    box-shadow: 0 14px 34px var(--gold-shadow);
}

.history-admin-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.history-admin-card-head strong {
    color: var(--gold-strong);
    font-size: 21px;
}

.history-admin-card-head span {
    padding: 5px 10px;
    color: var(--gold-strong);
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(139, 91, 6, 0.18);
    border-radius: 999px;
    background: #fff2c9;
}

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

.history-admin-slot {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 14px;
    border: 1px dashed rgba(221, 195, 137, 0.95);
    border-radius: 15px;
    background: rgba(255, 250, 240, 0.82);
}

.history-admin-slot-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    overflow: hidden;
    color: var(--muted);
    border: 1px solid rgba(221, 195, 137, 0.85);
    border-radius: 12px;
    background: #f8efda;
}

.history-admin-slot-preview img {
    display: block;
    width: 100%;
    height: 210px;
    object-fit: cover;
}

.history-admin-slot-preview.is-empty {
    border-style: dashed;
}

.history-admin-delete {
    color: var(--danger);
}

@media (max-width: 820px) {
    .admin-sidebar {
        position: static;
        width: auto;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 12px;
    }

    .admin-sidebar h1 {
        width: 100%;
        margin-bottom: 8px;
        font-size: 18px;
    }

    .admin-sidebar a {
        flex: 1 1 calc(50% - 8px);
        margin: 0;
        padding: 10px 8px;
        text-align: center;
    }

    .admin-main {
        margin-left: 0;
        padding: 18px 14px 24px;
    }

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

    .admin-head {
        flex-direction: column;
        align-items: stretch;
    }

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

    .admin-form-section-grid {
        grid-template-columns: 1fr;
    }

    .history-admin-page-form {
        grid-template-columns: 1fr;
    }

    .history-admin-slot-grid {
        grid-template-columns: 1fr;
    }

    .frame-admin-card-head {
        flex-direction: column;
    }

    .frame-admin-preview-image {
        height: 220px;
    }

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

    .lottery-editor-shell {
        padding: 16px;
    }

    .lottery-stage-head {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 560px) {
    h2 {
        font-size: 22px;
    }

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

    .admin-sidebar a,
    button,
    .button {
        width: 100%;
    }

    .frame-admin-card {
        padding: 14px;
    }

    .history-admin-card {
        padding: 14px;
    }

    .history-admin-card-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-admin-slot {
        padding: 10px;
    }

    .history-admin-slot-preview,
    .history-admin-slot-preview img {
        min-height: 160px;
        height: 180px;
    }

    .frame-admin-preview-image {
        height: 190px;
    }

    .frame-admin-actions {
        flex-direction: column;
    }

    .admin-form,
    .lottery-editor-form,
    .lottery-editor-shell,
    .login-card {
        padding: 12px;
        border-radius: 14px;
    }

    th,
    td {
        padding: 10px 12px;
    }

    .lottery-live-editor {
        gap: 14px;
    }

    .lottery-live-editor {
        grid-template-columns: 1fr;
    }

    .lottery-stage {
        padding: 10px;
    }
}

.lottery-admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr);
    gap: 24px;
    align-items: start;
}

.lottery-editor-shell {
    border: 2px solid var(--line);
    background: linear-gradient(180deg, #fffdf7 0%, #fff7e8 100%);
    border-radius: 18px;
    box-shadow: 0 14px 34px var(--gold-shadow);
    padding: 22px;
}

.lottery-live-editor {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr);
    gap: 24px;
    align-items: start;
}

.lottery-stage {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 2px solid rgba(221, 195, 137, 0.9);
    border-radius: 18px;
    background: linear-gradient(180deg, #fffef9 0%, #fff7e8 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.lottery-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(221, 195, 137, 0.8);
}

.lottery-stage-head strong {
    color: var(--gold-strong);
    font-size: 18px;
}

.lottery-stage-head span {
    color: var(--muted);
    font-size: 13px;
}

.lottery-stage .kj-bar {
    border: 2px solid rgba(221, 195, 137, 0.92);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 22px rgba(139, 91, 6, 0.08);
}

.lottery-editor-form {
    max-width: none;
    padding: 18px;
    border: 2px solid rgba(221, 195, 137, 0.92);
    background: linear-gradient(180deg, #fffef9 0%, #fff7e8 100%);
}

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

.lottery-field-wide {
    grid-column: 1 / -1;
}

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

.lottery-preview-box {
    padding: 16px;
    background: #fff;
    border: 2px solid rgba(221, 195, 137, 0.92);
    border-radius: 12px;
}

.lottery-preview-box h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.lottery-preview-box .kj-bar {
    max-width: 100%;
    border: 1px solid #efefef;
    border-radius: 8px;
    overflow: hidden;
}

.material-update-counter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 14px 0 10px;
}

.material-update-counter-chip {
    min-height: 42px;
    padding: 10px 14px;
    color: var(--gold-strong);
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff7dd 0%, #f4e0ad 100%);
    box-shadow: 0 10px 18px rgba(139, 91, 6, 0.08);
}

.material-update-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 14px;
}

.target-sync-panel {
    padding: 28px;
    border: 2px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(145deg, #fffef9 0%, #fff4d5 58%, #f1d794 100%);
    box-shadow: 0 18px 42px rgba(139, 91, 6, 0.14);
}

.target-sync-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.target-sync-head h2 {
    margin: 5px 0 8px;
}

.target-sync-head p,
.target-sync-scope {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.target-sync-kicker {
    color: var(--gold-strong);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.target-sync-state {
    flex: 0 0 auto;
    padding: 8px 12px;
    color: #8c5b10;
    font-size: 13px;
    font-weight: 800;
    border: 1px solid #d8b66d;
    border-radius: 999px;
    background: #fff7df;
}

.target-sync-state.is-ok {
    color: #17673b;
    border-color: #9fd3b5;
    background: #ecfbf2;
}

.target-sync-button {
    width: 100%;
    min-height: 66px;
    font-size: 20px;
    font-weight: 900;
    border-radius: 16px;
}

.target-sync-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.target-sync-note {
    margin-top: 12px;
    color: var(--gold-strong);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.target-sync-scope {
    margin-top: 18px;
    text-align: center;
}

.target-sync-stats {
    margin-top: 20px;
}

@media (max-width: 900px) {
    .target-sync-panel {
        padding: 20px;
    }

    .target-sync-head {
        flex-direction: column;
    }

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

    .lottery-live-editor {
        grid-template-columns: 1fr;
    }

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

    .lottery-field-grid {
        grid-template-columns: 1fr;
    }
}
