/* ==========================================================================
   Lorenzo Jalyuzi — Professional Design System v2.0
   - Modern indigo/blue palette
   - Clean typography
   - 4px grid spacing
   - Subtle shadows
   - No emojis anywhere
   ========================================================================== */

/* ===================== Reset & Base ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette — Lorenzo brendbuk: navy #19234e, peach #fdb47e, cream #f7e8c8 */
  --brand-50:  #eef0f7;
  --brand-100: #d9dcea;
  --brand-200: #b3b9d3;
  --brand-300: #8390b8;
  --brand-400: #4f5f95;
  --brand-500: #2b3a6e;   /* primary (navy-500) */
  --brand-600: #19234e;   /* asosiy navy */
  --brand-700: #141c40;
  --brand-800: #101633;
  --brand-900: #0c1027;
  --brand-950: #080b1b;
  --navy:  #19234e;
  --peach: #fdb47e;
  --peach-soft: #fde3cc;
  --cream: #f7e8c8;

  /* Neutral */
  --gray-0:   #ffffff;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic */
  --success:  #10b981;
  --success-bg:  #d1fae5;
  --warning:  #f59e0b;
  --warning-bg:  #fef3c7;
  --danger:   #ef4444;
  --danger-bg:   #fee2e2;
  --info:     #06b6d4;
  --info-bg:     #cffafe;
  --purple:   #8b5cf6;
  --purple-bg:   #ede9fe;

  /* Surfaces */
  --bg:        #f7f9fc;
  --surface:   #ffffff;
  --surface-hover: #f8fafc;
  --border:    #e5e9f2;
  --border-strong: #cbd5e1;

  /* Text */
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-soft:   #94a3b8;
  --text-inverse: #ffffff;

  /* Primary aliases */
  --primary:        var(--brand-500);
  --primary-hover:  var(--brand-600);
  --primary-active: var(--brand-700);
  --primary-soft:   var(--brand-50);
  --primary-fg:     var(--text-inverse);

  /* Effects */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,.07), 0 4px 8px rgba(15,23,42,.04);
  --shadow-lg: 0 16px 40px rgba(15,23,42,.10), 0 8px 16px rgba(15,23,42,.05);
  --shadow-xl: 0 24px 60px rgba(15,23,42,.12), 0 12px 24px rgba(15,23,42,.06);

  --ring:    0 0 0 3px rgba(253,180,126,.45);
  --ring-success: 0 0 0 3px rgba(16,185,129,.18);
  --ring-danger:  0 0 0 3px rgba(239,68,68,.18);

  /* Geometry */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs:     14px;
  --fs-md:  15px;
  --fs-lg:  16px;
  --fs-xl:  18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;
  --fs-4xl: 36px;

  /* Layout */
  --sidebar-w: 248px;
  --header-h:  60px;
  --content-padding: 24px;
  --content-max: 1480px;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(.4,.0,.2,1);
  --t: 200ms cubic-bezier(.4,.0,.2,1);
  --t-slow: 320ms cubic-bezier(.4,.0,.2,1);
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
code { font-family: var(--font-mono); font-size: .92em; background: var(--gray-100); padding: 1px 5px; border-radius: var(--r-xs); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ===================== Scrollbar ===================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 10px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===================== App Layout ===================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ===================== Sidebar ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--gray-100);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--gray-0);
}
.sidebar-logo svg { color: var(--peach); flex-shrink: 0; }
.sidebar-logo img { height: 34px; width: auto; display: block; }
.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r);
  color: var(--gray-300);
  font-size: var(--fs);
  font-weight: 500;
  transition: all var(--t-fast);
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--gray-0);
}
.nav-item.active {
  background: var(--peach);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.nav-item.active svg { color: var(--navy); }
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--gray-400);
  transition: color var(--t-fast);
}
.nav-item:hover svg { color: var(--gray-200); }
.nav-divider {
  margin: 16px 8px;
  padding: 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.07);
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--peach);
  color: var(--navy);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  font-weight: 600;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.18); }

