/* ─── Reset & Base ───────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: #1890ff; text-decoration: none; }
a:hover { color: #40a9ff; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.main-content { flex: 1; padding: 20px 20px 40px; }
.mt-20 { margin-top: 20px; }

/* ─── Navbar ─────────────────────────────────────────────────── */
.navbar {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0 20px;
    height: 56px;
}
.nav-flex { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.nav-brand { font-size: 18px; font-weight: 700; color: #1890ff; }
.nav-brand i { margin-right: 6px; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-user { color: #666; font-size: 14px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 20px; border: none; border-radius: 6px;
    font-size: 14px; cursor: pointer; transition: all .2s;
    text-decoration: none; font-weight: 500;
}
.btn-primary { background: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; color: #fff; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; color: #fff; }
.btn-warning { background: #faad14; color: #fff; }
.btn-warning:hover { background: #ffc53d; color: #fff; }
.btn-outline { background: transparent; border: 1px solid #d9d9d9; color: #666; }
.btn-outline:hover { border-color: #1890ff; color: #1890ff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 17px; border-radius: 8px; }
.btn-link { background: none; color: #1890ff; padding: 4px 8px; }
.btn-link:hover { background: #e6f7ff; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 15px; color: #555; font-weight: 500; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid #d9d9d9;
    border-radius: 6px; font-size: 15px; transition: border-color .2s;
    outline: none;
}
.form-control:focus { border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.1); }
.form-sm { width: 200px; }
.form-row { display: flex; gap: 12px; align-items: center; }
.form-row .form-control { flex: 1; }
.form-inline-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.form-row-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: #fff; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 20px; overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.card-header h3 { font-size: 16px; font-weight: 600; color: #333; }
.card-header h3 i { margin-right: 8px; color: #1890ff; }
.card-body { padding: 20px; }

/* ─── Alerts ─────────────────────────────────────────────────── */
.flash-messages {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 9999; width: 90%; max-width: 480px;
}
.alert {
    padding: 12px 18px; border-radius: 10px; font-size: 14px;
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
    transition: opacity .3s;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
}
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #52c41a; }
.alert-error { background: #fff2f0; border: 1px solid #ffccc7; color: #ff4d4f; }
.alert-close { margin-left: auto; cursor: pointer; font-size: 18px; line-height: 1; }

/* ─── Auth Pages ─────────────────────────────────────────────── */
.auth-wrapper {
    display: flex; justify-content: center; align-items: center;
    min-height: 80vh;
}
.auth-card {
    background: #fff; border-radius: 12px; padding: 50px 60px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    width: 100%; max-width: 560px;
}
.auth-card-wide {
    max-width: 680px; padding: 50px 70px;
}
.auth-header { text-align: center; margin-bottom: 36px; }
.auth-icon { font-size: 56px; color: #1890ff; margin-bottom: 14px; display: block; }
.auth-header h2 { font-size: 24px; color: #333; font-weight: 700; }
.auth-title {
    font-size: 28px; font-weight: 700; color: #333;
    margin-bottom: 36px; text-align: left;
}
.auth-footer { text-align: center; margin-top: 28px; font-size: 15px; color: #999; }
.required { color: #ff4d4f; margin-right: 2px; }
.form-control-line {
    border: none; border-bottom: 1px solid #d9d9d9;
    border-radius: 0; padding: 10px 4px; font-size: 15px;
}
.form-control-line:focus {
    border-bottom-color: #1890ff;
    box-shadow: none;
}
.captcha-row { display: flex; align-items: center; gap: 16px; }
.captcha-row .form-control { flex: 1; }
.captcha-row canvas { border-radius: 4px; flex-shrink: 0; }
.auth-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 30px; padding-top: 10px;
}
.forgot-link { color: #1890ff; font-size: 14px; }
.auth-btns { display: flex; gap: 12px; }
.btn-auth { padding: 8px 32px; font-size: 15px; border-radius: 4px; }
.btn-info { background: #36cfc9; color: #fff; }
.btn-info:hover { background: #5cdbd3; color: #fff; }
.btn-send { padding: 6px 24px; font-size: 14px; flex-shrink: 0; }
.btn-disabled { background: #b0b0b0 !important; cursor: not-allowed; }
.auth-actions-right { justify-content: flex-end; }

/* ─── Dashboard User Card ────────────────────────────────────── */
.user-card-top {
    display: flex; align-items: center; gap: 20px;
    padding: 24px; background: linear-gradient(135deg, #1890ff 0%, #36cfc9 100%);
    color: #fff;
}
.user-avatar { font-size: 60px; opacity: 0.9; }
.user-info-main h2 { font-size: 22px; margin-bottom: 4px; }
.uid-badge {
    background: rgba(255,255,255,0.2); padding: 2px 10px;
    border-radius: 10px; font-size: 13px;
}
.user-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    padding: 0;
}
.stat-item {
    padding: 20px 24px; border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 13px; color: #999; margin-bottom: 6px; }
.stat-value { font-size: 18px; font-weight: 600; color: #333; }
.points-value { color: #1890ff; }
.stat-sub { font-size: 12px; color: #aaa; margin-top: 4px; }
.stat-actions { margin-top: 8px; }

/* ─── Recharge Form ──────────────────────────────────────────── */
.recharge-form .form-row { max-width: 500px; }

/* ─── Announcements ──────────────────────────────────────────── */
.announcement-list { max-height: 300px; overflow-y: auto; }
.announcement-item {
    padding: 12px 0; border-bottom: 1px solid #f5f5f5;
}
.announcement-item:last-child { border-bottom: none; }
.announcement-content { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.announcement-time { font-size: 12px; color: #aaa; margin-top: 6px; }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.table th { background: #fafafa; font-weight: 600; color: #666; font-size: 13px; }
.table tbody tr:hover { background: #f8faff; }
.action-cell { display: flex; gap: 6px; }
code { background: #f5f5f5; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 10px;
    font-size: 12px; font-weight: 500;
}
.badge-green { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.badge-red { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }

/* ─── Edit Panel ─────────────────────────────────────────────── */
.edit-row td { background: #fafafa; }
.edit-panel { display: flex; flex-direction: column; gap: 8px; }

/* ─── Generated textarea ─────────────────────────────────────── */
.generated-textarea { font-family: monospace; font-size: 13px; resize: vertical; }

/* ─── Site Sidebar Layout ────────────────────────────────────── */
.has-sidebar { display: flex; flex-direction: column; }
.site-sidebar {
    width: 220px; background: #1d2029; color: #fff;
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; bottom: 0; z-index: 200;
}
.site-sidebar .sidebar-brand {
    padding: 18px 20px; font-size: 17px; font-weight: 700;
    display: flex; align-items: center; gap: 10px; color: #fff;
}
.site-sidebar .sidebar-nav { flex: 1; padding: 0; }
.site-sidebar .sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; color: rgba(255,255,255,0.65);
    font-size: 14px; transition: all .2s; text-decoration: none;
}
.site-sidebar .sidebar-link:hover { color: #fff; }
.site-sidebar .sidebar-link.active { color: #409eff; }
.site-sidebar .sidebar-link i { width: 18px; text-align: center; }

/* Sidebar menu group (collapsible) */
.sidebar-group-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; color: rgba(255,255,255,0.65);
    font-size: 14px; cursor: pointer; transition: all .2s;
    user-select: none;
}
.sidebar-group-header:hover { color: #fff; }
.sidebar-group.open .sidebar-group-header { color: #fff; }
.sidebar-group-header .group-title {
    display: flex; align-items: center; gap: 10px;
}
.sidebar-group-header .group-title i { width: 18px; text-align: center; }
.sidebar-group-header .group-arrow {
    font-size: 12px; transition: transform .25s; color: rgba(255,255,255,0.35);
}
.sidebar-group.open .sidebar-group-header .group-arrow { transform: rotate(180deg); }
.sidebar-group-items {
    max-height: 0; overflow: hidden; transition: max-height .3s ease;
}
.sidebar-group.open .sidebar-group-items { max-height: 300px; }
.sidebar-group-items .sidebar-link {
    padding: 12px 20px 12px 52px; font-size: 13px;
    color: rgba(255,255,255,0.65);
}
.sidebar-group-items .sidebar-link:hover { color: #fff; }
.sidebar-group-items .sidebar-link.active { color: #fff; }

.site-header {
    position: fixed; top: 0; left: 220px; right: 0; height: 50px; z-index: 150;
    background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
}
.header-left { display: flex; align-items: center; }
.mobile-menu-btn {
    display: none; background: none; border: none; font-size: 18px;
    color: #666; cursor: pointer; padding: 4px 8px;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.header-uid { font-size: 13px; color: #999; background: #f0f2f5; padding: 4px 12px; border-radius: 12px; }
.header-btn {
    font-size: 13px; color: #666; text-decoration: none;
    padding: 4px 12px; border-radius: 4px; transition: all .2s;
}
.header-btn:hover { color: #1890ff; background: #e6f7ff; }
.header-btn-logout:hover { color: #ff4d4f; background: #fff2f0; }

.site-main {
    margin-left: 220px; margin-top: 50px;
    padding: 24px; min-height: calc(100vh - 50px - 48px);
}
.site-footer {
    margin-left: 220px;
    text-align: center; padding: 16px 0; color: #aaa; font-size: 13px;
}

/* ─── Dialog Box ─────────────────────────────────────────────── */
.dialog-box {
    border: none; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 0; width: 100%; max-width: 440px;
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
.dialog-box::backdrop { background: rgba(0,0,0,0.4); }
.dialog-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid #f0f0f0;
}
.dialog-header h3 { font-size: 16px; font-weight: 600; }
.dialog-close {
    background: none; border: none; font-size: 22px; color: #999;
    cursor: pointer; line-height: 1; padding: 0;
}
.dialog-close:hover { color: #333; }
.dialog-body { padding: 24px; }

/* ─── Admin Layout ───────────────────────────────────────────── */
.admin-body { background: #f0f2f5; }
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 240px; background: #001529; color: #fff;
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; bottom: 0; z-index: 100;
}
.admin-sidebar .sidebar-brand {
    padding: 20px; font-size: 18px; font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 10px;
}
.admin-sidebar .sidebar-nav { flex: 1; padding: 10px 0; }
.admin-sidebar .sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 24px; color: rgba(255,255,255,0.65);
    font-size: 14px; transition: all .2s;
}
.admin-sidebar .sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.05); }
.admin-sidebar .sidebar-link.active { color: #fff; background: #1890ff; }
.admin-sidebar .sidebar-link i { width: 16px; text-align: center; }
.sidebar-footer {
    padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; color: rgba(255,255,255,0.5);
}
.sidebar-footer a { color: rgba(255,255,255,0.5); font-size: 16px; }
.sidebar-footer a:hover { color: #fff; }

.admin-main { flex: 1; margin-left: 240px; }
.admin-topbar {
    background: #fff; padding: 16px 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.admin-topbar h1 { font-size: 18px; font-weight: 600; }
.admin-content { padding: 24px; }

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card {
    background: #fff; border-radius: 8px; padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex; align-items: center; gap: 16px;
}
.stat-card-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
}
.bg-blue { background: #1890ff; }
.bg-green { background: #52c41a; }
.bg-orange { background: #faad14; }
.bg-purple { background: #722ed1; }
.stat-card-value { font-size: 24px; font-weight: 700; color: #333; }
.stat-card-label { font-size: 13px; color: #999; }

.text-muted { color: #999; }

/* ─── Settings Dialog ──────────────────────────────────────── */
.dialog-wide { width: 600px; max-width: 92%; padding: 0; border: none; border-radius: 6px; overflow: hidden; }
.dialog-wide::backdrop { background: rgba(0,0,0,0.4); }
.dialog-header-blue {
    background: #409eff; color: #fff;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; margin: 0;
}
.dialog-header-blue h3 { color: #fff; margin: 0; font-size: 16px; font-weight: 500; }
.dialog-header-blue .dialog-close { color: #fff; background: none; border: none; font-size: 22px; cursor: pointer; }
.settings-layout { display: flex; min-height: 360px; }
.settings-side {
    width: 130px; background: #fafafa; border-right: 1px solid #ebeef5;
    display: flex; flex-direction: column; padding: 20px 0;
}
.settings-tab {
    padding: 12px 20px; font-size: 14px; color: #606266;
    text-decoration: none; border-left: 3px solid transparent;
    transition: all .2s; cursor: pointer;
}
.settings-tab:hover { color: #409eff; }
.settings-tab.active { color: #409eff; background: #fff; border-left-color: #409eff; }
.settings-content { flex: 1; padding: 24px 28px; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.settings-pane .form-group { margin-bottom: 16px; }
.settings-pane label { display: block; margin-bottom: 6px; font-size: 13px; color: #606266; }
.dialog-body .form-row { display: flex; gap: 16px; }
.dialog-body .form-group { margin-bottom: 14px; }
.dialog-body .form-group > label { display: block; margin-bottom: 6px; font-size: 13px; color: #606266; }

/* ─── Breadcrumb ────────────────────────────────────────────── */
.breadcrumb {
    font-size: 13px; color: #999; margin-bottom: 16px;
}

/* ─── Table cell helpers ────────────────────────────────────── */
.table { border: 1px solid #ebeef5; border-collapse: collapse; }
.table th, .table td {
    border-right: 1px solid #ebeef5;
    border-bottom: 1px solid #ebeef5;
    padding: 10px 12px;
    color: #333;
}
.table th { background: #fafafa; font-weight: 500; color: #666; }
.table th:last-child, .table td:last-child { border-right: none; }
.table tbody tr:hover { background: #f5f7fa; }
.text-orange { color: #f56c6c; font-weight: 500; }
.badge-info {
    display: inline-block; padding: 2px 10px; border-radius: 3px;
    font-size: 12px; background: #ecf5ff; color: #409eff;
    border: 1px solid #d9ecff;
}
.badge-green {
    display: inline-block; padding: 2px 10px; border-radius: 3px;
    font-size: 12px; background: #f0f9eb; color: #67c23a;
    border: 1px solid #e1f3d8;
}
.badge-warning {
    display: inline-block; padding: 2px 10px; border-radius: 3px;
    font-size: 12px; background: #fef0f0; color: #f56c6c;
    border: 1px solid #fbc4c4;
}
.link-primary { color: #409eff; text-decoration: none; font-size: 13px; }
.link-primary:hover { color: #66b1ff; text-decoration: underline; }
.link-danger { color: #f56c6c; text-decoration: none; font-size: 13px; }
.link-danger:hover { color: #f78989; text-decoration: underline; }
.link-success { color: #67c23a; text-decoration: none; font-size: 13px; }
.link-success:hover { color: #85ce61; text-decoration: underline; }
.op-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
    min-width: 180px;
}
.op-btn {
    background: none; border: none; cursor: pointer; padding: 0;
    font-size: 13px; text-align: left; white-space: nowrap;
}
.op-btn i { margin-right: 4px; font-size: 12px; }

/* ─── Search Bar ────────────────────────────────────────────── */
.search-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.search-bar label { font-size: 13px; color: #666; white-space: nowrap; }
.form-control-sm { padding: 6px 10px; font-size: 13px; width: 140px; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-xs { padding: 3px 10px; font-size: 12px; }
.btn-success {
    background: #67c23a; color: #fff; border: none; border-radius: 4px;
    cursor: pointer; transition: background .2s;
}
.btn-success:hover { background: #5daf34; }

/* ─── Tab Nav ───────────────────────────────────────────────── */
.tab-nav {
    display: flex; gap: 0; border-bottom: 2px solid #e8e8e8; margin-bottom: 20px;
}
.tab-item {
    padding: 10px 24px; font-size: 14px; color: #666;
    text-decoration: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all .2s;
}
.tab-item:hover { color: #409eff; }
.tab-item.active { color: #409eff; border-bottom-color: #409eff; }

/* ─── Gift Grid ─────────────────────────────────────────────── */
.gift-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px; margin-top: 16px;
}
.gift-card {
    background: #fff; border: 1px solid #eee; border-radius: 8px;
    padding: 20px; text-align: center;
}
.gift-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.gift-desc { font-size: 13px; color: #999; margin-bottom: 12px; }
.gift-price { font-size: 20px; font-weight: 700; color: #ff4d4f; margin-bottom: 12px; }

/* ─── Table Footer ──────────────────────────────────────────── */
.table-footer {
    padding: 12px 0; font-size: 13px; color: #999; text-align: right;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.footer { text-align: center; padding: 16px 0; color: #aaa; font-size: 13px; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .site-sidebar {
        transform: translateX(-100%); transition: transform .3s;
    }
    .sidebar-open .site-sidebar { transform: translateX(0); }
    .site-header { left: 0; }
    .site-main { margin-left: 0; }
    .site-footer { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .admin-sidebar { width: 200px; }
    .admin-main { margin-left: 200px; }
    .user-stats { grid-template-columns: 1fr; }
    .stat-item { border-right: none; }
    .form-row { flex-direction: column; }
    .form-row .form-control { width: 100%; }
}
@media (max-width: 576px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; }
    .auth-card { margin: 20px; padding: 28px 24px; }
}
