/* ================= 基础重置 ================= */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: #111827;
    -webkit-font-smoothing: antialiased;
}

a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ================= 前台 ================= */
body.public {
    min-height: 100vh;
    background: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 100%);
    position: relative;
    overflow-x: hidden;
}

.bg-decoration {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(700px 400px at 12% 8%, rgba(99, 102, 241, .22), transparent 60%),
        radial-gradient(600px 400px at 88% 92%, rgba(236, 72, 153, .18), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 780px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 46px;
}

.logo { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.site-header nav a { font-size: 14px; color: #4b5563; }

.hero { text-align: center; margin-bottom: 34px; }
.hero h1 {
    font-size: 34px;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #4f46e5, #a855f7 55%, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -.5px;
}
.hero p { margin: 0; color: #6b7280; font-size: 15px; }

.card {
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 12px 40px rgba(79, 70, 229, .10), 0 2px 8px rgba(0, 0, 0, .04);
    border: 1px solid rgba(255, 255, 255, .8);
}

.input-row { display: flex; gap: 10px; }

.input-row input[type="text"] {
    flex: 1;
    padding: 14px 16px;
    font-size: 15px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: .2s;
    min-width: 0;
}
.input-row input[type="text"]:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.input-row button {
    padding: 0 26px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 18px rgba(99, 102, 241, .35);
    transition: .2s;
    white-space: nowrap;
}
.input-row button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(99, 102, 241, .42); }
.input-row button:disabled { opacity: .65; cursor: not-allowed; }

.options-toggle { margin-top: 14px; text-align: right; }

.link-btn {
    background: none;
    border: 0;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
}
.link-btn:hover { color: #6366f1; }

.options {
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px dashed #e5e7eb;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.options label {
    display: block;
    font-size: 12.5px;
    color: #4b5563;
    font-weight: 600;
}

.options input {
    width: 100%;
    margin-top: 6px;
    padding: 10px 13px;
    font-size: 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    transition: .2s;
}
.options input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }

/* ---- 提示信息 ---- */
.message {
    margin-top: 18px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
}
.message.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.message.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

/* ---- 生成结果 ---- */
.result {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px dashed #e5e7eb;
    animation: fadeUp .3s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.result-main {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f3ff;
    border: 1.5px solid #ddd6fe;
    border-radius: 12px;
    padding: 12px 16px;
}
.result-main a {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #5b21b6;
    word-break: break-all;
}
.result-main button {
    padding: 8px 18px;
    border: 0;
    border-radius: 9px;
    background: #6366f1;
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}
.result-main button:hover { background: #4f46e5; }

.result-extra {
    display: flex;
    gap: 20px;
    margin-top: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.qr img {
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    display: block;
    background: #fff;
}
.result-extra .meta { flex: 1; min-width: 200px; font-size: 13.5px; color: #4b5563; }
.result-extra .meta p { margin: 0 0 8px; word-break: break-all; line-height: 1.7; }
.muted { color: #9ca3af; font-size: 12.5px; }

.site-footer { text-align: center; margin-top: 44px; color: #9ca3af; font-size: 13px; }

/* ================= 后台 ================= */
body.admin {
    background: #f1f5f9;
    min-height: 100vh;
}

.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 226px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1e293b, #0f172a);
    color: #cbd5e1;
    padding: 22px 0;
    display: flex;
    flex-direction: column;
}
.sidebar .brand {
    padding: 0 22px 22px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 14px;
}
.sidebar a {
    display: block;
    padding: 12px 22px;
    color: #cbd5e1;
    font-size: 14px;
    transition: .15s;
    border-left: 3px solid transparent;
}
.sidebar a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar a.active {
    background: rgba(99, 102, 241, .18);
    color: #fff;
    border-left-color: #6366f1;
    font-weight: 600;
}
.sidebar .spacer { flex: 1; }
.sidebar .logout { color: #f87171; }

.main {
    flex: 1;
    padding: 28px 32px 60px;
    min-width: 0;
}

.page-title {
    font-size: 22px;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.page-title small { font-size: 13px; color: #64748b; font-weight: 400; }

.panel {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .07);
    margin-bottom: 22px;
}

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
    text-align: left;
    padding: 12px 14px;
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
table.data td {
    padding: 13px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
table.data tr:hover td { background: #fafbff; }
table.data .url-cell {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #475569;
}
table.data .code-cell a { font-weight: 600; color: #4f46e5; }

/* ---- 徽章 ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge.active   { background: #dcfce7; color: #15803d; }
.badge.disabled { background: #f1f5f9; color: #64748b; }
.badge.expired  { background: #fee2e2; color: #b91c1c; }

/* ---- 按钮 ---- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border: 0;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: .15s;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-light { background: #eef2ff; color: #4338ca; }
.btn-light:hover { background: #e0e7ff; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ---- 表单 ---- */
.form-grid { display: grid; gap: 16px; max-width: 640px; }
.form-grid label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-grid .hint { font-size: 12px; color: #94a3b8; font-weight: 400; margin-left: 6px; }

.form-grid input[type="text"],
.form-grid input[type="password"],
.form-grid input[type="number"],
.form-grid input[type="datetime-local"],
.form-grid select {
    width: 100%;
    padding: 10px 13px;
    font-size: 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    outline: none;
    transition: .2s;
    background: #fff;
}
.form-grid input:focus, .form-grid select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.search-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    font-size: 14px;
    outline: none;
}
.search-bar input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }

/* ---- 分页 ---- */
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span {
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 13px;
    background: #f1f5f9;
    color: #475569;
}
.pagination a:hover { background: #e0e7ff; color: #4338ca; text-decoration: none; }
.pagination .current { background: #6366f1; color: #fff; font-weight: 600; }
.pagination .info { background: none; color: #94a3b8; padding: 7px 4px; }

/* ---- 统计卡片 ---- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: #fff;
    border-radius: 13px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .07);
}
.stat-card .label { font-size: 12.5px; color: #64748b; margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: #1e293b; letter-spacing: -.5px; }

/* ---- 柱状图 ---- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; overflow-x: auto; }
.bars .bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
                 min-width: 42px; flex: 1; height: 100%; }
.bars .bar {
    width: 100%;
    max-width: 38px;
    background: linear-gradient(180deg, #818cf8, #6366f1);
    border-radius: 6px 6px 0 0;
    min-height: 3px;
    transition: .3s;
}
.bars .bar-label { font-size: 11px; color: #94a3b8; margin-top: 6px; white-space: nowrap; }
.bars .bar-value { font-size: 11px; color: #6366f1; font-weight: 600; margin-bottom: 4px; }

/* ---- 登录页 ---- */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6 50%, #ec4899);
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 390px;
    background: #fff;
    border-radius: 18px;
    padding: 36px 32px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}
.login-box h1 { margin: 0 0 6px; font-size: 21px; text-align: center; }
.login-box .sub { margin: 0 0 24px; text-align: center; font-size: 13px; color: #94a3b8; }
.login-box label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.login-box input {
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 16px;
    outline: none;
    transition: .2s;
}
.login-box input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .13); }
.login-box button {
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.login-box button:hover { filter: brightness(1.06); }
.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* ---- 响应式 ---- */
@media (max-width: 720px) {
    .hero h1 { font-size: 26px; }
    .input-row { flex-direction: column; }
    .input-row button { padding: 14px; }
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 0; }
    .sidebar .brand { display: none; }
    .sidebar a { padding: 14px 16px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .sidebar a.active { border-left: none; border-bottom-color: #6366f1; }
    .sidebar .spacer { display: none; }
    .main { padding: 20px 16px 50px; }
    table.data .url-cell { max-width: 160px; }
}