/* WecarDiagnostic Design System (Wecar ERP 참조) */
:root {
  --primary: #03c75a;
  --primary-dark: #02a84a;
  --primary-soft: rgba(3, 199, 90, 0.12);
  --navy: #0f172a;
  --slate: #64748b;
  --bg: #eef2f6;
  --surface: #ffffff;
  --border: #e2e8f0;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  --header-h: 60px;
  --font-base: 0.875rem;
  --font-sm: 0.8125rem;
  --table-header-bg: #1e293b;
  --table-header-color: #f8fafc;
  --table-hover-bg: #f0fdf4;
}

* { box-sizing: border-box; }

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--font-base);
  background: var(--bg);
  color: var(--navy);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  min-height: var(--header-h);
}

.app-navbar .navbar-brand {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
}

.app-navbar .brand-icon {
  color: var(--primary);
}

.app-navbar .nav-link.active { color: var(--primary-dark) !important; }

.app-navbar .nav-link { color: var(--slate); font-size: var(--font-sm); }

.user-badge {
  font-size: var(--font-sm);
  color: var(--slate);
  padding: 0.25rem 0.75rem;
  background: #f8fafc;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.app-content { padding: 1rem 1.25rem 1.5rem; max-width: 100%; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: var(--font-sm);
  border-radius: var(--radius);
  border-color: var(--border);
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.stat-card .stat-label {
  font-size: var(--font-sm);
  color: var(--slate);
}

.wecar-table {
  width: max-content;
  min-width: 100%;
  margin: 0;
  font-size: var(--font-sm);
  table-layout: auto;
}

.wecar-table.vehicle-table {
  min-width: 1540px;
  table-layout: fixed;
}

.wecar-table .col-id { width: 52px; min-width: 52px; }
.wecar-table .col-mfr { width: 90px; min-width: 90px; }
.wecar-table .col-model { width: 120px; min-width: 120px; }
.wecar-table .col-grade { width: 220px; min-width: 180px; white-space: normal; word-break: keep-all; }
.wecar-table .col-fuel { width: 94px; min-width: 94px; max-width: 94px; text-align: center; padding: 0.45rem 0.35rem !important; }
.wecar-table .col-year { width: 76px; min-width: 76px; }
.wecar-table .col-dtc { width: 98px; min-width: 98px; max-width: 98px; text-align: center; padding: 0.45rem 0.35rem !important; }
.wecar-table .col-vin { width: 92px; min-width: 92px; max-width: 92px; text-align: center; padding: 0.45rem 0.35rem !important; }
.wecar-table .col-ev { width: 98px; min-width: 98px; max-width: 98px; text-align: center; padding: 0.45rem 0.35rem !important; }
.wecar-table .col-memo { width: 160px; min-width: 140px; white-space: normal; }
.wecar-table .col-progress { width: 96px; min-width: 96px; max-width: 96px; text-align: center; padding: 0.45rem 0.35rem !important; }
.wecar-table .col-image { width: 68px; min-width: 68px; text-align: center; }
.wecar-table .col-history { width: 64px; min-width: 64px; text-align: center; padding: 0.35rem 0.4rem !important; }
.wecar-table .col-diag { width: 68px; min-width: 68px; text-align: center; padding: 0.35rem 0.4rem !important; }
.wecar-table .col-action { width: 210px; min-width: 210px; padding: 0.35rem 0.5rem !important; }

/* 버튼 열: 셀 크기에 맞춰 버튼 정렬 */
.wecar-table .btn-cell {
  padding: 0.35rem 0.45rem !important;
  vertical-align: middle;
  overflow: visible;
  text-overflow: clip;
}

.wecar-table .btn-cell .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.wecar-table .col-history .btn,
.wecar-table .col-diag .btn {
  width: 100%;
  min-width: 0;
}

.wecar-table .col-action .btn-group {
  display: flex;
  width: 100%;
  gap: 0;
}

.wecar-table .col-action .btn-group .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.28rem 0.35rem;
  font-size: 0.72rem;
}

