/* ========== VARIABLES ========== */
:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-light: #fef2f2;
  --primary-mid: #fee2e2;

  --sidebar-bg: #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(220,38,38,0.15);
  --sidebar-active-border: #dc2626;

  --content-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;

  --green: #16a34a; --green-bg: #f0fdf4;
  --blue: #2563eb;  --blue-bg: #eff6ff;
  --amber: #d97706; --amber-bg: #fffbeb;
  --purple: #7c3aed; --purple-bg: #faf5ff;
  --cyan: #0891b2;  --cyan-bg: #ecfeff;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --transition: 0.18s ease;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ========== RESET ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--content-bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
ul { list-style: none; }
svg { display: block; flex-shrink: 0; }

/* ========== LOGIN PAGE ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 45%, #111827 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(220,38,38,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(124,58,237,0.08) 0%, transparent 50%);
}

.login-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.login-header {
  padding: 36px 36px 28px;
  text-align: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  position: relative;
}

.login-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #dc2626, #7c3aed, #dc2626);
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #dc2626, #9f1239);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(220,38,38,0.4);
}

.login-logo svg { color: white; width: 28px; height: 28px; }

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.login-body { padding: 32px 36px; }

.login-lang {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  border: 1px solid transparent;
}

.lang-btn:hover { color: var(--text-secondary); background: var(--border); }
.lang-btn.active {
  background: var(--primary-mid);
  color: var(--primary);
  border-color: var(--primary-mid);
  font-weight: 600;
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: #fafafa;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
}

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

.input-wrap { position: relative; }

.input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  width: 20px; height: 20px;
}

.input-wrap .form-input { padding-right: 40px; }

.login-error {
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #b91c1c;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 12px rgba(220,38,38,0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--content-bg); }

.btn-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: white;
  box-shadow: 0 2px 8px rgba(217,119,6,0.3);
}
.btn-warning:hover { background: linear-gradient(135deg, #b45309, #92400e); }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ========== APP LAYOUT ========== */
.app-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
  transition: transform var(--transition);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #dc2626, #9f1239);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}

.brand-icon svg { color: white; width: 20px; height: 20px; }

.brand-text { min-width: 0; }

.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--sidebar-text);
  font-weight: 400;
  letter-spacing: 0.2px;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #475569;
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 1px;
  position: relative;
  user-select: none;
}

