:root {
    --red: #e53935;
    --red-dark: #b71c1c;
    --teal: #00897b;
    --teal-dark: #00695c;
    --teal-light: #e0f2f1;
    --bg: #f5f5f5;
    --white: #ffffff;
    --text: #212121;
    --text-muted: #757575;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { text-decoration: none; color: inherit; }

/* login page */
.login-wrap {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--red-dark) 0%, var(--teal-dark) 100%);
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo h1 {
    font-size: 26px;
    color: var(--red);
    font-weight: 700;
}

.login-logo span {
    color: var(--teal);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color .2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--teal);
}

.btn {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .2s, transform .1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--red);
    color: var(--white);
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

.btn-primary:hover { background: var(--red-dark); }

.btn-teal {
    background: var(--teal);
    color: var(--white);
}

.btn-teal:hover { background: var(--teal-dark); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--teal);
    color: var(--teal);
}

.btn-outline:hover { background: var(--teal); color: var(--white); }

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

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: var(--red-dark); }

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error { background: #ffebee; color: var(--red-dark); border: 1px solid #ffcdd2; }
.alert-success { background: #e0f2f1; color: var(--teal-dark); border: 1px solid #b2dfdb; }
.alert-warning { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }

/* page loading overlay */
#nav-loader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

#nav-loader.show { display: flex; }

.loader-box {
    background: var(--white);
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    min-width: 200px;
}

.loader-spinner {
    width: 52px;
    height: 52px;
    border: 5px solid var(--teal-light);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 16px;
}

.loader-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

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

.loader-dots span {
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--teal);
    border-radius: 50%;
    margin: 0 2px;
    animation: dot-bounce .9s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) { animation-delay: -.3s; }
.loader-dots span:nth-child(2) { animation-delay: -.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.5); opacity: .4; }
    40%            { transform: scale(1);   opacity: 1; }
}

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

.sidebar {
    width: 240px;
    background: var(--text);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h2 {
    font-size: 18px;
    color: var(--red);
    font-weight: 700;
}

.sidebar-logo h2 span { color: var(--teal); }

.sidebar-logo small {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
}

.sidebar nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,0.75);
    font-size: 14px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border-left-color: var(--teal);
}

.sidebar nav a svg { flex-shrink: 0; }

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.sidebar-footer a {
    color: var(--red);
    font-weight: 600;
}

.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.user-badge .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--teal);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.content { padding: 24px; flex: 1; }

/* progress bar */
#page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--red));
    z-index: 9999;
    transition: width .3s ease;
    border-radius: 0 2px 2px 0;
}

#page-loader.loading {
    animation: loader-progress 1.8s ease-in-out forwards;
}

#page-loader.done {
    width: 100% !important;
    opacity: 0;
    transition: width .2s ease, opacity .4s ease .1s;
}

@keyframes loader-progress {
    0%   { width: 0%; }
    30%  { width: 40%; }
    60%  { width: 70%; }
    85%  { width: 88%; }
    100% { width: 92%; }
}

/* cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--teal);
}

.stat-card.red { border-left-color: var(--red); }

.stat-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* table */
.card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.card-header h2 {
    font-size: 15px;
    font-weight: 700;
}

.card-body { padding: 20px; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: #fafafa;
}

table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

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

table tr:hover td { background: var(--teal-light); }

/* filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin: 0;
    min-width: 140px;
}

.filter-bar input, .filter-bar select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.filter-bar input:focus, .filter-bar select:focus {
    border-color: var(--teal);
}

/* badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #e0f2f1; color: var(--teal-dark); }
.badge-danger { background: #ffebee; color: var(--red-dark); }
.badge-admin { background: #fce4ec; color: #880e4f; }
.badge-user { background: #e3f2fd; color: #0d47a1; }

/* period tabs */
.period-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.period-tab {
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--text-muted);
    transition: all .2s;
}

.period-tab.active {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--white);
}

.otp-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 16px 0;
}

.otp-inputs input {
    width: 46px;
    height: 54px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.otp-inputs input:focus { border-color: var(--teal); }

.text-red { color: var(--red); }
.text-teal { color: var(--teal); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h3 {
    font-size: 17px;
    margin-bottom: 18px;
    color: var(--text);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.checkbox-row input[type=checkbox] {
    width: 18px; height: 18px;
    accent-color: var(--teal);
}

.chart-wrap {
    position: relative;
    height: 260px;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
}
