/* ============================================
   MESOTYS — Premium Design System v4
   SaaS-grade aesthetics
   ============================================ */

/* ===== CSS Custom Properties (Light) ===== */
:root {
  --primary: #2563EB;
  --primary-light: #60A5FA;
  --primary-dark: #1D4ED8;
  --accent: #F43F5E;
  --accent-light: #FB7185;
  --success: #10B981;
  --success-light: #34D399;
  --warning: #F59E0B;
  --danger: #EF4444;

  --bg: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-hover: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --border: #E2E8F0;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --sidebar-bg: linear-gradient(180deg, #0F172A 0%, #1E293B 50%, #334155 100%);
  --header-bg: rgba(255, 255, 255, 0.85);
  --header-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --nav-bg: rgba(255, 255, 255, 0.92);

  /* Spacing Scale (4/8pt) */
  --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-9: 36px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography Scale */
  --text-2xs: 0.688rem;
  --text-xs: 0.75rem;
  --text-sm: 0.813rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg: #0B1120;
  --bg-card: #151D2E;
  --bg-hover: #1E293B;
  --surface: #151D2E;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #475569;
  --border: #1E293B;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);

  --sidebar-bg: linear-gradient(180deg, #060A14 0%, #0B1120 50%, #151D2E 100%);
  --header-bg: rgba(21, 29, 46, 0.9);
  --header-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --nav-bg: rgba(21, 29, 46, 0.95);

  --primary: #3B82F6;
  --primary-light: #60A5FA;
}

[data-theme="dark"] .form-control {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] table thead {
  background: var(--bg);
}

[data-theme="dark"] table tbody tr:hover {
  background: var(--bg-hover);
}

[data-theme="dark"] .donut-center {
  fill: var(--text);
}

[data-theme="dark"] .donut-sub {
  fill: var(--text-secondary);
}

[data-theme="dark"] .toggle-group button {
  background: var(--bg);
  color: var(--text-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .toggle-group button.active {
  background: var(--primary);
  color: white;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-3 {
  margin-top: var(--space-3);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mb-2 {
  margin-bottom: var(--space-2);
}

.mb-3 {
  margin-bottom: var(--space-3);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

.mb-6 {
  margin-bottom: var(--space-6);
}

.fw-600 {
  font-weight: 700;
}

.text-primary {
  color: var(--primary);
}

.text-accent {
  color: var(--accent);
}

.text-danger {
  color: var(--danger);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* Flex Utilities */
.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

/* ===== Skeleton Loading ===== */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line:last-child {
  width: 60%;
}

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}

.skeleton-card .skeleton-line {
  height: 12px;
}

.skeleton-card .skeleton-title {
  height: 20px;
  width: 40%;
  margin-bottom: var(--space-4);
}

/* ===== Error State ===== */
.error-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--danger);
}

.error-state svg {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.error-state h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-2);
  color: var(--text);
}

.error-state p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0 0 var(--space-4);
}

/* ===== Layout ===== */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.main-content {
  flex: 1;
  padding: 1.25rem;
  padding-bottom: 5.5rem;
  max-width: 100%;
  overflow-x: hidden;
}

/* ===== Header ===== */
.app-header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--header-shadow);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* Logo images */
.header-logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo-img {
  height: 28px;
  width: auto;
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
}

/* ===== Global Search ===== */
.header-search {
  position: relative;
  flex: 1;
  max-width: 340px;
  margin: 0 1rem;
}

.header-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 1000;
}

.search-results.active {
  display: block;
}

.search-results .sr-category {
  padding: 0.4rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.search-results .sr-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-results .sr-item:last-child {
  border-bottom: none;
}

.search-results .sr-item:hover {
  background: var(--bg);
}

.search-results .sr-item .sr-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.search-results .sr-item .sr-text {
  flex: 1;
  min-width: 0;
}

.search-results .sr-item .sr-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.search-results .sr-item .sr-sub {
  font-size: 0.7rem;
  color: var(--text-light);
}

.search-results .sr-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .header-search {
    max-width: none;
    margin: 0 0.5rem;
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-user span {
  font-size: 0.813rem;
  color: var(--text-secondary);
  display: none;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.role-badge {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.04));
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.688rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid rgba(37, 99, 235, 0.12);
}

/* Theme toggle */
.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  transition: all 0.25s;
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  transform: rotate(15deg);
}

