/* ==========================================================================
   PULSOCORP - DESIGN SYSTEM: CORPORATE PRECISION
   Corporate Modernism & Precision SaaS Interface
   ========================================================================== */

:root {
  /* Surface & Canvas */
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-dim: #d9dadf;
  --surface-bright: #f9f9fe;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3f3f8;
  --surface-container: #ededf3;
  --surface-container-high: #e7e8ed;
  --surface-container-highest: #e2e2e7;

  /* Typography & Neutral Content */
  --on-surface: #191c1f;
  --on-surface-variant: #42474f;
  --text-primary: #191c1f;
  --text-secondary: #515f74;
  --text-muted: #727780;
  --inverse-surface: #2e3034;
  --inverse-on-surface: #f0f0f5;

  /* Primary Brand: Trust Blue */
  --primary: #0f4c81;
  --primary-hover: #00355f;
  --primary-container: #0f4c81;
  --on-primary: #ffffff;
  --on-primary-container: #8ebdf9;
  --primary-fixed: #d2e4ff;
  --primary-fixed-dim: #a0c9ff;
  --on-primary-fixed: #001c37;
  --surface-tint: #2d6197;

  /* Secondary: Corporate Slate */
  --secondary: #515f74;
  --on-secondary: #ffffff;
  --secondary-container: #d5e3fd;
  --on-secondary-container: #57657b;
  --secondary-fixed: #e2e8f0;
  --sidebar-bg: #e2e8f0;

  /* Tertiary: Amber / Bronze Accent */
  --tertiary: #532800;
  --tertiary-container: #743b00;
  --on-tertiary-container: #f9a767;
  --tertiary-fixed: #ffdcc4;

  /* Functional Semantics */
  --accent-emerald: #10b981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.1);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.1);
  --accent-rose: #ba1a1a;
  --accent-rose-bg: rgba(186, 26, 26, 0.1);
  --accent-cyan: #0284c7;
  --accent-purple: #7c3aed;

  /* Structural Borders & Lines */
  --outline: #727780;
  --outline-variant: #c2c7d1;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  /* Typography Specs */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Precision Radii (Soft & Precise) */
  --radius-xs: 2px;
  --radius-sm: 4px;   /* Default for buttons, inputs, pills */
  --radius-md: 6px;
  --radius-lg: 8px;   /* Default for cards & modal containers */
  --radius-full: 9999px;

  /* Spacing Grid (4px baseline) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Shadows (Ambient & Diffused) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(15, 76, 129, 0.08);
  --shadow-modal: 0 12px 32px rgba(0, 0, 0, 0.12);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== GLOBAL RESETS ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'tnum';
}

code {
  font-family: var(--font-mono);
  background: var(--surface-container-low);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--primary);
  border: 1px solid var(--border-color);
}

/* ==================== LOGIN VIEW ==================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 20%, #e2e8f0 0%, #f8fafc 80%);
}

.login-glass-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-modal);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(15, 76, 129, 0.2);
}

.login-brand h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-brand h2 span {
  color: var(--secondary);
  font-weight: 400;
}

.brand-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.db-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-container-low);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  width: 100%;
  justify-content: center;
}

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

.login-form .form-group {
  margin-bottom: 18px;
  text-align: left;
}

.login-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.input-with-icon input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.btn-eye {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

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

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==================== APP LAYOUT ==================== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--background);
}

/* ==================== SIDEBAR ==================== */
.app-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  z-index: 50;
  transition: var(--transition);
}

.sidebar-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.4);
}

.brand-badge {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-info h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.brand-info h3 span {
  color: var(--primary);
  font-weight: 800;
}

.db-badge {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  margin: 1px 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  width: calc(100% - 8px);
}

.nav-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

.nav-item:hover i {
  color: var(--primary);
}

.nav-item.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  border-color: var(--border-color);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.nav-item.active i {
  color: var(--primary);
}

.badge-count {
  margin-left: auto;
  background: var(--surface-container-high);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.nav-item.active .badge-count {
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
}

.badge-tag-new {
  margin-left: auto;
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.4);
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-fixed);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.5px;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-logout:hover {
  color: var(--accent-rose);
  background: var(--accent-rose-bg);
}

/* ==================== MAIN CONTENT AREA ==================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--background);
}

/* ==================== TOP NAVBAR ==================== */
.app-header {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-color);
  padding-right: 14px;
}

