/* 안드로이드 WebView 전용 오버라이드 — 5.2″(~360px) 기준
   mobile-app.css 이후에 로드. 데스크탑 관리자 레이아웃을 폰에 맞게 강제. */

html.scar-native-app,
html.scar-native-app body {
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  overscroll-behavior-x: none !important;
}

.scar-native-app.scar-dash-shell,
.scar-native-app.scar-dash-shell body {
  position: fixed !important;
  inset: 0 !important;
  height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
}

.scar-native-app.scar-dash-shell #app,
.scar-native-app.scar-dash-shell .adm-wrap,
.scar-native-app.scar-dash-shell .dealer-wrap,
.scar-native-app.scar-dash-shell .adm-main,
.scar-native-app.scar-dash-shell .dealer-main {
  width: 100% !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

.scar-native-app.scar-dash-shell .adm-wrap,
.scar-native-app.scar-dash-shell .dealer-wrap {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #f1f5f9 !important;
}

.scar-native-app.scar-dash-shell .adm-main,
.scar-native-app.scar-dash-shell .dealer-main {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* 유일한 세로 스크롤 */
.scar-native-app.scar-dash-shell #admin-content,
.scar-native-app.scar-dash-shell #dealer-content {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-x: none !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
  padding: 10px 12px calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.45;
}

.scar-native-app.scar-dash-shell #admin-content > *,
.scar-native-app.scar-dash-shell #dealer-content > *,
.scar-native-app.scar-dash-shell .adm-section,
.scar-native-app.scar-dash-shell .dealer-section {
  max-width: 100% !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.scar-native-app.scar-dash-shell #admin-content img,
.scar-native-app.scar-dash-shell #dealer-content img,
.scar-native-app.scar-dash-shell #admin-content video,
.scar-native-app.scar-dash-shell #dealer-content video,
.scar-native-app.scar-dash-shell #admin-content iframe,
.scar-native-app.scar-dash-shell #dealer-content iframe {
  max-width: 100% !important;
  height: auto;
}

/* —— 타이포: 옅은 회색 라벨 → 고대비 —— */
.scar-native-app.scar-dash-shell #admin-content h2,
.scar-native-app.scar-dash-shell #dealer-content h2,
.scar-native-app.scar-dash-shell .scar-app-page-title {
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 18px !important;
  letter-spacing: -0.02em;
}

.scar-native-app.scar-dash-shell #admin-content h3,
.scar-native-app.scar-dash-shell #dealer-content h3 {
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 15px !important;
}

.scar-native-app.scar-dash-shell .scar-app-page-desc,
.scar-native-app.scar-dash-shell #admin-content > .adm-section > p,
.scar-native-app.scar-dash-shell #dealer-content > .dealer-section > p {
  color: #334155 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
}

.scar-native-app.scar-dash-shell #admin-content label,
.scar-native-app.scar-dash-shell #dealer-content label {
  color: #334155 !important;
  font-weight: 700 !important;
}

.scar-native-app.scar-dash-shell #admin-content input,
.scar-native-app.scar-dash-shell #admin-content select,
.scar-native-app.scar-dash-shell #admin-content textarea,
.scar-native-app.scar-dash-shell #dealer-content input,
.scar-native-app.scar-dash-shell #dealer-content select,
.scar-native-app.scar-dash-shell #dealer-content textarea {
  max-width: 100% !important;
  font-size: 16px !important;
  color: #0f172a !important;
}

/* 인라인 min-width는 레이아웃 넘침 방지용 — 테이블 셀은 제외 */
.scar-native-app.scar-dash-shell #admin-content [style*="min-width"]:not(table):not(th):not(td),
.scar-native-app.scar-dash-shell #dealer-content [style*="min-width"]:not(table):not(th):not(td) {
  min-width: 0 !important;
}

.scar-native-app.scar-dash-shell .adm-table-scroll th,
.scar-native-app.scar-dash-shell .adm-table-scroll td,
.scar-native-app.scar-dash-shell .adm-table-wrap th,
.scar-native-app.scar-dash-shell .adm-table-wrap td {
  min-width: auto !important;
}

