/* ==============================================================================
   public/css/dashboard.css
   Enterprise Operations Console — Professional Corporate Design System
   ============================================================================== */

/* ==============================================================================
   Zero-FOUC Instant Session Gate
   ============================================================================== */
#login-view {
  display: none;
}
#app-view {
  display: none;
}
html.has-session #app-view {
  display: grid !important;
}
html.has-session #login-view {
  display: none !important;
}
html.no-session #login-view {
  display: flex !important;
}
html.no-session #app-view {
  display: none !important;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--text-primary);
}

/* ==============================================================================
   1. AUTHENTICATION VIEWPORT (Executive Login Portal)
   ============================================================================== */
.auth-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(ellipse at top, rgba(79, 70, 229, 0.08) 0%, transparent 65%),
    linear-gradient(to bottom, var(--bg-app), #04060a);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-header {
  margin-bottom: var(--space-6);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.auth-brand-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.auth-env-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--brand-primary-subtle);
  color: #818cf8;
  border: 1px solid var(--brand-primary-border);
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.auth-error-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-5);
  background: var(--status-rose-subtle);
  border: 1px solid var(--status-rose-border);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.82rem;
}

.auth-form .form-group {
  margin-bottom: var(--space-4);
}

.auth-hint-pill {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.auth-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.auth-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

.auth-security-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==============================================================================
   2. ENTERPRISE APPLICATION SHELL (Grid Layout)
   ============================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--transition-smooth);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* ==============================================================================
   3. SIDEBAR NAVIGATION
   ============================================================================== */
.app-sidebar {
  grid-area: sidebar;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 0 12px rgba(79, 70, 229, 0.4);
}

.brand-text {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 var(--space-3) var(--space-2);
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

.app-shell.sidebar-collapsed .nav-group-title {
  opacity: 0;
  pointer-events: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--brand-primary-subtle);
  color: #a5b4fc;
  border-color: var(--brand-primary-border);
}

.nav-item svg {
  flex-shrink: 0;
  stroke: currentColor;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
}

.nav-item.active .nav-badge {
  background: var(--brand-primary);
  color: #ffffff;
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.btn-collapse-sidebar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-collapse-sidebar:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* ==============================================================================
   4. TOP BAR
   ============================================================================== */
.app-topbar {
  grid-area: topbar;
  background-color: var(--bg-topbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.btn-mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.view-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
}

.view-breadcrumb .root-title {
  color: var(--text-muted);
}

.view-breadcrumb .separator {
  color: var(--border-strong);
}

.view-breadcrumb .current-title {
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Global Search Input with Shortcut Chip */
.global-search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  width: 240px;
  transition: all var(--transition-fast);
}

.global-search-bar:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-surface-elevated);
  width: 280px;
}

.global-search-bar input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  width: 100%;
  outline: none;
}

.global-search-bar input::placeholder {
  color: var(--text-muted);
}

.kbd-shortcut {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  line-height: 1.2;
}

/* Status Chip */
.edge-status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.status-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--status-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* User Profile Pill */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-left: var(--space-3);
  border-left: 1px solid var(--border-subtle);
}

.user-avatar-initials {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #818cf8;
}

.user-meta-block {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-meta-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ==============================================================================
   5. MAIN VIEWPORT & SECTIONS
   ============================================================================== */
.app-main-viewport {
  grid-area: main;
  overflow-y: auto;
  padding: var(--space-6);
  background-color: var(--bg-app);
}

.view-section {
  display: none;
  animation: fadeIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.view-title-group h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.view-title-group p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.view-action-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ==============================================================================
   6. METRIC & KPI CARDS (Executive Grid)
   ============================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
  position: relative;
  transition: border-color var(--transition-fast);
}

.kpi-card:hover {
  border-color: var(--border-medium);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.kpi-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 4px;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Metric Accents */
.kpi-card.accent-indigo::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-primary);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.kpi-card.accent-amber::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--status-amber);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.kpi-card.accent-rose::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--status-rose);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

/* ==============================================================================
   7. TABLE-FIRST DATA GRIDS
   ============================================================================== */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: var(--bg-surface-subtle);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.table-search-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  width: 220px;
}

.table-search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  width: 100%;
  outline: none;
}

.table-search-box input::placeholder {
  color: var(--text-muted);
}

.filter-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--border-focus);
}

.table-responsive-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  width: 100%;
}

.enterprise-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

.enterprise-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 var(--border-subtle);
  user-select: none;
}

.enterprise-table th.th-right {
  text-align: right;
}

.enterprise-table td {
  padding: 11px var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-primary);
  vertical-align: middle;
}

.enterprise-table tbody tr {
  transition: background-color var(--transition-fast);
}

