/* ==========================================================================
   通用 + 前台 + 后台样式
   ========================================================================== */

:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff4ff;
    --ok: #15803d;
    --err: #dc2626;
    --radius: 16px;
    --shadow: 0 18px 45px rgba(30, 58, 138, .12);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
}

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

.hidden {
    display: none !important;
}

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

.nowrap {
    white-space: nowrap;
}

/* ------------------------------ 按钮 ------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    transition: background .18s, border-color .18s, transform .1s, box-shadow .18s;
}

.btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: .65;
    cursor: default;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, var(--primary));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f8ff7, var(--primary-dark));
    border-color: transparent;
}

.btn-block {
    width: 100%;
    padding: 13px 20px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 9px;
}

.btn-danger {
    color: var(--err);
    border-color: #fecaca;
    background: #fff5f5;
}

.btn-danger:hover {
    background: #fee2e2;
}

/* ------------------------------ 提示 ------------------------------ */

.alert {
    margin: 12px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.alert.err {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--err);
}

.alert.ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--ok);
}

/* ==========================================================================
   前台
   ========================================================================== */

.site-body {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    overflow-x: hidden;
    background:
        radial-gradient(1100px 680px at 8% -12%, #dbeafe 0%, rgba(219, 234, 254, 0) 60%),
        radial-gradient(900px 620px at 105% 2%, #e0f2fe 0%, rgba(224, 242, 254, 0) 55%),
        radial-gradient(900px 700px at 50% 125%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
        linear-gradient(160deg, #fbfdff 0%, #eff4fb 55%, #e9eef8 100%);
}

.site-body::before,
.site-body::after {
    content: "";
    position: fixed;
    z-index: 0;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .5;
    pointer-events: none;
}

.site-body::before {
    width: 420px;
    height: 420px;
    top: -140px;
    left: -120px;
    background: #bfdbfe;
}

.site-body::after {
    width: 380px;
    height: 380px;
    right: -110px;
    bottom: -150px;
    background: #c7d2fe;
}

.site-body::-webkit-scrollbar {
    width: 10px;
}

.site-body::-webkit-scrollbar-track {
    background: transparent;
}

.site-body::-webkit-scrollbar-thumb {
    background: #c7d2e5;
    border: 3px solid transparent;
    border-radius: 10px;
    background-clip: content-box;
}

.site-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin: auto;
    text-align: center;
}

.site-card {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(255, 255, 255, .95);
    border-radius: 26px;
    box-shadow:
        0 34px 70px -34px rgba(30, 58, 138, .45),
        0 2px 6px rgba(30, 58, 138, .05);
    padding: 38px 30px 28px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    animation: rise .5s cubic-bezier(.2, .8, .3, 1) both;
}

.site-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #60a5fa, #6366f1 55%, #22d3ee);
    opacity: .9;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.logo {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 20px;
    background: linear-gradient(140deg, #60a5fa, #3b82f6 55%, #4f46e5);
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 16px 30px -10px rgba(59, 130, 246, .6),
        inset 0 1px 0 rgba(255, 255, 255, .45);
}

.site-title {
    margin: 0 0 7px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: .4px;
    color: #0f172a;
}

.site-desc {
    margin: 0 0 24px;
    font-size: 13.5px;
    line-height: 1.7;
    color: #64748b;
}

.status-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 26px;
    padding: 11px 16px;
    border: 1px solid #e6ecf5;
    border-radius: 14px;
    background: #fff;
    color: #334155;
    font-size: 13.5px;
    box-shadow: 0 10px 24px -18px rgba(15, 23, 42, .5);
}

.spinner {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, .22);
    border-top-color: var(--primary);
    animation: spin .8s linear infinite;
    flex: none;
}

.spinner.done {
    border-color: var(--ok);
    animation: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.result-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    text-align: left;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 7px;
    border: 1px solid #e8edf5;
    border-radius: 12px;
    font-size: 13px;
    color: var(--muted);
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

.result-item::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: #cbd5e1;
}

.result-item .result-name {
    flex: 1;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-item .result-time {
    flex: none;
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
}

.result-item.win {
    border-color: #bbf7d0;
    background: linear-gradient(180deg, #f2fdf6, #ecfdf3);
    color: var(--ok);
}

.result-item.win::before {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .14);
}

.result-item.win .result-name {
    color: var(--ok);
    font-weight: 600;
}

.result-item.fail {
    opacity: .6;
}

.result-item.fail::before {
    background: #f87171;
}

.site-foot {
    margin: 20px 0 0;
    font-size: 12px;
    letter-spacing: .3px;
    color: #94a3b8;
}

/* ------------------------------ 内嵌主站 ------------------------------ */

html.frame-mode,
body.frame-mode {
    overflow: hidden;
    height: 100%;
}

.frame-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 80;
    background: #fff;
}

.frame-view {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    transform-origin: top left;
}

.frame-bar {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 81;
}

.frame-btn {
    border: 1px solid rgba(148, 163, 184, .5);
    background: rgba(255, 255, 255, .92);
    color: #475569;
    font-size: 13px;
    font-family: inherit;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .16);
    opacity: .72;
    transition: opacity .18s, background .18s;
}

.frame-btn:hover {
    opacity: 1;
    background: #fff;
}

/* ------------------------------ 弹窗 ------------------------------ */

.mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 620px at 50% 0%, rgba(59, 130, 246, .16) 0%, rgba(59, 130, 246, 0) 62%),
        rgba(8, 12, 24, .68);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    backdrop-filter: blur(18px) saturate(120%);
    opacity: 1;
    visibility: visible;
    transition: opacity .3s ease, visibility .3s ease;
}

