/* ===== DESIGN SYSTEM ===== */
:root {
  --primary: #4F3CC9;
  --primary-light: #7B6CE6;
  --primary-dark: #3527A0;
  --accent: #FF6B35;
  --accent-light: #FF8C5A;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  --bg: #F7F8FC;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E1B4B;
  --bg-sidebar-hover: #2D2A6E;

  --text-primary: #1E1B4B;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-white: #FFFFFF;

  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --border-focus: #4F3CC9;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;

  --sidebar-width: 240px;
  --header-height: 60px;

  --grade-s: #7C3AED;
  --grade-a: #2563EB;
  --grade-b: #10B981;
  --grade-c: #F59E0B;
  --grade-d: #EF4444;
}

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

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

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ===== TEST MODE BANNER ===== */
.test-banner {
  background: linear-gradient(90deg, #FF6B35, #FF8C5A);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.test-banner .badge {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-white);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4F3CC9, #FF6B35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-section-label {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: rgba(79,60,201,0.3);
  color: #fff;
  border-left-color: var(--primary-light);
}
.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.app-header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-badge {
  background: rgba(79,60,201,0.1);
  color: var(--primary);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon {
  font-size: 16px;
}

/* ===== SEARCH BAR ===== */
.search-section {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  margin-bottom: 24px;
  color: white;
}
.search-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.search-section p {
  font-size: 13px;
  opacity: 0.75;
  margin-bottom: 16px;
}
.search-box {
  display: flex;
  gap: 10px;
  max-width: 680px;
}
.search-input {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 14px;
  outline: none;
  background: rgba(255,255,255,0.95);
  color: var(--text-primary);
}
.search-input::placeholder { color: var(--text-muted); }
.search-btn {
  height: 48px;
  padding: 0 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s;
  white-space: nowrap;
}
.search-btn:hover { background: var(--accent-light); }
.search-quick {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-chip {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.quick-chip:hover {
  background: rgba(255,255,255,0.25);
}

/* ===== GRADE BADGE ===== */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 900;
  color: white;
}
.grade-badge.S { background: var(--grade-s); }
.grade-badge.A { background: var(--grade-a); }
.grade-badge.B { background: var(--grade-b); }
.grade-badge.C { background: var(--grade-c); }
.grade-badge.D { background: var(--grade-d); }

.grade-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}
.grade-tag.S { background: var(--grade-s); }
.grade-tag.A { background: var(--grade-a); }
.grade-tag.B { background: var(--grade-b); }
.grade-tag.C { background: var(--grade-c); }
.grade-tag.D { background: var(--grade-d); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}
.tab-item {
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ===== STAT ITEM ===== */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.stat-value.highlight { color: var(--primary); }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ===== RISK ITEM ===== */
.risk-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.risk-item:last-child { border-bottom: none; }
.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.risk-dot.safe { background: var(--success); }
.risk-dot.warn { background: var(--warning); }
.risk-dot.danger { background: var(--danger); }
.risk-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.risk-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.risk-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}
.risk-status.safe { background: rgba(16,185,129,0.1); color: var(--success); }
.risk-status.warn { background: rgba(245,158,11,0.1); color: var(--warning); }
.risk-status.danger { background: rgba(239,68,68,0.1); color: var(--danger); }

/* ===== PRICE CARD ===== */
.price-main {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}
.price-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.price-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
}
.price-unit { font-size: 16px; font-weight: 600; }
.price-range {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.price-confidence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  background: rgba(79,60,201,0.08);
  color: var(--primary);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== COMPARE CASE ===== */
.compare-case {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border-left: 3px solid var(--primary-light);
}
.compare-case:last-child { margin-bottom: 0; }
.compare-case .case-addr { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.compare-case .case-detail { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.compare-case .case-price { font-size: 13px; font-weight: 700; color: var(--primary); }

/* ===== REGION CARD ===== */
.region-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.region-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}
.region-card.featured {
  border-color: var(--primary);
  background: rgba(79,60,201,0.03);
}
.region-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.region-meta { display: flex; gap: 12px; margin-bottom: 8px; }
.region-meta-item { font-size: 11px; color: var(--text-secondary); }
.region-meta-item strong { color: var(--text-primary); font-weight: 600; }
.region-bar-wrap { background: var(--border-light); border-radius: 4px; height: 6px; margin-bottom: 4px; }
.region-bar { height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.region-bar-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }

/* ===== FAV BUTTON ===== */
.fav-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.15s;
  line-height: 1;
}
.fav-btn:hover { transform: scale(1.2); }

/* ===== RESULT HEADER ===== */
.result-header {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.result-addr { font-size: 16px; font-weight: 700; }
.result-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.result-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.result-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* ===== LOADING SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}
