/* ── 리셋 & 변수 ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg2:         #181c27;
  --bg3:         #1e2335;
  --border:      #2a3050;
  --border2:     #3a4570;
  --accent:      #2563eb;
  --accent-h:    #3b82f6;
  --accent-dim:  rgba(37,99,235,0.15);
  --green:       #22c55e;
  --green-dim:   rgba(34,197,94,0.12);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,0.12);
  --yellow:      #f59e0b;
  --text:        #e2e8f0;
  --text2:       #94a3b8;
  --text3:       #64748b;
  --font-head:   'DM Mono', 'Courier New', monospace;
  --font-body:   'Pretendard', 'Noto Sans KR', sans-serif;
  --radius:      6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
}

/* ── 폰트 ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&display=swap');
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

/* ── 레이아웃 ─────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── 로그인 ─────────────────────────────────────────────────── */
#login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  background-image: 
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(37,99,235,0.08) 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, var(--border) 39px, var(--border) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, var(--border) 39px, var(--border) 40px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(37,99,235,0.1);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .brand {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text);
}

.login-logo .brand span { color: var(--accent-h); }

.login-logo .sub {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── 네비게이션 ─────────────────────────────────────────────── */
#navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-right: 16px;
}
.nav-brand span { color: var(--accent-h); }

.nav-tab {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: var(--font-body);
}
.nav-tab:hover { background: var(--bg3); color: var(--text); }
.nav-tab.active { background: var(--accent-dim); color: var(--accent-h); }

.nav-spacer { flex: 1; }

.nav-user {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--font-head);
}
.nav-user .role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-left: 8px;
}
.role-badge.admin { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.role-badge.dealer { background: var(--accent-dim); color: var(--accent-h); border: 1px solid rgba(37,99,235,0.3); }

/* ── 컨텐츠 영역 ─────────────────────────────────────────────── */
#content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ── 섹션 헤더 ─────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.section-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.03em;
}
.section-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg3);
  color: var(--text3);
  font-family: var(--font-head);
}

/* ── 카드 ─────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── 서머리 그리드 ─────────────────────────────────────────── */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}
.summary-card:hover { border-color: var(--border2); }
.summary-card .label { font-size: 11px; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.summary-card .value { font-family: var(--font-head); font-size: 24px; color: var(--text); }
.summary-card .sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── 툴바 ─────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ── 입력 ─────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text3); }
select option { background: var(--bg2); }
label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 4px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.form-group { display: flex; flex-direction: column; }

/* ── 버튼 ─────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--border2); }
.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.2); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 테이블 ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg3);
  color: var(--text3);
  font-size: 11px;
  font-family: var(--font-head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); color: var(--text); }
.mono { font-family: var(--font-head); font-size: 12px; }

/* ── 배지 ─────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-family: var(--font-head); }
.badge-ok    { background: var(--green-dim); color: var(--green); }
.badge-low   { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-zero  { background: var(--red-dim); color: var(--red); }
.badge-blue  { background: var(--accent-dim); color: var(--accent-h); }
.badge-gray  { background: var(--bg3); color: var(--text3); }

/* ── 검색 패널 ─────────────────────────────────────────────── */
.search-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.search-panel-title {
  font-family: var(--font-head);
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.price-result {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}
.price-result-header {
  background: var(--bg3);
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.price-detail-row {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.price-info-item { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.price-info-item .key { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.price-info-item .val { font-family: var(--font-head); font-size: 15px; color: var(--text); }
.price-main { font-family: var(--font-head); font-size: 28px; color: var(--accent-h); }

/* ── 모달 ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-family: var(--font-head); font-size: 15px; margin-bottom: 20px; color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── 알림 ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.toast-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.toast-info    { background: var(--accent-dim); color: var(--accent-h); border: 1px solid rgba(37,99,235,0.3); }

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

/* ── 업로드 존 ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text3);
}
.upload-zone:hover { border-color: var(--accent); color: var(--accent-h); background: var(--accent-dim); }
.upload-zone.dragging { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone .icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone .hint { font-size: 12px; margin-top: 6px; }

/* ── 탭 ─────────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent-h); border-bottom-color: var(--accent-h); }

/* ── 로더 ─────────────────────────────────────────────────── */
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent-h); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 40px; color: var(--text3); }

/* ── 유틸 ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text3); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }

/* ── 모델 선택 ─────────────────────────────────────────────── */
.model-row { cursor: pointer; }
.model-row.selected td { background: var(--accent-dim) !important; color: var(--accent-h) !important; }
.model-row.selected td .mono { color: var(--accent-h); }

/* ── 워터마크 ─────────────────────────────────────────────── */
.price-watermark {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 20px 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    rgba(37,99,235,0.03) 8px,
    rgba(37,99,235,0.03) 9px
  );
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-head);
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
}

/* 가격 결과 영역 전체 복사 방지 */
#price-result-box {
  user-select: none;
  -webkit-user-select: none;
}