/* Alert badge */
.alert-badge {
  background: linear-gradient(135deg, var(--accent), #E11D48);
  color: white;
  font-size: 0.625rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
  z-index: 100;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0.375rem 0.625rem;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.625rem;
  font-family: var(--font);
  font-weight: 600;
  transition: all 0.25s;
  border-radius: 10px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: all 0.25s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  stroke-width: 2.4;
  transform: translateY(-1px);
}

/* ===== Screens ===== */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s, transform 0.3s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.2px;
}

/* ===== Stock Alerts ===== */
.stock-alerts {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, rgba(245, 158, 11, 0.04) 100%);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  border-left: 4px solid var(--danger);
}

.stock-alert-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.813rem;
  color: var(--danger);
}

.stock-alert-item svg {
  flex-shrink: 0;
}

/* ===== Metric Cards ===== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px 3px 0 0;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
}

.metric-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

.metric-icon.blue {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.05));
  color: var(--primary);
}

.metric-icon.red {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(244, 63, 94, 0.05));
  color: var(--accent);
}

.metric-icon.amber {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.05));
  color: var(--warning);
}

.metric-icon.green {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.05));
  color: var(--success);
}

.metric-label {
  font-size: 0.688rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin: 0.125rem 0 0.25rem;
  letter-spacing: -1px;
}

.metric-change {
  font-size: 0.688rem;
  font-weight: 700;
}

.metric-change.up {
  color: var(--success);
}

.metric-change.down {
  color: var(--accent);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* ===== Bar Chart ===== */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.bar-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 55px;
  flex-shrink: 0;
  font-weight: 600;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 5px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
}

/* ===== Donut Chart ===== */
.donut-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.donut-svg {
  width: 150px;
  height: 150px;
}

.donut-center {
  font-size: 22px;
  font-weight: 800;
  fill: var(--text);
}

