/* ============================================================
   HSW Digital — Contractor Management Portal
   main.css — Enterprise Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Brand */
  --primary: #456DB3;
  --primary-dark: #375994;
  --primary-light: #E8EEF8;
  --primary-subtle: #C3D3EE;

  /* Semantic Colors */
  --success: #059669;
  --success-bg: #ECFDF5;
  --success-border: #A7F3D0;

  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;

  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;

  --info: #0891B2;
  --info-bg: #ECFEFF;

  --orange: #EA580C;
  --orange-bg: #FFF7ED;
  --orange-border: #FED7AA;

  --purple: #7C3AED;
  --purple-bg: #F5F3FF;

  /* Surfaces — Light Theme */
  --bg-page: #ECF0F7;
  --bg-card: #FFFFFF;
  --bg-elevated: #F8FAFC;
  --bg-hover: #F1F5F9;
  --bg-input: #FFFFFF;
  --bg-sidebar: #1E2A3B;
  --bg-topbar: #FFFFFF;

  /* Text */
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;
  --text-inverse: #FFFFFF;
  --text-link: #2563EB;

  /* Borders */
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-subtle: #F1F5F9;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);

  /* Sidebar Colors */
  --sidebar-text: #CBD5E1;
  --sidebar-text-muted: #64748B;
  --sidebar-active-bg: rgba(37, 99, 235, 0.15);
  --sidebar-active-text: #93C5FD;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-border: rgba(255, 255, 255, 0.07);

  /* Typography */
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 60px;
}

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

::selection {
  background: #456DB3;
  color: white;
}

::-moz-selection {
  background: #456DB3;
  color: white;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-primary);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: var(--font-main);
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: var(--font-main);
}

svg {
  flex-shrink: 0;
}

/* ── App Layout ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  height: 100vh;
  overflow: hidden;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 60px 1fr;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / 3;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width var(--transition-normal);
  z-index: 100;
}

.sidebar-logo {
  padding: 0 20px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}

.sidebar-logo-text {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo-title {
  font-size: 13px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--sidebar-text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 12px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 12px;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.demo-role-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: #93C5FD;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
}

.demo-role-btn:hover {
  background: rgba(37, 99, 235, 0.2);
}

.demo-role-btn svg {
  width: 14px;
  height: 14px;
}

#demo-role-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(37, 99, 235, 0.2);
  color: #93C5FD;
  white-space: nowrap;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-breadcrumb span {
  color: var(--text-subtle);
}

.topbar-spacer {
  flex: 1;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.topbar-bu-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.topbar-bu-selector:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.topbar-filter-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-filter-pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.topbar-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-icon-btn svg {
  width: 17px;
  height: 17px;
}

.topbar-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid white;
}

/* User Pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-pill:hover {
  border-color: var(--primary);
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.user-pill-info {
  line-height: 1.2;
}

.user-pill-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-pill-role {
  font-size: 10px;
  color: var(--text-muted);
}

.user-pill-chevron {
  color: var(--text-muted);
  margin-left: 2px;
}

.user-pill-chevron svg {
  width: 12px;
  height: 12px;
}

/* Role Indicator */
.role-indicator-badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* User Menu Dropdown */
.user-menu {
  position: absolute;
  top: calc(var(--topbar-height) + 4px);
  right: 16px;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  overflow: hidden;
}

.user-menu.hidden {
  display: none;
}

.user-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.user-menu-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-menu-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-menu-items {
  padding: 6px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.user-menu-item svg {
  width: 14px;
  height: 14px;
}

.user-menu-item.danger {
  color: var(--danger);
}

.user-menu-item.danger:hover {
  background: var(--danger-bg);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  background: var(--bg-page);
  overflow-y: auto;
  overflow-x: hidden;
}

#page-container {
  min-height: 100%;
}

/* ── Page Wrapper ───────────────────────────────────────────── */
.page {
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}