/* 관제 맵|OBD 2열만 세로 스택 — OBD 메트릭 그리드는 건드리지 않음 */
.scar-native-app.scar-dash-shell .vrd-fleet-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  min-height: 0 !important;
  grid-template-columns: none !important;
}

/* —— 테이블 → 앱 카드 (좌우 스크롤 없이 한 화면) —— */
.scar-native-app.scar-dash-shell .adm-table-scroll,
.scar-native-app.scar-dash-shell .adm-table-wrap,
.scar-native-app.scar-dash-shell .d-table-wrap,
.scar-native-app.scar-dash-shell .car-table-wrap {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  margin: 0 0 12px !important;
  border: none;
  border-radius: 0;
  background: transparent;
}

.scar-native-app.scar-dash-shell .scar-app-cardify,
.scar-native-app.scar-dash-shell .adm-table-scroll.scar-app-cardify {
  overflow: visible !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table,
.scar-native-app.scar-dash-shell .scar-app-cardify table {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  font-size: 13px !important;
  color: #0f172a !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table thead,
.scar-native-app.scar-dash-shell .scar-app-cardify thead {
  display: none !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table tbody,
.scar-native-app.scar-dash-shell .scar-app-cardify tbody {
  display: block !important;
  width: 100% !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-row,
.scar-native-app.scar-dash-shell .scar-app-cardify tbody tr.scar-app-card-row,
.scar-native-app.scar-dash-shell .scar-app-cardify tbody tr.customer-row {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: #fff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 12px 14px !important;
  margin: 0 0 10px !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.scar-native-app.scar-dash-shell .scar-app-card-empty,
.scar-native-app.scar-dash-shell .scar-app-cardify tbody tr.scar-app-card-empty {
  display: block !important;
  padding: 20px 12px !important;
  text-align: center;
  color: #64748b;
  background: #fff;
  border: 1px dashed #e2e8f0;
  border-radius: 12px;
}

.scar-native-app.scar-dash-shell .scar-app-card-table td,
.scar-native-app.scar-dash-shell .scar-app-cardify td {
  display: flex !important;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100% !important;
  white-space: normal !important;
  padding: 5px 0 !important;
  border: none !important;
  border-bottom: 1px solid #f1f5f9 !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  color: #0f172a !important;
  text-align: right !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table td:last-child,
.scar-native-app.scar-dash-shell .scar-app-cardify td:last-child {
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table td::before,
.scar-native-app.scar-dash-shell .scar-app-cardify td::before {
  content: attr(data-label);
  flex: 0 0 36%;
  max-width: 40%;
  text-align: left;
  font-size: 11px !important;
  font-weight: 800 !important;
  color: #475569 !important;
}

.scar-native-app.scar-dash-shell .scar-app-card-table th,
.scar-native-app.scar-dash-shell .scar-app-cardify th {
  display: none !important;
}

/* 카드화 불가 테이블만 가로 스크롤 유지 */
.scar-native-app.scar-dash-shell .adm-table-scroll:not(.scar-app-cardify),
.scar-native-app.scar-dash-shell .adm-table-wrap:not(.scar-app-cardify),
.scar-native-app.scar-dash-shell .d-table-wrap:not(.scar-app-cardify) {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}

.scar-native-app.scar-dash-shell .adm-table-scroll:not(.scar-app-cardify) table,
.scar-native-app.scar-dash-shell .adm-table-wrap:not(.scar-app-cardify) table,
.scar-native-app.scar-dash-shell .d-table-wrap:not(.scar-app-cardify) table {
  display: table !important;
  width: max-content !important;
  min-width: 100% !important;
  font-size: 12px !important;
}

.scar-native-app.scar-dash-shell .adm-table-scroll:not(.scar-app-cardify) th,
.scar-native-app.scar-dash-shell .adm-table-scroll:not(.scar-app-cardify) td {
  white-space: nowrap !important;
  padding: 10px 12px !important;
}

/* —— OBD 메트릭: 한눈에 들어오는 2열 그리드 —— */
.scar-native-app .vrd-obd-grid,
.scar-native-app .vrd-dtc-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px !important;
  margin: 8px 0 !important;
}

.scar-native-app .vrd-obd-cell {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  padding: 8px 6px !important;
  text-align: center !important;
  min-height: 0 !important;
  height: auto !important;
}

.scar-native-app .vrd-obd-label {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: #475569 !important;
  margin-bottom: 2px !important;
  line-height: 1.2 !important;
}

.scar-native-app .vrd-obd-value {
  font-weight: 800 !important;
  font-size: 14px !important;
  color: #0f172a !important;
  line-height: 1.25 !important;
}

.scar-native-app .vrd-obd-unit {
  font-size: 10px !important;
  font-weight: 600 !important;
  color: #64748b !important;
}

.scar-native-app #vrd-detail > div {
  height: auto !important;
  min-height: 0 !important;
}

.scar-native-app #vrd-toolbar > div {
  align-items: stretch !important;
}

/* 세부 메뉴 → 세로 리스트 */
.scar-native-app .dash-menu-hub-grid,
.scar-native-app .dash-menu-hub-grid--2,
.scar-native-app .dash-menu-hub-grid--3,
.scar-native-app .dash-menu-hub-grid--4 {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

.scar-native-app .dash-hub-card {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  min-height: 54px !important;
  padding: 12px 14px !important;
  border-radius: 12px !important;
  border-width: 1px !important;
  box-shadow: none !important;
  transform: none !important;
  text-align: left !important;
}

.scar-native-app .dash-hub-card:hover,
.scar-native-app .dash-hub-card:active {
  transform: none !important;
  background: #f8fafc !important;
}

.scar-native-app .dash-hub-card-icon {
  width: 26px !important;
  height: 26px !important;
  font-size: 20px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}

.scar-native-app .dash-hub-card-label {
  flex: 1 !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  margin: 0 !important;
  color: #0f172a !important;
}

.scar-native-app .dash-hub-card-desc {
  display: none !important;
}

.scar-native-app .dash-hub-card::after {
  content: '›';
  color: #94a3b8;
  font-size: 22px;
  line-height: 1;
  margin-left: 4px;
}

.scar-native-app .dash-menu-hub-title {
  font-size: 18px !important;
  color: #0f172a !important;
  font-weight: 800 !important;
}

.scar-native-app .dash-menu-hub-desc {
  font-size: 13px !important;
  color: #334155 !important;
  font-weight: 600 !important;
}

.scar-native-app #vrd-kakao-map,
.scar-native-app #kakao-map {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 220px !important;
  height: 220px !important;
  flex: none !important;
}

.scar-native-app #vrd-badges {
  max-height: 72px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

.scar-native-app .scar-app-bottom-nav {
  width: 100% !important;
  max-width: 100vw !important;
}

.scar-native-app .scar-app-bottom-btn {
  min-width: 0 !important;
}

.scar-native-app .scar-app-bottom-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-weight: 700;
  color: #475569;
}

.scar-native-app .scar-app-bottom-btn.active .scar-app-bottom-label {
  color: #1d4ed8;
}

/* 대화 FAB — 하단탭·콘텐츠와 겹치지 않게 */
html.scar-native-app.scar-dash-shell #chat-fab {
  right: 12px !important;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 210 !important;
  width: 52px !important;
  height: 52px !important;
}

html.scar-native-app.scar-dash-shell #chat-panel {
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  bottom: 0 !important;
  border-radius: 16px 16px 0 0 !important;
}

/* —— 계약서 인앱 뷰어 (WebView window.open 대체) —— */
.scar-doc-viewer {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10100 !important;
  background: #fff !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100vw !important;
  height: 100% !important;
  height: 100dvh !important;
}

.scar-doc-viewer__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: #0f172a;
  color: #fff;
}