.wecar-table thead th {
  background: var(--table-header-bg);
  color: var(--table-header-color);
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  border: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.wecar-table tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wecar-table tbody tr:hover { background: var(--table-hover-bg); }

/* 유종·DTC·전기·진행 — 내용 크기에 맞게 표시 (잘림 방지) */
.wecar-table .col-fuel,
.wecar-table .col-dtc,
.wecar-table .col-ev,
.wecar-table .col-progress {
  overflow: visible;
  text-overflow: clip;
}

.wecar-table .col-fuel span,
.wecar-table .col-dtc span,
.wecar-table .col-vin span,
.wecar-table .col-ev span,
.wecar-table .col-progress span {
  display: inline-block;
  white-space: nowrap;
  font-size: 0.75rem;
  line-height: 1.3;
}

.cell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.badge-cell {
  text-align: center;
  overflow: hidden;
}

.status-badge {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.fuel-badge {
  max-width: 100%;
}

.progress-badge.badge-done {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.progress-badge.badge-pending {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.add-horizontal .form-select {
  min-width: 0;
}

.add-horizontal .form-label {
  display: block;
}

.wecar-table .col-fuel span[style*="padding"] {
  padding: 1px 6px !important;
  font-size: 0.72rem !important;
}

.wecar-table .col-progress .badge-done,
.wecar-table .col-progress .badge-pending,
.wecar-table .col-progress span[style*="border-radius"] {
  padding: 2px 7px !important;
  font-size: 0.72rem !important;
  line-height: 1.3;
}

.wecar-table thead th.col-fuel,
.wecar-table thead th.col-dtc,
.wecar-table thead th.col-ev,
.wecar-table thead th.col-progress {
  text-align: center;
  padding: 0.65rem 0.35rem;
}

.table-scroll {
  max-height: calc(100vh - 280px);
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 5px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.table-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.badge-done {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-fuel {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-primary {
  color: var(--primary-dark);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.login-wrap {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-card .login-logo {
  font-size: 2.5rem;
  color: var(--primary);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: var(--font-sm);
  color: var(--slate);
}

.diagnosis-drawer .modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.status-group label {
  font-size: var(--font-sm);
  margin-right: 0.75rem;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.image-slot {
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: #fafbfc;
}

.image-slot img { width: 100%; height: 100%; object-fit: cover; }

.image-slot .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
}

.ev-disabled { opacity: 0.5; }
.ev-disabled .ev-status-radios { pointer-events: none; }
.ev-section:not(.ev-disabled) .ev-req { display: inline; }

.vehicle-info-box {
  background: #f8fafc;
  border: 1px solid var(--border);
}

.step-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.step-indicator .step {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--slate);
  border: 1px solid var(--border);
}

.step-indicator .step.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary);
  font-weight: 600;
}

.step-indicator .step.done {
  background: #dcfce7;
  color: #166534;
}

.add-cascade {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.add-field-row {
  animation: fadeSlideIn 0.2s ease;
}

.add-field-row .form-label {
  font-size: var(--font-sm);
  margin-bottom: 0.35rem;
  color: var(--slate);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.action-cell .btn-group { width: 100%; }

.memo-cell { min-width: 150px; max-width: 220px; white-space: normal; }

.inline-editable {
  cursor: pointer;
  position: relative;
}

.inline-editable:hover .cell-display {
  background: var(--primary-soft);
  border-radius: 4px;
  outline: 1px dashed var(--primary);
}

.inline-editable.editing { padding: 0.15rem; }

.inline-editable .inline-input {
  font-size: 0.75rem;
  min-width: 90px;
}

.inline-editable.inline-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.inline-editable.inline-disabled:hover .cell-display {
  background: none;
  outline: none;
}

.pwa-install-section .btn { min-width: 180px; }

@media (max-width: 768px) {
  .table-scroll { max-height: calc(100vh - 340px); }
  .filter-bar .col-md-2, .filter-bar .col-md-3 { margin-bottom: 0.5rem; }
}
