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

:root {
  --ms-blue: #0078d4;
  --ms-blue-dark: #005a9e;
  --ms-blue-light: #deecf9;
  --ms-blue-lighter: #eff6fc;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #243245;
  --sidebar-active: #0078d4;
  --header-bg: #ffffff;
  --surface: #ffffff;
  --surface2: #f3f2f1;
  --border: #edebe9;
  --text: #201f1e;
  --text-muted: #605e5c;
  --text-light: #a19f9d;
  --success: #107c10;
  --success-bg: #dff6dd;
  --warning: #ca5010;
  --warning-bg: #fff4ce;
  --danger: #d13438;
  --danger-bg: #fde7e9;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ─── Login ─────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1a2332 0%, #0d1b2a 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-card {
  background: #fff;
  border-radius: 8px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex; justify-content: center; margin-bottom: 16px;
}
.login-card h1 {
  font-size: 22px; font-weight: 600; text-align: center;
  color: var(--text); margin-bottom: 4px;
}
.login-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-error {
  background: var(--danger-bg); color: #a80000;
  border: 1px solid #fbd4d4; border-radius: 4px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}
.login-footer { text-align: center; font-size: 11px; color: var(--text-light); margin-top: 24px; }
.btn-block { width: 100%; justify-content: center; }

/* ─── App Layout ────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 228px; min-width: 228px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 100;
}
.sidebar-logo { padding: 14px 14px 10px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-logo-inner { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-title { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-logo-sub { font-size: 10px; color: rgba(255,255,255,0.4); }

.tenant-switcher {
  margin: 8px 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; padding: 8px 10px;
  cursor: pointer; position: relative;
  transition: background 0.15s;
}
.tenant-switcher:hover { background: rgba(255,255,255,0.11); }
.tenant-label { font-size: 9px; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 2px; }
.tenant-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 14px; }
.tenant-domain { font-size: 10px; color: rgba(255,255,255,0.4); }
.tenant-caret { position: absolute; right: 10px; top: 12px; color: rgba(255,255,255,0.4); font-size: 11px; }

.tenant-dropdown {
  position: absolute; left: 0; top: calc(100% + 4px);
  width: 100%; background: #fff;
  border-radius: 6px; border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 500; overflow: hidden;
}
.tenant-option { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f3f2f1; }
.tenant-option:hover { background: #f3f2f1; }
.tenant-option:last-child { border-bottom: none; }
.tenant-option-name { font-size: 13px; font-weight: 500; color: #201f1e; }
.tenant-option-domain { font-size: 11px; color: #605e5c; }
.tenant-option.active { background: var(--ms-blue-lighter); }

.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav::-webkit-scrollbar { width: 0; }
.nav-section {
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.3);
  padding: 10px 16px 3px;
  letter-spacing: 0.8px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px;
  cursor: pointer; color: rgba(255,255,255,0.65);
  font-size: 13px; text-decoration: none;
  transition: background 0.12s, color 0.12s;
  position: relative; border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.9); }
.nav-item.active {
  background: rgba(0,120,212,0.25);
  color: #fff;
  border-left-color: var(--ms-blue);
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--danger);
  color: #fff; font-size: 10px;
  border-radius: 10px; padding: 1px 6px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px; color: rgba(255,255,255,0.35);
}

/* ─── Main ──────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 48px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-breadcrumb { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.topbar-breadcrumb a { color: var(--ms-blue); cursor: pointer; text-decoration: none; }
.topbar-breadcrumb a:hover { text-decoration: underline; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-tenant-badge {
  font-size: 11px; color: var(--ms-blue);
  background: var(--ms-blue-lighter);
  padding: 2px 10px; border-radius: 10px;
  font-weight: 500;
}
.topbar-user { display: flex; align-items: center; }
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--ms-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff; cursor: pointer;
}

.content {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  background: var(--surface2);
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #c8c6c4; border-radius: 3px; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 4px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.12s; line-height: 1; text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ms-blue); color: #fff; border-color: var(--ms-blue); }
.btn-primary:hover:not(:disabled) { background: var(--ms-blue-dark); }
.btn-outline { background: #fff; color: var(--ms-blue); border-color: var(--ms-blue); }
.btn-outline:hover:not(:disabled) { background: var(--ms-blue-lighter); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #a80000; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 3px; }

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px 18px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 28px; font-weight: 300; color: var(--text); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text-light); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.stat-sub.up { color: var(--success); }
.stat-sub.down { color: var(--danger); }
.stat-sub.warn { color: var(--warning); }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
.table-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.table-title { font-size: 14px; font-weight: 600; color: var(--text); }
.table-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  padding: 9px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  background: #faf9f8; white-space: nowrap; cursor: pointer;
  user-select: none;
}
th:hover { background: #f3f2f1; }
td {
  font-size: 13px; padding: 9px 14px;
  border-bottom: 1px solid #f3f2f1;
  color: var(--text); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: #f9f8f7; cursor: pointer; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px; font-size: 13px; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 12px;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-blocked { background: #fdf0e7; color: #6b4226; }
.badge-info { background: var(--ms-blue-light); color: var(--ms-blue-dark); }
.badge-gray { background: #f3f2f1; color: var(--text-muted); }

/* ─── Progress ───────────────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 7px; }
.progress { height: 4px; background: #e1dfdd; border-radius: 2px; overflow: hidden; width: 72px; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.progress-label { font-size: 11px; color: var(--text-muted); min-width: 28px; }

/* ─── Search ─────────────────────────────────────────────────── */
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 10px;
}
.search-wrap input {
  border: none; outline: none; font-size: 13px;
  background: transparent; color: var(--text); width: 200px;
}
.search-wrap svg { color: var(--text-light); flex-shrink: 0; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 5px; display: block; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; color: var(--text);
  outline: none; background: #fff;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--ms-blue);
  box-shadow: 0 0 0 2px rgba(0,120,212,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── Cards ──────────────────────────────────────────────────── */
.section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 18px 20px; margin-bottom: 16px;
}
.section-card h3 {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ─── Toggle ─────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f3f2f1; }
.toggle-row:last-child { border-bottom: none; padding-bottom: 0; }
.toggle-info { flex: 1; }
.toggle-title { font-size: 13px; font-weight: 500; color: var(--text); }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle {
  width: 40px; height: 22px; background: #c8c6c4;
  border-radius: 11px; cursor: pointer; position: relative;
  transition: background 0.2s; flex-shrink: 0; margin-top: 2px;
  border: none; outline: none; appearance: none;
}
.toggle.on { background: var(--ms-blue); }
.toggle::after {
  content: ''; width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 20px; }

/* ─── User Header ────────────────────────────────────────────── */
.user-header {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 18px 22px;
  display: flex; align-items: center; gap: 18px; margin-bottom: 16px;
}
.user-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.user-meta h2 { font-size: 18px; font-weight: 600; margin-bottom: 2px; }
.user-meta .user-email { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.user-meta .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.user-actions { margin-left: auto; display: flex; gap: 8px; }

/* ─── Chart Cards ────────────────────────────────────────────── */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px;
}
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.chart-wrap { position: relative; width: 100%; }

/* ─── Activity Log ───────────────────────────────────────────── */
.activity-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f3f2f1; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.activity-dot.critical { background: var(--danger); }
.activity-dot.warning { background: var(--warning); }
.activity-dot.info { background: #0078d4; }
.activity-body { flex: 1; font-size: 12px; }
.activity-action { font-weight: 500; color: var(--text); }
.activity-detail { color: var(--text-muted); margin-top: 1px; }
.activity-time { font-size: 11px; color: var(--text-light); white-space: nowrap; }

/* ─── Alert Banners ──────────────────────────────────────────── */
.alert-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 4px;
  font-size: 13px; margin-bottom: 12px; border: 1px solid;
}
.alert-banner svg { flex-shrink: 0; }
.alert-danger { background: var(--danger-bg); color: #a80000; border-color: #fbd4d4; }
.alert-warning { background: var(--warning-bg); color: #7a3b00; border-color: #f7caac; }
.alert-info { background: var(--ms-blue-light); color: var(--ms-blue-dark); border-color: #b0d3f0; }

/* ─── Loading ────────────────────────────────────────────────── */
.loading-spinner { display: flex; justify-content: center; align-items: center; padding: 80px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid #edebe9;
  border-top-color: var(--ms-blue); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, #f3f2f1 25%, #e8e6e5 50%, #f3f2f1 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: slideIn 0.2s ease-out;
  max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--ms-blue); }
@keyframes slideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Back Button ────────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ms-blue); font-size: 13px; cursor: pointer;
  margin-bottom: 14px; background: none; border: none; padding: 0;
}
.back-btn:hover { text-decoration: underline; }

/* ─── Misc ───────────────────────────────────────────────────── */
.page-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--ms-blue-light); color: var(--ms-blue-dark);
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.fw-500 { font-weight: 500; }
.flex-center { display: flex; align-items: center; gap: 6px; }
.ml-auto { margin-left: auto; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Security Audit Styles ──────────────────────────────────── */
.finding-card { border-left: 4px solid var(--border); }
.finding-card-critical { border-left-color: var(--danger); }
.finding-card-high     { border-left-color: var(--warning); }
.finding-card-medium   { border-left-color: #ca8c00; }
.finding-card-low      { border-left-color: var(--success); }
.finding-card-info     { border-left-color: var(--ms-blue); }

/* ─── Bulk Action Bar ────────────────────────────────────────── */
#bulk-action-bar { background: var(--sidebar-bg); border-radius: 6px; padding: 10px 16px; }

/* ─── Setup Wizard Transition ────────────────────────────────── */
.step-panel { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

/* ─── Alert Rule Toggle in Table ─────────────────────────────── */
td .toggle { margin: 0; }

/* ─── CSV Export Icon ────────────────────────────────────────── */
.btn svg { pointer-events: none; }
