/* ===== VARIABLES ===== */
:root {
    --brand: #001845;
    --brand-light: #002d72;
    --brand-lighter: #e8eef8;
    --accent: #0066cc;
    --accent-light: #e8f2ff;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #1a1d29;
    --text-secondary: #5a6178;
    --text-muted: #9098b1;
    --border: #e2e6ef;
    --success: #0d9e6b;
    --success-bg: #ecfdf5;
    --danger: #dc3545;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,24,69,0.06);
    --shadow: 0 2px 8px rgba(0,24,69,0.08);
    --shadow-lg: 0 8px 30px rgba(0,24,69,0.1);
    --transition: 0.2s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ===== LAYOUT ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--brand);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-logo {
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo img { height: 28px; filter: brightness(0) invert(1); }
.sidebar-logo span {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-top: 6px;
    font-weight: 500;
}

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a,
.sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 450;
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.sidebar-nav a:hover,
.sidebar-nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active,
.sidebar-nav button.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; }
.sidebar-nav .nav-icon { font-size: 1.15rem; width: 22px; text-align: center; }

.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}
.top-bar h1 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}
.top-bar .breadcrumb { font-size: 0.82rem; color: var(--text-muted); }
.top-bar .breadcrumb span { color: var(--text); font-weight: 600; }

.page-content { padding: 28px 32px; max-width: 1400px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
}
.card-body { padding: 24px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #eef1f6; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0b8a5e; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c82333; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 8px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}
.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
    outline: none;
}
.form-input:focus,
.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,102,204,0.1); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.readonly { background: var(--bg); color: var(--text-secondary); cursor: default; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
}

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
tbody td {
    padding: 14px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--accent-light); }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--danger-bg); color: var(--danger); }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-user { background: var(--accent-light); color: var(--accent); }
.badge-master { background: #fef3c7; color: #b45309; }
.badge-system { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.badge-active .badge-dot { background: var(--success); }
.badge-inactive .badge-dot { background: var(--danger); }

/* ===== STATS ROW ===== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.stat-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: #ede9fe; color: #6d28d9; }
.stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-value { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab {
    padding: 12px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    position: relative;
    transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--brand);
    font-weight: 700;
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0; right: 0;
    height: 2px;
    background: var(--brand);
    border-radius: 2px 2px 0 0;
}

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,24,69,0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 95%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
}
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 320px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--brand); color: #fff; }

/* ===== STEPPER ===== */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 32px; padding: 0 8px; }
.step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    position: relative;
}
.step:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 12px;
    transition: var(--transition);
}
.step:not(:last-child).completed::after { background: var(--success); }
.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #fff;
    transition: var(--transition);
    flex-shrink: 0;
}
.step.active .step-circle { border-color: var(--brand); color: var(--brand); background: var(--brand-lighter); }
.step.completed .step-circle { border-color: var(--success); color: #fff; background: var(--success); }
.step-label { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.step.active .step-label { color: var(--brand); font-weight: 700; }
.step.completed .step-label { color: var(--success); }

/* ===== PROGRESS ===== */
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,24,69,0.5);
    backdrop-filter: blur(6px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.progress-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    min-width: 400px;
}
.progress-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
.progress-text { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.progress-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 6px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; margin-bottom: 20px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5cad4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9098b1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar { width: 72px; }
    .sidebar-logo span,
    .sidebar-nav a span,
    .sidebar-nav button span { display: none; }
    .sidebar-logo { padding: 16px; text-align: center; }
    .sidebar-nav a, .sidebar-nav button { justify-content: center; padding: 12px; }
    .main-content { margin-left: 72px; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .page-content { padding: 16px; }
    .top-bar { padding: 0 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ===== AD SYNC ADDITIONS ===== */
.ou-item:hover { background: var(--accent-light) !important; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1024px) {
    .form-row-3 { grid-template-columns: 1fr; }
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(0,102,204,0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(0,45,114,0.2) 0%, transparent 50%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo {
    height: 40px;
    margin-bottom: 16px;
}
.login-header h1 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: 4px;
}
.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.login-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.login-alert.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220,53,69,0.15);
}
.login-alert.info {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid rgba(0,102,204,0.15);
}
.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.login-btn:hover:not(:disabled) { background: var(--brand-light); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.otp-input {
    text-align: center;
    font-size: 1.5rem !important;
    letter-spacing: 10px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', monospace;
}
.otp-info {
    text-align: center;
    margin-bottom: 20px;
}
.otp-info p { color: var(--text-secondary); font-size: 0.88rem; }
.otp-info strong { color: var(--text); }
.otp-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}
.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
.spinner-sm {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
.validation-message { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }

/* ===== LAYOUT TOP BAR (User Info + Logout) ===== */
.layout-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-user {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}
.topbar-user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}
.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}
.topbar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.topbar-logout {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.topbar-logout:hover {
    background: var(--danger-bg);
    border-color: rgba(220,53,69,0.2);
    color: var(--danger);
}
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 0;
}

/* ===== MODALS ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,24,69,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-sm { max-width: 400px; }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== CHECKBOX ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}
.checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--accent);
}

/* ===== BADGES (additional) ===== */
.badge-accent {
    background: var(--accent-light);
    color: var(--accent);
}
.badge-default {
    background: var(--brand-lighter);
    color: var(--brand);
}

/* ===== RESPONSIVE: topbar ===== */
@media (max-width: 1024px) {
    .topbar-user-details { display: none; }
    .layout-topbar { padding: 0 16px; }
}