/* ===================== Main Content Area ===================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* ===================== Header ===================== */
.header {
  height: var(--header-h);
  padding: 0 var(--content-padding);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 4;
}
.header-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===================== Content ===================== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--content-padding);
}
.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ===================== Page Header ===================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: 2px;
}

/* ===================== Cards ===================== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { color: var(--text-muted); width: 18px; height: 18px; }
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* ===================== Stat Cards (KPIs) ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-200);
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--brand-50);
  color: var(--brand-600);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.bg-success { background: var(--success-bg); color: var(--success); }
.stat-icon.bg-warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.bg-danger  { background: var(--danger-bg);  color: var(--danger);  }
.stat-icon.bg-info    { background: var(--info-bg);    color: var(--info);    }
.stat-icon.bg-purple  { background: var(--purple-bg);  color: var(--purple);  }
.stat-icon.bg-neutral { background: var(--gray-100);   color: var(--gray-600);}
.stat-content { flex: 1; min-width: 0; }
.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.2;
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stat-trend {
  font-size: var(--fs-xs);
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-weight: 600;
}
.stat-trend.up   { color: var(--success); background: var(--success-bg); }
.stat-trend.down { color: var(--danger);  background: var(--danger-bg);  }
.stat-trend.flat { color: var(--text-muted); background: var(--gray-100);   }
.stat-trend svg { width: 12px; height: 12px; }

/* KPI tile variant - larger */
.stat-card.kpi {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  border-color: var(--brand-600);
}
.stat-card.kpi .stat-icon { background: rgba(255,255,255,.18); color: white; }
.stat-card.kpi .stat-label { color: rgba(255,255,255,.85); }
.stat-card.kpi .stat-value { color: white; }
.stat-card.kpi:hover { transform: translateY(-4px); }

/* ===================== Grid Layouts ===================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 20px; } .mt-6 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 20px; } .mb-6 { margin-bottom: 32px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 12px; } .gap-3 { gap: 16px; } .gap-4 { gap: 20px; }

@media (max-width: 1024px) {
  .grid-2, .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r);
  font-size: var(--fs);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:focus-visible { box-shadow: var(--ring); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--border-strong); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-50); }

.btn-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
}

.btn-sm  { padding: 6px 10px; font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg  { padding: 11px 20px; font-size: var(--fs-md); }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { display: flex; width: 100%; }

/* ===================== Forms ===================== */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: var(--fs);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.form-textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.form-select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg fill='%2364748b' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-soft); }
.form-help { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* ===================== Badges ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  line-height: 1.4;
}
.badge svg { width: 12px; height: 12px; }
.badge-new       { background: var(--info-bg);    color: var(--info);    }
.badge-confirmed { background: var(--brand-100);  color: var(--brand-700); }
.badge-production{ background: var(--purple-bg);  color: var(--purple);  }
.badge-ready     { background: var(--warning-bg); color: var(--warning); }
.badge-installing{ background: #fde68a;           color: #92400e;       }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--danger-bg);  color: var(--danger);  }
.badge-pending   { background: var(--gray-100);   color: var(--gray-700);}
.badge-paid      { background: var(--success-bg); color: var(--success); }
.badge-partial   { background: var(--warning-bg); color: var(--warning); }
.badge-outline   { background: transparent; border: 1px solid currentColor; }

/* ===================== Tables ===================== */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs);
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--gray-50);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: 0; }

.table td .table-meta { color: var(--text-muted); font-size: var(--fs-xs); }
.table td.font-bold, .table td strong { font-weight: 600; color: var(--text); }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* Compact table */
.table-sm th, .table-sm td { padding: 8px 10px; font-size: var(--fs-sm); }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fadeIn var(--t) ease-out;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: zoomIn var(--t) ease-out;
}
@keyframes zoomIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 980px; }
.modal-sm { max-width: 380px; }
.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -.01em;
}
.modal-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--gray-50);
}