.select-input-sm {
  background: var(--surface-container-low);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.select-input-sm:focus {
  border-color: var(--primary);
}

/* ==================== BUTTONS ==================== */
.btn-primary, .btn-primary-sm {
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.btn-primary {
  padding: 10px 18px;
  font-size: 13.5px;
}

.btn-primary-sm {
  padding: 6px 14px;
  font-size: 12.5px;
}

.btn-primary:hover, .btn-primary-sm:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-hover);
}

.btn-secondary-sm {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-secondary-sm:hover {
  background: var(--surface-container-low);
  border-color: var(--outline-variant);
}

.btn-accent-sm {
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

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

.btn-ghost, .btn-ghost-sm {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  transition: var(--transition);
}

.btn-ghost:hover, .btn-ghost-sm:hover {
  background: var(--surface-container);
  color: var(--text-primary);
}

.btn-block { width: 100%; }

/* ==================== GLOBAL FILTER BAR ==================== */
.global-filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 32px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.select-input, .date-input, .input-text {
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  font-family: var(--font-family);
  outline: none;
  min-height: 36px;
  transition: var(--transition);
}

.select-input:focus, .date-input:focus, .input-text:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.custom-date-inputs, .date-range-flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==================== EXPORT DROPDOWN ==================== */
.export-dropdown { position: relative; }

.dropdown-panel {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 240px;
  box-shadow: var(--shadow-modal);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--surface-container-low);
  color: var(--primary);
}

/* ==================== TAB CONTENT ==================== */
.tab-content-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-panel.active { display: block; }

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

/* ==================== CARDS & CONTAINERS ==================== */
.glass-card, .chart-card, .table-container, .card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.glass-card:hover, .chart-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--outline-variant);
}

/* ==================== KPI CARDS GRID ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.kpi-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon-wrap.accent-blue { background: rgba(15, 76, 129, 0.1); color: var(--primary); }
.kpi-icon-wrap.accent-purple { background: rgba(124, 58, 237, 0.1); color: var(--accent-purple); }
.kpi-icon-wrap.accent-emerald { background: var(--accent-emerald-bg); color: var(--accent-emerald); }
.kpi-icon-wrap.accent-amber { background: var(--accent-amber-bg); color: var(--accent-amber); }
.kpi-icon-wrap.accent-cyan { background: rgba(2, 132, 199, 0.1); color: var(--accent-cyan); }
.kpi-icon-wrap.accent-rose { background: var(--accent-rose-bg); color: var(--accent-rose); }

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

.kpi-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.kpi-value.text-sm { font-size: 16px; }

.kpi-highlight { color: var(--primary); }

.kpi-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==================== CHARTS ==================== */
.charts-grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
}

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

.chart-header h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.chart-wrapper {
  position: relative;
  flex: 1;
  min-height: 260px;
}

.toggle-group {
  display: flex;
  background: var(--surface-container-low);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-toggle-group {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.btn-toggle-group.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ==================== DATA TABLES ==================== */
.table-container {
  padding: 0;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header-controls {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface);
  flex-wrap: wrap;
  gap: 12px;
}

.table-header-controls h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
}

.table-search-box i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.table-search-box input {
  width: 100%;
  background: var(--surface-container-low);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px 7px 34px;
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.table-search-box input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}

.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table thead {
  background: var(--surface-container-low);
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  padding: 12px 18px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 13px 18px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background-color: var(--surface-container-low);
}

.data-table .text-right { text-align: right; }

.table-btn-action {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--transition);
}

.table-btn-action:hover {
  background: var(--surface-container);
  color: var(--primary);
  border-color: var(--border-color);
}