.scar-doc-viewer__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scar-doc-viewer__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.scar-doc-viewer__btn {
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.scar-doc-viewer__btn--primary {
  background: #2563eb;
}

.scar-doc-viewer__frame {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  background: #fff;
}

body.scar-doc-viewer-open {
  overflow: hidden !important;
}

/* —— 영업관리·계약 UI (입점/렌트 전자계약) —— */
.scar-native-app .dpc-page {
  max-width: 100% !important;
  padding: 0 0 16px !important;
}

.scar-native-app .dpc-title {
  font-size: 18px !important;
  color: #0f172a !important;
}

.scar-native-app .dpc-desc {
  font-size: 13px !important;
  color: #334155 !important;
  font-weight: 600 !important;
}

.scar-native-app .dpc-modal-overlay,
.scar-native-app .dpc-modal-backdrop {
  z-index: 10050 !important;
  padding: 8px !important;
  align-items: stretch !important;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
}

.scar-native-app .dpc-modal,
.scar-native-app .dpc-modal--wide {
  max-width: 100% !important;
  width: 100% !important;
  max-height: calc(100dvh - 16px) !important;
  margin: 0 !important;
  border-radius: 14px !important;
  padding: 16px 14px !important;
  overflow: auto !important;
  box-sizing: border-box !important;
}

.scar-native-app .dpc-form-grid {
  grid-template-columns: 1fr !important;
}

.scar-native-app .dpc-send-row {
  flex-direction: column !important;
  align-items: stretch !important;
}

.scar-native-app .dpc-send-row label,
.scar-native-app .dpc-input--wide {
  min-width: 0 !important;
  width: 100% !important;
}

.scar-native-app .dpc-tpl-layout {
  grid-template-columns: 1fr !important;
}

.scar-native-app .dpc-tabs {
  overflow-x: auto;
  flex-wrap: nowrap !important;
  -webkit-overflow-scrolling: touch;
}

.scar-native-app .dpc-tab {
  flex-shrink: 0;
  font-size: 13px !important;
  padding: 10px 12px !important;
}

.scar-native-app .dpc-actions {
  gap: 8px !important;
}

.scar-native-app .dpc-btn {
  min-height: 40px;
  font-size: 13px !important;
}

.scar-native-app .dpc-sig-canvas {
  max-width: 100% !important;
  width: 100% !important;
}

.scar-native-app .dpc-table-wrap.scar-app-cardify,
.scar-native-app .dpc-table-wrap {
  overflow: visible !important;
  border: none !important;
  background: transparent !important;
}

/* 영업관리 PC 다열 그리드 → 2열 */
.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns:repeat(5"],
.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns: repeat(5"],
.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns:repeat(4"],
.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns: repeat(4"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns:repeat(5"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns: repeat(5"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns:repeat(4"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns: repeat(4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns:repeat(3"],
.scar-native-app.scar-dash-shell #admin-content [style*="grid-template-columns: repeat(3"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns:repeat(3"],
.scar-native-app.scar-dash-shell #dealer-content [style*="grid-template-columns: repeat(3"] {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

/* OBD 메트릭은 위에서 2열로 이미 고정 — 인라인 3열 덮어쓰기 방지 */
.scar-native-app .vrd-obd-grid,
.scar-native-app .vrd-dtc-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

/* 견적 카드 내부 3열 → 1열 */
.scar-native-app.scar-dash-shell #dealer-content [style*="repeat(3,1fr)"],
.scar-native-app.scar-dash-shell #dealer-content [style*="repeat(3, 1fr)"],
.scar-native-app.scar-dash-shell #admin-content [style*="repeat(3,1fr)"],
.scar-native-app.scar-dash-shell #admin-content [style*="repeat(3, 1fr)"] {
  grid-template-columns: 1fr !important;
}

html.scar-native-app.scar-public-shell.scar-staff-on-public #app {
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important;
}

.scar-native-app .btn-center-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scar-native-app.scar-dash-shell #admin-content [style*="min-width:160px"],
.scar-native-app.scar-dash-shell #admin-content [style*="min-width: 160px"],
.scar-native-app.scar-dash-shell #admin-content [style*="min-width:220px"],
.scar-native-app.scar-dash-shell #admin-content [style*="width:220px"],
.scar-native-app.scar-dash-shell #dealer-content [style*="min-width:160px"],
.scar-native-app.scar-dash-shell #dealer-content [style*="width:220px"] {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.scar-native-app.scar-dash-shell #admin-content a[target="_blank"],
.scar-native-app.scar-dash-shell #dealer-content a[target="_blank"] {
  /* WebView에서 새 탭 대신 같은 뷰에서 열리도록 JS에서 처리 권장 — 레이아웃만 보정 */
  word-break: break-all;
}
