:root {
  --primary: #2563EB;
  --sidebar: #0F172A;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
  --topbar-height: 60px;
  --sidebar-width: 270px;
  --sidebar-compact-width: 88px;
  --content-padding: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

a { text-decoration: none; color: inherit; }
.text-primary { color: var(--primary); }

.app-layout { min-height: 100vh; height: 100vh; display: grid; grid-template-columns: minmax(0, var(--sidebar-width)) minmax(0, 1fr); padding-top: var(--topbar-height); overflow: hidden; transition: grid-template-columns .3s ease; }
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  z-index: 1350;
  background: #020b2a;
  color: #cbd5e1;
  padding: 20px 14px;
  padding-top: 12px;
  border-right: 1px solid #0f204a;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: var(--sidebar-width);
  min-width: 0;
  min-height: calc(100vh - var(--topbar-height));
  max-height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  transition: width .3s ease, padding .3s ease, border-color .3s ease, transform .3s ease, opacity .25s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  color: #e2e8f0;
  padding: 4px 8px 10px;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #38bdf8;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.16);
}
.nav-group { display: grid; gap: 6px; }
.nav-section-title {
  margin: 12px 8px 2px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 14px;
  color: #cbd5e1;
  border: 1px solid transparent;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
}
.nav-item:hover {
  background: rgba(148,163,184,.14);
  color: #fff;
  border-color: rgba(148,163,184,.18);
  transform: translateX(2px);
  box-shadow: 0 10px 20px rgba(2, 11, 42, 0.18);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, .28), rgba(59, 130, 246, .16));
  color: #fff;
  border-color: rgba(59,130,246,.45);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}
.nav-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: 0 0 18px; }
.nav-label { min-width: 0; }
.svg-icon { line-height: 0; }
.svg-icon svg { width: 18px; height: 18px; display: block; fill: currentColor; }

.content { padding: var(--content-padding); min-width: 0; grid-column: 2; height: calc(100vh - var(--topbar-height)); overflow-y: auto; overflow-x: hidden; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 0;
}
.page-title { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); }
.section-title { margin: 0; font-size: 18px; }
.section-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-kicker { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #2563eb; font-weight: 700; }

.inline-actions { display: flex; gap: 10px; align-items: center; }
.dashboard-trend-controls { flex-wrap: wrap; justify-content: flex-end; }
.dashboard-trend-controls select { min-width: 130px; }
.monitor-actions { flex-wrap: wrap; justify-content: flex-end; }
.live-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #fff, #f8fbff);
  color: #1e293b;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  font-size: 13px;
  font-weight: 600;
}
.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.14);
  animation: aitsm-live-pulse 1.8s ease infinite;
}
.live-status-chip[data-state='loading'] .live-dot {
  background: #3b82f6;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
}
.live-status-chip[data-state='error'] .live-dot {
  background: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.14);
}
@keyframes aitsm-live-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.72; }
}
.grid { display: grid; gap: 20px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stats.compact-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.summary-balanced-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; }
.summary-balanced-grid > * { grid-column: span 3; }
.summary-balanced-grid > *:nth-child(n + 5) { grid-column: span 4; }
.admin-panels { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.metric-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.metric-value { font-size: 36px; margin: 6px 0 2px; font-weight: 700; letter-spacing: -.01em; }
.metric-hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.metric-card { position: relative; overflow: hidden; min-height: 190px; display: flex; flex-direction: column; justify-content: space-between; }
.compact-grid .metric-card { min-height: 150px; }
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, rgba(37,99,235,.12), transparent 65%);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 14px;
  height: 44px;
  padding: 0 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}
