*,
        *::before,
        *::after {
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: #f0f0f0;
            color: #333;
            margin: 0;
            padding: 24px;
            min-height: 100vh;
        }

        /* ── Layout ──────────────────────────────────────────────── */
        .container {
            max-width: 1000px;
            margin: 0 auto;
        }

        /* ── Header ─────────────────────────────────────────────── */
        .admin-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
        }

        .admin-title {
            font-size: 22px;
            font-weight: 700;
            color: #111;
            letter-spacing: -0.3px;
        }

        .header-actions {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        /* ── Buttons ────────────────────────────────────────────── */
        button {
            padding: 8px 16px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-family: inherit;
            font-size: 13px;
            font-weight: 500;
            transition: all .2s ease;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            line-height: 1.4;
        }

        .btn-primary {
            background: #111;
            color: #fff;
        }

        .btn-primary:hover {
            background: #333;
        }

        .btn-secondary {
            background: #e8e8e8;
            color: #444;
        }

        .btn-secondary:hover {
            background: #d8d8d8;
            color: #222;
        }

        .btn-danger {
            background: #fff0f0;
            color: #c0392b;
            font-size: 12px;
        }

        .btn-danger:hover {
            background: #ffe0e0;
        }

        .btn-icon {
            background: transparent;
            border: 1px solid rgba(0, 0, 0, 0.12);
            border-radius: 8px;
            padding: 0;
            width: 34px;
            height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: #666;
        }

        .btn-icon:hover {
            color: #111;
            border-color: rgba(0, 0, 0, 0.25);
        }

        .btn-icon svg {
            width: 15px;
            height: 15px;
        }

        /* Sponsor toggle states */
        #sponsorToggleBtn.sponsor-on {
            color: #16a34a;
            border-color: rgba(22, 163, 74, 0.3);
        }

        #sponsorToggleBtn.sponsor-off {
            color: #999;
        }

        /* ── Cards / Panels ─────────────────────────────────────── */
        .panel {
            background: #fff;
            border: 1px solid #e5e5e5;
            border-radius: 14px;
            padding: 24px;
            margin-bottom: 20px;
        }

        .panel-title {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            margin: 0 0 16px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .panel-title svg {
            width: 16px;
            height: 16px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            color: #888;
        }

        /* ── Tabs ───────────────────────────────────────────────── */
        .tabs {
            display: flex;
            gap: 20px;
            margin-bottom: 24px;
            border-bottom: 1px solid #e0e0e0;
        }

        .tab {
            padding: 10px 16px;
            font-size: 15px;
            font-weight: 600;
            color: #666;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            transition: all .2s;
        }

        .tab:hover {
            color: #111;
        }

        .tab.active {
            color: #111;
            border-bottom-color: #111;
        }

        [data-theme="dark"] .tabs {
            border-bottom-color: rgba(255, 255, 255, 0.08);
        }

        [data-theme="dark"] .tab {
            color: #888;
        }

        [data-theme="dark"] .tab:hover {
            color: #d0d0d0;
        }

        [data-theme="dark"] .tab.active {
            color: #fff;
            border-bottom-color: #fff;
        }

        .tab-pane {
            display: none;
        }

        .tab-pane.active {
            display: block;
        }

        /* ── Stats Panel ────────────────────────────────────────── */
        #statsChart {
            max-height: 220px;
        }

        /* ── Media Panel ────────────────────────────────────────── */
        .media-upload-row {
            display: flex;
            gap: 12px;
            align-items: center;
            margin-bottom: 14px;
        }

        .media-upload-row input[type="file"] {
            flex: 1;
            font-size: 13px;
        }

        #uploadMsg {
            font-size: 13px;
            color: #666;
            margin: 0 0 14px;
        }

        .media-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 12px;
        }

        .media-item {
            border: 1px solid #e8e8e8;
            border-radius: 10px;
            overflow: hidden;
            background: #fafafa;
        }

        .media-item img {
            width: 100%;
            height: 100px;
            object-fit: cover;
            display: block;
        }

        .media-item-info {
            padding: 8px 10px;
        }

        .media-item-name {
            font-size: 11px;
            color: #777;
            margin: 0 0 6px;
            word-break: break-all;
            line-height: 1.3;
        }

        .media-item button {
            width: 100%;
            font-size: 12px;
            padding: 5px 8px;
        }

        /* WeChat QR section */
        .wechat-qr-section {
            margin-top: 20px;
            padding-top: 18px;
            border-top: 1px solid #eee;
        }

        .wechat-qr-section h4 {
            margin: 0 0 14px;
            font-size: 14px;
            font-weight: 600;
            color: #333;
        }

        .wechat-qr-row {
            display: flex;
            gap: 20px;
            align-items: flex-start;
            flex-wrap: wrap;
        }

        .wechat-qr-preview {
            width: 110px;
            height: 110px;
            border-radius: 10px;
            border: 1px solid #e0e0e0;
            object-fit: cover;
            flex-shrink: 0;
        }

        .wechat-qr-controls {
            flex: 1;
            min-width: 200px;
        }

        .wechat-qr-controls label {
            font-size: 12px;
            color: #888;
            display: block;
            margin-bottom: 6px;
        }

        .wechat-qr-input-row {
            display: flex;
            gap: 8px;
        }

        .wechat-qr-input-row input {
            flex: 1;
            padding: 9px 12px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-family: inherit;
            font-size: 13px;
        }

        .wechat-qr-hint {
            font-size: 11px;
            color: #aaa;
            margin: 8px 0 0;
        }

        /* ── Table ──────────────────────────────────────────────── */
        .table-panel {
            padding: 0;
            overflow: hidden;
        }

        .table-panel-header {
            padding: 20px 24px 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th,
        td {
            text-align: left;
            padding: 10px 16px;
            border-bottom: 1px solid #f0f0f0;
            font-size: 13px;
        }

        th {
            font-weight: 600;
            font-size: 13px;
            color: #777;
            background: #f9f9f9;
        }

        tr:last-child td {
            border-bottom: none;
        }

        tr:hover td {
            background: #fafafa;
        }

        /* ── Pagination ─────────────────────────────────────────── */
        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 6px;
            padding: 20px;
            border-top: 1px solid #f0f0f0;
        }

        .page-btn {
            min-width: 32px;
            height: 32px;
            padding: 0 8px;
            border-radius: 6px;
            border: 1px solid #e0e0e0;
            background: #fff;
            color: #555;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            display: inline-flex;
            justify-content: center;
            align-items: center;
            transition: all .2s;
        }

        .page-btn:hover:not(:disabled) {
            border-color: #111;
            color: #111;
        }

        .page-btn.active {
            background: #111;
            border-color: #111;
            color: #fff;
        }

        .page-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        [data-theme="dark"] .pagination {
            border-top-color: rgba(255, 255, 255, 0.05);
        }

        [data-theme="dark"] .page-btn {
            background: #181818;
            border-color: rgba(255, 255, 255, 0.1);
            color: #aaa;
        }

        [data-theme="dark"] .page-btn:hover:not(:disabled) {
            border-color: #fff;
            color: #fff;
        }

        [data-theme="dark"] .page-btn.active {
            background: #fff;
            border-color: #fff;
            color: #111;
        }

        .td-actions {
            display: flex;
            gap: 6px;
        }

        .td-id {
            font-family: 'SF Mono', 'Fira Code', monospace;
            font-size: 12px;
            color: #666;
        }

        /* ── Login ──────────────────────────────────────────────── */
        #loginOverlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f5f5f5;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-box {
            text-align: center;
            width: 320px;
            background: #fff;
            padding: 40px 32px;
            border-radius: 16px;
            border: 1px solid #e8e8e8;
            box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06);
        }

        .login-box h2 {
            margin: 0 0 24px;
            font-size: 20px;
            font-weight: 700;
            color: #111;
        }

        .login-box input {
            width: 100%;
            padding: 11px 14px;
            margin-bottom: 12px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            font-family: inherit;
            font-size: 14px;
            transition: border-color .2s;
        }

        .login-box input:focus {
            outline: none;
            border-color: #111;
        }

        /* ── Modal ──────────────────────────────────────────────── */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(4px);
            z-index: 500;
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: #fff;
            padding: 30px;
            border-radius: 16px;
            width: 600px;
            max-width: 90%;
            max-height: 90vh;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
        }

        .modal-content h3 {
            margin: 0 0 20px;
            font-size: 18px;
            font-weight: 700;
        }

        .modal-body {
            flex: 1;
            overflow-y: auto;
            padding-right: 8px;
        }

        .form-group {
            margin-bottom: 16px;
        }

        .form-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 600;
            font-size: 12px;
            color: #666;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }

        .form-group input,
        .form-group textarea,
        .form-group select {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            font-family: inherit;
            font-size: 14px;
            transition: border-color .2s;
        }

        .form-group input:focus,
        .form-group textarea:focus,
        .form-group select:focus {
            outline: none;
            border-color: #111;
        }

        .form-group textarea {
            resize: vertical;
            min-height: 80px;
        }

        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #f0f0f0;
        }

        /* ── Link rows ─────────────────────────────────────────── */
        .link-row {
            display: flex;
            gap: 8px;
            margin-bottom: 8px;
        }

        .link-row input {
            flex: 1;
        }

        .link-row button {
            padding: 0 12px;
            font-weight: 600;
            background: #fff0f0;
            color: #c0392b;
            border-radius: 6px;
        }

        .tag-input-desc {
            font-size: 12px;
            color: #aaa;
            margin-top: 4px;
        }

        /* ── Toast ──────────────────────────────────────────────── */
        #toast {
            position: fixed;
            top: 24px;
            right: 24px;
            padding: 12px 20px;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 500;
            color: #fff;
            opacity: 0;
            transition: opacity .3s;
            z-index: 9999;
            pointer-events: none;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        }

        #toast.show {
            opacity: 1;
        }

        #toast.success {
            background: #1a7f37;
        }

        #toast.error {
            background: #c0392b;
        }

        /* =========================================
           Dark Theme Overrides
           ========================================= */
        html {
            transition: background .25s, color .25s;
        }

        [data-theme="dark"] body {
            background: #0e0e0e;
            color: #c8c8c8;
        }

        [data-theme="dark"] .admin-title {
            color: #e0e0e0;
        }

        [data-theme="dark"] .panel {
            background: #181818;
            border-color: rgba(255, 255, 255, 0.06);
        }

        [data-theme="dark"] .panel-title {
            color: #c0c0c0;
        }

        [data-theme="dark"] .panel-title svg {
            color: #555;
        }

        [data-theme="dark"] .btn-primary {
            background: #e0e0e0;
            color: #111;
        }

        [data-theme="dark"] .btn-primary:hover {
            background: #fff;
        }

        [data-theme="dark"] .btn-secondary {
            background: #222;
            color: #aaa;
        }

        [data-theme="dark"] .btn-secondary:hover {
            background: #2e2e2e;
            color: #d0d0d0;
        }

        [data-theme="dark"] .btn-danger {
            background: rgba(200, 50, 50, 0.12);
            color: #e88;
        }

        [data-theme="dark"] .btn-danger:hover {
            background: rgba(200, 50, 50, 0.2);
        }

        [data-theme="dark"] .btn-icon {
            color: #666;
            border-color: rgba(255, 255, 255, 0.1);
        }

        [data-theme="dark"] .btn-icon:hover {
            color: #d0d0d0;
            border-color: rgba(255, 255, 255, 0.25);
        }

        [data-theme="dark"] #sponsorToggleBtn.sponsor-off {
            border-color: rgba(255, 255, 255, 0.08);
        }

        /* Login */
        [data-theme="dark"] #loginOverlay {
            background: #0e0e0e;
        }

        [data-theme="dark"] .login-box {
            background: #181818;
            border-color: rgba(255, 255, 255, 0.06);
            box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
        }

        [data-theme="dark"] .login-box h2 {
            color: #e0e0e0;
        }

        [data-theme="dark"] .login-box input {
            background: #111;
            border-color: rgba(255, 255, 255, 0.1);
            color: #d0d0d0;
        }

        /* Table */
        [data-theme="dark"] th {
            background: #141414;
            color: #555;
            border-bottom-color: rgba(255, 255, 255, 0.05);
        }

        [data-theme="dark"] td {
            color: #bbb;
            border-bottom-color: rgba(255, 255, 255, 0.05);
        }

        [data-theme="dark"] tr:hover td {
            background: #1a1a1a;
        }

        [data-theme="dark"] .td-id {
            color: #888;
        }

        /* Modal */
        [data-theme="dark"] .modal-content {
            background: #181818;
            color: #c8c8c8;
            box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
        }

        [data-theme="dark"] .form-group label {
            color: #777;
        }

        [data-theme="dark"] .form-group input,
        [data-theme="dark"] .form-group textarea,
        [data-theme="dark"] .form-group select {
            background: #111;
            border-color: rgba(255, 255, 255, 0.08);
            color: #d0d0d0;
        }

        [data-theme="dark"] .modal-footer {
            border-top-color: rgba(255, 255, 255, 0.06);
        }

        [data-theme="dark"] .link-row button {
            background: rgba(200, 50, 50, 0.12);
            color: #e88;
        }

        /* Media panel */
        [data-theme="dark"] .media-item {
            background: #1a1a1a;
            border-color: rgba(255, 255, 255, 0.06);
        }

        [data-theme="dark"] .media-item-name {
            color: #888;
        }

        [data-theme="dark"] .wechat-qr-section {
            border-top-color: rgba(255, 255, 255, 0.06);
        }

        [data-theme="dark"] .wechat-qr-section h4 {
            color: #c0c0c0;
        }

        [data-theme="dark"] .wechat-qr-preview {
            border-color: rgba(255, 255, 255, 0.08);
        }

        [data-theme="dark"] .wechat-qr-controls label {
            color: #666;
        }

        [data-theme="dark"] .wechat-qr-input-row input {
            background: #111;
            border-color: rgba(255, 255, 255, 0.08);
            color: #d0d0d0;
        }

        [data-theme="dark"] .wechat-qr-hint {
            color: #555;
        }

        /* Stats panel */
        [data-theme="dark"] #statsPanel {
            background: #181818;
        }

        /* Responsive */
        @media (max-width: 768px) {
            body {
                padding: 12px;
            }

            .admin-header {
                flex-direction: column;
                gap: 12px;
                align-items: flex-start;
            }

            .header-actions {
                flex-wrap: wrap;
            }

            th,
            td {
                padding: 10px 14px;
            }

            .modal-content {
                padding: 20px;
            }
        }
