/* ==========================================================
   RAQAMLI MONITORING — Design System v5.0
   Modern SaaS Light Theme — Fresh Indigo Palette
   ========================================================== */

/* ----------------------------------------------------------
   0. CSS CUSTOM PROPERTIES
   ---------------------------------------------------------- */
:root {
  /* Layout */
  --sb-w:        248px;
  --sb-w-sm:      64px;

  /* Core palette */
  --bg:            #f0f2f5;
  --bg-alt:        #f9fafb;
  --bg-hover:      #f3f4f6;
  --card-bg:       #ffffff;
  --sidebar-bg:    #ffffff;

  /* Text */
  --text:          #111827;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;
  --sidebar-text:  #374151;

  /* Borders */
  --border-color:  #e8ecf2;
  --border-light:  #e8ecf2;
  --border-input:  #d1d5db;

  /* Accent (indigo-600) */
  --accent:        #4f46e5;
  --accent-dark:   #4338ca;
  --accent-light:  #eef2ff;

  /* Semantic colours */
  --success:       #10b981;
  --success-dark:  #059669;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #3b82f6;
  --info-light:    #dbeafe;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 1px 4px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.03);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);

  /* Radii */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius:     12px;
  --radius-full:9999px;

  /* Motion */
  --transition: 0.18s ease;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', Consolas, monospace;

  /* Legacy / page-specific aliases */
  --white:        #ffffff;
  --accent-soft:  #eef2ff;
  --border:       #e8ecf2;
  --r-sm:         6px;
  --r-lg:         16px;
  --sh-lg:        0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  --tx-1:         #111827;
  --tx-2:         #6b7280;
  --green-soft:   #d1fae5;
  --blue-soft:    #dbeafe;
  --purple-soft:  #ede9fe;
}

/* ----------------------------------------------------------
   1. RESET & BASE
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  /* Fallback gradient — hidden behind the live canvas (#app-bg-canvas) when loaded */
  background: linear-gradient(135deg, #f0f4ff 0%, #eef2ff 50%, #f5f0ff 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font: inherit;
}

/* ----------------------------------------------------------
   2. APP LAYOUT
   ---------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.main-content {
  flex: 1;
  margin-left: var(--sb-w);
  min-height: 100vh;
  background: transparent;
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 28px 32px;
}


.page-wrapper {
  flex: 1;
  padding: 28px 32px;
  max-width: 1440px;
  width: 100%;
}

/* ----------------------------------------------------------
   3. SIDEBAR
   ---------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sb-w);
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Logo / Header */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  min-height: 64px;
  flex-shrink: 0;
  position: relative;
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.5px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  transition: opacity 0.15s, width 0.22s;
  white-space: nowrap;
}

.logo-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

/* Sidebar Toggle Button — fixed outside sidebar so overflow:hidden doesn't clip */
.sb-toggle {
  position: fixed;
  top: 20px;
  left: calc(var(--sb-w) - 12px);
  width: 24px;
  height: 24px;
  background: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  z-index: 201;
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s;
  padding: 0;
}

.sb-toggle:hover {
  background: #f0f0ff;
  border-color: var(--accent);
}

.sb-toggle svg {
  width: 12px;
  height: 12px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When collapsed: button moves to collapsed edge + arrow rotates.
   .sb-toggle is fixed on body (not inside .app-layout), so we target body.sb-collapsed */
body.sb-collapsed .sb-toggle {
  left: calc(var(--sb-w-sm) - 12px);
}

body.sb-collapsed .sb-toggle svg {
  transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 0.685rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 4px;
  white-space: nowrap;
  transition: opacity 0.15s, width 0.22s;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 18px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #374151;
  font-size: 0.855rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  border: none;
  background: none;
  width: calc(100% - 16px);
  transition: background 0.14s, color 0.14s, padding 0.22s, justify-content 0.22s;
  position: relative;
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  transition: color 0.14s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item:hover .nav-icon {
  color: var(--text);
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-label {
  flex: 1;
  transition: opacity 0.15s, width 0.22s;
  overflow: hidden;
  white-space: nowrap;
}

.nav-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  transition: opacity 0.15s;
}

/* Sidebar Footer / User */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px 8px;
  flex-shrink: 0;
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* PremiumSoft signature */
.sidebar-ps-sig {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(139,92,246,.06));
  border: 1px solid rgba(99,102,241,.14);
  color: #6366f1;
  text-decoration: none;
  font-size: .67rem;
  font-weight: 600;
  letter-spacing: .3px;
  transition: all .18s ease;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-ps-sig:hover {
  background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(139,92,246,.14));
  border-color: rgba(99,102,241,.3);
  color: #4338ca;
  box-shadow: 0 4px 12px rgba(99,102,241,.12);
}
.sidebar-ps-sig svg { flex-shrink: 0; }
.sidebar-ps-sig b { font-weight: 800; letter-spacing: .2px; }
.app-layout.sb-collapsed .sidebar-ps-sig span { display: none; }
.app-layout.sb-collapsed .sidebar-ps-sig {
  padding: 6px; border-radius: 10px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.14s, justify-content 0.22s;
}

.sidebar-user:hover {
  background: var(--bg-hover);
}

.user-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: margin 0.22s;
}