.mask.hide {
    opacity: 0;
    visibility: hidden;
}

.dialog {
    position: relative;
    width: 100%;
    max-width: 388px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 26px;
    padding: 34px 30px 26px;
    text-align: center;
    box-shadow:
        0 50px 100px -40px rgba(2, 6, 23, .7),
        0 1px 0 rgba(255, 255, 255, .8) inset;
    animation: pop .36s cubic-bezier(.2, .9, .3, 1.15) both;
}

.dialog::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 140px;
    background: radial-gradient(70% 110% at 50% 0%, rgba(59, 130, 246, .16), rgba(59, 130, 246, 0) 70%);
    pointer-events: none;
}

@keyframes pop {
    from { opacity: 0; transform: scale(.94) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.dialog-icon {
    position: relative;
    width: 58px;
    height: 58px;
    margin: 0 auto 16px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(140deg, #60a5fa, #3b82f6 55%, #4f46e5);
    box-shadow:
        0 16px 30px -12px rgba(59, 130, 246, .65),
        inset 0 1px 0 rgba(255, 255, 255, .5);
}

.dialog-icon svg {
    width: 29px;
    height: 29px;
}

.dialog h2 {
    position: relative;
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .3px;
    color: #0f172a;
}

.dialog-tip {
    position: relative;
    margin: 0 0 22px;
    font-size: 13px;
    line-height: 1.7;
    color: #64748b;
}

.dialog form {
    position: relative;
}

.dialog .btn-primary.btn-block {
    height: 50px;
    border-radius: 14px;
    font-size: 16px;
    letter-spacing: 2px;
    box-shadow: 0 18px 34px -16px rgba(37, 99, 235, .8);
}

.dialog .btn-primary.btn-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 38px -14px rgba(37, 99, 235, .85);
}

.dialog .btn-primary.btn-block:active {
    transform: translateY(0);
}

.dialog .btn-primary.btn-block:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .35);
    outline-offset: 2px;
}

.dialog .alert {
    position: relative;
    text-align: left;
}

/* ==========================================================================
   后台
   ========================================================================== */

.admin-body {
    min-height: 100vh;
    background: #f2f5fa;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(700px 400px at 15% 0%, #dbeafe 0%, rgba(219, 234, 254, 0) 60%),
        linear-gradient(160deg, #f8fafc, #eef2f9);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 18px;
    padding: 30px 26px 26px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 20px;
}

.login-card label {
    display: block;
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
}

.login-card input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fbfcfe;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.login-card input:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
    background: #fff;
}

.login-card .btn-block {
    margin-top: 22px;
}

/* 顶部导航 */

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 18px;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 0;
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(135deg, #60a5fa, var(--primary));
    display: inline-block;
}

.admin-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: auto;
}

.admin-nav a {
    padding: 7px 13px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.admin-nav a:hover {
    background: #f1f5f9;
    color: var(--text);
}

.admin-nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.topbar-actions form {
    margin: 0;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 18px 48px;
}

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

.page-head h1 {
    margin: 0;
    font-size: 19px;
}

.page-head p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--muted);
}

/* 卡片 / 面板 */

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.panel h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.panel .panel-sub {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--muted);
}

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

.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
}

.stat-value {
    margin-top: 4px;
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-value small {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
    margin-left: 4px;
}

/* 表格 */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 560px;
}

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

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: #fbfdff;
}

.table .center {
    text-align: center;
}

.table input[type="text"],
.table input[type="url"],
.table input:not([type]) {
    width: 100%;
    min-width: 150px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fbfcfe;
    outline: none;
}

.table input:focus {
    border-color: #93c5fd;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.icon-btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 7px;
    padding: 4px 8px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    font-family: inherit;
    margin: 0 2px;
}

.icon-btn:hover {
    background: #f1f5f9;
}

.icon-btn.danger {
    color: var(--err);
    border-color: #fecaca;
}

.icon-btn.danger:hover {
    background: #fef2f2;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.badge.gray {
    background: #f1f5f9;
    color: var(--muted);
}

/* 表单 */

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

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

.field {
    display: block;
}

.field.full {
    grid-column: 1 / -1;
}

.field span {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #475569;
}

.field input,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fbfcfe;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field textarea {
    min-height: 84px;
    resize: vertical;
}

.field input:focus,
.field textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
    background: #fff;
}

.field .hint {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
}

details.help {
    margin-top: 18px;
    border-top: 1px dashed var(--line);
    padding-top: 14px;
    font-size: 13px;
    color: var(--muted);
}

details.help summary {
    cursor: pointer;
    color: #475569;
    font-weight: 600;
    outline: none;
}

details.help p {
    margin: 10px 0 0;
}

@media (max-width: 860px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-height: 560px) {
    .site-body {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .site-card {
        padding-top: 30px;
    }

    .logo {
        width: 52px;
        height: 52px;
        margin-bottom: 12px;
        border-radius: 16px;
        font-size: 23px;
    }
}

@media (max-width: 520px) {
    .site-body {
        padding: 32px 14px;
    }

    .site-card {
        padding: 30px 20px 24px;
        border-radius: 22px;
    }

    .site-title {
        font-size: 22px;
    }

    .dialog {
        padding: 30px 22px 24px;
        border-radius: 22px;
    }

    .dialog-icon {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    .dialog h2 {
        font-size: 19px;
    }

    .container {
        padding: 18px 12px 36px;
    }

    .panel {
        padding: 16px 14px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat {
        padding: 13px 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .admin-nav {
        width: 100%;
        margin-left: 0;
        order: 3;
        padding-bottom: 10px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .topbar-inner {
        gap: 10px;
    }

    .topbar-actions {
        padding: 0;
    }
}
