/* -- Reset & Base ------------------------------------------------------------- */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

:root {
    --primary: #105bab;
    --primary-dark: #0a3d73;
    --primary-light: #1a73d4;
    --yellow: #f5c518;
    --bg: #f0f2f5;
    --white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #e8e8e8;
    --gray-400: #999;
    --gray-600: #666;
    --text: #1a1a1a;
    --text-mid: #444;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --sidebar-w: 240px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

/* -- Login Page --------------------------------------------------------------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

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

.login-title {
    text-align: center; font-size: 28px; color: var(--primary-dark); margin-bottom: 4px;
}

.login-subtitle {
    text-align: center; font-size: 13px; color: var(--gray-400); margin-bottom: 28px;
}

.login-card label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-mid); margin: 14px 0 4px; text-transform: uppercase;
}

.login-card label:first-of-type { margin-top: 0; }

.login-card input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200);
    border-radius: 8px; font-size: 14px; font-family: inherit;
    transition: border-color 0.2s;
}

.login-card input:focus { outline: none; border-color: var(--primary); }

.login-error {
    margin-top: 12px; padding: 10px; border-radius: 8px;
    background: #fce4ec; color: #c62828; font-size: 13px; text-align: center;
}

.login-card button[type="submit"] {
    margin-top: 20px; width: 100%; padding: 12px;
    background: var(--primary); color: var(--white); border: none;
    border-radius: 8px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}

.login-card button[type="submit"]:hover { background: var(--primary-dark); }
.login-card button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* -- Admin Layout ------------------------------------------------------------- */
.admin-layout {
    display: flex; height: 100vh; overflow: hidden;
}

.admin-sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--primary-dark); color: var(--white);
    display: flex; flex-direction: column; height: 100vh;
}

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

.sidebar-brand h2 { font-size: 18px; font-weight: 700; }

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

.nav-item {
    display: block; padding: 10px 20px; color: rgba(255,255,255,0.7);
    font-size: 13px; cursor: pointer; border-left: 3px solid transparent;
    transition: all 0.15s; text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active {
    background: rgba(255,255,255,0.12); color: var(--white);
    border-left-color: var(--yellow);
}

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px;
}

.btn-logout {
    background: transparent; border: 1px solid rgba(255,255,255,0.3);
    color: var(--white); padding: 4px 12px; border-radius: 6px;
    cursor: pointer; font-size: 12px; transition: background 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.1); }

/* -- Main Content ------------------------------------------------------------- */
.admin-main {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.admin-topbar {
    height: 56px; padding: 0 24px;
    display: flex; align-items: center; gap: 12px;
    background: var(--white); border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.admin-topbar h1 { font-size: 18px; font-weight: 600; }

.sidebar-toggle {
    display: none; background: none; border: none;
    font-size: 20px; cursor: pointer; color: var(--text);
}

.admin-content {
    flex: 1; overflow-y: auto; padding: 24px;
}

/* -- Dashboard 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: 0 1px 3px rgba(0,0,0,0.08);
}

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

.stat-card .stat-label {
    font-size: 12px; color: var(--gray-400); text-transform: uppercase;
    margin-top: 4px; letter-spacing: 0.5px;
}

.stat-card.warning .stat-value { color: var(--danger); }

/* -- Tables ------------------------------------------------------------------- */
.table-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}

.table-header h2 { font-size: 16px; }

.btn-primary {
    background: var(--primary); color: var(--white); border: none;
    padding: 8px 16px; border-radius: 8px; font-size: 13px;
    cursor: pointer; font-weight: 600; transition: background 0.2s;
}

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

.data-table {
    width: 100%; border-collapse: collapse; background: var(--white);
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th {
    text-align: left; padding: 12px 16px; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--gray-400); background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 10px 16px; border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}

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

.data-table tr:hover td { background: var(--gray-100); }

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

.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #fce4ec; color: #c62828; }
.badge-admin { background: #e3f2fd; color: #1565c0; }
.badge-super { background: #f3e5f5; color: #7b1fa2; }

.btn-sm {
    padding: 4px 10px; border-radius: 6px; font-size: 12px;
    cursor: pointer; border: 1px solid var(--gray-200); background: var(--white);
    transition: all 0.2s; margin-right: 4px;
}

.btn-sm:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm.danger { color: var(--danger); }
.btn-sm.danger:hover { border-color: var(--danger); }

/* -- Modal -------------------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
}

.modal {
    background: var(--white); border-radius: 12px;
    width: 480px; max-width: 92vw; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 20px 0;
}

.modal-header h3 { font-size: 17px; color: var(--primary-dark); }

.modal-close {
    background: none; border: none; font-size: 24px;
    cursor: pointer; color: var(--gray-400); line-height: 1; padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 16px 20px 20px; }

.modal-body label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-mid); margin: 12px 0 4px;
    text-transform: uppercase; letter-spacing: 0.3px;
}

.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200);
    border-radius: 8px; font-size: 14px; font-family: inherit;
    color: var(--text); background: var(--white); transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body select:focus { outline: none; border-color: var(--primary); }

.modal-body .checkbox-group {
    display: flex; gap: 16px; margin-top: 4px;
}

.modal-body .checkbox-group label {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; text-transform: none; font-weight: 400;
    cursor: pointer; margin: 0;
}

.modal-body .checkbox-group input[type="checkbox"] {
    width: auto; cursor: pointer;
}

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

.btn-cancel {
    padding: 8px 16px; border-radius: 8px; font-size: 13px;
    cursor: pointer; border: 1px solid var(--gray-200);
    background: var(--white); color: var(--text-mid);
}

.btn-cancel:hover { background: var(--gray-100); }

/* -- Company Admin: Read-only Info -------------------------------------------- */
.info-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    background: var(--white); border-radius: 10px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.info-item .info-label {
    font-size: 11px; text-transform: uppercase; color: var(--gray-400);
    letter-spacing: 0.5px; margin-bottom: 4px;
}

.info-item .info-value {
    font-size: 15px; font-weight: 500; color: var(--text);
}

/* -- Responsive --------------------------------------------------------------- */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed; left: 0; top: 0; z-index: 999;
        transform: translateX(-100%); transition: transform 0.3s;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .admin-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}