.btn:focus-visible { outline: 3px solid #bfdbfe; outline-offset: 1px; }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; box-shadow: 0 10px 24px rgba(37,99,235,.25); }
.btn-primary:hover { filter: brightness(.99); transform: translateY(-1px); box-shadow: 0 14px 28px rgba(37,99,235,.28); }
.btn-ghost { background: linear-gradient(180deg, #fff, #f8fbff); border-color: #d8e1ef; color: #334155; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05); }
.btn-ghost:hover { border-color: #cbd5e1; background: #f8fafc; transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15, 23, 42, 0.09); }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-only-btn {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
}
.icon-only-btn.text-danger { color: var(--danger); }
.icon-only-btn.text-danger:hover { color: #b91c1c; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}
td { padding: 13px 12px; border-bottom: 1px solid #edf2f7; }
tr:hover td { background: #f8fbff; }
.badge {
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 10px;
  font-weight: 700;
  display: inline-block;
}
.badge.open { background: #fee2e2; color: #991b1b; }
.badge.in-progress { background: #dbeafe; color: #1e40af; }
.badge.resolved { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(210px, 1fr)); gap: 16px; }
.form-group { display: grid; gap: 8px; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 48px; }
.password-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.password-toggle-btn:hover { background: rgba(148, 163, 184, 0.18); color: #0f172a; }
.password-toggle-btn:focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }
.password-toggle-icon { font-size: 16px; line-height: 1; }
label { font-size: 13px; font-weight: 600; color: #334155; }
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; outline: none; }
textarea { resize: vertical; min-height: 120px; }
.small { color: var(--muted); font-size: 13px; }

.chart-panel { min-height: 240px; }
.chart-placeholder {
  border: 1px dashed #dbe4f2;
  border-radius: var(--radius-md);
  padding: 10px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}
.spark-chart { height: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(65px, 1fr)); gap: 10px; align-items: end; }
.spark-col { display: grid; gap: 5px; align-content: end; }
.spark-bar-wrap { height: 142px; border: 1px solid #dbe6fb; border-radius: 10px; background: #f8fbff; display: flex; align-items: flex-end; padding: 8px; }
.spark-bar { width: 100%; border-radius: 8px; background: linear-gradient(180deg, #60a5fa, #1d4ed8); min-height: 6px; }
.spark-value { text-align: center; font-size: 12px; font-weight: 700; color: #1e293b; }
.spark-label { text-align: center; font-size: 11px; color: var(--muted); }


.admin-chart { min-height: 320px; }
.viz-svg { width: 100%; height: 250px; }
.viz-axis-label { fill: #64748b; font-size: 12px; }
.viz-axis-hint { fill: #94a3b8; font-size: 11px; }
.viz-legend { display: flex; gap: 14px; align-items: center; margin-top: 8px; color: #475569; font-size: 13px; }
.viz-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.viz-dot.open { background: #2563eb; }
.viz-dot.resolved { background: #22c55e; }
.viz-dot.cpu { background: #2563eb; }
.viz-dot.memory { background: #3b82f6; }
.viz-dot.telemetry { background: #8b5cf6; }
.pie-wrap { display: grid; place-items: center; gap: 8px; }
.pie-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 16px; }
.viz-priority { font-size: 14px; font-weight: 600; }
.viz-priority.high { color: #f97316; }
.viz-priority.critical { color: #ef4444; }
.viz-priority.low { color: #22c55e; }
.viz-priority.medium { color: #ca8a04; }
.perf-grid { display: grid; grid-template-columns: repeat(6, minmax(80px, 1fr)); gap: 10px; align-items: end; height: 250px; }
.perf-slot { display: grid; gap: 8px; align-items: end; }
.perf-bars { height: 210px; display: flex; align-items: end; gap: 4px; padding: 6px; border: 1px dashed #dbe4f2; border-radius: 10px; background: #fff; }
.perf-bar { width: 100%; border-radius: 7px 7px 4px 4px; min-height: 6px; }
.perf-bar.cpu { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.perf-bar.memory { background: linear-gradient(180deg, #60a5fa, #3b82f6); }
.perf-bar.telemetry { background: linear-gradient(180deg, #8b5cf6, #7c3aed); }
.perf-health-list { display: grid; gap: 12px; }
.perf-health-item { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.perf-health-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.perf-health-label { font-size: 13px; color: #334155; font-weight: 600; }
.perf-health-value { font-size: 13px; color: #0f172a; font-weight: 700; }
.perf-health-track { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.perf-health-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #22c55e, #f59e0b, #ef4444); }

.insight-grid { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.insight-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: #fff; min-width: 0; }
.insight-label { font-size: 12px; color: var(--muted); }
.insight-value { font-size: 20px; font-weight: 700; margin-top: 2px; min-width: 0; }

.empty-state {
  border: 1px dashed #c7d2e6;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f8fbff, #f1f6ff);
  padding: 24px;
  text-align: center;
}
.empty-state h3 { margin: 0 0 8px; }
.empty-state p { margin: 0 0 14px; color: var(--muted); }


.notification-list { display: grid; gap: 12px; }
.notification-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 12px;
}
.notification-item p { margin: 8px 0 0; color: #334155; }
.notification-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.ticket-link { color: #1d4ed8; font-weight: 600; text-decoration: none; }
.ticket-link:hover { color: #1e40af; text-decoration: underline; }
.ticket-link-title { display: inline-block; max-width: min(100%, 320px); white-space: normal; overflow-wrap: anywhere; }
.ticket-row-focus td { background: #eff6ff; }
.monitor-text-wrap { min-width: 0; overflow-wrap: break-word; word-break: normal; hyphens: auto; }

.monitor-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.device-kpis { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; }
.kpi-chip {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.kpi-chip .kpi-label { color: var(--muted); font-size: 12px; }
.kpi-chip .kpi-value { font-size: 24px; margin-top: 4px; font-weight: 700; }
.monitor-device-card { min-width: 0; }
.monitor-device-head { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.monitor-device-title { flex: 1 1 220px; min-width: 0; overflow-wrap: break-word; word-break: normal; hyphens: auto; }
.monitor-telemetry-badge { max-width: 100%; white-space: nowrap; text-align: center; overflow-wrap: normal; word-break: keep-all; flex: 0 0 auto; margin-left: auto; }
.monitor-device-meta { display: flex; flex-wrap: wrap; gap: 6px; line-height: 1.5; }
.monitor-meta-separator { color: #94a3b8; }
.monitor-device-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.monitor-health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.monitor-updated-at { font-size: 17px; line-height: 1.45; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #edf2f7; }
.toggle-row:last-child { border-bottom: 0; }
.toggle { width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; position: relative; }
.toggle::after { content: ""; width: 16px; height: 16px; border-radius: 999px; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.active { background: var(--primary); }
.toggle.active::after { left: 21px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(700px, 100%); }
.eula-box { max-height: 140px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; padding: 12px; color: #475569; }
.portal-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 12px; }
.portal-tile { border: 1px solid #dbeafe; background: #f8fbff; border-radius: 14px; padding: 14px; }
.hero-card { background: linear-gradient(180deg, #fff, #f8fbff); }
.eyebrow { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; color: var(--primary); font-weight: 700; letter-spacing: .08em; }

/* Login page inspired by dark centered portal reference */
.auth-dark { background: radial-gradient(circle at 25% 10%, #16213e 0%, #0b1536 35%, #081631 100%); }
.auth-panel {
  width: min(420px, 100%);
  background: rgba(4, 15, 45, .92);
  border: 1px solid rgba(99, 141, 255, .25);
  box-shadow: 0 25px 55px rgba(0, 0, 0, .45);
  border-radius: 16px;
  padding: 28px;
  color: #e6edff;
}
.auth-title { margin: 0 0 8px; font-size: 38px; text-align: center; color: #fff; }
.auth-subtitle { margin: 0 0 16px; color: #a7b5db; text-align: center; }
.auth-panel label { color: #d9e4ff; }
.auth-panel input { background: #f4f7ff; border-color: #dbe4ff; }
.auth-login-btn { width: 100%; margin-top: 8px; background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%); border-radius: 14px; }
.remember-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; color: #c8d5f7; font-size: 14px; }
.auth-links { margin-top: 12px; text-align: left; }
.auth-field-link { display: flex; justify-content: flex-end; margin-top: 8px; }
.link-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { text-decoration-thickness: 2px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: #b8c6e8; font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; background: rgba(184, 198, 232, .28); flex: 1; }
.auth-divider span { white-space: nowrap; }
.auth-social-actions { display: grid; gap: 10px; }
.auth-provider-btn { width: 100%; justify-content: center; border-color: rgba(191, 219, 254, .48); background: rgba(255, 255, 255, .96); color: #0f172a; }
.auth-provider-btn:hover, .auth-provider-btn:focus-visible { background: #fff; border-color: #60a5fa; }
.provider-mark { width: 20px; height: 20px; display: inline-grid; place-items: center; margin-right: 8px; border-radius: 4px; font-weight: 800; }
.provider-google { color: #4285f4; }
.auth-oauth-message { min-height: 18px; margin: 10px 0 0; color: #bfdbfe; }
.mfa-enrollment-card { width: min(520px, 100%); text-align: center; }
.mfa-enrollment-card h3 { margin: 4px 0 8px; color: var(--text); }
.mfa-qr-code { display: block; width: 240px; height: 240px; margin: 16px auto; border: 10px solid #fff; border-radius: 12px; }
.mfa-manual-key { display: block; margin: 10px 0 16px; padding: 10px; border-radius: 8px; background: #eef2ff; color: #1e293b; overflow-wrap: anywhere; user-select: all; }
.mfa-code-group { text-align: left; }
.mfa-code-group input { text-align: center; font-size: 22px; letter-spacing: .3em; }
.mfa-enrollment-error { min-height: 20px; color: #b91c1c; text-align: left; }
.mfa-enrollment-actions { justify-content: flex-end; }
.mfa-recovery-codes { padding: 16px; border-radius: 10px; background: #0f172a; color: #e2e8f0; text-align: left; line-height: 1.6; user-select: all; }
.mfa-finish-button { width: 100%; margin-top: 12px; }
.auth-dark .text-primary { color: #8ec7ff; }
.auth-panel-wide { width: min(700px, 100%); }
.signup-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.auth-heading { margin: 0 0 8px; font-size: 40px; color: #fff; letter-spacing: -0.02em; }
.auth-subtitle-left { text-align: left; margin-bottom: 18px; }
.auth-eyebrow { color: #8ec7ff; margin-bottom: 10px; }
.auth-section-title { margin: 18px 0 10px; color: #f8fbff; }
.auth-eula-box { border-color: rgba(99, 141, 255, .3); background: rgba(15, 31, 75, .72); color: #c4d4ff; }
.signup-eula { margin-top: 12px; }
.auth-actions { margin-top: 14px; }
.auth-ghost-btn { background: rgba(11, 24, 62, .8); border-color: rgba(148, 163, 184, .45); color: #d7e4ff; }
.auth-ghost-btn:hover { background: rgba(24, 44, 96, .95); border-color: rgba(186, 206, 255, .65); }
.signup-eula-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: #c8d5f7; }
.signup-eula-wrap input { width: auto; }
.eula-link-btn { border: 0; background: transparent; color: #8ec7ff; text-align: left; padding: 0; cursor: pointer; font-size: 14px; }
.eula-link-btn:hover { text-decoration: underline; }
.eula-modal-card {
  background: linear-gradient(180deg, #102250 0%, #0c1b42 100%);
  border-color: rgba(99, 141, 255, .38);
  color: #e6edff;
  width: min(620px, 100%);
  padding: 0;
  overflow: hidden;
}
.eula-modal-head { padding: 20px 20px 10px; border-bottom: 1px solid rgba(148, 163, 184, .22); }
.eula-modal-eyebrow { color: #8ec7ff; margin-bottom: 6px; }
.eula-modal-card .section-title { color: #fff; margin: 0; }
.eula-modal-subtitle { margin-top: 8px; color: #c4d4ff; }
.eula-modal-card .eula-box {
  margin: 14px 20px;
  background: rgba(8, 22, 60, .85);
  border-color: rgba(99, 141, 255, .35);
  color: #cbd8ff;
  max-height: 260px;
}
.eula-points { margin: 0; padding-left: 18px; display: grid; gap: 12px; }
.eula-points li { line-height: 1.45; }
.eula-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(148, 163, 184, .22);
}

@media (max-width: 1180px) {
  .admin-panels, .monitor-grid, .settings-grid { grid-template-columns: 1fr; }
  .summary-balanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-balanced-grid > *, .summary-balanced-grid > *:nth-child(n + 5) { grid-column: span 1; }
}

@media (min-width: 981px) and (orientation: portrait) {
  :root {
    --sidebar-width: var(--sidebar-compact-width);
    --content-padding: 18px;
  }

  .app-layout {
    grid-template-columns: minmax(0, var(--sidebar-compact-width)) minmax(0, 1fr);
  }

  .sidebar {
    width: var(--sidebar-compact-width);
    padding-left: 10px;
    padding-right: 10px;
    gap: 12px;
    overflow-x: hidden;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: 270px;
    padding-left: 14px;
    padding-right: 14px;
    box-shadow: 18px 0 34px rgba(2, 11, 42, 0.22);
  }

  .nav-section-title,
  .nav-label {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity .18s ease, max-width .18s ease;
  }

  .sidebar:hover .nav-section-title,
  .sidebar:focus-within .nav-section-title,
  .sidebar:hover .nav-label,
  .sidebar:focus-within .nav-label {
    opacity: 1;
    max-width: 180px;
  }

  .nav-section-title {
    margin-left: 0;
    margin-right: 0;
    text-align: center;
  }

  .sidebar:hover .nav-section-title,
  .sidebar:focus-within .nav-section-title {
    margin-left: 8px;
    text-align: left;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
    gap: 0;
  }

  .sidebar:hover .nav-item,
  .sidebar:focus-within .nav-item {
    justify-content: flex-start;
    gap: 12px;
  }

  .content {
    padding: var(--content-padding);
  }

  .topbar,
  .card-head,
  .global-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .page-actions,
  .inline-actions,
  .dashboard-trend-controls,
  .monitor-actions {
    justify-content: flex-start;
  }

  .summary-balanced-grid,
  .stats,
  .stats.compact-grid,
  .device-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .summary-balanced-grid > *,
  .summary-balanced-grid > *:nth-child(n + 5) {
    grid-column: span 1;
  }

  .admin-panels,
  .monitor-grid,
  .settings-grid,
  .ai-assistant-layout {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 150px;
  }

  .chart-panel,
  .admin-chart {
    min-height: 280px;
  }

  .spark-chart,
  .perf-grid {
    min-width: 620px;
  }

  .chart-placeholder,
  .table-wrap {
    overflow-x: auto;
  }
}

@media (min-width: 981px) and (orientation: landscape) {
  :root {
    --sidebar-width: 270px;
    --content-padding: 24px;
  }

  .summary-balanced-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .admin-panels {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  }
}

@media (max-width: 980px) {
  .admin-panels { grid-template-columns: 1fr; }
  .app-layout { grid-template-columns: minmax(0, 1fr); padding-top: var(--topbar-height); }
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    z-index: 1350;
    width: min(280px, calc(100vw - 36px));
    flex-direction: column;
    overflow: auto;
    box-shadow: 0 18px 36px rgba(2, 11, 42, 0.26);
  }
  .content { padding: 18px; grid-column: 1; }
  .page-title { font-size: 30px; }
  .form-grid, .portal-grid, .device-kpis, .insight-grid, .monitor-device-stats, .monitor-health-grid { grid-template-columns: 1fr; }
  .signup-grid { grid-template-columns: 1fr; }
  .perf-grid { grid-template-columns: repeat(3, minmax(80px, 1fr)); height: auto; }
  .perf-bars { height: 160px; }
  .stats, .stats.compact-grid, .summary-balanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .summary-balanced-grid > *, .summary-balanced-grid > *:nth-child(n + 5) { grid-column: span 1; }
  .metric-card { padding: 16px; min-height: 156px; }
  .metric-value { font-size: 30px; }
}

@media (max-width: 640px) {
  .content { padding: 16px; }
  .dashboard-trend-controls { justify-content: flex-start; }
  .dashboard-trend-controls select { min-width: 0; width: 100%; }
  .monitor-actions { justify-content: flex-start; }
  .live-status-chip { width: 100%; justify-content: center; }
  .utility-bar { padding: 0 10px; }
  .utility-left, .utility-right { gap: 8px; }
  .utility-brand { font-size: 16px; max-width: 150px; }
  .page-title { font-size: 24px; }
  .page-subtitle { font-size: 15px; line-height: 1.45; }
  .card { padding: 16px; }
  .stats, .stats.compact-grid, .summary-balanced-grid { grid-template-columns: 1fr; }
  .summary-balanced-grid > *, .summary-balanced-grid > *:nth-child(n + 5) { grid-column: auto; }
  .metric-card { min-height: 140px; }
  .metric-label, .metric-hint { font-size: 12px; }
  .metric-value { font-size: 28px; margin-top: 10px; }
  .card-head { align-items: flex-start; }
  .card-icon { width: 30px; height: 30px; font-size: 13px; }
  .viz-legend { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .utility-brand { max-width: 132px; }
  .stats, .stats.compact-grid, .summary-balanced-grid { gap: 10px; }
  .metric-card { padding: 14px; min-height: 132px; }
  .metric-value { font-size: 24px; }
}

.utility-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1400;
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #020b2a;
  border-color: #0f204a;
  color: #e2e8f0;
  height: var(--topbar-height);
  padding: 0 14px;
}
.utility-left, .utility-right { display: flex; align-items: center; gap: 10px; }
.utility-brand {
  color: #e2e8f0;
  font-weight: 700;
  letter-spacing: .01em;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 2px;
}
.utility-brand:hover { color: #ffffff; }

.header-icon-btn {
  border-color: rgba(59, 130, 246, 0.18);
  background: linear-gradient(180deg, rgba(18, 35, 84, 0.98), rgba(11, 26, 68, 0.98));
  color: #e2e8f0;
  box-shadow: 0 12px 24px rgba(2, 11, 42, 0.28);
}
.header-icon-btn:hover {
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.28), rgba(30, 64, 175, 0.18));
  border-color: rgba(96, 165, 250, 0.34);
}

.admin-header-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #020b2a;
  border: 1px solid #1f325f;
  border-radius: 12px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 1300;
}

.utility-right { position: relative; }
.admin-header-menu a,
.admin-header-menu button {
  color: #e2e8f0;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.admin-header-menu a:hover,
.admin-header-menu button:hover {
  background: rgba(255,255,255,0.1);
}
.menu-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.menu-action-btn .nav-icon {
  width: 16px;
  height: 16px;
  color: #93c5fd;
}
.menu-action-btn.danger .nav-icon,
.menu-action-btn.danger span {
  color: #fca5a5;
}

body.sidebar-hidden .app-layout {
  grid-template-columns: 0 minmax(0, 1fr);
}
body.sidebar-hidden .sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-color: transparent;
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.app-alert-card { width: min(420px, 100%); }
.profile-page { display: grid; width: min(100%, 1180px); min-width: 0; gap: 16px; margin: 0 auto; }
.profile-hero { overflow: hidden; padding: 0; }
.profile-cover { height: 156px; background: linear-gradient(135deg, #0b4d83, #1565a8 55%, #0f4c81); position: relative; }
.profile-cover::after { content: ''; position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(45deg, transparent 48%, #fff 49%, #fff 51%, transparent 52%), linear-gradient(-45deg, transparent 48%, #fff 49%, #fff 51%, transparent 52%); background-size: 42px 42px; }
.profile-hero-content { min-height: 142px; display: flex; min-width: 0; align-items: flex-end; gap: 22px; padding: 0 30px 25px; }
.profile-identity { flex: 1; min-width: 0; padding-bottom: 2px; }
.profile-photo-wrap { position: relative; flex: 0 0 auto; width: 154px; height: 154px; margin-top: -75px; }
.profile-photo { width: 154px; height: 154px; object-fit: cover; border-radius: 50%; border: 5px solid #fff; background: #f1f5f9; box-shadow: var(--shadow-md); }
.profile-photo-camera { position: absolute; right: 0; top: 0; width: 40px; height: 40px; border: 2px solid #fff; border-radius: 50%; background: #2563eb; color: #fff; cursor: pointer; box-shadow: var(--shadow-md); font-size: 18px; }
.profile-photo-camera:hover, .profile-photo-camera:focus-visible { background: #1d4ed8; outline: 3px solid #93c5fd; outline-offset: 2px; }
.profile-photo-camera:disabled { cursor: wait; opacity: .65; }
.profile-actions { flex: 0 0 auto; padding-bottom: 8px; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.profile-actions .btn { min-width: 132px; }
.profile-name { margin: 0; color: var(--text); font-size: clamp(26px, 4vw, 38px); overflow-wrap: anywhere; }
.profile-email, .profile-department { margin: 0; color: var(--muted); }
.profile-photo-status { min-height: 20px; margin: 0 4px; }
.profile-details-grid { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: 16px; align-items: start; }
.profile-details-grid.colleague-view { grid-template-columns: minmax(0, 1fr); }
.profile-info-card, .profile-account-card { margin: 0; }
.profile-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0 0; }
.profile-facts div { padding: 14px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--border); }
.profile-facts dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.profile-facts dd { margin: 6px 0 0; color: var(--text); font-weight: 700; overflow-wrap: anywhere; }
.approval-photo-preview { width: 56px; height: 56px; object-fit: cover; border-radius: 50%; border: 1px solid var(--border); }
.colleague-page-heading { margin-bottom: 14px; }
.colleague-mobile-tabs { display: none; }
.colleague-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(280px, 320px) minmax(360px, 1fr);
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}
.colleague-panel {
  box-sizing: border-box;
  height: clamp(520px, calc(100dvh - 190px), 720px);
  min-width: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.colleague-panel > .card-head { flex: 0 0 auto; }
.colleague-discovery-panel > input { flex: 0 0 auto; width: 100%; box-sizing: border-box; }
.colleague-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 2px 3px 2px 0;
}
.colleague-search-list { flex: 1 1 50%; margin: 12px 0; }
.colleague-request-list { flex: 0 1 34%; margin-top: 10px; }
.conversation-list { flex: 1 1 auto; margin-top: 12px; }
.colleague-subsection-head { flex: 0 0 auto; padding-top: 12px; border-top: 1px solid var(--border); }
.colleague-subsection-head .section-title { font-size: 16px; }
.colleague-row,
.colleague-request-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.colleague-identity { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; }
.colleague-identity > div { min-width: 0; display: grid; gap: 2px; }
.colleague-identity strong,
.colleague-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colleague-email { color: var(--muted); }
.colleague-avatar,
.chat-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
  font-weight: 800;
}
.colleague-avatar img,
.chat-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.colleague-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.colleague-actions .btn { min-height: 38px; padding: 8px 12px; }
.colleague-request-row > div:first-child { min-width: 0; display: grid; gap: 3px; }
.relationship-note { color: var(--muted); font-size: 12px; font-weight: 700; }
.conversation-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.conversation-row:hover,
.conversation-row:focus-visible,
.conversation-row.is-active { border-color: #93c5fd; background: #eff6ff; outline: none; }
.conversation-copy { display: grid; min-width: 0; gap: 4px; }
.conversation-copy > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.conversation-topline { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 8px; }
.conversation-topline strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-topline small { flex: 0 0 auto; color: var(--muted); }
.chat-unread-pill { min-width: 22px; min-height: 22px; padding: 2px 6px; border-radius: 999px; display: inline-grid; place-items: center; background: #2563eb; color: #fff; font-size: 11px; font-weight: 800; }
.chat-card { min-width: 0; }
.chat-page-header { min-height: 48px; }
.message-list { flex: 1 1 auto; min-height: 0; display: grid; align-content: start; gap: 8px; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: 12px 3px 12px 0; }
.message { justify-self: start; max-width: min(78%, 620px); padding: 10px 12px; border-radius: 14px 14px 14px 4px; background: #f1f5f9; overflow-wrap: anywhere; }
.message.mine { justify-self: end; border-radius: 14px 14px 4px 14px; background: #dbeafe; }
.message p { margin: 0; white-space: pre-wrap; }
.message time { display: block; margin-top: 4px; font-size: 10px; opacity: .65; }
.chat-form { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-form textarea { min-height: 48px; max-height: 130px; flex: 1; resize: vertical; }
.chat-send-status { min-height: 18px; margin: 5px 0 0; color: var(--muted); }
.colleague-empty-state { min-height: 96px; padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; display: grid; place-content: center; justify-items: center; gap: 5px; color: var(--muted); text-align: center; }
.colleague-empty-state strong { color: var(--text); }
.colleague-empty-state.is-error { border-color: #fecaca; background: #fff7f7; color: #991b1b; }

/* Shared non-blocking chat drawer used by admin and end-user shells. */
.chat-drawer-shell {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2600;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.chat-drawer-shell.is-open,
.chat-drawer-shell.is-minimized { pointer-events: auto; }
.chat-drawer {
  height: min(680px, calc(100dvh - 96px));
  min-height: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}
.chat-minimized-bar { display: none; align-items: center; gap: 9px; min-height: 48px; margin-left: auto; padding: 10px 15px; border: 1px solid #1d4ed8; border-radius: 999px; background: #08205a; color: #fff; box-shadow: 0 16px 36px rgba(15, 23, 42, .28); font: inherit; font-weight: 800; cursor: pointer; }
.chat-drawer-shell.is-minimized .chat-drawer { display: none; }
.chat-drawer-shell.is-minimized .chat-minimized-bar { display: flex; }
.chat-minimized-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: #ef4444; color: #fff; font-size: 11px; }
.chat-drawer-header { flex: 0 0 auto; min-height: 62px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #020b2a; color: #f8fafc; }
.chat-drawer-header > div:first-child { display: grid; gap: 2px; }
.chat-drawer-status { color: #bfdbfe; font-size: 11px; }
.chat-drawer-controls { display: flex; gap: 6px; }
.chat-drawer-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border: 1px solid rgba(147, 197, 253, .28); border-radius: 10px; background: rgba(30, 64, 175, .2); color: inherit; font: inherit; font-size: 20px; cursor: pointer; }
.chat-drawer-icon:hover,
.chat-drawer-icon:focus-visible { background: rgba(59, 130, 246, .35); outline: 2px solid #93c5fd; outline-offset: 1px; }
.chat-drawer-body { flex: 1 1 auto; min-height: 0; display: flex; }
.chat-conversation-view { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-drawer-section-head { flex: 0 0 auto; padding: 13px 14px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.chat-drawer-section-head a { color: #2563eb; font-size: 12px; font-weight: 700; }
.chat-drawer-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: grid; align-content: start; gap: 6px; }
.chat-conversation-row { width: 100%; min-width: 0; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.chat-conversation-row:hover,
.chat-conversation-row:focus-visible,
.chat-conversation-row.has-unread { border-color: #bfdbfe; background: #eff6ff; outline: none; }
.chat-conversation-copy { display: grid; min-width: 0; gap: 3px; }
.chat-conversation-copy > small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conversation-topline { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.chat-conversation-topline strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conversation-topline small { flex: 0 0 auto; color: var(--muted); }
.chat-active-header { flex: 0 0 auto; min-height: 58px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.chat-active-header .chat-drawer-icon { color: #1e3a8a; background: #eff6ff; border-color: #bfdbfe; }
.chat-active-person { min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 8px; }
.chat-active-person .chat-avatar { width: 38px; height: 38px; }
.chat-active-person > span { min-width: 0; display: grid; }
.chat-active-person strong,
.chat-active-person small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-active-person small { color: var(--muted); }
.chat-profile-link { border: 0; background: transparent; color: #2563eb; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.chat-profile-link:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
.chat-message-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 12px; background: #f8fafc; }
.chat-message { justify-self: start; max-width: 82%; padding: 9px 11px; border-radius: 13px 13px 13px 4px; background: #fff; border: 1px solid #e2e8f0; overflow-wrap: anywhere; }
.chat-message.mine { justify-self: end; border-radius: 13px 13px 4px 13px; border-color: #bfdbfe; background: #dbeafe; }
.chat-message p { margin: 0; white-space: pre-wrap; }
.chat-message time { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.chat-drawer-form { flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: #fff; }
.chat-drawer-form textarea { min-height: 44px; max-height: 110px; resize: vertical; }
.chat-drawer-form .btn { min-height: 44px; }
.chat-drawer .chat-send-status { padding: 0 10px; background: #fff; }
.chat-drawer .chat-empty-state { min-height: 110px; margin: 8px; padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; display: grid; place-content: center; justify-items: center; gap: 5px; color: var(--muted); text-align: center; }
.chat-drawer .chat-empty-state strong { color: var(--text); }
.chat-drawer .chat-empty-state.is-error { border-color: #fecaca; background: #fff7f7; color: #991b1b; }

@media (max-width: 1180px) {
  .colleague-mobile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
  .colleague-mobile-tabs button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 800; cursor: pointer; }
  .colleague-mobile-tabs button.is-active { background: #dbeafe; color: #1d4ed8; }
  .colleague-layout { display: block; }
  .colleague-panel { display: none; height: clamp(520px, calc(100dvh - 210px), 760px); }
  .colleague-panel.is-mobile-active { display: flex; }
}

@media (max-width: 640px) {
  .colleague-page-heading .page-subtitle { max-width: 34ch; }
  .colleague-panel { height: calc(100dvh - 204px); min-height: 480px; padding: 14px; border-radius: 12px; }
  .colleague-actions { justify-content: stretch; }
  .colleague-actions .btn { flex: 1 1 auto; }
  .chat-form { display: grid; grid-template-columns: 1fr; }
  .chat-drawer-shell.is-open { inset: 0; width: 100%; height: 100dvh; }
  .chat-drawer-shell.is-open .chat-drawer { width: 100%; height: 100dvh; min-height: 0; max-height: none; border: 0; border-radius: 0; }
  .chat-drawer-shell.is-minimized { right: 12px; bottom: 12px; width: auto; }
  .chat-drawer-header { padding-top: max(12px, env(safe-area-inset-top)); }
  .chat-drawer-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (max-width: 980px) {
  /* A hidden fixed sidebar must not leave content in a zero-width grid column. */
  body.sidebar-hidden .app-layout { grid-template-columns: minmax(0, 1fr); }
  body.sidebar-hidden .content { grid-column: 1; }
  .profile-details-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .profile-cover { height: 112px; }
  .profile-hero-content { align-items: flex-start; padding: 0 18px 20px; gap: 14px; }
  .profile-actions { width: 100%; }
  .profile-actions .btn { width: 100%; }
  .profile-photo-wrap { width: 112px; height: 112px; margin-top: -52px; }
  .profile-photo { width: 112px; height: 112px; }
  .profile-facts { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .profile-cover { height: 92px; }
  .profile-hero-content { display: grid; padding: 0 16px 18px; }
  .profile-photo-wrap { width: 96px; height: 96px; margin-top: -44px; }
  .profile-photo { width: 96px; height: 96px; }
  .profile-photo-camera { width: 36px; height: 36px; font-size: 15px; }
  .profile-name { font-size: 26px; }
  .profile-facts div { padding: 12px; }
}
.app-alert-message { white-space: pre-wrap; margin: 4px 0 14px; color: #334155; }
#globalSearchModal { z-index:3000; align-items:start; overflow:auto; box-sizing:border-box; padding:clamp(16px, 7vh, 72px) 16px; }
body.global-search-open { overflow:hidden; }
.global-search-card { box-sizing:border-box; width:min(640px, 100%); max-height:calc(100dvh - clamp(32px, 14vh, 144px)); display:flex; flex-direction:column; overflow:hidden; padding:18px; border-radius:16px; box-shadow:0 20px 48px rgba(15, 23, 42, .24); }
.global-search-card .card-head { margin-bottom:10px; }
.global-search-input { width:100%; box-sizing:border-box; margin:0; padding:11px 13px; border-radius:10px; }
.global-search-results { display:grid; gap:6px; min-height:0; overflow:auto; margin-top:12px; padding-right:2px; }
.global-search-section { margin:10px 0 2px; color:var(--muted); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; }
.global-search-result { display:block; width:100%; box-sizing:border-box; padding:12px 13px; border:1px solid transparent; border-radius:9px; background:transparent; color:var(--text); text-align:left; cursor:pointer; overflow-wrap:anywhere; }
.global-search-result:hover,.global-search-result:focus-visible { border-color:#bfdbfe; background:#eff6ff; outline:none; }
.global-search-hint { margin:8px 2px; color:var(--muted); }
@media (max-width:640px) { #globalSearchModal { padding:12px; } .global-search-card { max-height:calc(100dvh - 24px); padding:16px; border-radius:12px; } }
.hidden { display: none !important; }
.show { display: grid; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.single-col { grid-template-columns: 1fr; }
.text-success { color: #166534; }
.text-danger { color: #991b1b; }

.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}


.page-splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(2, 11, 42, 0.42);
  backdrop-filter: blur(3px);
}

.page-splash-card {
  width: min(340px, calc(100% - 24px));
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 20px;
  text-align: center;
}

.page-splash-card h3 { margin: 8px 0 6px; }
.page-splash-hidden { opacity: 0; pointer-events: none; transition: opacity .2s ease; }

.page-splash-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #bfdbfe;
  border-top-color: var(--primary);
  display: inline-block;
  animation: aitsm-spin .8s linear infinite;
}

@keyframes aitsm-spin { to { transform: rotate(360deg); } }

.analytics-buffering {
  display: grid;
  place-items: center;
  min-height: 220px;
}

.analytics-buffer-msg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #475569;
  font-weight: 600;
}

.analytics-skeleton {
  opacity: .92;
  border-style: dashed;
}
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #e2e8f0 20%, #f8fafc 50%, #e2e8f0 80%);
  background-size: 200% 100%;
  animation: aitsm-skeleton 1.2s ease-in-out infinite;
}
.skeleton::after { content: none; }
.skeleton-text { border-radius: 999px; display: block; }
.skeleton-label { width: 108px; height: 12px; }
.skeleton-value { width: 72px; height: 38px; margin: 10px 0 12px; }
.skeleton-hint { width: 136px; height: 12px; }
.skeleton-icon { width: 34px; height: 34px; }
.skeleton-chart { width: 100%; height: 180px; border-radius: 14px; }
.skeleton-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.skeleton-pill { width: 88px; height: 12px; border-radius: 999px; }
.analytics-skeleton-panel { width: 100%; }
@keyframes aitsm-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


.notif-trigger-btn { position: relative; }
.notif-count { position: absolute; top: -4px; right: -4px; font-size: 11px; background: linear-gradient(135deg, #ef4444, #f97316); color: #fff; border-radius: 999px; padding: 2px 6px; margin-left: 0; box-shadow: 0 8px 18px rgba(239, 68, 68, 0.35); }
.help-tip { display:inline-grid; place-items:center; width:16px; height:16px; border-radius:999px; background:#dbeafe; color:#1d4ed8; font-size:11px; font-weight:700; cursor:help; margin-left:6px; }

.row-action-wrap { position: relative; display: inline-flex; justify-content: center; }
.row-action-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 170px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); z-index: 40; display: grid; padding: 6px; }
.row-action-menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: #0f172a; }
.row-action-menu button:hover { background: #f1f5f9; }

.action-menu-backdrop { position: fixed; inset: 0; background: transparent; z-index: 35; }
.row-action-menu { z-index: 50; }
.remember-row{display:inline-flex;align-items:center;gap:6px;cursor:pointer;white-space:nowrap;}

.ai-assistant-layout {
  margin-top: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
  align-items: start;
}
.ai-chat-card {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto auto;
  gap: 12px;
}
.ai-chat-thread {
  min-height: 420px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 10px;
}
.ai-message {
  display: grid;
  gap: 6px;
}
.ai-message-user {
  justify-items: end;
}
.ai-message-bubble {
  max-width: min(100%, 740px);
  border: 1px solid #d7e4ff;
  border-radius: 14px;
  padding: 11px 12px;
  background: #fff;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}
.ai-message-user .ai-message-bubble {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-color: #2563eb;
}
.ai-message-meta {
  font-size: 12px;
  color: var(--muted);
}
.ai-ticket-btn {
  height: 36px;
  font-size: 13px;
}
.ai-composer {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.ai-composer textarea {
  min-height: 100px;
  max-height: 240px;
}
.ai-loading {
  color: #1e40af;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}
.ai-suggestions-card {
  display: grid;
  gap: 10px;
}
.ai-prompt-list {
  display: grid;
  gap: 8px;
}
.ai-prompt {
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  min-height: 42px;
}

@media (max-width: 1020px) {
  .ai-assistant-layout {
    grid-template-columns: 1fr;
  }
  .ai-chat-thread {
    max-height: none;
    min-height: 360px;
  }
}

.ai-sections {
  margin-top: 8px;
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
  display: grid;
  gap: 8px;
}
.ai-sections p,
.ai-sections ul,
.ai-sections ol {
  margin: 4px 0 0;
  padding-left: 18px;
}
.ai-sections p { padding-left: 0; }

.ai-advisory-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #f8fbff;
  display: grid;
  gap: 14px;
}
.ai-advisory-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ai-advisory-heading p { margin: 4px 0 0; }
.ai-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-preview-grid .form-group:nth-child(-n + 2) { grid-column: 1 / -1; }
.ai-preview-grid textarea { min-height: 120px; }
.ai-recommendation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-recommendation-grid > section { min-width: 0; display: grid; align-content: start; gap: 8px; }
.ai-recommendation-item { display: grid; gap: 3px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; }
.ai-recommendation-item:hover,
.ai-recommendation-item:focus-visible { border-color: #60a5fa; background: #eff6ff; outline: none; }
.ai-recommendation-item span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.ai-ticket-assistance { margin-top: 16px; }
.ai-ticket-assistance-results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.ai-ticket-assistance-results > section { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.ai-ticket-assistance-results h4 { margin: 0 0 10px; }
.ai-review-copy { white-space: pre-wrap; line-height: 1.6; overflow-wrap: anywhere; }
.ai-checklist { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.ai-resolution-editor { grid-column: 1 / -1; }
.ai-resolution-editor textarea { width: 100%; min-height: 180px; }

@media (max-width: 760px) {
  .ai-preview-grid,
  .ai-recommendation-grid,
  .ai-ticket-assistance-results { grid-template-columns: 1fr; }
  .ai-preview-grid .form-group:nth-child(-n + 2),
  .ai-resolution-editor { grid-column: auto; }
  .ai-advisory-heading { align-items: stretch; }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.status-pill-neutral { background: #e2e8f0; color: #334155; }
.status-pill-ok { background: #dcfce7; color: #166534; }
.status-pill-fail { background: #fee2e2; color: #991b1b; }

.gemini-card .inline-actions { flex-wrap: wrap; }

/* Fail visibly and keep content usable if a role shell is delayed or cannot load. */
.utility-bar:empty::after {
  content: "Loading workspace…";
  color: #cbd5e1;
  font-size: 13px;
  padding-left: 4px;
}

.app-layout:has(> .sidebar:empty) {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-layout > .sidebar:empty {
  width: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}

.app-layout:has(> .sidebar:empty) > .content {
  grid-column: 2;
}

@media (max-width: 980px) {
  .app-layout:has(> .sidebar:empty) {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-layout:has(> .sidebar:empty) > .content { grid-column: 1; }
}