/* Ranking Badges */
.ranking-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  background: var(--surface-container);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.ranking-badge.top-1 { background: #fef3c7; color: #b45309; }
.ranking-badge.top-2 { background: #e2e8f0; color: #475569; }
.ranking-badge.top-3 { background: #ffedd5; color: #c2410c; }

/* Status Badges */
.badge-success {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-warning {
  background: var(--accent-amber-bg);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-muted {
  background: var(--surface-container-low);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 600;
}

.badge-role-admin { background: var(--primary-fixed); color: var(--on-primary-fixed); }
.badge-role-user { background: var(--surface-container); color: var(--text-secondary); }

/* ==================== PAGINATION ==================== */
.pagination-bar {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-secondary);
}

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

.btn-page {
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-page:hover:not(:disabled) {
  background: var(--surface-container-low);
  border-color: var(--outline-variant);
}

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

.page-current {
  font-weight: 700;
  color: var(--primary);
  padding: 0 4px;
}

/* ==================== WEEKLY SCHEDULE MATRIX ==================== */
.weekly-schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.day-schedule-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.day-schedule-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

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

.day-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-turn-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 50px;
}

.turn-item {
  background: var(--surface-container-low);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.turn-item:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.turn-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.turn-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
}

.turn-time-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.turn-actions { display: flex; gap: 4px; }

.btn-icon-xs {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.btn-icon-xs:hover {
  color: var(--primary);
  background: var(--surface-container);
}

.btn-icon-xs.delete:hover {
  color: var(--accent-rose);
  background: var(--accent-rose-bg);
}

.empty-turns-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 0;
  text-align: center;
}

/* ==================== OPERATOR PROFILE DETAIL ==================== */
.operator-detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
}

.operator-profile-card {
  padding: 24px;
}

.op-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.op-avatar {
  width: 52px;
  height: 52px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.op-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--on-surface);
}

.op-stats-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.op-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 8px;
}

.op-stat-item .label { color: var(--text-secondary); }
.op-stat-item .value { font-weight: 600; color: var(--on-surface); }

.ip-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface-container-low);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.ip-count { font-weight: 600; color: var(--primary); }

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-container-low);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}
.btn-close-modal:hover { color: var(--accent-rose); }

.modal-card form { padding: 24px; }

.modal-card .form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-card label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.alert-box.error {
  background: var(--accent-rose-bg);
  color: var(--accent-rose);
  border: 1px solid rgba(186, 26, 26, 0.25);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-primary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-modal);
  min-width: 280px;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--primary); }

/* ==================== RBAC & PERMISSION MATRIX ==================== */
.modal-card-lg {
  max-width: 820px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-card-lg form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(90vh - 80px);
}

.modal-body-scrollable {
  overflow-y: auto;
  padding-right: 4px;
  max-height: calc(90vh - 160px);
}

.permission-matrix-container {
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-container-low);
}

.matrix-toolbar {
  padding: 10px 14px;
  background: var(--surface-container);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.matrix-toolbar-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-quick-actions {
  display: flex;
  gap: 6px;
}

.matrix-btn-quick {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.matrix-btn-quick:hover {
  background: var(--surface-container-high);
  border-color: var(--primary);
  color: var(--primary);
}

.permission-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.permission-matrix-table th {
  background: var(--surface);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.permission-matrix-table th:first-child {
  text-align: left;
  width: 38%;
}

.permission-matrix-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--surface-container);
  text-align: center;
  vertical-align: middle;
}

.permission-matrix-table td:first-child {
  text-align: left;
}

.permission-matrix-table tr:hover td {
  background: rgba(15, 76, 129, 0.03);
}

.module-meta-title {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.module-meta-desc {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.perm-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  border-radius: 4px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: var(--surface-container-high);
  color: var(--text-primary);
}

.role-badge.admin {
  background: rgba(15, 76, 129, 0.12);
  color: var(--primary);
  border: 1px solid rgba(15, 76, 129, 0.25);
}

.role-badge.supervisor {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.role-badge.auditor {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.role-badge.custom {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.ml-auto { margin-left: auto; }
.col-span-2 { grid-column: span 2; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .charts-grid-2col, .operator-detail-grid {
    grid-template-columns: 1fr;
  }
  .col-span-2 { grid-column: span 1; }
}

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-toggle {
    display: inline-flex;
  }
  .app-header, .global-filter-bar, .tab-content-wrapper {
    padding-left: 16px;
    padding-right: 16px;
  }
}