/* ===================== Quote builder totals ===================== */
.quote-totals {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
}
.quote-totals .tcell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
}
.quote-totals .tcell span {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.quote-totals .tcell b {
  font-size: var(--fs-md);
  font-weight: 600;
}
.quote-totals .tcell.total {
  background: var(--primary-bg);
  border-color: var(--primary-border, var(--border));
}
.quote-totals .tcell.total b { color: var(--primary); }
.quote-item { background: var(--surface); }

/* ===================== Toast ===================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  animation: slideIn var(--t) ease-out;
  min-width: 280px;
  border: 1px solid var(--border);
  border-left-width: 4px;
}
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.success { border-left-color: var(--success); }
.toast.success svg { color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning svg { color: var(--warning); }
.toast.info    { border-left-color: var(--info); }
.toast.info svg { color: var(--info); }

/* ===================== Empty / Loading ===================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--gray-300);
  margin-bottom: 12px;
}
.empty-state h3 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-state p { font-size: var(--fs-sm); margin-top: 8px; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--brand-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* ===================== Login ===================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at top left, rgba(67,104,245,.10), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139,92,246,.10), transparent 50%),
    linear-gradient(160deg, #19234e 0%, #2b3a6e 55%, #4f5f95 100%);
}
.login-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  display: block;
  margin: 0 auto 10px;
}
.login-logo .logo-icon img { width: 220px; max-width: 80%; height: auto; display: block; margin: 0 auto; }
.login-logo .logo-icon svg { width: 32px; height: 32px; }
.login-logo h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.login-logo .subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: 2px;
}
.login-hint {
  margin-top: 20px;
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--r);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.6;
  border: 1px dashed var(--border-strong);
}
.login-hint strong { color: var(--text); font-weight: 600; }

/* ===================== Charts ===================== */
.chart {
  position: relative;
  height: 280px;
}
.chart-sm { height: 160px; }
.chart-lg { height: 360px; }
.chart-tall { height: 420px; }
.chart-axis-label {
  font-size: var(--fs-xs);
  fill: var(--text-muted);
}
.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 240px;
  padding: 0 4px;
  position: relative;
}
.bar-chart .bar {
  flex: 1;
  min-width: 8px;
  background: linear-gradient(to top, var(--navy), var(--brand-400));
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: all var(--t);
  cursor: pointer;
}
.bar-chart .bar:hover { opacity: .85; transform: scaleY(1.02); }
.bar-chart .bar-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.bar-chart .bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--text);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--t);
  white-space: nowrap;
}
.bar-chart .bar:hover .bar-value { opacity: 1; }
.bar-chart-wrapper { padding-bottom: 28px; }

.line-chart-svg {
  width: 100%;
  height: 240px;
}
.line-chart-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.line-chart-svg .axis-text { font-size: 11px; fill: var(--text-muted); }
.line-chart-svg .trend-line { fill: none; stroke: var(--primary); stroke-width: 2.5; }
.line-chart-svg .trend-area { fill: var(--primary); opacity: .1; }
.line-chart-svg .data-point { fill: var(--primary); stroke: white; stroke-width: 2; }

.donut-chart {
  width: 100%;
  height: 220px;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
}
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-legend-label { color: var(--text); flex: 1; }
.donut-legend-value { color: var(--text-muted); font-weight: 600; }