.user-info {
  flex: 1;
  overflow: hidden;
  transition: opacity 0.15s, width 0.22s;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-logout {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.btn-logout:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ----------------------------------------------------------
   4. COLLAPSED SIDEBAR STATE
   ---------------------------------------------------------- */
.app-layout.sb-collapsed .sidebar {
  width: var(--sb-w-sm);
}

.app-layout.sb-collapsed .main-content {
  margin-left: var(--sb-w-sm);
}

.app-layout.sb-collapsed .nav-label,
.app-layout.sb-collapsed .logo-text,
.app-layout.sb-collapsed .logo-sub,
.app-layout.sb-collapsed .user-info,
.app-layout.sb-collapsed .nav-section-label,
.app-layout.sb-collapsed .nav-badge {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.app-layout.sb-collapsed .nav-item {
  justify-content: center;
  align-items: center;
  padding: 10px 0;
  border-left-width: 0;        /* border olgan 3px joyni olib tashlaydi */
  margin: 1px 6px;
  width: calc(100% - 12px);
  gap: 0;                      /* yashirilgan label bilan gap yo'q */
}

.app-layout.sb-collapsed .nav-item .nav-label {
  flex: 0 0 0;                 /* flex:1 ni bekor qiladi, joy olmaydi */
  width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-layout.sb-collapsed .nav-item.active {
  border-left-color: transparent;
  background: var(--accent-light);
}

.app-layout.sb-collapsed .sidebar-logo {
  justify-content: center;
  padding: 16px 0;
}

.app-layout.sb-collapsed .sidebar-footer {
  padding: 10px 8px;
}

.app-layout.sb-collapsed .sidebar-user {
  justify-content: center;
  padding: 8px 0;
}

.app-layout.sb-collapsed .user-avatar {
  margin: 0;
}

.app-layout.sb-collapsed .btn-logout {
  display: none;
}

/* ----------------------------------------------------------
   5. TOP NAVBAR / TOPBAR
   ---------------------------------------------------------- */
.topbar {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

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

.topbar-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.topbar-breadcrumb a:hover {
  color: var(--accent);
}

.topbar-breadcrumb .sep {
  color: var(--border-input);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s;
  position: relative;
}

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

/* ----------------------------------------------------------
   6. PAGE HEADERS
   ---------------------------------------------------------- */
.page-header {
  margin-bottom: 24px;
}

.page-header h1,
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.page-subtitle {
  font-size: 0.855rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ----------------------------------------------------------
   7. CARDS
   ---------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-body {
  padding: 20px 22px;
}

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Hover card */
.card-hoverable {
  transition: box-shadow 0.18s, transform 0.18s;
  cursor: pointer;
}
.card-hoverable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  border-top: 3px solid var(--kpi-color, var(--accent));
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.18s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--kpi-color, var(--accent)) 14%, transparent);
  color: var(--kpi-color, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
}

.kpi-change {
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.kpi-change.up   { color: var(--success); }
.kpi-change.down { color: var(--danger); }
.kpi-change.flat { color: var(--text-muted); }

/* KPI color shorthands */
.kpi-blue    { --kpi-color: #3b82f6; }
.kpi-green   { --kpi-color: #10b981; }
.kpi-orange  { --kpi-color: #f59e0b; }
.kpi-red     { --kpi-color: #ef4444; }
.kpi-violet  { --kpi-color: #8b5cf6; }
.kpi-indigo  { --kpi-color: #4f46e5; }
.kpi-pink    { --kpi-color: #ec4899; }

/* ----------------------------------------------------------
   9. BUTTONS
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: 7px;
  font-size: 0.855rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  letter-spacing: -0.01em;
}

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

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
  box-shadow: 0 1px 3px rgba(79,70,229,0.3), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: #3730a3;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(79,70,229,0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:active {
  background: #3730a3;
  border-color: #312e81;
  box-shadow: 0 1px 2px rgba(79,70,229,0.2), inset 0 2px 4px rgba(0,0,0,0.15);
}

/* Secondary */
.btn-secondary {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 0 transparent;
}
.btn-secondary:hover {
  background: #f9fafb;
  border-color: #b4bac6;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.btn-secondary:active {
  background: #f3f4f6;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: #dc2626;
  box-shadow: 0 1px 3px rgba(239,68,68,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #b91c1c;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(239,68,68,0.35);
}
.btn-danger:active {
  background: #b91c1c;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success-dark);
  box-shadow: 0 1px 3px rgba(16,185,129,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-success:hover {
  background: var(--success-dark);
  border-color: #047857;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(16,185,129,0.35);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}
.btn-outline:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  text-decoration: none;
  color: var(--accent);
}

/* Ghost (no border) */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

/* Warning */
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: #d97706;
  box-shadow: 0 1px 3px rgba(245,158,11,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-warning:hover {
  background: #d97706;
  border-color: #b45309;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(245,158,11,0.35);
}

/* Sizes */
.btn-xs {
  height: 26px;
  padding: 0 9px;
  font-size: 0.75rem;
  border-radius: 5px;
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-lg {
  height: 40px;
  padding: 0 22px;
  font-size: 0.925rem;
  border-radius: 9px;
}

/* Icon-only button */
.btn-icon {
  padding: 0;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
}

/* Button group */
.btn-group {
  display: inline-flex;
}

.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}

.btn-group .btn:first-child {
  border-radius: 8px 0 0 8px;
}

.btn-group .btn:last-child {
  border-radius: 0 8px 8px 0;
  border-right-width: 1.5px;
}

/* ----------------------------------------------------------
   10. FORMS & INPUTS
   ---------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

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

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Base input / textarea / select */
.form-control,
.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea,
select {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.form-control::placeholder,
.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.form-control:hover,
.form-input:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="date"]:hover,
textarea:hover,
select:hover {
  border-color: #b4bac6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.form-control:focus,
.form-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), 0 1px 2px rgba(0,0,0,0.04);
}

.form-control.is-error,
.form-input.is-error {
  border-color: var(--danger);
}
.form-control.is-error:focus,
.form-input.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-control.is-success,
.form-input.is-success {
  border-color: var(--success);
}
.form-control.is-success:focus,
.form-input.is-success:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Select with chevron */
select {
  padding-left: 12px;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px;
  cursor: pointer;
}

/* Textarea */
textarea {
  height: auto;
  resize: vertical;
  min-height: 90px;
  padding: 8px 12px;
  line-height: 1.55;
}

/* Input with icon */
.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.input-wrapper .input-icon.left  { left: 12px; }
.input-wrapper .input-icon.right { right: 12px; }

.input-wrapper.has-left-icon  .form-control { padding-left: 38px; }
.input-wrapper.has-right-icon .form-control { padding-right: 38px; }

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 0.855rem;
  color: var(--text);
}

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--border-input);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.18s;
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* ----------------------------------------------------------
   11. TABLES
   ---------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.855rem;
}

.table th,
table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td,
table td {
  padding: 11px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

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

.table-striped tbody tr:nth-child(even) td {
  background: #fafbfc;
}

/* ----------------------------------------------------------
   12. BADGES & PILLS
   ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

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

/* Badge variants */
.badge-default  { background: var(--bg-hover);    color: var(--text-secondary); }
.badge-primary  { background: var(--accent-light); color: var(--accent); }
.badge-success  { background: var(--success-light);color: var(--success-dark); }
.badge-warning  { background: var(--warning-light);color: #92400e; }
.badge-danger   { background: var(--danger-light); color: #991b1b; }
.badge-info     { background: var(--info-light);   color: #1e40af; }

/* Status badge (with dot) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

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

.status-badge.active  .status-dot { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.status-badge.idle    .status-dot { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-light); }
.status-badge.error   .status-dot { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger-light); }
.status-badge.offline .status-dot { background: var(--text-muted); }

/* ----------------------------------------------------------
   13. MODALS
   ---------------------------------------------------------- */
.modal-backdrop,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

/* When inline style sets display:flex (legacy .modal-overlay toggling), force visible */
.modal-overlay[style*="display:flex"],
.modal-overlay[style*="display: flex"] {
  opacity: 1 !important;
  visibility: visible !important;
}
.modal-overlay[style*="display:flex"] .modal,
.modal-overlay[style*="display: flex"] .modal {
  transform: scale(1) translateY(0);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}

.modal-sm { max-width: 380px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
  padding: 0;
  transition: background 0.14s, color 0.14s, transform 0.14s;
}

.modal-close:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: rotate(90deg);
}

.modal-body {
  padding: 22px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-alt);
  border-radius: 0 0 16px 16px;
}

/* ----------------------------------------------------------
   14. TOASTS / ALERTS
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 300px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info    { border-left-color: var(--info); }

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error   .toast-icon { color: var(--danger); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-info    .toast-icon { color: var(--info); }

.toast-body {
  flex: 1;
}

.toast-title {
  font-size: 0.855rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s;
}
.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Inline alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: 0.855rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-light); border-color: var(--success); color: #065f46; }
.alert-error   { background: var(--danger-light);  border-color: var(--danger);  color: #991b1b; }
.alert-warning { background: var(--warning-light); border-color: var(--warning); color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: var(--info);    color: #1e40af; }

/* ----------------------------------------------------------
   15. TABS
   ---------------------------------------------------------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 18px;
  font-size: 0.855rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -2px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-item:hover {
  color: var(--text);
  text-decoration: none;
}

.tab-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Pill tabs */
.tabs-pill {
  display: flex;
  gap: 4px;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  width: fit-content;
  margin-bottom: 20px;
}

.tabs-pill .tab-item {
  border: none;
  border-radius: 7px;
  padding: 7px 16px;
  margin-bottom: 0;
}

.tabs-pill .tab-item.active {
  background: #fff;
  color: var(--accent);
  border-color: transparent;
  box-shadow: var(--shadow-xs);
}

/* ----------------------------------------------------------
   16. SEARCH BAR
   ---------------------------------------------------------- */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  padding-left: 38px;
  padding-right: 12px;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* ----------------------------------------------------------
   17. DROPDOWNS
   ---------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 4px;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.845rem;
  font-weight: 500;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.dropdown-item.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

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

/* ----------------------------------------------------------
   18. PROGRESS BARS
   ---------------------------------------------------------- */
.progress {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-success .progress-bar { background: var(--success); }
.progress-warning .progress-bar { background: var(--warning); }
.progress-danger  .progress-bar { background: var(--danger); }

.progress-lg { height: 10px; }
.progress-sm { height: 4px; }

/* ----------------------------------------------------------
   19. LOADING STATES
   ---------------------------------------------------------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3.5px; }

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

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #e8ecf2 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-card  { height: 120px; border-radius: var(--radius); }

/* ----------------------------------------------------------
   20. EMPTY STATE
   ---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.empty-state p {
  font-size: 0.855rem;
  color: var(--text-secondary);
  max-width: 320px;
}

/* ----------------------------------------------------------
   21. AVATARS
   ---------------------------------------------------------- */
.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-xs { width: 24px; height: 24px; font-size: 0.65rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.9rem;  }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem;  }

.avatar-indigo { background: var(--accent-light); color: var(--accent); }
.avatar-green  { background: var(--success-light); color: var(--success-dark); }
.avatar-red    { background: var(--danger-light);  color: var(--danger); }
.avatar-orange { background: var(--warning-light); color: #92400e; }

.avatar-group {
  display: flex;
  align-items: center;
}

.avatar-group .avatar {
  border: 2px solid #fff;
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

/* ----------------------------------------------------------
   22. CODE & MONO
   ---------------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-hover);
  color: #7c3aed;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.65;
  box-shadow: var(--shadow);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

/* ----------------------------------------------------------
   23. DIVIDERS & SPACING
   ---------------------------------------------------------- */
hr,
.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 20px 0;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* Grid utilities */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); gap: 16px; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

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

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }

.text-xs  { font-size: 0.72rem; }
.text-sm  { font-size: 0.82rem; }
.text-md  { font-size: 0.9rem;  }
.text-lg  { font-size: 1.05rem; }
.text-xl  { font-size: 1.2rem;  }
.text-2xl { font-size: 1.5rem;  }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semi    { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-black   { font-weight: 800; }

.text-primary   { color: var(--text); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: #d97706; }

/* ----------------------------------------------------------
   24. CHARTS & DATA VIZ CONTAINERS
   ---------------------------------------------------------- */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   25. PAGINATION
   ---------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-input);
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.page-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

/* ----------------------------------------------------------
   26. TOOLTIPS
   ---------------------------------------------------------- */
[data-tooltip] {
  position: relative;
  cursor: default;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 0.73rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 800;
}

[data-tooltip]:hover::before {
  opacity: 1;
}

/* ----------------------------------------------------------
   27. FILTER / TOOLBAR ROW
   ---------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar-left  { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ----------------------------------------------------------
   28. NOTIFICATION DOT
   ---------------------------------------------------------- */
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ----------------------------------------------------------
   29. RESPONSIVE
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .main-content {
    margin-left: var(--sb-w-sm);
  }

  .sidebar {
    width: var(--sb-w-sm);
  }

  .app-layout .nav-label,
  .app-layout .logo-text,
  .app-layout .logo-sub,
  .app-layout .user-info,
  .app-layout .nav-section-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .app-layout .nav-item {
    justify-content: center;
    padding: 10px 0;
  }

  .app-layout .sidebar-logo {
    justify-content: center;
  }

  .app-layout .sidebar-user {
    justify-content: center;
  }

  .app-layout .btn-logout {
    display: none;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page-wrapper { padding: 20px 20px; }
}

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3   { grid-template-columns: repeat(2, 1fr); }
  .grid-2   { grid-template-columns: 1fr; }
  .page-header-row { flex-direction: column; align-items: flex-start; }
  .page-wrapper { padding: 16px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-3   { grid-template-columns: 1fr; }
  .modal    { max-width: 100%; border-radius: 12px 12px 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
}

/* ----------------------------------------------------------
   30. SCROLLBAR (global)
   ---------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #c8cdd7;
}

/* ----------------------------------------------------------
   31. SELECTION
   ---------------------------------------------------------- */
::selection {
  background: rgba(79, 70, 229, 0.18);
  color: inherit;
}

/* ----------------------------------------------------------
   32. BOTTOM NAV (mobile)
   ---------------------------------------------------------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border-color);
  z-index: 150;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 10px 6px;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.14s;
  flex: 1;
  min-width: 0;
}

.bottom-nav-item:hover { color: var(--text-secondary); text-decoration: none; }
.bottom-nav-item.active { color: var(--accent); }

.bottom-nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.bottom-nav-icon svg { width: 20px; height: 20px; }
.bottom-nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56px; }

.bottom-nav-inner { display: flex; justify-content: space-around; }

/* ----------------------------------------------------------
   33. STAT CARD (legacy alias)
   ---------------------------------------------------------- */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card .stat-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-change { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

/* ----------------------------------------------------------
   34. FILTER BAR (call-history, qa, etc.)
   ---------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

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

.filter-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-group input,
.filter-group select {
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  height: 36px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  appearance: none;
  -webkit-appearance: none;
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.filter-group input { width: 175px; }
.filter-group select { min-width: 140px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; padding-right: 30px; }
.filter-group input[type="date"] { width: 148px; }

/* ----------------------------------------------------------
   35. LEGACY COMPAT ALIASES
   ---------------------------------------------------------- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.tab  { padding: 9px 18px; font-size: 0.855rem; font-weight: 500; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; font-family: inherit; transition: color var(--transition), border-color var(--transition); white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ch-table, ast-table aliases → reuse global table styles */
.ch-table, .ast-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ch-table thead tr, .ast-table thead { background: var(--bg-alt); }
.ch-table th, .ast-table th { padding: 10px 14px; text-align: left; font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 2px solid var(--border-color); white-space: nowrap; }
.ch-table td, .ast-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; color: var(--text); }
.ch-table tbody tr:hover td, .ast-table tbody tr:hover td { background: rgba(79,70,229,0.03); }
.ch-table tbody tr:last-child td, .ast-table tbody tr:last-child td { border-bottom: none; }
.ch-table-wrap, .table-wrap { overflow-x: auto; }

/* Badge aliases */
.badge-status-active   { background: var(--success-light); color: var(--success-dark); padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; display: inline-block; }
.badge-status-done     { background: var(--bg-hover); color: var(--text-secondary); padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; display: inline-block; border: 1px solid var(--border-color); }
.badge-origin-app      { background: var(--info-light); color: #1e40af; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; display: inline-block; }
.badge-origin-live     { background: #ede9fe; color: #5b21b6; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; display: inline-block; }

/* ----------------------------------------------------------
   36. PRINT
   ---------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .sb-toggle, .bottom-nav { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-wrapper { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ----------------------------------------------------------
   37. MOBILE RESPONSIVE
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sb-toggle { display: none; }
  .main-content { margin-left: 0 !important; padding: 16px 16px 80px; }
  .bottom-nav { display: block; }
  .bottom-nav-inner { display: flex; }
}