.enterprise-table tbody tr:hover {
  background-color: var(--bg-surface-hover);
}

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

.cell-primary {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-secondary {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.table-footer-meta {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-surface-subtle);
}

/* ==============================================================================
   8. STATUS BADGES & TAGS
   ============================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: currentColor;
}

.badge-emerald {
  background-color: var(--status-emerald-subtle);
  color: var(--status-emerald);
  border: 1px solid var(--status-emerald-border);
}

.badge-amber {
  background-color: var(--status-amber-subtle);
  color: var(--status-amber);
  border: 1px solid var(--status-amber-border);
}

.badge-rose {
  background-color: var(--status-rose-subtle);
  color: var(--status-rose);
  border: 1px solid var(--status-rose-border);
}

.badge-sky {
  background-color: var(--status-sky-subtle);
  color: var(--status-sky);
  border: 1px solid var(--status-sky-border);
}

.badge-slate {
  background-color: var(--status-slate-subtle);
  color: var(--status-slate);
  border: 1px solid var(--status-slate-border);
}

/* ==============================================================================
   9. BUTTON HIERARCHY
   ============================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 10px 18px;
  font-size: 0.9rem;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--brand-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-destructive {
  background-color: var(--status-rose-subtle);
  border-color: var(--status-rose-border);
  color: #fca5a5;
}
.btn-destructive:hover {
  background-color: var(--status-rose);
  color: #ffffff;
}

.btn-emerald {
  background-color: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}
.btn-emerald:hover {
  background-color: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.btn-icon-only {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-icon-only:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* ==============================================================================
   10. FORMS & INPUTS
   ============================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.82rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}

.form-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--brand-primary);
  width: 15px;
  height: 15px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 32px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.btn-toggle-pwd:hover {
  color: var(--text-primary);
}

/* ==============================================================================
   11. ENTERPRISE MODALS & DRAWERS
   ============================================================================== */
dialog:not([open]),
.enterprise-modal:not([open]),
.enterprise-drawer:not([open]) {
  display: none !important;
}

.enterprise-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  width: 90%;
  max-width: 540px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  outline: none;
  z-index: 1000;
}

.enterprise-modal[open] {
  display: flex;
  flex-direction: column;
}

.enterprise-modal::backdrop {
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(4px);
}

.enterprise-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  margin: 0 0 0 auto;
  height: 100vh;
  max-height: 100vh;
  width: 480px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  border-top: none;
  border-right: none;
  border-bottom: none;
  padding: 0;
  box-shadow: var(--shadow-drawer);
  outline: none;
  z-index: 1000;
}

.enterprise-drawer[open] {
  display: flex;
  flex-direction: column;
}

.enterprise-drawer::backdrop {
  background: rgba(4, 6, 12, 0.65);
  backdrop-filter: blur(2px);
}

.dialog-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-header .dialog-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.dialog-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.dialog-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-surface-subtle);
}

/* Renewal Modal Specifics */
.renewal-preview-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-2);
}

.renewal-progression-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

/* ==============================================================================
   12. TIMELINE & ACTIVITY ENTRIES (Audit / Reminders)
   ============================================================================== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.timeline-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.82rem;
}

.timeline-time {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.timeline-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ==============================================================================
   13. SETTINGS & SYSTEM CARDS
   ============================================================================== */
.settings-section-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-6);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-8);
}

.settings-meta-col h3 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.settings-meta-col p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ==============================================================================
   14. TOAST NOTIFICATIONS
   ============================================================================== */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: slideToast 200ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 380px;
}

.toast.toast-success {
  border-left: 3px solid var(--status-emerald);
}

.toast.toast-error {
  border-left: 3px solid var(--status-rose);
}

@keyframes slideToast {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.6s linear infinite;
}

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

/* Skeletons */
.skeleton-row td {
  padding: 14px var(--space-4);
}
.skeleton-box {
  height: 14px;
  background: linear-gradient(90deg, var(--bg-surface-elevated) 25%, var(--bg-surface-hover) 50%, var(--bg-surface-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.kpi-placeholder {
  display: inline-block;
  min-width: 48px;
  height: 1.15em;
  vertical-align: middle;
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--bg-surface-elevated) 25%, var(--bg-surface-hover) 50%, var(--bg-surface-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  color: transparent !important;
  user-select: none;
}

/* ==============================================================================
   15. RESPONSIVE BREAKPOINTS & MOBILE ADAPTATION
   ============================================================================== */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--sidebar-collapsed-width) 1fr;
  }
  .app-sidebar .sidebar-brand .brand-text,
  .app-sidebar .nav-item span:not(.nav-badge),
  .app-sidebar .nav-group-title,
  .app-sidebar .btn-collapse-sidebar span {
    display: none;
  }
  .settings-section-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    width: 260px;
    transition: left var(--transition-smooth);
    box-shadow: var(--shadow-lg);
  }

  .app-sidebar.mobile-open {
    left: 0;
  }

  .app-sidebar .sidebar-brand .brand-text,
  .app-sidebar .nav-item span:not(.nav-badge),
  .app-sidebar .nav-group-title {
    display: block !important;
  }

  .btn-mobile-nav-toggle {
    display: flex;
  }

  .global-search-bar {
    display: none;
  }

  .edge-status-chip {
    display: none;
  }

  .app-main-viewport {
    padding: var(--space-4);
  }

  .form-row, .checkbox-group {
    grid-template-columns: 1fr;
  }

  .enterprise-drawer {
    width: 100vw;
    max-width: 100vw;
  }
}