.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Grid Layouts ───────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-12 {
  grid-template-columns: repeat(12, 1fr);
}

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

.col-span-6 {
  grid-column: span 6;
}

.col-span-8 {
  grid-column: span 8;
}

.col-span-12 {
  grid-column: span 12;
}

.full-width {
  grid-column: 1 / -1;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  transition: all var(--transition-fast);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ── KPI Card ───────────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.kpi-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi-card.trend-up::before {
  background: linear-gradient(90deg, var(--danger), var(--orange));
}

.kpi-card.trend-down::before {
  background: linear-gradient(90deg, var(--success), #10B981);
}

.kpi-card.trend-neutral::before {
  background: linear-gradient(90deg, var(--primary), #818CF8);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.kpi-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-wrap svg {
  width: 20px;
  height: 20px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-top: 8px;
}

.kpi-trend.up {
  color: var(--danger);
}

.kpi-trend.down {
  color: var(--success);
}

.kpi-trend svg {
  width: 12px;
  height: 12px;
}

.kpi-change {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--font-main);
  line-height: 1;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #B91C1C;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-sm svg {
  width: 12px;
  height: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-icon-only {
  padding: 7px;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary-light);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  font-family: var(--font-main);
}

.badge-approved {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-danger,
.badge-suspended {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-draft {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-review {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(8, 145, 178, 0.2);
}

.badge-critical {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

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

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 2px;
}

.badge-approved.badge-dot::before {
  background: var(--success);
}

.badge-warning.badge-dot::before {
  background: var(--warning);
}

.badge-danger.badge-dot::before {
  background: var(--danger);
}

/* Risk Badges */
.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.risk-low {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.risk-medium {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.risk-high {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
}

.risk-critical {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* ── Data Tables ────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table th:hover {
  color: var(--text-primary);
}

.data-table th .sort-icon {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}

.data-table th.sort-active .sort-icon {
  opacity: 1;
  color: var(--primary);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-secondary);
}

.data-table tbody tr:hover td {
  background: var(--bg-elevated);
}

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

.data-table .col-name {
  font-weight: 600;
  color: var(--text-primary);
}

.data-table .col-action a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.data-table .col-action a:hover {
  text-decoration: underline;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition-fast);
  font-family: var(--font-main);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.search-bar svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  font-family: var(--font-main);
}

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

/* ── Filters Bar ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-wrap: wrap;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 700;
  border-bottom-color: var(--primary);
}

.tab-count {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.tab-btn.active .tab-count {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 13px;
}

.alert-bar.danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #991B1B;
}

.alert-bar.warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: #92400E;
}

.alert-bar svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.alert-bar-title {
  font-weight: 700;
}

.alert-bar-body {
  font-size: 12px;
  margin-top: 2px;
  opacity: 0.8;
}

/* Escalation Banner */
.escalation-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #FEF2F2, #FFF5F5);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.escalation-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Progress Bars ──────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s ease;
}

.progress-good {
  background: linear-gradient(90deg, var(--success), #34D399);
}

.progress-ok {
  background: linear-gradient(90deg, var(--warning), #FCD34D);
}

.progress-bad {
  background: linear-gradient(90deg, var(--danger), #F87171);
}

/* ── Charts ─────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
}

.bar-chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding: 0 4px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: height 0.8s ease;
  min-height: 2px;
}

.bar-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.chart-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Sparkline */
.sparkline {
  width: 80px;
  height: 32px;
}

/* ── Risk Quadrant ──────────────────────────────────────────── */
.risk-quadrant {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.risk-quadrant-inner {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.rq-quadrant {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.7;
}

.rq-tl {
  background: rgba(234, 88, 12, 0.08);
  color: var(--orange);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.rq-tr {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
  border-bottom: 1px solid var(--border);
  justify-content: flex-end;
}

.rq-bl {
  background: rgba(16, 185, 129, 0.08);
  color: var(--success);
  border-right: 1px solid var(--border);
}

.rq-br {
  background: rgba(37, 99, 235, 0.06);
  color: var(--primary);
  justify-content: flex-end;
}

.rq-axis-x {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.rq-axis-y {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.rq-dot {
  position: absolute;
  transform: translate(-50%, 50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid white;
  box-shadow: var(--shadow-md);
  text-transform: uppercase;
}

.rq-dot:hover {
  transform: translate(-50%, 50%) scale(1.3);
  z-index: 10;
}

/* ── Stats Row ──────────────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.stat-row-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Avatar ─────────────────────────────────────────────────── */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.pagination-info {
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.page-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalPop 0.2s ease;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--text-primary);
  color: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  font-weight: 500;
  min-width: 240px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.success {
  background: var(--success);
}

.toast.warning {
  background: var(--warning);
}

.toast.danger {
  background: var(--danger);
}

.toast.info {
  background: var(--info);
}

.toast svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-icon svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-body {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

/* ── Utilities ──────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

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

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.text-sm {
  font-size: 12px;
}

.text-xs {
  font-size: 11px;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Splash Screen ──────────────────────────────────────────── */
.splash-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1E2A3B, #0F172A);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease;
}

.splash-screen.fade-out {
  opacity: 0;
}

.splash-logo-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.splash-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  color: white;
  box-shadow: 0 0 40px rgba(37, 99, 235, 0.5);
}

.splash-title {
  font-size: 28px;
  font-weight: 900;
  color: white;
  letter-spacing: -0.5px;
}

.splash-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.splash-loader {
  width: 200px;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 60px;
}

.splash-loader-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: splashLoad 2s ease-in-out forwards;
}

@keyframes splashLoad {
  from {
    width: 0;
  }

  to {
    width: 100%;
  }
}

.splash-loading-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Notification/Alert Items ───────────────────────────────── */
.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.notif-item:hover {
  background: var(--bg-elevated);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.unread {
  background: var(--primary-light);
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.notif-body {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.notif-time {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ── Timeline ───────────────────────────────────────────────── */
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  position: relative;
}

.timeline-line {
  position: absolute;
  left: 16px;
  top: 40px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.timeline-body {
  flex: 1;
  min-width: 0;
}

.timeline-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-user {
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-comment {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  line-height: 1.5;
}

.timeline-date {
  font-size: 11px;
  color: var(--text-subtle);
  white-space: nowrap;
  margin-top: 4px;
}

/* ── Export / Action Toolbar ────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-wrap: wrap;
}

.table-toolbar-start {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.table-toolbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.table-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

/* ── Section headers ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Compliance Status  ─────────────────────────────────────── */
.compliance-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compliance-pct {
  font-size: 13px;
  font-weight: 800;
  min-width: 34px;
}

.compliance-pct.good {
  color: var(--success);
}

.compliance-pct.ok {
  color: var(--warning);
}

.compliance-pct.bad {
  color: var(--danger);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 16px;
  }

  .col-span-8,
  .col-span-6 {
    grid-column: span 12;
  }
}

/* ── AI Panel ───────────────────────────────────────────────── */
.ai-panel {
  background: linear-gradient(135deg, var(--purple-bg), var(--primary-light));
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.1);
  color: var(--purple);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 10px;
}

.ai-badge svg {
  width: 12px;
  height: 12px;
}

.ai-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.ai-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--purple);
  color: #ffffff !important;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  line-height: 1;
  transition: all var(--transition-fast);
}

.ai-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ai-btn:hover {
  background: #6D28D9;
}

.ai-btn.secondary {
  background: white;
  color: var(--purple);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.ai-progress {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: var(--radius-full);
  animation: aiGenerate 6s ease-in-out forwards;
}

@keyframes aiGenerate {
  from {
    width: 0;
  }

  to {
    width: 85%;
  }
}

.ai-progress-label {
  font-size: 11px;
  color: var(--purple);
  font-weight: 600;
}