.donut-sub {
  font-size: 10px;
  fill: var(--text-secondary);
  font-weight: 600;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.813rem;
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-label {
  flex: 1;
  color: var(--text-secondary);
}

.donut-legend-value {
  font-weight: 700;
  color: var(--text);
}

/* ===== Sparklines ===== */
.sparkline-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.sparkline-row:last-child {
  border-bottom: none;
}

.sparkline-info {
  flex: 1;
  min-width: 0;
}

.sparkline-name {
  font-size: 0.813rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sparkline-sub {
  font-size: 0.688rem;
  color: var(--text-secondary);
}

.sparkline-svg {
  width: 80px;
  height: 32px;
  flex-shrink: 0;
}

.sparkline-val {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text);
  min-width: 55px;
  text-align: right;
  flex-shrink: 0;
}

/* ===== Timeline ===== */
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.timeline-dot.entry {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.timeline-dot.exit {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15);
}

.timeline-dot.pending {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.timeline-content {
  flex: 1;
  font-size: 0.813rem;
  line-height: 1.5;
  color: var(--text);
}

.timeline-time {
  font-size: 0.688rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 600;
}

/* ===== Section Header ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ===== Filters/Search Bar ===== */
.filters-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filters-bar .form-control {
  flex: 1;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.hint {
  display: block;
  font-size: 0.688rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Toggle group */
.toggle-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.toggle-group button {
  flex: 1;
  padding: 0.625rem 1rem;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.813rem;
  font-weight: 700;
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.25s;
}

.toggle-group button.active {
  background: var(--primary);
  color: white;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.813rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger-text {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}

.btn-danger-text:hover {
  background: rgba(239, 68, 68, 0.06);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.813rem;
}

thead {
  background: var(--bg);
}

th {
  padding: 0.75rem 0.875rem;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.688rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* ===== Badges ===== */
.badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.688rem;
  font-weight: 700;
  display: inline-block;
}

.badge-entry {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-exit {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ===== Result Cards (Estimation) ===== */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 0.875rem;
  box-shadow: var(--shadow-xs);
  transition: all 0.3s;
}

.result-card:hover {
  box-shadow: var(--shadow);
}

.result-card-title {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.813rem;
  color: var(--text-secondary);
}

.result-row .value {
  font-weight: 700;
  color: var(--text);
}

.result-row.total {
  border-top: 2px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-weight: 800;
  font-size: 0.875rem;
  color: var(--text);
}

.grand-total-card {
  background: linear-gradient(135deg, var(--primary) 0%, #1D4ED8 100%);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: white;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
}

.grand-total-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  font-weight: 700;
}

.grand-total-card .amount {
  font-size: 2.25rem;
  font-weight: 800;
  margin: 0.375rem 0;
  letter-spacing: -1px;
}

.grand-total-card .supplement {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ===== Info Box ===== */
.info-box {
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  font-size: 0.813rem;
  color: var(--text-secondary);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke-width: 1;
  margin-bottom: 0.875rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ===== Settings Grid ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ===== Layouts ===== */
.stock-layout,
.estimation-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* ===== Stagger Animation ===== */
.animate-in {
  opacity: 0;
  transform: translateY(14px);
  animation: slideUp 0.5s ease forwards;
}

.animate-in:nth-child(1) {
  animation-delay: 0s;
}

.animate-in:nth-child(2) {
  animation-delay: 0.06s;
}

.animate-in:nth-child(3) {
  animation-delay: 0.12s;
}

.animate-in:nth-child(4) {
  animation-delay: 0.18s;
}

.animate-in:nth-child(5) {
  animation-delay: 0.24s;
}

.animate-in:nth-child(6) {
  animation-delay: 0.3s;
}

.animate-in:nth-child(7) {
  animation-delay: 0.36s;
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== Print Styles ===== */
@media print {
  body {
    background: white !important;
    color: #000 !important;
    font-size: 11pt;
  }

  .sidebar,
  .app-header,
  .bottom-nav,
  .btn,
  .filters-bar,
  .modal-footer,
  .section-header button,
  .theme-toggle-btn,
  .alert-badge {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
  }

  .screen {
    display: none !important;
  }

  .screen.active {
    display: block !important;
  }

  .print-header {
    display: block !important;
  }

  .card,
  .result-card,
  .grand-total-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd;
  }

  .grand-total-card {
    background: #2563EB !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .modal-overlay.active {
    display: block !important;
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }

  .modal-overlay.active .modal {
    max-width: 100% !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-height: none !important;
  }
}

/* ===== Tablet (768px+) ===== */
@media (min-width: 768px) {
  .metric-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stock-layout,
  .estimation-layout {
    grid-template-columns: 1fr 1fr;
  }

  .header-user span {
    display: inline;
  }
}

/* ===== Desktop (1024px+) ===== */
/* ===== Onboarding Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bounceIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== Login Screen ===== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 2.5rem;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.login-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0 0 1.5rem;
}

.login-card .form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.login-card .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  display: block;
}

.login-card .role-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.login-card .role-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-size: 0.8rem;
  color: var(--text);
}

.login-card .role-btn.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  font-weight: 700;
}

/* ===== Tablet Mode (768px – 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  .main-content {
    padding: 1.5rem 2rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .estimation-layout {
    grid-template-columns: 1fr;
  }

  .client-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Larger touch targets */
  .btn,
  button {
    min-height: 44px;
  }

  .form-control {
    min-height: 44px;
    font-size: 1rem;
  }

  .nav-item {
    min-height: 52px;
  }

  .table-wrapper td,
  .table-wrapper th {
    padding: 0.75rem;
  }
}

/* ===== Desktop (1024px+) ===== */
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--sidebar-bg);
    z-index: 60;
    padding: 1.75rem 1rem;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-logo {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
  }

  .sidebar-logo h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    letter-spacing: 2px;
  }

  .sidebar-logo span {
    font-size: 0.688rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.125rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.25s;
    width: 100%;
    text-align: left;
    margin-bottom: 0.375rem;
  }

  .sidebar-nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
    flex-shrink: 0;
  }

  .sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
  }

  .sidebar-nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 700;
    box-shadow: inset 3px 0 0 white;
  }

  .app-header {
    margin-left: 260px;
  }

  .main-content {
    margin-left: 260px;
    padding: 2rem 2.5rem;
    padding-bottom: 2rem;
    max-width: 1200px;
  }

  .bottom-nav {
    display: none;
  }
}

/* ===== Devis Requests Cards ===== */
.devis-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.devis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.2s;
}

.devis-card:hover {
  box-shadow: var(--shadow-md);
}