/* Progress bar */
.progress {
  height: 8px;
  background: var(--gray-100);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--brand-500), var(--brand-600));
  border-radius: var(--r-pill);
  transition: width var(--t-slow);
}
.progress-fill.success { background: linear-gradient(to right, var(--success), #059669); }
.progress-fill.warning { background: linear-gradient(to right, var(--warning), #d97706); }
.progress-fill.danger  { background: linear-gradient(to right, var(--danger), #dc2626); }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  z-index: 1;
}
.timeline-item.success::before { background: var(--success); border-color: var(--success); }
.timeline-item.warning::before { background: var(--warning); border-color: var(--warning); }
.timeline-item.danger::before  { background: var(--danger);  border-color: var(--danger); }
.timeline-title {
  font-weight: 600;
  font-size: var(--fs);
  color: var(--text);
}
.timeline-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.timeline-body {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===================== User Menu ===================== */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-menu:hover { background: var(--gray-50); }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.user-name {
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--text);
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
}
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 10;
}
.dropdown.show { display: block; animation: zoomIn .15s ease-out; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-divider {
  margin: 6px 0;
  border-top: 1px solid var(--border);
  height: 0;
}

/* ===================== Utility Classes ===================== */
.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-bold, .font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.uppercase { text-transform: uppercase; letter-spacing: .04em; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ===================== Alerts ===================== */
.alert {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  border-left: 4px solid;
  margin-bottom: 16px;
  background: var(--surface);
  font-size: var(--fs-sm);
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: #065f46; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger);  color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: #78350f; }
.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: #155e75; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }

/* ===================== Tabs ===================== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 4px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: var(--fs);
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab svg { width: 16px; height: 16px; }

/* ===================== Filter Bar ===================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .form-input, .filter-bar .form-select {
  width: auto;
  min-width: 180px;
}
.search-input {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-input svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input .form-input {
  padding-left: 36px;
}

/* ===================== Page-specific ===================== */
.data-list {
  display: flex;
  flex-direction: column;
}
.data-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.data-list-item:last-child { border-bottom: 0; }
.data-list-item:hover { background: var(--gray-50); }
.data-list-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.data-list-icon.success { background: var(--success-bg); color: var(--success); }
.data-list-icon.warning { background: var(--warning-bg); color: var(--warning); }
.data-list-icon.danger  { background: var(--danger-bg);  color: var(--danger);  }
.data-list-icon.info    { background: var(--info-bg);    color: var(--info);    }
.data-list-icon.purple  { background: var(--purple-bg);  color: var(--purple);  }
.data-list-icon svg { width: 18px; height: 18px; }
.data-list-content { flex: 1; min-width: 0; }
.data-list-title { font-weight: 500; font-size: var(--fs); color: var(--text); }
.data-list-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.data-list-value { font-weight: 600; color: var(--text); }

/* Avatars list */
.avatar-stack {
  display: flex;
  align-items: center;
}
.avatar-stack .user-avatar {
  margin-left: -8px;
  border: 2px solid var(--surface);
}
.avatar-stack .user-avatar:first-child { margin-left: 0; }
.avatar-stack .avatar-more {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  margin-left: -8px;
  border: 2px solid var(--surface);
}

/* ===================== Mobile ===================== */
#menuBtn { display: none !important; }
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0;
    --content-padding: 16px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--t);
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 45;
    display: none;
  }
  .sidebar-backdrop.show { display: block; }
  #menuBtn { display: inline-flex !important; }
  .header-actions .user-name, .header-actions .user-role { display: none; }
}

/* ===================== Print ===================== */
@media print {
  .sidebar, .header, .btn, .no-print { display: none !important; }
  .main-content { background: white; }
  .card { box-shadow: none; border: 1px solid var(--gray-300); }
  body { overflow: visible; }
}

/* Animation utility */
.animate-fade-in { animation: fadeIn var(--t) ease-out; }
.animate-slide-up { animation: slideUp var(--t) ease-out; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.hover-lift { transition: all var(--t); }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ===================== Dashboard MVP 2.0 blocks ===================== */
.task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.task-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text); transition: all var(--t);
}
.task-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-border, var(--primary)); }
.task-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.task-warning .task-icon { background: #f59e0b; }
.task-info .task-icon { background: #0ea5e9; }
.task-primary .task-icon { background: var(--primary); }
.task-danger .task-icon { background: #ef4444; }
.task-value { font-size: var(--fs-lg); font-weight: 700; line-height: 1; }
.task-label { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 120px; font-size: var(--fs-sm); color: var(--text-muted); flex-shrink: 0; text-align: right; }
.funnel-bar-wrap { flex: 1; background: var(--gray-100); border-radius: 6px; overflow: hidden; height: 30px; }
.funnel-bar {
  height: 100%; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px; font-size: var(--fs-sm); font-weight: 600; color: #fff;
  background: linear-gradient(90deg, #4368f5, #638cff); border-radius: 6px 0 0 6px;
  min-width: 36px;
}

/* ===================== MVP 2.0 ikkinchi bosqich stillari ===================== */

/* KPI grid (finance) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.kpi-card { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.kpi-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-card.primary .kpi-icon { background: #4368f5; }
.kpi-card.success .kpi-icon { background: #10b981; }
.kpi-card.danger .kpi-icon { background: #ef4444; }
.kpi-card.warning .kpi-icon { background: #f59e0b; }
.kpi-card.info .kpi-icon { background: #0ea5e9; }
.kpi-label { font-size: var(--fs-xs); color: var(--text-muted); }
.kpi-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }

/* Umumiy yordamchi */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }

/* Chip */
.chip { display: inline-flex; align-items: center; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: var(--fs-sm); }

/* Badge turlari */
.badge-primary { background: rgba(67,104,245,.12); color: #4368f5; }
.badge-success { background: rgba(16,185,129,.12); color: #10b981; }
.badge-danger { background: rgba(239,68,68,.12); color: #ef4444; }
.text-success { color: #10b981; } .text-danger { color: #ef4444; }

/* Notifications */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.notif-item:hover { background: var(--bg-soft); }
.notif-item.unread { background: rgba(67,104,245,.05); }
.notif-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.notif-icon.primary { background: #4368f5; } .notif-icon.success { background: #10b981; }
.notif-icon.warning { background: #f59e0b; } .notif-icon.muted { background: #94a3b8; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: var(--fs-sm); color: var(--text); }
.notif-body { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: #4368f5; position: absolute; top: 16px; right: 16px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.photo-thumb { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* Overdue row */
.row-overdue { background: rgba(239,68,68,.06); }

/* Alert */
.alert { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 10px; font-size: var(--fs-sm); margin-bottom: 16px; }
.alert-warning { background: rgba(245,158,11,.12); color: #b45309; border: 1px solid rgba(245,158,11,.3); }

/* Documents / Tasks utility */
.badge-danger { color: #ef4444; }

/* Filters grid (inventory movements, reports) */
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }

/* Signature pad */
.signature-pad-wrap { border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--gray-50); }
.signature-pad { width: 100%; height: 160px; display: block; touch-action: none; cursor: crosshair; border-radius: 10px; }
.signature-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Map link */
.map-link { display: inline-flex; align-items: center; gap: 4px; color: #4368f5; text-decoration: none; font-size: var(--fs-sm); }

/* Field-team action bar (mobile-first) */
.field-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.field-actions .btn { flex: 1; min-width: 130px; justify-content: center; }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.detail-item { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.detail-label { font-size: var(--fs-xs); color: var(--text-muted); }
.detail-value { font-weight: 600; font-size: var(--fs-sm); margin-top: 2px; }

/* Status timeline */
.timeline { display: flex; flex-direction: column; gap: 0; margin: 8px 0 16px; }
.timeline-step { display: flex; gap: 12px; align-items: flex-start; position: relative; padding-bottom: 14px; }
.timeline-step::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border); }
.timeline-step:last-child::before { display: none; }
.timeline-dot { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--gray-200); color: var(--text-muted); z-index: 1; }
.timeline-dot.done { background: #10b981; color: #fff; }
.timeline-body { padding-top: 2px; }
.timeline-title { font-size: var(--fs-sm); font-weight: 600; }
.timeline-time { font-size: var(--fs-xs); color: var(--text-muted); }

/* Mobile bottom nav */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .field-actions .btn { min-width: 100px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--card); border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(15,23,42,.06); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; text-decoration: none; color: var(--text-muted); font-size: 11px; }
  .bottom-nav a.active { color: #4368f5; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .app-main { padding-bottom: 72px; }
}
