:root {
    --primary: #07c160;
    --primary-dark: #06ad56;
    --primary-soft: #e8f8ef;
    --danger: #f04438;
    --danger-soft: #fef3f2;
    --blue: #2e7cf6;
    --blue-soft: #eaf2ff;
    --orange: #f79009;
    --orange-soft: #fff6e8;
    --text: #1f2329;
    --text-2: #5b6470;
    --text-3: #8f959e;
    --border: #e6e9ee;
    --bg: #f4f6f9;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(31, 35, 41, .03), 0 6px 20px rgba(31, 35, 41, .05);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

code {
    font-family: var(--mono);
    font-size: 12.5px;
    background: #f0f2f5;
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--text-2);
}

/* ===== 顶部导航 ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.brand-logo {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    background: linear-gradient(135deg, #22d47a, var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(7, 193, 96, .28);
}
.brand-logo svg { width: 20px; height: 20px; }
.brand-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub {
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub code { font-size: 11.5px; padding: 0 5px; }

/* ===== 布局 ===== */
.admin-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
}
.admin-layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.sidenav {
    position: sticky;
    top: 86px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--text-2);
    text-decoration: none;
    font-weight: 500;
    transition: background .15s, color .15s;
    position: relative;
}
.nav-item:hover { background: #f5f7fa; color: var(--text); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-item svg { flex: none; }
.nav-dot {
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.nav-dot.on { background: var(--primary); box-shadow: 0 0 0 3px rgba(7, 193, 96, .18); }
.nav-dot.off { background: #d0d5dd; }
.sidenav-tip {
    margin: 10px 4px 4px;
    padding: 12px;
    border-radius: 10px;
    background: #f7f9fb;
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.8;
    word-break: break-all;
}
.sidenav-tip-title {
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 4px;
}
.sidenav-tip code {
    font-size: 11px;
    padding: 0 4px;
    background: #fff;
}
.admin-main { min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease-out; }
@keyframes fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ===== 卡片 ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.card-title svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex: none;
}
.card-title .count {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-3);
    margin-left: 2px;
}
.card-desc {
    font-size: 13px;
    color: var(--text-3);
    line-height: 1.7;
    margin: -6px 0 16px;
}

/* ===== 链接横幅 ===== */
.link-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #0bd36d, #05a352);
    color: #fff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 24px rgba(7, 193, 96, .22);
}
.link-banner-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.link-banner-icon svg { width: 20px; height: 20px; }
.link-banner-body { flex: 1; min-width: 0; }
.link-banner-label { font-size: 12px; opacity: .85; }
.link-banner-url {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.5;
}
.link-banner .btn {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: none;
    flex: none;
}
.link-banner .btn.btn-ghost {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    border-color: rgba(255, 255, 255, .35);
}
.link-banner .btn:hover { filter: brightness(.97); }
.link-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: none;
}

/* ===== 统计 ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon {
    width: 46px;
    height: 46px;
    flex: none;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.green { background: var(--primary-soft); color: var(--primary); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat .num {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat .label { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ===== 表单 ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    margin-bottom: 16px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-section {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: .6px;
    text-transform: uppercase;
    margin: 6px 0 10px;
    padding-left: 8px;
    border-left: 3px solid var(--primary);
    line-height: 1.2;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}
.field label .hint {
    font-weight: 400;
    color: var(--text-3);
    font-size: 12px;
    margin-left: 4px;
}
.field input,
.field textarea,
.field select,
.input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fafbfc;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea {
    resize: vertical;
    line-height: 1.5;
}
.field textarea.mono {
    font-family: var(--mono);
    font-size: 12px;
}
.field input:focus,
.field textarea:focus,
.input-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(7, 193, 96, .14);
}
.field input:disabled {
    color: var(--text-3);
    background: #f0f2f5;
    cursor: not-allowed;
}
.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.input-group input { flex: 1; min-width: 0; font-family: var(--mono); }
.url-preview {
    font-size: 12px;
    color: var(--text-3);
    word-break: break-all;
}
.url-preview code { color: var(--primary-dark); background: var(--primary-soft); }
.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}
.checkbox-line input { accent-color: var(--primary); }
.icon-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.icon-preview {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #fff;
}
.icon-upload input[type="file"] { font-size: 13px; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .1s, box-shadow .15s, color .15s;
    box-shadow: 0 4px 12px rgba(7, 193, 96, .22);
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; box-shadow: none; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-ghost {
    background: #fff;
    color: var(--text-2);
    border-color: var(--border);
    box-shadow: none;
}
.btn-ghost:hover { background: #f5f7fa; color: var(--text); }
.btn-red { background: var(--danger); box-shadow: none; }
.btn-red:hover { background: #d92d20; }
.btn-red.btn-ghost {
    background: #fff;
    color: var(--danger);
    border-color: #fecdca;
}
.btn-red.btn-ghost:hover { background: var(--danger-soft); }
.btn-done { background: var(--primary-dark) !important; color: #fff !important; }
.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.actions form { display: inline-flex; align-items: center; gap: 6px; }
.actions select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    font-family: inherit;
}
.link {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}
.link:hover { text-decoration: underline; }

/* ===== 标签 / 提示 ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.tag-green { background: var(--primary-soft); color: var(--primary-dark); }
.tag-gray { background: #f0f2f5; color: var(--text-3); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.code-chip {
    display: inline-block;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-soft);
    padding: 3px 10px;
    border-radius: 8px;
}
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background: #ccc;
}
.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.6;
    word-break: break-all;
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-error { background: var(--danger-soft); color: #b42318; }
.alert-success { background: var(--primary-soft); color: var(--primary-dark); }

/* ===== 表格 ===== */
.table-scroll { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
    padding: 12px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}
th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    background: #fafbfc;
    letter-spacing: .3px;
}
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 8px 8px 0; }
tbody tr:hover { background: #fafcfd; }
tbody tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; }
.cell-mono {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-2);
}
.muted { color: var(--text-3); }
.empty-row td {
    text-align: center;
    color: var(--text-3);
    padding: 36px 12px;
}

/* ===== 登录页 ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(7, 193, 96, .18), transparent 60%),
        radial-gradient(700px 400px at 110% 110%, rgba(46, 124, 246, .12), transparent 60%),
        var(--bg);
}
.login-box { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-logo {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    margin: 0 auto 14px;
}
.login-brand .brand-logo svg { width: 28px; height: 28px; }
.login-brand h1 { font-size: 22px; font-weight: 700; }
.login-brand p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.login-card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(31, 35, 41, .08);
    padding: 26px 24px;
}
.login-card .field { margin-bottom: 14px; }
.login-card .btn-block { margin-top: 6px; }
.login-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-3);
    margin-top: 18px;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .sidenav {
        position: static;
        display: flex;
        gap: 4px;
        overflow-x: auto;
        padding: 6px;
    }
    .nav-item { white-space: nowrap; padding: 9px 12px; }
    .sidenav-tip { display: none; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .admin-wrap, .admin-layout { padding: 14px; }
    .card { padding: 16px; }
    .table-scroll { margin: 0 -16px; padding: 0 16px; }
    .topbar-inner { padding: 0 14px; }
    .link-banner { flex-wrap: wrap; }
    .link-banner-actions { flex-direction: row; width: 100%; }
    .stat .num { font-size: 22px; }
}
