/* ITMS — full app styles (login + dashboard + admin pages) */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1f2937;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── LOGIN PAGE ─── */
.login-shell {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
}

.login-card {
    background: white; width: 100%; max-width: 420px;
    padding: 2.5rem 2rem; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.brand { text-align: center; margin-bottom: 2rem; }

.brand-logo {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; font-weight: 800; font-size: 1.75rem; letter-spacing: 2px;
    padding: 0.5rem 1.25rem; border-radius: 10px; margin-bottom: 0.5rem;
}

.brand-logo.small { font-size: 1rem; padding: 0.3rem 0.75rem; letter-spacing: 1.5px; }
.brand-tagline { color: #6b7280; font-size: 0.875rem; font-weight: 500; }

.login-card h1 {
    font-size: 1.5rem; font-weight: 700; color: #111827;
    margin-bottom: 0.5rem; text-align: center;
}

.subtitle { color: #6b7280; text-align: center; margin-bottom: 1.5rem; font-size: 0.95rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: #374151; margin-bottom: 0.4rem; }

.form-input,
.form-group input {
    width: 100%; padding: 0.75rem 1rem;
    border: 1.5px solid #e5e7eb; border-radius: 8px;
    font-size: 1rem; background: #f9fafb;
    transition: all 0.15s ease; font-family: inherit;
}
.form-input:focus,
.form-group input:focus {
    outline: none; border-color: #667eea; background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.btn-primary {
    width: 100%; padding: 0.85rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    margin-top: 0.5rem;
    transition: transform 0.1s, box-shadow 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%; animation: spin 0.7s linear infinite;
    display: inline-block;
}
.btn-primary .spinner { border-color: rgba(255, 255, 255, 0.3); border-top-color: white; }

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

.error-box {
    margin-top: 1rem; padding: 0.75rem 1rem;
    background: #fef2f2; border: 1px solid #fecaca;
    color: #b91c1c; border-radius: 8px; font-size: 0.9rem;
}

.footer-note {
    margin-top: 2rem; text-align: center; color: #9ca3af; font-size: 0.75rem;
}
.footer-note .dot { margin: 0 0.5rem; }

.validation-message { color: #b91c1c; font-size: 0.8rem; margin-top: 0.25rem; display: block; }

/* ─── DASHBOARD SHELL (sidebar + main) ─── */
.dashboard-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    background: #f3f4f6;
}

.app-shell { min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    background: #1e293b;
    color: #cbd5e1;
    display: flex; flex-direction: column;
    padding: 1.5rem 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid #334155;
}

.sidebar-tenant {
    font-weight: 600; color: white; font-size: 0.9rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

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

.nav-section { margin-bottom: 1.5rem; }

.nav-section-title {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.5px; color: #64748b;
    padding: 0 1.5rem 0.5rem;
}

.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 1.5rem; color: #cbd5e1;
    text-decoration: none; font-size: 0.9rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-item:hover { background: #334155; color: white; }

.nav-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, transparent 100%);
    color: white; border-left-color: #667eea; font-weight: 600;
}

.nav-item.disabled { opacity: 0.4; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: #cbd5e1; }

.nav-icon { width: 20px; text-align: center; font-size: 1.1rem; }

.badge-soon {
    margin-left: auto; font-size: 0.65rem;
    background: #475569; color: #cbd5e1;
    padding: 0.15rem 0.45rem; border-radius: 4px;
    font-weight: 600;
}

.sidebar-footer {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
}

.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; flex-shrink: 0;
}
.user-avatar.small { width: 32px; height: 32px; font-size: 0.85rem; }

.user-info { flex: 1; overflow: hidden; }
.user-info-name {
    font-weight: 600; color: white; font-size: 0.85rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-info-email {
    color: #94a3b8; font-size: 0.7rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.logout-btn {
    background: transparent; border: 1px solid #475569;
    color: #cbd5e1; font-size: 1rem;
    width: 32px; height: 32px; border-radius: 6px;
    cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.logout-btn:hover { background: #b91c1c; border-color: #b91c1c; color: white; }

/* MAIN CONTENT AREA */
.dashboard-main { padding: 2rem 2.5rem; overflow-y: auto; }

/* ─── PAGE HEADER ─── */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.75rem; font-weight: 700; color: #111827; margin-bottom: 0.25rem; }
.page-subtitle { color: #6b7280; font-size: 0.95rem; }

.btn-primary-sm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; border: none; padding: 0.55rem 1.25rem;
    border-radius: 8px; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.btn-primary-sm:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); }
.btn-primary-sm:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ─── DASHBOARD WELCOME ─── */
.welcome-card {
    background: white; padding: 2rem; border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.welcome-card h1 { font-size: 1.75rem; font-weight: 700; color: #111827; margin-bottom: 0.5rem; }
.welcome-card .subtitle { text-align: left; margin: 0; }

.grid-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

.card {
    background: white; padding: 1.25rem;
    border-radius: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card-label {
    font-size: 0.75rem; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem;
}
.card-value { font-size: 1.1rem; font-weight: 600; color: #111827; }
.card-value.small { font-size: 0.85rem; }
.mono { font-family: 'SF Mono', Monaco, 'Courier New', monospace; }

.info-banner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    padding: 1.5rem; border-radius: 12px;
    color: #78350f;
}
.info-banner h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.info-banner p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 0.5rem; }
.info-banner .note { font-size: 0.8rem; opacity: 0.7; margin-top: 0.75rem; margin-bottom: 0; }

/* ─── DATA TABLE ─── */
.data-table-card {
    background: white; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); overflow: hidden;
}

.data-table-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.data-table-count { font-size: 0.85rem; font-weight: 600; color: #4b5563; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table thead th {
    text-align: left; padding: 0.75rem 1.25rem;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: #6b7280;
    background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.data-table tbody td {
    padding: 0.85rem 1.25rem; border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f9fafb; }
.data-table tbody tr:last-child td { border-bottom: none; }

.user-cell { display: flex; align-items: center; gap: 0.75rem; }
.user-cell-name { font-weight: 600; color: #111827; }
.user-cell-sub { font-size: 0.75rem; color: #6b7280; margin-top: 0.1rem; }

.muted { color: #9ca3af; }

/* CHIPS */
.chip {
    display: inline-block; padding: 0.2rem 0.55rem;
    border-radius: 12px; font-size: 0.75rem; font-weight: 600;
    margin-right: 0.25rem;
}
.chip-blue { background: #dbeafe; color: #1e40af; }
.chip-green { background: #d1fae5; color: #065f46; }
.chip-red { background: #fee2e2; color: #991b1b; }
.chip-amber { background: #fef3c7; color: #92400e; }
.chip-purple { background: #ede9fe; color: #5b21b6; }
.chip-muted { background: #f3f4f6; color: #6b7280; }

/* ─── EMPTY / LOADING ─── */
.loading-state,
.empty-state {
    background: white; padding: 3rem 2rem; border-radius: 12px;
    text-align: center; color: #6b7280;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: #374151; margin-bottom: 0.25rem; }

/* ─── SETTINGS PAGE ─── */
.settings-grid {
    display: grid; grid-template-columns: 1fr; gap: 1.5rem;
    max-width: 800px;
}

.settings-section {
    background: white; padding: 1.5rem; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.settings-section h2 {
    font-size: 1rem; font-weight: 700; color: #111827;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.settings-row {
    display: grid; grid-template-columns: 200px 1fr;
    gap: 1rem; padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.settings-row:last-child { border-bottom: none; }

.settings-label { font-size: 0.85rem; font-weight: 500; color: #6b7280; }
.settings-value { font-size: 0.95rem; color: #111827; }
.settings-value.mono { font-family: 'SF Mono', Monaco, 'Courier New', monospace; font-size: 0.8rem; }
.settings-value.small { font-size: 0.85rem; }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    padding: 1.25rem; border-radius: 10px; text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: #667eea; line-height: 1; }
.stat-label {
    font-size: 0.8rem; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-top: 0.5rem;
}

/* ─── FORMS ─── */
.form-card {
    background: white; border-radius: 12px; padding: 1.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); max-width: 800px;
    margin-bottom: 1.5rem;
}

.form-card.danger-section {
    border: 1px solid #fee2e2;
}

.form-section { margin-bottom: 2rem; }
.form-section:last-child { margin-bottom: 0; }
.form-section h2 {
    font-size: 1rem; font-weight: 700; color: #111827;
    margin-bottom: 0.5rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.form-hint {
    color: #6b7280; font-size: 0.85rem; margin-bottom: 1rem;
}

.form-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem; margin-bottom: 1rem;
}

.required { color: #dc2626; }

.form-input:disabled {
    background: #f3f4f6; color: #6b7280; cursor: not-allowed;
}

.form-actions {
    display: flex; gap: 0.75rem; justify-content: flex-end;
    margin-top: 1.5rem; padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.btn-secondary {
    background: white; color: #4b5563; border: 1.5px solid #e5e7eb;
    padding: 0.55rem 1.25rem; border-radius: 8px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s; display: flex; align-items: center; gap: 0.5rem;
}
.btn-secondary:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background: #fef2f2; color: #b91c1c; border: 1.5px solid #fecaca;
    padding: 0.55rem 1.25rem; border-radius: 8px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
}
.btn-danger:hover { background: #b91c1c; color: white; border-color: #b91c1c; }

.success-box {
    margin-top: 1rem; padding: 0.75rem 1rem;
    background: #f0fdf4; border: 1px solid #bbf7d0;
    color: #166534; border-radius: 8px; font-size: 0.9rem;
}

.back-link {
    color: #6b7280; font-size: 0.85rem; text-decoration: none;
    margin-bottom: 0.5rem; display: inline-block;
}
.back-link:hover { color: #667eea; }

/* ─── ROLE CHECKBOXES ─── */
.role-checkbox-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.role-checkbox {
    display: flex; gap: 0.65rem; align-items: flex-start;
    padding: 0.85rem; border: 1.5px solid #e5e7eb;
    border-radius: 8px; cursor: pointer;
    background: white; transition: all 0.15s;
}
.role-checkbox:hover {
    border-color: #667eea; background: #f9fafb;
}
.role-checkbox input[type="checkbox"] { margin-top: 0.15rem; cursor: pointer; }
.role-checkbox-name { font-weight: 600; color: #111827; font-size: 0.9rem; }
.role-checkbox-desc { font-size: 0.75rem; color: #6b7280; margin-top: 0.15rem; }

/* ─── ACTION ROWS (edit user danger zone) ─── */
.action-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.action-row:last-child { border-bottom: none; }
.action-row strong { color: #111827; font-size: 0.95rem; }

.reset-password-inline {
    display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap;
}
.reset-password-inline .form-input { flex: 1; min-width: 220px; }

/* ─── CLICKABLE ROWS ─── */
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: #f9fafb; }
.actions-col { width: 30px; text-align: right; }
.row-arrow { color: #9ca3af; font-size: 1.25rem; font-weight: 300; }

.loading-state.inline {
    background: transparent; padding: 0.5rem 0;
    flex-direction: row; box-shadow: none; gap: 0.5rem;
    justify-content: flex-start;
}

/* ─── ASSIGNED USERS LIST ─── */
.assigned-list {
    list-style: none; padding: 0; margin: 0;
}
.assigned-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.assigned-row:last-child { border-bottom: none; }

textarea.form-input {
    resize: vertical; min-height: 80px; font-family: inherit;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    .dashboard-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .dashboard-main { padding: 1.25rem; }
    .page-header { flex-direction: column; gap: 1rem; }
    .settings-row { grid-template-columns: 1fr; gap: 0.25rem; }
    .data-table { font-size: 0.8rem; }
    .data-table thead th, .data-table tbody td { padding: 0.5rem 0.75rem; }
}