/* ==============================================================================
   9. CLIENT SELECTION & SECTIONED MODAL FORM STYLES
   ============================================================================== */
.form-section-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color var(--transition-fast);
}

.form-section-card:focus-within {
  border-color: var(--border-medium);
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-subtle);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.form-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.form-section-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.client-linked-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  color: #34d399;
  font-size: 0.78rem;
  margin-bottom: var(--space-1);
}

.client-linked-chip svg {
  flex-shrink: 0;
}

.btn-chip-action {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-chip-action:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #fff;
}

/* ==============================================================================
   10. PORTFOLIO VIEW SWITCHER & CLIENT DIRECTORY
   ============================================================================== */
.view-segmented-tabs {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  margin-bottom: var(--space-4);
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-pill.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.client-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.client-dir-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.client-dir-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.client-dir-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.client-dir-company {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.client-dir-contact {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.client-dir-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.client-dir-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-dir-metrics {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.client-metric-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-metric-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.client-metric-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.client-dir-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.client-dir-actions .btn {
  flex: 1;
  justify-content: center;
}

/* ==============================================================================
   16. CUSTOM SEARCHABLE COMBOBOX (Dark Theme Elevated)
   ============================================================================== */
.custom-combobox {
  position: relative;
  width: 100%;
}

.combobox-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.combobox-trigger:hover {
  background: var(--bg-surface-hover);
  border-color: var(--brand-primary);
}

.combobox-trigger:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--brand-primary-subtle);
}

.combobox-selected-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
}

.combobox-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-subtle);
  color: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.combobox-text-group {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.combobox-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-arrow {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
  margin-left: var(--space-2);
}

.custom-combobox.open .combobox-arrow {
  transform: rotate(180deg);
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #131b2e; /* Solid elevated dark slate for crystal-clear visibility */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 10000;
  max-height: 290px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 120ms ease;
}

.combobox-search-wrapper {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f1626;
}

.combobox-search-wrapper svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.combobox-search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}

.combobox-search-input::placeholder {
  color: var(--text-muted);
}

.combobox-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.75rem;
}
.combobox-clear-btn:hover {
  color: var(--text-primary);
}

.combobox-options {
  list-style: none;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  max-height: 230px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.combobox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.combobox-option:hover, .combobox-option.highlighted {
  background: var(--bg-surface-hover);
}

.combobox-option.selected {
  background: var(--brand-primary-subtle);
}

.combobox-option-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.combobox-option.selected .combobox-option-avatar {
  background: var(--brand-primary);
  color: #ffffff;
}

.combobox-option-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.combobox-option-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.combobox-option.add-new {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}
.combobox-option.add-new .combobox-option-title {
  color: #818cf8;
}

.combobox-empty-message {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ==============================================================================
   17. MODE SWITCHER & BATCH MULTI-DOMAIN BUILDER
   ============================================================================== */
.mode-segmented-control {
  display: inline-flex;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  width: 100%;
}

.mode-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-pill:hover {
  color: var(--text-primary);
}

.mode-pill.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

#client-modal.enterprise-drawer.batch-mode-active {
  width: 720px;
  max-width: 96vw;
}

.batch-defaults-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.batch-defaults-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.batch-defaults-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr auto;
  gap: var(--space-2);
  align-items: center;
}

.batch-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  white-space: nowrap;
}

.batch-table th {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.batch-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.batch-input, .batch-date-input, .batch-select {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast);
}

.batch-input:focus, .batch-date-input:focus, .batch-select:focus {
  border-color: var(--border-focus);
}

.batch-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

.btn-remove-batch-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-remove-batch-row:hover {
  background: var(--status-rose-subtle);
  color: var(--status-rose);
}

.batch-table-footer {
  padding: 8px 12px;
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.batch-summary-chip {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.bulk-paste-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bulk-paste-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: vertical;
  min-height: 80px;
  outline: none;
}
.bulk-paste-textarea:focus {
  border-color: var(--border-focus);
}

