/* ===== CSS Variables ===== */
:root {
  --primary: #1A6BFF;
  --primary-dark: #0050D8;
  --primary-light: #E8F0FF;
  --accent: #00C896;
  --accent-dark: #009C73;
  --danger: #E84040;
  --warning: #F5A623;
  --success: #00C896;
  --gray-900: #1A1D23;
  --gray-800: #2C3040;
  --gray-700: #3E4358;
  --gray-600: #5A607A;
  --gray-500: #7B82A0;
  --gray-400: #A0A8C4;
  --gray-300: #C8CDD8;
  --gray-200: #E2E5EE;
  --gray-100: #F2F4F8;
  --gray-50: #F8F9FC;
  --white: #FFFFFF;
  --font: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 4px rgba(26,107,255,0.08);
  --shadow-md: 0 4px 16px rgba(26,107,255,0.12);
  --shadow-lg: 0 8px 32px rgba(26,107,255,0.16);
  --header-height: 56px;
  --bottom-nav-height: 68px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); outline: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ===== Typography ===== */
.text-xs  { font-size: 11px; line-height: 1.5; }
.text-sm  { font-size: 13px; line-height: 1.5; }
.text-base{ font-size: 15px; line-height: 1.6; }
.text-lg  { font-size: 17px; line-height: 1.5; }
.text-xl  { font-size: 20px; line-height: 1.4; }
.text-2xl { font-size: 24px; line-height: 1.3; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-muted   { color: var(--gray-500); }
.text-danger  { color: var(--danger); }

/* ===== Layout ===== */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}
.page-with-nav {
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}
.container { padding: 0 16px; }
.section { margin-bottom: 20px; }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--gray-200);
}
.app-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  transition: background var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); }
.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--white);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--bottom-nav-height);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.bottom-nav.hidden {
  transform: translateX(-50%) translateY(100%);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--gray-500);
  transition: color var(--transition);
  position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item.center-active {
  color: var(--white);
}
.nav-item .nav-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-item .nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.2px;
}
.nav-center-btn {
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(26,107,255,0.4);
  color: var(--white);
  margin-top: -16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.nav-center-btn:active { transform: scale(0.95); }
.nav-center-btn .nav-label {
  color: var(--white);
  font-size: 10px;
  font-weight: 600;
}

/* ===== Cards ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--gray-200);
}
.card-sm { padding: 12px; border-radius: var(--radius-md); }
.card-flush { padding: 0; overflow: hidden; }

/* ===== Section Title ===== */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 20px;
  height: 44px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  transition: all var(--transition);
  letter-spacing: -0.2px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(26,107,255,0.3);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-accent {
  background: var(--accent);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(0,200,150,0.3);
}
.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

/* ===== Form ===== */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--gray-900);
  transition: border-color var(--transition), background var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  background: var(--white);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237B82A0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: #E6FAF4; color: #009C73; }
.badge-warning { background: #FFF4E0; color: #C07800; }
.badge-danger  { background: #FDEAEA; color: #C42020; }
.badge-info    { background: #E8F0FF; color: #0050D8; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ===== List Items ===== */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--gray-50); }
.list-item .item-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.list-item .item-content { flex: 1; min-width: 0; }
.list-item .item-title {
  font-size: 14px; font-weight: 500;
  color: var(--gray-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item .item-sub {
  font-size: 12px; color: var(--gray-500);
  margin-top: 2px;
}
.list-item .item-right { flex-shrink: 0; }
.chevron-right { color: var(--gray-400); font-size: 18px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 320px; }
th {
  background: var(--gray-50);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 12px;
  font-size: 13px;
  color: var(--gray-800);
  border-bottom: 1px solid var(--gray-100);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ===== Pagination ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px 0;
}
.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  background: var(--white);
  transition: all var(--transition);
}
.page-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Stat Card ===== */
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 14px;
}
.stat-card .stat-label {
  font-size: 11px; font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 22px; font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}
.stat-card .stat-sub {
  font-size: 11px; color: var(--gray-500);
  margin-top: 3px;
}

/* ===== Progress Bar ===== */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--primary);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.progress-fill.accent { background: var(--accent); }
.progress-fill.warning { background: var(--warning); }

/* ===== Alert / Notice ===== */
.notice-bar {
  background: linear-gradient(135deg, var(--primary), #3B82FF);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.notice-bar .notice-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ===== Tabs ===== */
.tab-wrap {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--gray-500);
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--white);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ===== Modal / Layer ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex; align-items: flex-end;
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-sheet {
  width: 100%;
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 36px; height: 4px;
  background: var(--gray-300);
  border-radius: 100px;
  margin: 10px auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 16px; }

/* ===== Camera View ===== */
.camera-view {
  width: 100%;
  aspect-ratio: 4/3;
  background: #0A0A0A;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
.scan-line {
  position: absolute;
  left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 2.5s ease-in-out infinite;
}
.scan-frame {
  position: absolute;
  width: 200px; height: 200px;
  border: 2px solid var(--accent);
  border-radius: 12px;
}
.scan-frame::before, .scan-frame::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-color: var(--accent);
  border-style: solid;
}
.scan-frame::before { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scan-frame::after  { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
@keyframes scan {
  0%   { top: 10%; }
  50%  { top: 80%; }
  100% { top: 10%; }
}

/* ===== Avatar ===== */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.p-0 { padding: 0; } .pt-2 { padding-top: 8px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--gray-100); margin: 4px 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }