/* ──────────────────────────────────────────────────────────────────
   KazPrice Design System  •  Modern Car Analytics Dashboard
   Inspired by Linear / Vercel / Carvana visual language
   ────────────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-50:  #edfaf3;
  --brand-100: #d1f4e3;
  --brand-200: #a0e6c5;
  --brand-500: #0f8f55;
  --brand-600: #0c7445;
  --brand-700: #095c36;
  --brand-800: #06401f;

  /* Neutrals */
  --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 */
  --bg:          #f4f7fb;
  --surface:     #ffffff;
  --surface-soft: #f8fafc;
  --text:        var(--gray-900);
  --text-muted:  var(--gray-500);
  --border:      var(--gray-200);
  --primary:     var(--brand-500);
  --primary-h:   var(--brand-600);
  --danger:      #ef4444;
  --danger-h:    #dc2626;
  --warning:     #f59e0b;
  --success:     #10b981;

  /* Sidebar */
  --sidebar-bg:      #0f172a;
  --sidebar-text:    #94a3b8;
  --sidebar-text-h:  #e2e8f0;
  --sidebar-active:  rgba(15,143,85,.18);
  --sidebar-w:       220px;

  /* Misc */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --transition: all 150ms ease;
}

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

html, body {
  height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout shell ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.2rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; font-weight: 800;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: .88rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: .7rem;
  color: var(--sidebar-text);
  font-weight: 400;
}

.sidebar-nav {
  padding: .75rem .6rem;
  flex: 1;
}

.sidebar-section {
  margin-bottom: .2rem;
}

.sidebar-section-label {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: .75rem .5rem .3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .52rem .75rem;
  border-radius: var(--radius-xs);
  font-size: .84rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text-h);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #34d399;
}

.sidebar-link .icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.sidebar-link.active .icon { opacity: 1; }

.sidebar-footer {
  padding: .75rem .6rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

/* ── Main content area ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  justify-content: space-between;
}

.topbar-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Containers ─────────────────────────────────────────────────── */
.container {
  width: min(1200px, 100%);
  margin-inline: auto;
}

/* ── Typography ─────────────────────────────────────────────────── */
.h1 { font-size: 1.7rem; font-weight: 800; line-height: 1.2; }
.h2 { font-size: 1.4rem; font-weight: 700; line-height: 1.25; }
.h3 { font-size: 1.15rem; font-weight: 700; }
.h4 { font-size: 1rem; font-weight: 700; }
.h5 { font-size: .92rem; font-weight: 600; }
.h6 { font-size: .85rem; font-weight: 600; }

.text-muted  { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-right  { text-align: right !important; }
.text-end    { text-align: right !important; }
.text-nowrap { white-space: nowrap; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--gray-500) !important; }
.text-light { color: #f1f5f9 !important; }

.fw-bold    { font-weight: 700; }
.fw-semibold{ font-weight: 600; }
.fw-medium  { font-weight: 500; }
.small      { font-size: .82rem; }
.smaller    { font-size: .74rem; }

/* ── Spacing ────────────────────────────────────────────────────── */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .35rem !important; }
.mb-2 { margin-bottom: .6rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.4rem !important; }
.mt-1 { margin-top: .35rem !important; }
.mt-2 { margin-top: .6rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.4rem !important; }
.me-1 { margin-right: .35rem !important; }
.me-2 { margin-right: .6rem !important; }
.ms-auto { margin-left: auto !important; }
.my-2  { margin-block: .6rem !important; }
.my-3  { margin-block: 1rem !important; }
.mx-auto { margin-inline: auto !important; }
.p-0   { padding: 0 !important; }
.p-2   { padding: .6rem !important; }
.p-3   { padding: 1rem !important; }
.p-4   { padding: 1.35rem !important; }
.px-3  { padding-inline: 1rem !important; }
.py-0  { padding-block: 0 !important; }
.py-2  { padding-block: .6rem !important; }
.py-3  { padding-block: 1rem !important; }
.py-4  { padding-block: 1.4rem !important; }
.pt-2  { padding-top: .6rem !important; }
.pb-0  { padding-bottom: 0 !important; }

/* ── Display / Flex ─────────────────────────────────────────────── */
.d-flex   { display: flex !important; }
.d-none   { display: none !important; }
.d-block  { display: block !important; }
.d-grid   { display: grid !important; }
.d-inline-flex { display: inline-flex !important; }
.align-items-center  { align-items: center !important; }
.align-items-start   { align-items: flex-start !important; }
.align-items-end     { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-end     { justify-content: flex-end !important; }
.flex-wrap   { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.flex-1      { flex: 1 !important; }
.gap-1  { gap: .35rem !important; }
.gap-2  { gap: .6rem !important; }
.gap-3  { gap: 1rem !important; }
.gap-4  { gap: 1.4rem !important; }
.w-100  { width: 100% !important; }
.w-auto { width: auto !important; }
.min-vh-100 { min-height: 100vh !important; }
.min-vh-70  { min-height: 70vh; }
.flex-shrink-0 { flex-shrink: 0; }

/* ── Grid system ────────────────────────────────────────────────── */
.row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: .75rem;
}

.g-0 { gap: 0; }
.g-1 { gap: .35rem; }
.g-2 { gap: .5rem; }
.g-3 { gap: .75rem; }
.g-4 { gap: 1rem; }

/* Mobile-first: all columns full-width */
.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-12 { grid-column: span 12; }

.col-md-1, .col-md-2, .col-md-3, .col-md-4,
.col-md-6, .col-md-8, .col-md-12 { grid-column: span 12; }

.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4,
.col-lg-5, .col-lg-6, .col-lg-8, .col-lg-9,
.col-lg-10, .col-lg-12 { grid-column: span 12; }

@media (min-width: 640px) {
  .col-sm-6  { grid-column: span 6; }
  .col-sm-12 { grid-column: span 12; }
}

@media (min-width: 768px) {
  .col-md-1  { grid-column: span 1; }
  .col-md-2  { grid-column: span 2; }
  .col-md-3  { grid-column: span 3; }
  .col-md-4  { grid-column: span 4; }
  .col-md-6  { grid-column: span 6; }
  .col-md-8  { grid-column: span 8; }
  .col-md-12 { grid-column: span 12; }
}

@media (min-width: 992px) {
  .col-lg-1  { grid-column: span 1; }
  .col-lg-2  { grid-column: span 2; }
  .col-lg-3  { grid-column: span 3; }
  .col-lg-4  { grid-column: span 4; }
  .col-lg-5  { grid-column: span 5; }
  .col-lg-6  { grid-column: span 6; }
  .col-lg-8  { grid-column: span 8; }
  .col-lg-9  { grid-column: span 9; }
  .col-lg-10 { grid-column: span 10; }
  .col-lg-12 { grid-column: span 12; }
}

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

.card-header {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--surface);
}

.card-body {
  padding: 1.1rem;
}

.card-footer {
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  font-size: .82rem;
}

.border-0  { border: 0 !important; }
.rounded   { border-radius: var(--radius-sm) !important; }
.rounded-sm{ border-radius: var(--radius-xs) !important; }

/* shadow variants */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow    { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ── KPI Stat cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--brand-100); color: var(--brand-600); }
.stat-icon.blue  { background: #dbeafe; color: #2563eb; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red   { background: #fee2e2; color: #dc2626; }
.stat-icon.purple{ background: #ede9fe; color: #7c3aed; }

.stat-body {}
.stat-label {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .25rem;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1;
  letter-spacing: -.02em;
}

.stat-sub {
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ── Hero banner ────────────────────────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, #0f172a 0%, #0c3d25 55%, var(--brand-700) 100%);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.2rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(52,211,153,.25) 0%, transparent 70%);
  border-radius: 50%;
}

.page-hero-eyebrow {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6ee7b7;
  margin-bottom: .4rem;
}

.page-hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.page-hero-sub {
  font-size: .85rem;
  color: #a7f3d0;
  margin-top: .45rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .55rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn:hover       { transform: translateY(-1px); }
.btn:active      { transform: translateY(0); }
.btn:disabled    { opacity: .5; cursor: not-allowed; transform: none !important; }

.btn-sm { padding: .38rem .72rem; font-size: .78rem; }
.btn-xs { padding: .26rem .52rem; font-size: .72rem; }
.btn-lg { padding: .72rem 1.4rem; font-size: .96rem; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(15,143,85,.3);
}
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-h); border-color: var(--danger-h); }

.btn-light {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-light:hover { background: var(--gray-50); }

.btn-dark {
  background: var(--gray-800);
  color: #fff;
  border-color: var(--gray-800);
}
.btn-dark:hover { background: var(--gray-900); }

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

.btn-outline-secondary {
  background: #fff;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-outline-secondary:hover { background: var(--gray-50); }

.btn-outline-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-outline-danger:hover { background: #fee2e2; }

.btn-outline-dark {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-400);
}
.btn-outline-dark:hover { background: var(--gray-100); }

.btn-outline-light {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.5);
}
.btn-outline-light:hover { background: rgba(255,255,255,.12); }

.btn-outline-info {
  background: #fff;
  color: #2563eb;
  border-color: #bfdbfe;
}
.btn-outline-info:hover { background: #eff6ff; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
}
.btn-link:hover { text-decoration-color: var(--primary); transform: none; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .3rem;
  letter-spacing: .01em;
}

.form-control,
.form-select,
textarea {
  width: 100%;
  padding: .58rem .75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  background: #fff;
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 120ms, box-shadow 120ms;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-control::placeholder,
textarea::placeholder { color: var(--gray-400); }

.form-control:focus,
.form-select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,143,85,.15);
}

.form-control-sm,
.form-select-sm {
  padding: .38rem .65rem;
  font-size: .8rem;
  border-radius: var(--radius-xs);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  background-size: 14px;
  padding-right: 2rem;
  cursor: pointer;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
  flex: 1;
}

.input-group .btn {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* ── Tables ─────────────────────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.table th,
.table td {
  padding: .62rem .7rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  text-align: left;
}

.table thead th {
  background: var(--gray-50);
  font-weight: 700;
  font-size: .76rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--gray-500);
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-sm th,
.table-sm td {
  padding: .44rem .6rem;
  font-size: .8rem;
}

.table-light thead th { background: var(--gray-50); }

.table-hover tbody tr { transition: background 80ms; }
.table-hover tbody tr:hover { background: #f0fdf7; }

.table-striped tbody tr:nth-child(even) { background: var(--gray-50); }

/* sticky header inside scrollable container */
.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--gray-200);
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .22em .6em;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 99px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: var(--brand-100); color: var(--brand-700); }

/* ── Progress ───────────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 10px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), #34d399);
  border-radius: 99px;
  transition: width .4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: #fff;
  white-space: nowrap;
}

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

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .84rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* ── Toast notification ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: #f1f5f9;
  padding: .7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: .5rem;
  pointer-events: auto;
  animation: toastIn .22s ease;
  min-width: 220px;
  max-width: 360px;
}

.toast.toast-success { border-left: 3px solid #34d399; }
.toast.toast-error   { border-left: 3px solid #ef4444; }
.toast.toast-info    { border-left: 3px solid #60a5fa; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ── Collapse ───────────────────────────────────────────────────── */
.collapse     { display: none; }
.collapse.show{ display: block; }

/* ── Misc utilities ─────────────────────────────────────────────── */
.bg-white  { background: var(--surface) !important; }
.bg-light  { background: var(--gray-50) !important; }
.bg-dark   { background: var(--gray-900) !important; }
.bg-danger { background: var(--danger) !important; }
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.position-relative { position: relative; }
pre, .pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: .8rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: .75rem 0;
}

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