.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
  margin-left: -12px;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: rgba(220,38,38,0.2);
  color: #f87171;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.user-card:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.logout-btn {
  color: #475569;
  padding: 6px;
  border-radius: 7px;
  transition: var(--transition);
}
.logout-btn:hover { color: #f87171; background: rgba(220,38,38,0.1); }
.logout-btn svg { width: 16px; height: 16px; }

/* ========== MAIN CONTENT ========== */
.main {
  margin-left: var(--sidebar-w);
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========== TOP BAR ========== */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

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

.topbar-breadcrumb span { color: var(--text-secondary); font-weight: 500; }

.topbar-spacer { flex: 1; }

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

.lang-select {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  background: white;
}
.lang-select:hover { border-color: var(--primary); color: var(--primary); }

/* ========== PAGE CONTENT ========== */
.page-content {
  padding: 24px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Direct children are width-contained; NO overflow-x: hidden here
   (that would clip .table-scroll-container nested inside cards) */
.page-content > * {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

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

.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.page-desc { font-size: 14px; color: var(--text-muted); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ========== STAT CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
  cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-info { min-width: 0; }

.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }

.stat-blue  .stat-icon { background: var(--blue-bg);   color: var(--blue); }
.stat-green .stat-icon { background: var(--green-bg);  color: var(--green); }
.stat-amber .stat-icon { background: var(--amber-bg);  color: var(--amber); }
.stat-purple .stat-icon { background: var(--purple-bg); color: var(--purple); }
.stat-cyan   .stat-icon { background: var(--cyan-bg);   color: var(--cyan); }

.stat-blue  .stat-value { color: var(--blue); }
.stat-green .stat-value { color: var(--green); }
.stat-amber .stat-value { color: var(--amber); }
.stat-purple .stat-value { color: var(--purple); }
.stat-cyan   .stat-value { color: var(--cyan); }

/* ========== CARDS ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; /* prevent overflow when action buttons appear */
  gap: 8px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

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

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ========== TABLES ========== */
/* .table-scroll-container is the canonical wrapper; .table-wrap is an alias */
.table-scroll-container,
.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
/* Table inside scroll-container may be as wide as needed; container clips & scrolls it */
.table-scroll-container > table,
.table-wrap > table {
  min-width: 0; /* base; specific pages add their own min-width */
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: #f8fafc;
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-secondary);
  vertical-align: middle;
}

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

tbody tr:hover td { background: #fafbfc; }

td .cell-main {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}
td .cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-red    { background: var(--primary-mid); color: var(--primary); }
.badge-gray   { background: #f1f5f9; color: #64748b; }
.badge-cyan   { background: var(--cyan-bg); color: var(--cyan); }

/* Car statuses */
.status-bought       { background: #eff6ff; color: #2563eb; }
.status-disassembling { background: #fffbeb; color: #d97706; }
.status-disassembled  { background: #f0fdf4; color: #16a34a; }
.status-shipped       { background: #faf5ff; color: #7c3aed; }

/* Container statuses */
.status-forming    { background: #fffbeb; color: #d97706; }
.status-shipped    { background: #eff6ff; color: #2563eb; }
.status-in_transit { background: #ecfeff; color: #0891b2; }
.status-received   { background: #f0fdf4; color: #16a34a; }

/* ========== PROGRESS BAR ========== */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar {
  flex: 1;
  height: 7px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.progress-fill.green  { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress-fill.amber  { background: linear-gradient(90deg, #d97706, #fbbf24); }
.progress-fill.red    { background: linear-gradient(90deg, #dc2626, #f87171); }
.progress-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); min-width: 38px; text-align: right; }

/* ========== ALERTS ========== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 20px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }

/* ========== TOAST ========== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  max-width: 380px;
  border-left: 4px solid;
  pointer-events: all;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.toast-success { border-color: var(--green); }
.toast-success svg { color: var(--green); }
.toast-error   { border-color: var(--primary); }
.toast-error   svg { color: var(--primary); }
.toast-info    { border-color: var(--blue); }
.toast-info    svg { color: var(--blue); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-msg { flex: 1; color: var(--text-primary); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  opacity: 0.4;
  color: var(--text-muted);
}
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-desc  { font-size: 14px; }

/* ========== LOADING SKELETON ========== */
.skeleton {
  background: linear-gradient(90deg, #f0f4f8 25%, #e8eef4 50%, #f0f4f8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid #f1f5f9; }
.skeleton-circle { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.skeleton-line { height: 12px; border-radius: 6px; }
.skeleton-text { flex: 1; display: flex; flex-direction: column; gap: 6px; }

/* ========== SEARCH & FILTERS ========== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap { position: relative; }
.search-input {
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  width: 240px;
  outline: none;
  background: white;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(220,38,38,0.06); }
.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}

.filter-select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-secondary);
  background: white;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ========== DETAIL ROWS ========== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.detail-field { }
.detail-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ========== DASHBOARD SPECIFIC ========== */
.welcome-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  right: -20px; top: -30px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(220,38,38,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-text h2 {
  font-size: 22px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.4px;
}

.welcome-text p {
  font-size: 14px;
  color: #64748b;
  margin-top: 6px;
}

.welcome-icon {
  width: 64px; height: 64px;
  background: rgba(220,38,38,0.15);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.welcome-icon svg { width: 32px; height: 32px; color: #f87171; }

/* ========== MISC ========== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; }
.flex-gap-2 { gap: 8px; }
.fw-600 { font-weight: 600; }

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

/* ========== COMING SOON ========== */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  color: var(--text-muted);
}
.coming-soon svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 20px; }
.coming-soon h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.coming-soon p { font-size: 14px; max-width: 300px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; width: 100vw; max-width: 100vw; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .welcome-icon { display: none; }
  .login-card { border-radius: var(--radius); }
  .login-header, .login-body { padding: 24px; }
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  animation: fadeIn 0.18s ease;
}

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

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 860px;
  animation: slideUp 0.22s ease;
  margin: auto 0;
}

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

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--primary-mid);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-icon svg { color: var(--primary); width: 20px; height: 20px; }

.modal-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--content-bg); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; }

/* Method selector */
.method-tabs {
  display: flex;
  gap: 0;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--border);
}

.method-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px 8px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  background: none;
  transition: var(--transition);
}
.method-tab:hover { color: var(--text-secondary); background: var(--content-bg); }
.method-tab.active {
  color: var(--primary);
  background: white;
  border-color: var(--border);
  border-bottom-color: white;
}
.method-tab svg { width: 15px; height: 15px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: #fafbfc;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone svg { width: 44px; height: 44px; color: var(--text-muted); margin: 0 auto 14px; }
.upload-zone-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.upload-zone-desc  { font-size: 13px; color: var(--text-muted); }
.upload-zone-btn {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 18px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}
.upload-zone-btn:hover { border-color: var(--primary); color: var(--primary); }

.upload-preview-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.upload-preview-img {
  width: 220px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.upload-preview-img img { width: 100%; display: block; }
.upload-preview-info { flex: 1; }
.upload-analyzing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  color: #1d4ed8;
  font-size: 13.5px;
  font-weight: 500;
}
.upload-analyzing .spin { border-color: rgba(37,99,235,0.3); border-top-color: #2563eb; }
.upload-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--green-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: var(--green);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 10px;
}
.upload-ok svg { width: 16px; height: 16px; }

/* Form sections */
.modal-body {
  padding: 24px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

.form-section {
  margin-bottom: 24px;
}
.form-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title svg { width: 14px; height: 14px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-col-full { grid-column: 1 / -1; }

.form-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-label .req { color: var(--primary); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: white;
  transition: var(--transition);
  outline: none;
  font-family: var(--font);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.07);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-input:disabled, .form-select:disabled { background: #f8fafc; color: var(--text-muted); }

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

.form-textarea { resize: vertical; min-height: 72px; }

.color-select-wrap {
  position: relative;
}
.color-dot {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  pointer-events: none;
  transition: background 0.15s;
}
.color-select-wrap .form-select { padding-left: 32px; }

.input-unit {
  position: relative;
}
.input-unit .form-input { padding-right: 44px; }
.unit-label {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}

.receipt-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: white;
  font-family: monospace;
  letter-spacing: 1px;
  margin-bottom: 16px;
}
.receipt-preview svg { width: 14px; height: 14px; color: #94a3b8; }

/* Modal footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Edit button in table */
.btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  transition: var(--transition);
}
.btn-edit:hover { border-color: var(--primary); color: var(--primary); }
.btn-edit svg { width: 13px; height: 13px; }

/* Status change chip */
.status-select {
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  outline: none;
}

/* Responsive modal */
@media (max-width: 640px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 95vh; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .upload-preview-wrap { flex-direction: column; }
  .upload-preview-img { width: 100%; }
}

/* ========== CAR DETAIL PAGE ========== */

.car-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 16px;
  border: none;
  background: none;
}
.car-detail-back:hover { background: var(--border); color: var(--text-primary); }

.car-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.car-detail-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
  letter-spacing: 0.5px;
}
.car-detail-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Detail tabs ── */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin: -24px -24px 24px;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.detail-tabs::-webkit-scrollbar { display: none; }

.detail-tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.detail-tab:hover { color: var(--text-secondary); }
.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── Overview tab ── */
.overview-row {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.overview-label {
  min-width: 180px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.overview-value { font-weight: 500; }

/* ── Photo grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.photo-slot {
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.photo-slot.empty {
  border: 2px dashed var(--border);
  background: #fafafa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: var(--transition);
}
.photo-slot.empty:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-slot-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}
.photo-slot-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 4px;
  line-height: 1.2;
}
.photo-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-slot-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-slot.filled:hover .photo-slot-overlay { opacity: 1; }
.photo-slot-action {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s;
}
.photo-slot-action:hover { opacity: 0.85; }
.photo-slot-action.view { background: rgba(255,255,255,0.25); }
.photo-slot-action.del  { background: rgba(220,38,38,0.85); }
.slot-num-badge {
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1.3;
  pointer-events: none;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.28); }
.lightbox-close svg { width: 18px; height: 18px; }

/* ── New status badges ── */
.status-pre_registered        { background: #f0f9ff; color: #0369a1; }
.status-registered            { background: #ecfdf5; color: #059669; }
.status-ready_for_disassembly { background: #fff7ed; color: #c2410c; }

/* ── Stage form labels ── */
.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.stage-badge-1 { background: var(--blue-bg);  color: var(--blue); }
.stage-badge-2 { background: var(--green-bg); color: var(--green); }

.jp-era-display {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
  min-height: 16px;
}

/* ── Video section ── */
.video-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}
.video-upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }

.video-list { display: flex; flex-direction: column; gap: 10px; }
.video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
}
.video-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}
.video-icon svg { width: 18px; height: 18px; }
.video-info { flex: 1; min-width: 0; }
.video-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Date inline row (year / month / day in one line) ── */
.date-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: nowrap;
}
.date-inline .form-group { margin-bottom: 0; }
.date-yr { flex: 0 0 36%; }
.date-mo { flex: 0 0 26%; }
.date-dy { flex: 0 0 22%; }
.date-era-badge {
  flex: 1;
  font-size: 11.5px;
  color: var(--blue);
  font-weight: 600;
  font-style: italic;
  padding-bottom: 10px;
  white-space: nowrap;
  min-width: 60px;
}

/* ── Paint code + name inline ── */
.paint-inline { display: flex; gap: 8px; align-items: flex-start; }
.paint-code-wrap { flex: 0 0 115px; }
.paint-name-wrap { flex: 1; }

/* ── Photo slot SVG icon ── */
.photo-slot-icon {
  opacity: 0.35;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.photo-slot-icon svg { width: 36px; height: 27px; }

/* ── Auction raw response debug block ── */
.auction-raw-data {
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 11px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #334155;
  line-height: 1.5;
}
.auction-raw-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 2px;
}

/* ── Responsive photo grid ── */
@media (max-width: 900px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-tabs { margin: -16px -16px 16px; padding: 0 16px; }
  .overview-label { min-width: 120px; }
}

/* ========== DISASSEMBLY PAGE ========== */
.disassembly-page {
  padding-bottom: 100px;
}

.disassembly-header {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  background: white;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin: -28px -28px 0;
  padding: 0 28px;
}

.disassembly-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.disassembly-back {
  flex-shrink: 0;
}

.disassembly-car-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.disassembly-main-photo-wrap {
  width: 110px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.disassembly-main-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.dismNoPhoto {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.disassembly-thumbs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  max-width: 260px;
  align-content: flex-start;
}

.disassembly-thumb {
  width: 46px;
  height: 34px;
  object-fit: cover;
  border-radius: 5px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.65;
  transition: all 0.15s;
  flex-shrink: 0;
}

.disassembly-thumb:hover { opacity: 0.9; }
.disassembly-thumb.active {
  opacity: 1;
  border-color: var(--primary);
}

.disassembly-car-info {
  min-width: 0;
}

.disassembly-car-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.disassembly-car-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin: 2px 0;
}

.disassembly-car-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Controls bar ── */
.disassembly-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.disassembly-controls-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.disassembly-controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.disassembly-count-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}

/* ── Parts table ── */
.parts-table-wrap {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.parts-table thead th {
  background: #f8fafc;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.parts-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

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

.parts-table tbody tr:hover { background: #f8fafc; }

.part-category-header td {
  background: #f1f5f9 !important;
  padding: 6px 12px !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary) !important;
  border-top: 2px solid var(--border) !important;
  pointer-events: none;
}
.part-category-header:hover td { background: #f1f5f9 !important; }

.parts-table tbody td {
  padding: 6px 12px;
  vertical-align: middle;
}

.part-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.part-name {
  font-weight: 500;
  color: var(--text-primary);
}

.part-row-checked {
  background: rgba(220, 38, 38, 0.03) !important;
}

.part-row-checked .part-name {
  font-weight: 600;
  color: var(--primary);
}

.parts-table input[type="number"] {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  background: white;
  transition: border-color 0.15s;
}

.parts-table input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

.parts-table select {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  background: white;
  transition: border-color 0.15s;
}

.parts-table select:focus {
  outline: none;
  border-color: var(--primary);
}

.parts-table input:disabled,
.parts-table select:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #e2e8f0;
}

/* ── Sticky footer ── */
.disassembly-footer {
  position: sticky;
  bottom: 0;
  z-index: 30;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin: 20px -28px -28px;
}

@media (max-width: 900px) {
  .disassembly-thumbs { display: none; }
  .disassembly-header { padding: 0 16px; margin: -16px -16px 0; }
  .disassembly-footer { margin: 20px -16px -16px; padding: 12px 16px; }
  .disassembly-controls { padding: 12px 0 10px; }
}

/* ══════════════════════════════════════════════════
   PARTS PAGE — filters, sort levels, results
══════════════════════════════════════════════════ */

.parts-filter-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.parts-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.parts-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 140px;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-inputs .form-input { width: 90px; }
.range-sep { color: var(--text-muted); font-size: 14px; }

/* Sort section */
.parts-sort-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 16px;
}

.parts-sort-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sort-level {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.sort-level-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sort-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
  flex: 1;
  min-width: 0; /* allow shrinking below content size inside flex row */
}

.sort-dir-group {
  display: flex;
  gap: 4px;
  flex-shrink: 1; /* allow shrinking so it wraps cleanly on narrow viewports */
  flex-wrap: wrap;
}

.sort-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
  background: #f8fafc;
  color: var(--text);
}
.sort-radio-label:hover { border-color: var(--primary); background: #fff5f5; }
.sort-radio-label input[type="radio"] { display: none; }
.sort-radio-label:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.sort-radio-none { color: var(--text-muted); }
.sort-radio-none:has(input:checked) { background: #f1f5f9; color: var(--text-muted); border-color: var(--border); }

/* Search button + page size */
.parts-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  gap: 12px;
}
.parts-page-size-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: #f97316;
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-search:hover { background: #ea6c05; }
.btn-search:active { transform: scale(.98); }
.btn-search:disabled { opacity: .6; cursor: not-allowed; }
.btn-search svg { width: 18px; height: 18px; }

/* Results table */
.parts-results-card { margin-top: 0; }

.parts-results-table {
  width: 100%;
  min-width: 900px; /* ensures table never squishes below usable width; scroll kicks in */
}
.parts-results-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 8px 12px;
  white-space: nowrap;
  /* position: sticky removed — sticky inside overflow-x:auto causes Chrome/Safari to
     propagate the table's full intrinsic width to parent elements, breaking containment */
  border-bottom: 1px solid var(--border);
}
.parts-results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.parts-results-table tbody tr:hover { background: #fafbff; }

/* Russian invoice tables — fixed layout so ENGINES and PARTS columns align */
.ru-inv-table {
  width: 100%;
  min-width: unset;
  table-layout: fixed;
}
.ru-inv-table td:last-child,
.ru-inv-table th:last-child { text-align: right; }

/* Missing translation marker */
.missing-trans { color: var(--amber, #f59e0b); }

/* Totals footer */
.parts-totals-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-top: 2px solid var(--border);
  background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}
.parts-total-item {
  display: flex;
  flex-direction: column;
  padding: 12px 24px;
  border-right: 1px solid var(--border);
}
.parts-total-item:last-child { border-right: none; }
.parts-total-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}
.parts-total-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* Inline warehouse select in results table */
.part-wh-select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  min-width: 110px;
  max-width: 160px;
  transition: border-color .15s, background .15s;
}
.part-wh-select:hover { border-color: var(--primary-light, #f87171); }
.part-wh-select:focus { outline: none; border-color: var(--primary); background: white; }
.part-wh-select.part-wh-changed {
  border-color: #ca8a04;
  background: #fefce8;
  color: #854d0e;
  font-weight: 600;
}

/* Save changes bar — inline in card header */
.parts-save-bar-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}
.parts-save-info {
  font-size: 13px;
  color: var(--text-muted);
}
.parts-save-info strong {
  color: #ca8a04;
  font-weight: 700;
}

@media (max-width: 900px) {
  .parts-filters { gap: 10px; }
  .parts-filter-group { min-width: 130px; }
  .sort-level { gap: 6px; }
  .parts-totals-row { flex-wrap: wrap; }
  .parts-total-item { border-right: none; border-bottom: 1px solid var(--border); flex: 1 1 auto; }
  .parts-page-size-wrap { display: none; }
  .parts-scroll-btns { bottom: 16px; right: 16px; }
}

/* ── Totals top border (between header and top totals) */
.parts-results-card > .parts-totals-row:first-of-type {
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  background: #f0f9ff;
}
.parts-results-card > .parts-totals-row:last-of-type {
  border-top: 2px solid var(--border);
  background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Pagination ── */
.parts-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}
.parts-page-info {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.parts-page-info strong { color: var(--text); }

/* ── Fixed scroll buttons ── */
.parts-scroll-btns {
  position: fixed;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
}
.parts-scroll-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.14);
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
}
.parts-scroll-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(220,38,38,0.35);
  transform: scale(1.08);
}
.parts-scroll-btn:active { transform: scale(.95); }

/* ============================================================
   CONTAINERS MODULE
   ============================================================ */

/* ── List page ── */
.cnt-list { display: flex; flex-direction: column; gap: 12px; }

.cnt-card {
  padding: 0;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}
.cnt-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.cnt-card-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 24px;
}

.cnt-card-left { flex: 0 0 220px; min-width: 160px; }
.cnt-card-number { font-size: 16px; font-weight: 700; font-family: var(--font-mono, monospace); letter-spacing: 0.5px; }
.cnt-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.cnt-card-center { flex: 1; min-width: 180px; }
.cnt-card-vol { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.cnt-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cnt-card-date { font-size: 12px; color: var(--text-muted); }

/* ── Status flow strip ── */
.cnt-status-flow {
  display: flex;
  align-items: center;
  padding: 10px 24px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  gap: 0;
}
.cnt-flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  flex: 0 0 auto;
}
.cnt-flow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  transition: background .2s, border-color .2s;
}
.cnt-flow-done .cnt-flow-dot { background: var(--primary); border-color: var(--primary); }
.cnt-flow-active .cnt-flow-dot { background: white; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }
.cnt-flow-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.cnt-flow-done .cnt-flow-label { color: var(--primary); font-weight: 600; }
.cnt-flow-active .cnt-flow-label { color: var(--primary); font-weight: 700; }
.cnt-flow-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 20px;
  align-self: center;
  margin-bottom: 14px;
}

/* ── Detail page ── */
.cnt-status-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.cnt-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.cnt-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, border-color .15s;
}
.cnt-tab:hover { color: var(--text); }
.cnt-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.cnt-tab-badge {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.cnt-tab.active .cnt-tab-badge { background: rgba(220,38,38,0.08); color: var(--primary); border-color: rgba(220,38,38,0.2); }

.cnt-tab-content { min-height: 300px; }

/* ── Parts tab ── */
.cnt-parts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.cnt-parts-totals {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.cnt-parts-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px 20px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.cnt-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cnt-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.form-input-sm {
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
}
.form-select-sm {
  height: 32px;
  padding: 0 24px 0 8px;
  font-size: 13px;
}
.cnt-filter-pagination {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Container detail: filter + sort panel ── */
.cnt-filter-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cnt-filter-panel-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 24px;
}
.cnt-filter-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cnt-sort-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cnt-sort-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cnt-sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cnt-sort-level-label {
  width: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cnt-sort-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cnt-sort-field-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--content-bg);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.cnt-sort-field-btn:hover { background: var(--primary-light, #eff6ff); border-color: var(--primary); color: var(--primary); }
.cnt-sort-field-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cnt-sort-dirs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.cnt-sort-dir-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--content-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.cnt-sort-dir-btn:hover { border-color: var(--primary); color: var(--primary); }
.cnt-sort-dir-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cnt-parts-totals-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.cnt-parts-totals-bar strong { color: var(--text); }

.btn-icon-del {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-icon-del:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.btn-icon-edit { color: var(--primary); border-color: var(--primary); margin-right: 2px; }
.btn-icon-edit:hover { background: var(--primary-light, #eff6ff); color: var(--primary); border-color: var(--primary); }
.ru-eng-desc-text { cursor: pointer; }
.ru-eng-desc-text:hover { text-decoration: underline dotted; }

/* ── Expenses tab ── */
.cnt-expenses-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 4px 0;
}
.cnt-expenses-form .form-group { margin-bottom: 0; }
.cnt-expenses-form > button,
.cnt-expenses-form > div[style*="margin-top"] { grid-column: 1 / -1; }

.cnt-exp-total {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  padding: 12px 16px;
  background: #f0f9ff;
  border-radius: 8px;
  border: 1px solid #bae6fd;
  color: var(--text);
}
.cnt-exp-total strong { font-size: 18px; color: #0369a1; }

/* ── Scanner tab ── */
.cnt-scanner-wrap { max-width: 600px; }
.cnt-scanner-manual { margin-bottom: 20px; }
.cnt-scanner-camera { margin-bottom: 16px; }

.cnt-scan-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 16px;
}
.cnt-log-ok, .cnt-log-warn, .cnt-log-err {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-mono, monospace);
}
.cnt-log-ok   { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.cnt-log-warn { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }
.cnt-log-err  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Helpers ── */
.text-mono { font-family: var(--font-mono, 'Courier New', monospace); }
.text-sm   { font-size: 12px; }

/* ── Auto-number preview in modal ── */
.cnt-autonumber-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
}
.cnt-autonumber-label { font-size: 13px; color: var(--text-muted); }
.cnt-autonumber-value { font-size: 18px; font-weight: 700; color: #0369a1; font-family: var(--font-mono, monospace); letter-spacing: 1px; }

/* ── Real number badge in detail header ── */
.cnt-real-badge {
  display: inline-block;
  margin-left: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-mono, monospace);
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 2px 8px;
  vertical-align: middle;
}
.cnt-real-card {
  font-size: 12px;
  color: #15803d;
  font-family: var(--font-mono, monospace);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  margin-top: 2px;
}
.cnt-card-real { /* in list card */
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #15803d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
  margin: 2px 0;
}
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--primary); font-size: 13px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 2px;
  margin-left: 8px; vertical-align: middle;
}
.btn-link:hover { opacity: .8; }
.cnt-add-real { font-size: 12px; }

/* ── Parts toolbar in container detail ── */
.cnt-parts-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cnt-scan-btn { font-size: 13px; }

/* ── Scanner modal ── */
.cnt-scanner-modal { max-width: 440px; width: 96vw; }
.cnt-scanner-modal video { display: block; margin: 0 auto; }

/* ── Parts row selection ── */
.parts-row-selected td { background: #eff6ff !important; }
.parts-row-cb { accent-color: var(--primary); }

/* ── form-hint ── */
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Invoice pages ── */
.inv-grand-total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-top: 2px solid var(--border);
  font-size: 15px;
  color: var(--text-muted);
}
.inv-grand-total strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.inv-item-desc,
.inv-item-qty,
.inv-item-up {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--content-bg);
  color: var(--text);
  padding: 3px 6px;
  font-size: 13px;
  transition: border-color .15s;
}
.inv-item-desc:focus,
.inv-item-qty:focus,
.inv-item-up:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(220,38,38,.1);
}

/* Japan invoice — shipping header grid */
.inv-hdr-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.inv-hdr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  flex: 1 1 200px;
}
.inv-hdr-field-wide {
  flex: 2 1 380px;
}

/* ── Shipping header two-tier layout ── */

/* Upper tier: 2-column grid of large address blocks */
.sh-upper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
@media (max-width: 900px) {
  .sh-upper-grid { grid-template-columns: 1fr; }
}
/* Override _cpField inside upper grid to stretch full */
.sh-upper-grid .inv-hdr-field-wide {
  flex: unset;
  min-width: unset;
}
/* Make textarea in upper tier at least 4 rows */
.sh-upper-grid textarea.auto-grow {
  min-height: 90px;
}

/* Lower tier: auto-fit compact inputs, 4 per row on wide screens */
.sh-lower-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px 16px;
}
@media (max-width: 1100px) {
  .sh-lower-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}
@media (max-width: 750px) {
  .sh-lower-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Compact field in lower tier */
.sh-sm-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sh-sm-val {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Input in lower tier: on focus reveal full content via horizontal scroll */
.sh-lower-grid input.form-input {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sh-lower-grid input.form-input:focus {
  text-overflow: clip;
  overflow-x: auto;
}

/* Japan invoice — sub-total bar */
.inv-subtotal-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: .03em;
}
.inv-subtotal-bar strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  min-width: 130px;
  text-align: right;
}
.inv-sub-metric {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.inv-sub-metric b {
  color: var(--text);
  font-weight: 600;
}
.ru-eng-desc {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}
.inv-grand-total .inv-sub-metric {
  font-size: 13px;
}

/* ══════════════════════════════════════════════════
   COUNTERPARTIES PAGE
══════════════════════════════════════════════════ */

.badge-cyan   { background: var(--cyan-bg);   color: var(--cyan); }
.badge-gray   { background: #f1f5f9;           color: var(--text-secondary); }

/* ══════════════════════════════════════════════════
   DOCUMENT MANAGEMENT
══════════════════════════════════════════════════ */

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 4px 0;
}
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.doc-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }
.doc-card-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  cursor: pointer;
  background: #f1f5f9;
  display: block;
}
.doc-card-thumb-file {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  height: 110px;
  background: #f1f5f9;
  cursor: pointer;
}
.doc-card-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.doc-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--primary);
}
.doc-card-name {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.btn-xs {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
}

/* OCR status badges */
.ocr-status-badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 99px; }
.ocr-pending { background: #fef3c7; color: #b45309; }
.ocr-done    { background: #d1fae5; color: #065f46; }
.ocr-failed  { background: #fee2e2; color: #b91c1c; }
.ocr-skipped { background: #f1f5f9; color: #94a3b8; }

/* OCR viewer fields */
.ocr-field-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
}
.ocr-field-key {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 120px;
  flex-shrink: 0;
}
.ocr-field-val {
  color: var(--text);
  word-break: break-word;
}

/* ══════════════════════════════════════════════════
   REFERENCES / СПРАВОЧНИКИ NAV
══════════════════════════════════════════════════ */

.nav-section-collapsible {
  cursor: pointer;
  user-select: none;
}
.nav-section-collapsible:hover {
  color: var(--text);
}

/* ══════════════════════════════════════════════════
   CATALOG PARTS — full editor table
══════════════════════════════════════════════════ */

.cat-parts-table td, .cat-parts-table th {
  padding: 4px 6px;
  vertical-align: middle;
}
.cat-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  text-align: center;
  user-select: none;
  padding: 0 4px;
}
.cat-drag-handle:active { cursor: grabbing; }

.cat-field {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 12px;
  background: transparent;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.cat-field:focus, .cat-field:hover {
  border-color: var(--border);
  background: var(--bg-card);
  outline: none;
}
.cat-field-select {
  appearance: auto;
  font-size: 11px;
  padding: 3px 4px;
}
.cat-field-num {
  width: 60px;
  text-align: center;
}
.cat-vis-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.cat-vis-btn svg { width: 15px; height: 15px; }
.cat-vis-btn:hover { background: var(--bg-secondary); }

/* Hidden row dimming */
.cat-hidden-row { opacity: 0.45; }
.cat-hidden-row:hover { opacity: 0.8; }

/* Drag-and-drop visual indicators */
.cat-part-row.cat-dragging { opacity: 0.35; }
.cat-part-row.cat-drag-top { box-shadow: inset 0 3px 0 var(--primary); }
.cat-part-row.cat-drag-bot { box-shadow: inset 0 -3px 0 var(--primary); }
.cat-header-row.cat-drag-header { background: rgba(var(--primary-rgb, 79,70,229), 0.08); }

/* Category header row (already defined, just ensure compatible) */
.cat-header-row td {
  background: var(--surface-alt, #f8fafc);
  padding: 5px 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-top: 2px solid var(--border);
}

/* ══════════════════════════════════════════════════
   TOGGLE SWITCH — pill-style (used in catalog parts)
══════════════════════════════════════════════════ */

.toggle-sw {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  align-items: center;
}
.toggle-sw input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #cbd5e1;
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle-sw input:checked + .toggle-track { background: #22c55e; }
.toggle-sw input:checked + .toggle-track::after { transform: translateX(16px); }

/* ══════════════════════════════════════════════════
   СПРАВОЧНИКИ — hub page grid
══════════════════════════════════════════════════ */

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.ref-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  text-decoration: none;
  color: inherit;
}
.ref-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.ref-card-emoji {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}
.ref-card-body { flex: 1; min-width: 0; }
.ref-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 3px;
}
.ref-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.ref-card-arrow {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   CATALOG PARTS — redesigned clean table (.cp-*)
══════════════════════════════════════════════════ */

.cp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cp-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.cp-row {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.cp-row:hover { background: var(--bg-secondary, #f8fafc); }

.cp-row td { padding: 6px 10px; vertical-align: middle; }

.cp-row-hidden { opacity: 0.38; }
.cp-row-hidden:hover { opacity: 0.65; }

/* Drag states */
.cp-row.cp-dragging {
  opacity: 0.25;
  background: var(--bg-secondary);
}
.cp-row.cp-drag-top { box-shadow: inset 0 3px 0 var(--primary); }
.cp-row.cp-drag-bot { box-shadow: inset 0 -3px 0 var(--primary); }

/* Category header row */
.cp-cat-header td {
  background: var(--surface-alt, #f1f5f9);
  padding: 6px 10px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-top: 2px solid var(--border);
}
.cp-cat-header.cp-drag-header td { background: rgba(79,70,229,.07); }
.cp-cat-header-cell { display: flex; align-items: center; gap: 8px; }
.cp-cat-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}

/* Column widths */
.cp-handle {
  width: 28px;
  cursor: grab;
  color: var(--text-muted);
  font-size: 15px;
  user-select: none;
  text-align: center;
  padding: 6px 4px !important;
}
.cp-handle:active { cursor: grabbing; }
.cp-code {
  width: 110px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-secondary);
}
.cp-name-en { min-width: 160px; color: var(--text); }
.cp-name-ru { min-width: 160px; color: var(--text-secondary); }
.cp-toggle { width: 52px; text-align: center; }

/* Empty placeholder cell shown when table has no rows */
.empty-cell {
  padding: 40px !important;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ══════════════════════════════════════════════════
   PRINT STYLES — @media print
══════════════════════════════════════════════════ */

@media print {
  @page { size: A4; margin: 15mm 12mm; }

  /* Hide everything except invoice content */
  .sidebar,
  .topbar,
  .page-actions,
  .no-print,
  .card-header button,
  .btn,
  .alert,
  #invShippingHdrForm .detail-label + div > button,
  .sh-upper-grid .btn,
  .sh-lower-grid .btn {
    display: none !important;
  }

  /* Reset layout — full width, no sidebar offset */
  body { background: white !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .page-content { padding: 0 !important; }

  /* Cards — no shadow, white bg, thin border */
  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
    margin-bottom: 8px !important;
  }
  .card-header {
    background: #f0f0f0 !important;
    padding: 6px 10px !important;
  }
  .card-title { font-size: 11pt !important; font-weight: 700 !important; color: #000 !important; }

  /* Text */
  * { color: #000 !important; font-size: 10pt !important; }
  .page-title { font-size: 14pt !important; font-weight: 700 !important; }
  .page-desc  { font-size: 9pt !important; }

  /* Page header */
  .page-header { margin-bottom: 6mm !important; }
  .page-header .btn { display: none !important; }

  /* Info card */
  .detail-label { font-size: 8pt !important; color: #666 !important; }
  .detail-value { font-size: 10pt !important; }

  /* Shipping header fields — show as plain text */
  #invShippingHdrForm input,
  #invShippingHdrForm textarea {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    resize: none !important;
    height: auto !important;
    font-size: 10pt !important;
    color: #000 !important;
  }

  /* Upper tier — keep 2-col grid */
  .sh-upper-grid { grid-template-columns: 1fr 1fr !important; gap: 6mm !important; }
  .sh-lower-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 3mm !important; }

  /* Tables */
  table { border-collapse: collapse !important; width: 100% !important; }
  th, td {
    border: 1px solid #bbb !important;
    padding: 4px 6px !important;
    font-size: 9pt !important;
  }
  th { background: #eee !important; font-weight: 700 !important; }
  tbody tr { break-inside: avoid; }

  /* Russian invoice tables — keep auto width but show borders */
  .ru-inv-table { width: auto !important; }

  /* Badges */
  .badge { border: 1px solid #999 !important; background: #f5f5f5 !important; }

  /* Force black text on amber warning */
  .missing-trans { color: #b45309 !important; }
}
