:root {
  --c-navy:           #1a3a5c;
  --c-navy-hover:     #15304e;
  --c-navy-light:     #e8f0f8;
  --c-navy-border:    #b8cfe8;
  --c-red:            #e24b4a;
  --c-red-light:      #fdeaea;
  --c-amber:          #d97706;
  --c-amber-light:    #fef3e2;
  --c-green:          #2e7d32;
  --c-green-light:    #e8f5e9;
  --c-blue:           #2563eb;
  --c-blue-light:     #eff6ff;
  --c-purple:         #7c3aed;
  --c-purple-light:   #f5f3ff;
  --c-teal:           #0f766e;
  --c-teal-light:     #f0fdfa;
  --c-text-primary:   #111827;
  --c-text-secondary: #6b7280;
  --c-text-muted:     #9ca3af;
  --c-border:         #e5e7eb;
  --c-border-strong:  #d1d5db;
  --c-bg-page:        #f3f4f6;
  --c-bg-card:        #ffffff;
  --c-bg-hover:       #f9fafb;
  --c-bg-sidebar:     #ffffff;
  --r-sm: 5px;
  --r-md: 9px;
  --r-lg: 13px;
  --r-xl: 18px;
  --sidebar-width:     240px;
  --sidebar-collapsed: 60px;
  --topbar-height:     56px;
  --font-base: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "Fira Code", "Cascadia Code", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-base);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--c-text-primary);
  background: var(--c-bg-page);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
#main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
#topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-card);
  flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 600; flex-shrink: 0; }
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.muted { color: var(--c-text-secondary); }
.small { font-size: 12px; }

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.btn-primary { background: var(--c-navy); color: white; }
.btn-primary:hover { background: var(--c-navy-hover); text-decoration: none; }
.btn-secondary { background: var(--c-bg-card); border-color: var(--c-border-strong); color: var(--c-text-primary); }
.btn-secondary:hover { background: var(--c-bg-hover); text-decoration: none; }
.btn-danger { background: var(--c-red); color: white; }
.btn-danger:hover { background: #c63a39; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-secondary); font-size: 18px;
}
.icon-btn:hover { background: var(--c-bg-hover); color: var(--c-text-primary); }

.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--c-text-secondary); }
.form-input, .form-select {
  height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: white;
}
textarea.form-input { height: auto; resize: vertical; min-height: 60px; }
.form-input:focus, .form-select:focus { outline: 2px solid var(--c-navy-border); outline-offset: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid;
  font-size: 14px;
}
.flash i { font-size: 18px; flex-shrink: 0; }
.flash-close { margin-left: auto; background: transparent; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; }
.flash-success { background: var(--c-green-light); border-color: #c8e6c9; color: var(--c-green); }
.flash-error   { background: var(--c-red-light);   border-color: #f5c2c2; color: var(--c-red); }
.flash-warning { background: var(--c-amber-light); border-color: #f5d6a3; color: var(--c-amber); }
.flash-info    { background: var(--c-blue-light);  border-color: #c8dcfe; color: var(--c-blue); }

/* License banner — persistent, non-blocking; severity-styled with the
   same theme vars as .flash. Content works normally beneath it. */
.license-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid;
  font-size: 14px; margin: 0 0 16px;
}
.license-banner i { font-size: 18px; flex-shrink: 0; }
.license-banner__msg { flex: 1; }
.license-banner__action { margin: 0; }
.license-banner--critical { background: var(--c-red-light);   border-color: #f5c2c2; color: var(--c-red); }
.license-banner--warning  { background: var(--c-amber-light); border-color: #f5d6a3; color: var(--c-amber); }
.license-banner--info     { background: var(--c-blue-light);  border-color: #c8dcfe; color: var(--c-blue); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; line-height: 1.6;
  background: var(--c-bg-hover); color: var(--c-text-secondary);
}
.badge-warning { background: var(--c-amber-light); color: var(--c-amber); }
.badge-login-success    { background: var(--c-green-light); color: var(--c-green); }
.badge-login-failed     { background: var(--c-red-light); color: var(--c-red); }
.badge-logout           { background: var(--c-bg-hover); color: var(--c-text-secondary); }
.badge-password-changed { background: var(--c-blue-light); color: var(--c-blue); }
.badge-2fa-enabled      { background: var(--c-teal-light); color: var(--c-teal); }
.badge-2fa-verified     { background: var(--c-teal-light); color: var(--c-teal); }
.badge-2fa-failed       { background: var(--c-red-light); color: var(--c-red); }
.badge-agent-created    { background: var(--c-green-light); color: var(--c-green); }
.badge-agent-updated    { background: var(--c-blue-light); color: var(--c-blue); }
.badge-agent-deactivated{ background: var(--c-amber-light); color: var(--c-amber); }
.badge-agent-reactivated{ background: var(--c-green-light); color: var(--c-green); }
.badge-permissions-overridden { background: var(--c-purple-light); color: var(--c-purple); }
.badge-system-seeded    { background: var(--c-bg-hover); color: var(--c-text-secondary); }
.badge-account-locked   { background: var(--c-red-light); color: var(--c-red); }
.badge-password-reset   { background: var(--c-amber-light); color: var(--c-amber); }
.badge-2fa-reset        { background: var(--c-amber-light); color: var(--c-amber); }
.badge-role-created     { background: var(--c-green-light); color: var(--c-green); }
.badge-role-updated     { background: var(--c-blue-light); color: var(--c-blue); }
.badge-role-deleted     { background: var(--c-red-light); color: var(--c-red); }

.role-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  border: 1px solid;
}
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.status-badge.active   { background: var(--c-green-light); color: var(--c-green); }
.status-badge.inactive { background: var(--c-bg-hover); color: var(--c-text-secondary); }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
}
.data-table th {
  font-weight: 600; color: var(--c-text-secondary);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--c-bg-hover);
}
.data-table tr:hover td { background: var(--c-bg-hover); }
.data-table .empty { text-align: center; color: var(--c-text-muted); padding: 24px; }
.actions-cell { white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.mono { font-family: var(--font-mono); font-size: 12px; }

.toolbar {
  display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap;
}
.toolbar .btn-primary { margin-left: auto; }

.pagination {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  margin-top: 16px; font-size: 13px; color: var(--c-text-secondary);
}

.dropdown-host { position: relative; display: inline-block; }
.dropdown-menu, .dropdown-panel {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: white; border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 6px;
  min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  display: none; z-index: 100;
}
.dropdown-menu.open, .dropdown-panel.open { display: block; }
.dropdown-menu li { list-style: none; }
.dropdown-menu a, .dropdown-panel a, .dropdown-item-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--c-text-primary); font-size: 13px;
  background: transparent; border: none; width: 100%; text-align: left;
  cursor: pointer; font-family: inherit;
}
.dropdown-menu a:hover, .dropdown-panel a:hover, .dropdown-item-btn:hover {
  background: var(--c-bg-hover); text-decoration: none;
}
.dropdown-item-btn.danger { color: var(--c-red); }
.dp-header { padding: 8px 10px 10px; border-bottom: 1px solid var(--c-border); margin-bottom: 4px; font-weight: 600; font-size: 12px; color: var(--c-text-secondary); display: flex; flex-direction: column; gap: 4px; }
.dp-footer { display: block; padding: 8px 10px; border-top: 1px solid var(--c-border); margin-top: 4px; font-size: 12px; text-align: center; }
.dp-empty  { padding: 12px 10px; color: var(--c-text-muted); font-size: 12px; text-align: center; }

.notif-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; }
.notif-item:hover { background: var(--c-bg-hover); }
.notif-icon { color: var(--c-text-muted); flex-shrink: 0; margin-top: 2px; }
.notif-text { font-size: 13px; }
.notif-time { font-size: 11px; color: var(--c-text-muted); }
.notif-dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  background: var(--c-red); border-radius: 999px; border: 2px solid white;
}