/* ── Data table wrapper with sticky header ──────────────────────── */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: min(68vh, 700px);
}

.data-table-wrap .table thead th {
  background: var(--gray-50);
  box-shadow: inset 0 -1px 0 var(--gray-200);
  font-size: .74rem;
}

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

/* ── Login page ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #083d22 50%, var(--brand-700) 100%);
  padding: 1.5rem;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 18px;
  padding: 2.2rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  margin-bottom: 1.6rem;
}

.login-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; font-weight: 800;
}

.login-logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

/* ── Crawl pre ──────────────────────────────────────────────────── */
.crawl-pre {
  max-height: 280px;
  overflow: auto;
  font-size: .74rem;
  line-height: 1.4;
  border-radius: var(--radius-xs);
}

.cell-ellipsis {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── AI Chat ────────────────────────────────────────────────────── */
.chat-bubble {
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-size: .88rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Responsive: hide sidebar on mobile ─────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }

  .stat-card { padding: .85rem; }
  .stat-value { font-size: 1.25rem; }
}

/* ── Mobile menu toggle ─────────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--gray-600);
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }
  .sidebar.mobile-open { display: flex; }
}

/* ── Quality issues panel ───────────────────────────────────────── */
.quality-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  box-shadow: var(--shadow-sm);
  font-size: .82rem;
}

/* ── Progress card for crawling ─────────────────────────────────── */
.crawl-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

/* ── Dashboard matrix table ─────────────────────────────────────── */
#mileageMatrixTable thead th { white-space: nowrap; font-size: .74rem; }
#marketSummaryTable td,
#statsTable td { font-size: .82rem; }

/* ── Source badges ──────────────────────────────────────────────── */
.site-badge {
  display: inline-flex;
  align-items: center;
  padding: .18em .55em;
  font-size: .68rem;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: .01em;
  text-transform: lowercase;
}

.site-badge.kolesa  { background: #fef3c7; color: #92400e; }
.site-badge.olx     { background: #dbeafe; color: #1d4ed8; }
.site-badge.myauto  { background: #d1fae5; color: #065f46; }
.site-badge.avtoelon{ background: #ede9fe; color: #5b21b6; }

/* ── Price value cell styling ───────────────────────────────────── */
.price-kzt { color: var(--gray-700); }
.price-usd { color: #2563eb; font-weight: 600; }
.price-krw { color: var(--brand-600); font-weight: 600; }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
