:root {
    color-scheme: dark;
    --bg: #000000;
    --card-bg: #0a0a0a;
    --border: #222;
    --text-primary: #ededed;
    --text-secondary: #a1a1aa;
    --primary: #ffffff;
    --primary-hover: #e5e5e5;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 6px;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 24px;
}

/* Navigation */
.nav {
    display: flex;
    gap: 32px;
    margin-bottom: 48px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
    align-items: center;
}

.nav a {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    padding: 12px 0;
    transition: color 0.2s;
    position: relative;
}

.nav a:hover {
    color: var(--text-primary);
}

.nav a.active {
    color: var(--text-primary);
}

.nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--text-primary);
}

.nav #logout-btn {
    margin-left: auto;
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
}

.nav #logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

/* Buttons */
button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
}

button:hover {
    border-color: var(--text-secondary);
}

button.primary {
    background: var(--primary);
    color: #000;
    border: 1px solid var(--primary);
}

button.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

button.danger {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
}

button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

/* Tab Buttons (for login/register) */
.tab-group {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: #111;
    padding: 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 4px; /* slightly smaller radius inside */
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
    border-color: transparent;
}

.tab-btn.active {
    background: var(--bg);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 24px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h2 {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 16px;
    color: var(--text-primary);
}

/* Forms */
input, textarea, select {
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--text-secondary);
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

/* Utility */
.muted {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item > div:first-child {
    flex: 1;
    margin-right: 16px;
}

.small {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Status */
.status {
    padding: 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-top: 16px;
}
.status.error { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.status.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }

/* Table for Admin */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th {
    text-align: left;
    padding: 12px 8px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}
td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Admin Page Layout */
.admin-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a0a 0%, #111827 50%, #0a0a0a 100%);
}

/* Login Screen - Centered */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
    animation: bgFloat 20s ease-in-out infinite alternate;
}

@keyframes bgFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-2%, 2%) rotate(1deg); }
}

.login-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: rgba(15, 15, 18, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 48px 40px 40px;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.03) inset,
                0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.login-box h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box h1::after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    border-radius: 2px;
    margin: 16px auto 0;
}

#admin-login-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 32px;
}

#admin-login-form input[type="text"],
#admin-login-form input[type="password"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.25s ease;
    box-sizing: border-box;
    margin-bottom: 0;
}

#admin-login-form input[type="text"]:focus,
#admin-login-form input[type="password"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 0 20px rgba(99, 102, 241, 0.08);
    background: rgba(0, 0, 0, 0.5);
}

#admin-login-form input::placeholder {
    color: #555;
    font-size: 13px;
}

#admin-login-form button[type="submit"] {
    width: 100%;
    padding: 14px 20px;
    margin-top: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

#admin-login-form button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.45);
    filter: brightness(1.1);
}

#admin-login-form button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.error-msg {
    text-align: center;
    color: #ef4444;
    font-size: 13px;
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 8px;
    animation: shakeIn 0.35s ease-out;
}

@keyframes shakeIn {
    0% { opacity: 0; transform: translateX(-8px); }
    30% { transform: translateX(6px); }
    60% { transform: translateX(-3px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Admin Panel */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: rgba(15, 15, 18, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
}

.admin-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.admin-main {
    max-width: min(1800px, 95vw);
    margin: 0 auto;
    padding: 28px 40px;
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: rgba(15, 15, 18, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Tab Nav */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: rgba(15, 15, 18, 0.5);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-nav .tab-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-nav .tab-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-color: transparent;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.toolbar input[type="text"] {
    width: 180px;
    min-width: 140px;
    flex: none;
}

/* Table Wrapper */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    background: rgba(15, 15, 18, 0.4);
}

.table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0 0 12px 12px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.data-table {
    width: 100%;
    min-width: 1400px;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.2);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

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

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.badge-orange { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-yellow { background: rgba(250, 204, 21, 0.15); color: #eab308; }
.badge-gold { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-gray { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }

/* Buttons */
.btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-primary { background: rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.3); color: #a5b4fc; }
.btn-primary:hover { background: rgba(99, 102, 241, 0.3); border-color: rgba(99, 102, 241, 0.5); }
.btn-danger { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); color: #f87171; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4); }
.btn-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.btn-secondary { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.12); color: var(--text-secondary); }
.btn-outline { background: transparent; border-color: rgba(255, 255, 255, 0.15); color: var(--text-secondary); }
.btn-outline:hover { border-color: rgba(255, 255, 255, 0.3); color: var(--text-primary); }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 480px;
    background: rgba(15, 15, 18, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-content label {
    display: block;
    margin-bottom: 6px;
}

.modal-content input,
.modal-content select {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.detail-pre {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    margin: 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-width: 300px;
}

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: rgba(15, 15, 18, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-card-wide .chart-container {
    height: 320px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.page-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-right: 8px;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    pointer-events: auto;
    animation: toastIn 0.3s ease-out;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-width: 320px;
}

.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast-info { background: linear-gradient(135deg, #2563eb, #3b82f6); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-fade-out {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}