.topbar-search-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-bg-hover); cursor: pointer;
  color: var(--c-text-muted); font-size: 13px;
  font-family: var(--font-base);
  transition: border-color 150ms, background 150ms;
  min-width: 240px;
}
.topbar-search-btn:hover {
  border-color: var(--c-navy-border);
  background: var(--c-navy-light);
}
.search-btn-placeholder { flex: 1; text-align: left; }
.search-shortcut {
  font-size: 10px; padding: 1px 5px;
  background: var(--c-bg-card); border: 1px solid var(--c-border);
  border-radius: 4px; color: var(--c-text-muted);
  font-family: var(--font-mono);
}
.topbar-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.agent-avatar-btn {
  background: var(--c-navy); color: white; font-weight: 600;
  font-size: 12px;
}
.agent-avatar-btn:hover { background: var(--c-navy-hover); color: white; }

.greeting-card h2 { font-size: 22px; margin-bottom: 4px; }
.phase-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px; list-style: none;
}
.phase-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--c-border); background: var(--c-bg-hover);
}
.phase-pill .phase-num {
  background: var(--c-bg-card); border: 1px solid var(--c-border);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.phase-pill .phase-name { flex: 1; font-size: 13px; }
.phase-pill.phase-complete { background: var(--c-green-light); border-color: #c8e6c9; }
.phase-pill.phase-complete .phase-num { background: var(--c-green); color: white; border-color: var(--c-green); }
.phase-pill.phase-complete i { color: var(--c-green); }
.phase-pill.phase-pending { color: var(--c-text-muted); }
.status-ready { background: var(--c-green-light); border-color: #c8e6c9; }
.status-ready .card-title { color: var(--c-green); }

.quick-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--c-bg-card); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 26px; font-weight: 600; color: var(--c-navy); }
.stat-label { font-size: 12px; color: var(--c-text-secondary); }

.temp-password-banner {
  background: #fffbea; border: 1px solid #f5d99a; border-radius: var(--r-lg);
  padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.temp-password-banner code {
  font-family: var(--font-mono); background: white; padding: 4px 8px;
  border: 1px solid var(--c-border); border-radius: 6px;
  margin-left: 8px;
}
.temp-password-banner small { width: 100%; color: var(--c-text-secondary); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.link-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--c-blue); font-size: 12px; padding: 0;
}
.link-btn:hover { text-decoration: underline; }
