/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #3182ce;
    --danger: #f85149;
    --success: #2ea043;
    --glass-blur: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, rgba(88, 166, 255, 0.15) 0%, transparent 40%),
                      radial-gradient(circle at bottom left, rgba(46, 160, 67, 0.1) 0%, transparent 40%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.glass-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 24px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #8b949e);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav a {
    display: block;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    font-weight: 500;
}

nav a:hover, nav a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

nav a.active {
    border-left: 3px solid var(--accent);
}

/* MAIN CONTENT */
.content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

header h2 {
    font-weight: 600;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* CARD */
.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, background 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-date {
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(88, 166, 255, 0.2);
}

.card-body {
    margin-bottom: 20px;
}

.info-row {
    font-size: 13px;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-label {
    color: var(--text-muted);
    margin-right: 6px;
}

.info-val {
    color: var(--text-main);
    font-weight: 500;
}
.info-val a {
    color: var(--accent);
    text-decoration: none;
}
.info-val a:hover {
    text-decoration: underline;
}

.card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

/* BUTTONS */
button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}
.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
}
.btn-danger:hover {
    color: var(--danger);
}

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #161b22;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    width: 400px;
    max-width: 90%;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.wide-modal { width: 1000px; max-height: 85vh; display: flex; flex-direction: column;}

.logs-header-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 20px;
}
.stats-cards {
    display: flex;
    gap: 20px;
}
.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 25px;
    min-width: 140px;
}
.stat-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}
.search-box {
    flex: 1;
    max-width: 350px;
}
.search-box input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h3 { margin-bottom: 20px; font-weight: 600; }

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

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

/* QR Code Display */
.qr-modal { text-align: center; }
.qr-box {
    background: white;
    padding: 15px;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 15px;
}
.link-text {
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
    background: rgba(88, 166, 255, 0.1);
    padding: 8px;
    border-radius: 6px;
}
.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 20px;
}

/* Logs Table */
.table-container {
    overflow-y: auto;
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}

.logs-table th, .logs-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logs-table th:nth-child(1), .logs-table td:nth-child(1) { white-space: nowrap; }
.logs-table th:nth-child(2), .logs-table td:nth-child(2) { white-space: nowrap; }
.logs-table th:nth-child(3), .logs-table td:nth-child(3) { white-space: nowrap; min-width: 100px; }
.logs-table th:nth-child(4), .logs-table td:nth-child(4) { word-break: break-all; min-width: 250px; }

.logs-table th {
    background: rgba(255,255,255,0.02);
    position: sticky;
    top: 0;
    color: var(--text-muted);
    font-weight: 500;
}

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

.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    display: none;
}

/* --- Global Dashboard Stats UI --- */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.hero-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(var(--glass-blur));
    transition: transform 0.3s ease;
}

.hero-card:hover { transform: translateY(-3px); }

.hero-title {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.hero-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-main);
}

.glow-text {
    text-shadow: 0 0 20px rgba(88, 166, 255, 0.4);
    background: linear-gradient(135deg, #58a6ff, #ffffff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-title {
    margin-bottom: 20px;
    font-size: 20px;
    color: var(--text-main);
}

.leaderboard-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 40px;
}

.leaderboard-item {
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

.leaderboard-item .progress-bg {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--progress, 0%);
    background: linear-gradient(90deg, rgba(88,166,255,0.15) 0%, rgba(88,166,255,0.02) 100%);
    z-index: 0;
    transition: width 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.leaderboard-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.lb-info { display: flex; flex-direction: column; gap: 5px; }
.lb-name { font-size: 18px; font-weight: 600; color: var(--text-main); }
.lb-link { font-size: 13px; color: var(--accent); text-decoration: none; font-family: monospace;}
.lb-link:hover { text-decoration: underline; }

.lb-stats { display: flex; gap: 30px; text-align: right;}
.lb-stat-box { display: flex; flex-direction: column; align-items: flex-end;}
.lb-stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px;}
.lb-stat-number { font-size: 22px; font-weight: 700; color: var(--text-main); }
.lb-stat-today { color: var(--success); }

/* --- Login Screen --- */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    text-align: center;
    animation: fadeUp 0.6s ease;
}

.login-logo {
    font-size: 36px;
    color: var(--accent);
    margin-bottom: 15px;
}

.login-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 30px;
    letter-spacing: 1px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 15px;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.login-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0,0,0,0.5);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.2);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
