:root {
    --primary: #0f172a;
    --sidebar: #1e293b;
    --accent: #0284c7;
    --gold: #d97706;
    --green: #10b981;
    --red: #ef4444;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ================= SIDEBAR / APP ================= */
#sidebar {
    width: 270px;
    background-color: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.brand-box {
    padding: 22px 18px;
    text-align: center;
    background: #090d16;
    border-bottom: 1px solid #334155;
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 1px;
}

.brand-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.nav-menu {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-btn:hover, .nav-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.nav-btn span { font-size: 16px; }

#main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-navbar {
    background: var(--card);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.live-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

.content-area {
    padding: 24px;
    flex-grow: 1;
}

/* ================= KPI CARDS ================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
}

.kpi-card.blue::before { background: var(--accent); }
.kpi-card.green::before { background: var(--green); }
.kpi-card.gold::before { background: var(--gold); }
.kpi-card.red::before { background: var(--red); }
.kpi-card.purple::before { background: #8b5cf6; }

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

/* ================= FORMS ================= */
.form-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    align-items: flex-end;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}

.form-control {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
    background: #fff;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2,132,199,0.1);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: #0369a1; }

.btn-gold {
    background: var(--gold);
    color: #fff;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.btn-gold:hover { background: #b45309; }

/* ================= TABLES ================= */
.table-card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

tr:hover td { background: #f8fafc; }

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gold { background: #fef3c7; color: #b45309; }

/* ================= PROFESSIONAL LOGIN ================= */
#login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #020617 0%, #0f172a 55%, #1e293b 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#login-overlay.hidden { display: none; }

.auth-wrap {
    display: flex;
    width: 100%;
    max-width: 880px;
    min-height: 540px;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 70px rgba(0,0,0,0.55);
}

/* left brand side */
.auth-brand {
    flex: 1 1 46%;
    background: linear-gradient(160deg, #0f172a 0%, #1d4ed8 130%);
    color: #e2e8f0;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-logo {
    width: 62px; height: 62px;
    border-radius: 16px;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    color: #041016;
    font-size: 26px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 8px 20px rgba(2,132,199,0.45);
}

.auth-brand-name {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1.5px;
    color: #fff;
}

.auth-brand-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    margin-bottom: 26px;
}

.auth-features { list-style: none; }
.auth-features li {
    font-size: 13px;
    color: #cbd5e1;
    padding: 7px 0 7px 26px;
    position: relative;
}
.auth-features li::before {
    content: '\2713';
    position: absolute; left: 0;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(56,189,248,0.18);
    color: #38bdf8;
    font-size: 11px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    top: 8px;
}

.auth-brand-foot {
    margin-top: 30px;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid rgba(148,163,184,0.2);
    padding-top: 14px;
}

/* right form side */
.auth-panel {
    flex: 1 1 54%;
    padding: 36px 34px 26px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-panel-head h1 {
    font-size: 22px;
    color: #0f172a;
    margin-bottom: 4px;
}
.auth-panel-head p {
    color: #64748b;
    font-size: 13px;
    margin-bottom: 20px;
}

.auth-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 18px;
}
.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 9px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}
.auth-tab.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 4px rgba(15,23,42,0.12);
}

.field { margin-bottom: 14px; text-align: left; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}
.field label small { color: #94a3b8; font-weight: 500; }
.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 9px;
    font-size: 14px;
    outline: none;
    transition: border 0.15s, box-shadow 0.15s;
    background: #f8fafc;
}
.field input:focus {
    border-color: #0284c7;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(2,132,199,0.15);
}

.pass-box { position: relative; }
.pass-box input { padding-right: 44px; }
.toggle-pass {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 17px;
    opacity: 0.55;
    padding: 4px 6px;
    border-radius: 6px;
}
.toggle-pass:hover { opacity: 1; background: #f1f5f9; }

.auth-error {
    color: #dc2626;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.auth-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #fff;
    border: none;
    border-radius: 9px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.06s, box-shadow 0.15s;
    box-shadow: 0 6px 16px rgba(2,132,199,0.35);
}
.auth-btn:hover { box-shadow: 0 8px 22px rgba(2,132,199,0.5); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: 0.65; cursor: wait; }

.auth-btn-spin {
    width: 15px; height: 15px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
}

.auth-link {
    color: #0284c7;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

.auth-link-btn {
    width: 100%;
    margin-top: 10px;
    background: none;
    border: none;
    color: #0284c7;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.auth-link-btn:hover { text-decoration: underline; }

.auth-mode-badge {
    font-size: 10.5px;
    font-weight: 700;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    padding: 3px 9px;
    border-radius: 20px;
}
.auth-mode-badge.online {
    color: #065f46;
    background: #d1fae5;
    border-color: #6ee7b7;
}

.auth-server-msg {
    margin-top: 14px;
    font-size: 12.5px;
    color: #9a3412;
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 8px;
    padding: 10px 12px;
    line-height: 1.5;
}

.login-hint {
    margin-top: 14px;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}

.strength {
    height: 5px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-top: 7px;
    overflow: hidden;
}
.strength-bar {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: #ef4444;
    transition: width 0.2s, background 0.2s;
}
.strength-txt { font-size: 11px; color: #64748b; }

.otp-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 12.5px;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
    line-height: 1.5;
}
.otp-input {
    width: 100%;
    padding: 13px;
    border: 2px solid #cbd5e1;
    border-radius: 9px;
    font-size: 24px !important;
    letter-spacing: 14px;
    text-align: center;
    font-weight: 800;
    outline: none;
}
.otp-input:focus { border-color: #0284c7; }

/* ================= MODALS ================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,0.66);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-box {
    background: #fff;
    width: 100%;
    max-width: 430px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.5);
    max-height: 92vh;
    overflow-y: auto;
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.modal-head h3 { font-size: 17px; color: #0f172a; }
.modal-close {
    border: none;
    background: #f1f5f9;
    color: #64748b;
    width: 32px; height: 32px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { background: #e2e8f0; color: #0f172a; }
.modal-note {
    margin-top: 12px;
    font-size: 11.5px;
    color: #94a3b8;
    line-height: 1.5;
    text-align: center;
}

.app-shell.locked #sidebar,
.app-shell.locked #main-content {
    visibility: hidden;
    pointer-events: none;
}

/* ================= PRINT ================= */
@media print {
    #sidebar, #login-overlay, .nav-menu, .nav-btn, .modal-overlay { display: none !important; }
    body { background: #fff; }
    #main-content { margin: 0 !important; padding: 8px !important; width: 100% !important; }
    button, .btn-primary, .btn-gold { display: none !important; }
    .form-card, .table-card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
    table { font-size: 11px; }
    @page { size: A4; margin: 12mm; }
}

/* responsive login */
@media (max-width: 760px) {
    .auth-wrap { flex-direction: column; max-width: 440px; min-height: 0; }
    .auth-brand { padding: 26px 24px; }
    .auth-features { display: none; }
    .auth-brand-foot { margin-top: 12px; }
    .auth-panel { padding: 26px 22px; }
}

#user-badge { letter-spacing: 0.3px; }
