/* ===== Pretendard Font ===== */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand Colors — MES-Maint 동일 팔레트 */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;

  /* Semantic */
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info: #0284c7;

  /* Dark theme defaults */
  --bg: #0f172a;
  --bg-subtle: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card-hover: rgba(51, 65, 85, 0.7);
  --bg-input: rgba(30, 41, 59, 0.6);
  --bg-nav: rgba(15, 23, 42, 0.95);

  --surface: #1e293b;
  --surface-hover: #334155;
  --border: rgba(148, 163, 184, 0.12);
  --border-focus: rgba(37, 99, 235, 0.5);

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-placeholder: #475569;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.4);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --transition: .15s ease;
  --transition-md: .25s ease;

  /* Layout */
  --header-h: 52px;
  --nav-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --font: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* ===== Light Mode ===== */
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-subtle: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-input: rgba(241, 245, 249, 0.9);
  --bg-nav: rgba(255, 255, 255, 0.96);
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: rgba(15, 23, 42, 0.08);
  --border-focus: rgba(37, 99, 235, 0.4);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-placeholder: #94a3b8;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.1);
}

html {
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ===== SVG Icons (inline) ===== */
.icon-svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-svg.sm { width: 15px; height: 15px; }
.icon-svg.lg { width: 22px; height: 22px; }

/* ===== Splash Screen ===== */
#splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .4s ease, visibility .4s ease;
}
#splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  animation: splash-pulse 2s ease-in-out infinite;
}
.splash-logo svg { width: 28px; height: 28px; color: #fff; }
/* 사용자 제공 스플래시 이미지 (icons/splash-logo.png) */
.splash-img {
  width: 112px; height: 112px; object-fit: contain;
  margin-bottom: 1rem; border-radius: var(--radius-md);
  animation: splash-pulse 2s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.splash-text {
  font-size: 1rem; font-weight: 600;
  color: var(--text-secondary); letter-spacing: .02em;
}
.splash-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-top: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== App Shell ===== */
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ===== Header ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  /* 상태표시줄(노치) 높이만큼 위 여백 추가 — 네이티브 edge-to-edge 대응 */
  height: calc(var(--header-h) + var(--safe-top)); z-index: 100;
  display: flex; align-items: center;
  padding: var(--safe-top) 12px 0;
  background: var(--bg-nav);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.header-title {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
}
.header-logo {
  width: 30px; height: 30px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.header-logo svg { width: 16px; height: 16px; color: #fff; }
.header-title h1 {
  font-size: 0.93rem; font-weight: 700;
  color: var(--text); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.header-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.header-btn {
  width: 32px; height: 32px; border: none;
  background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); font-size: 0;
}
.header-btn:hover, .header-btn:active {
  background: var(--bg-input); color: var(--text);
}
.header-btn svg { width: 17px; height: 17px; }

/* Sync Badge */
.sync-badge {
  font-size: 0.65rem; padding: 2px 7px;
  background: var(--bg-input); color: var(--text-muted);
  border-radius: var(--radius-full); white-space: nowrap;
  border: 1px solid var(--border);
}

/* ===== Main Content ===== */
/* 헤더(검색·필터·탭·제목)는 페이지 상단에 고정, 목록(각 페이지의 마지막 자식)만 스크롤.
   .app-content 자체는 스크롤하지 않고, 활성 페이지를 flex 컬럼으로 채운다. */
.app-content {
  flex: 1; min-height: 0;
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow: hidden;
  display: flex; flex-direction: column;
}
.page {
  display: none; padding: 12px;
  animation: fadeIn .2s ease forwards;
}
.page.active {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
/* 헤더 영역(검색/필터/탭/통계/제목 등)은 고정 높이, 목록만 스크롤 */
.page.active > *:not(:last-child) { flex: 0 0 auto; }
.page.active > *:last-child {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--bg-nav);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 6px 0;
  color: var(--text-muted); text-decoration: none; cursor: pointer;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.nav-item svg { width: 20px; height: 20px; transition: transform var(--transition); }
.nav-item .nav-label {
  font-size: 0.6rem; font-weight: 600; letter-spacing: .01em;
}
.nav-item.active { color: var(--primary); }
[data-theme="light"] .nav-item.active { color: var(--primary); }
.nav-item.active svg { transform: scale(1.08); }
.nav-item.active::after {
  content: ''; position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--primary); border-radius: 0 0 2px 2px;
}

/* ===== Search Bar ===== */
.search-container { position: sticky; top: 0; z-index: 10; padding: 0 0 8px; }
.search-box {
  display: flex; align-items: center;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 10px;
  height: 38px; gap: 8px;
  transition: border var(--transition), box-shadow var(--transition);
}
.search-box.cursor-pointer { cursor: pointer; }
.search-box:focus-within, .search-box:hover {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.search-box .search-icon { color: var(--text-muted); flex-shrink: 0; display: flex; }
.search-box .search-icon svg { width: 15px; height: 15px; }
.search-placeholder {
  flex: 1; color: var(--text-placeholder); font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-box input::placeholder { color: var(--text-placeholder); }
.search-box .clear-btn {
  display: none; border: none; background: none;
  color: var(--text-muted); cursor: pointer; font-size: 0.85rem; padding: 2px;
}
.search-box .clear-btn.visible { display: block; }

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 0 0 8px; -ms-overflow-style: none; scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  color: var(--text-secondary); font-size: 0.75rem; font-weight: 500;
  white-space: nowrap; cursor: pointer; transition: all var(--transition);
}
.filter-chip.active, .filter-chip:hover {
  background: var(--primary-50); border-color: var(--primary-200);
  color: var(--primary);
}
[data-theme="dark"] .filter-chip.active,
[data-theme="dark"] .filter-chip:hover {
  background: rgba(37,99,235,.15); border-color: rgba(37,99,235,.3);
  color: var(--primary-light);
}
.filter-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.filter-dot.red { background: var(--danger); }
.filter-dot.blue { background: var(--info); }
.filter-dot.green { background: var(--success); }
.filter-dot.gray { background: var(--text-muted); }

/* ===== Date Range ===== */
.date-range {
  display: flex; align-items: center; gap: 6px; padding: 0 0 8px;
}
.date-input-wrapper { flex: 1; }
.date-input-wrapper input[type="date"] {
  width: 100%; height: 36px; padding: 0 10px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: #0f172a;
  font-size: 0.78rem; outline: none; transition: border var(--transition);
  color-scheme: light;
}
.date-input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.date-range .separator {
  color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin-bottom: 8px; transition: all var(--transition); cursor: pointer;
}
.card:hover, .card:active {
  background: var(--bg-card-hover); border-color: var(--border-focus);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.card-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 8px; gap: 8px;
}
.card-header > div { min-width: 0; flex: 1; }
.card-title {
  font-size: 0.88rem; font-weight: 700; color: var(--text);
  line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-subtitle {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 0.65rem; font-weight: 600; flex-shrink: 0; white-space: nowrap;
}
.badge-info { background: var(--primary-100); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warn { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-purple { background: #ede9fe; color: #7c3aed; }
[data-theme="dark"] .badge-info { background: rgba(37,99,235,.15); color: var(--primary-light); }
[data-theme="dark"] .badge-success { background: rgba(22,163,74,.15); color: #4ade80; }
[data-theme="dark"] .badge-warn { background: rgba(217,119,6,.15); color: #fbbf24; }
[data-theme="dark"] .badge-danger { background: rgba(220,38,38,.15); color: #f87171; }
[data-theme="dark"] .badge-purple { background: rgba(124,58,237,.15); color: #a78bfa; }

.card-body { display: flex; flex-direction: column; gap: 4px; }
.card-row {
  display: flex; align-items: center; gap: 8px; font-size: 0.78rem;
}
.card-row .row-label {
  color: var(--text-muted); min-width: 50px; flex-shrink: 0; font-weight: 500;
}
.card-row .row-value {
  color: var(--text-secondary); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-row .row-value.highlight { color: var(--text); font-weight: 600; }

/* ===== Detail View ===== */
.detail-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
}
.detail-overlay.open { display: flex; }
.detail-sheet {
  position: relative;
  width: calc(100% - 24px); max-width: 480px; max-height: 85dvh;
  background: var(--surface); border-radius: var(--radius-xl);
  overflow-y: auto; animation: modalPop .22s cubic-bezier(.16,1,.3,1);
  box-shadow: var(--shadow-lg);
}
@keyframes modalPop {
  from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; }
}
.detail-handle { display: none; }
.detail-header { padding: 16px 44px 14px 16px; border-bottom: 1px solid var(--border); }
.detail-header h2 { font-size: 1.05rem; font-weight: 700; }
.detail-header .detail-sub {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 3px;
}
.detail-body { padding: 14px 16px; }
.detail-section { margin-bottom: 18px; }
.detail-section-title {
  font-size: 0.7rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
[data-theme="light"] .detail-section-title { color: var(--primary-dark); }
.detail-field {
  display: flex; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.detail-field:last-child { border-bottom: none; }
.detail-field .field-label {
  min-width: 72px; font-size: 0.78rem; color: var(--text-muted); font-weight: 500;
}
.detail-field .field-value {
  flex: 1; font-size: 0.82rem; color: var(--text); word-break: break-word;
}

/* ===== Skeleton Loading ===== */
.skeleton-card {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px;
}
.skeleton-line {
  height: 12px; background: var(--bg-card); border-radius: 3px;
  margin-bottom: 8px; position: relative; overflow: hidden;
}
.skeleton-line::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(148,163,184,.06), transparent);
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-80 { width: 80%; }

/* ===== Stats Row ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 6px; text-align: center;
}
.stat-value {
  font-size: 1.3rem; font-weight: 800; color: var(--primary); line-height: 1.2;
}
[data-theme="dark"] .stat-value { color: var(--primary-light); }
.stat-label {
  font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; font-weight: 500;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 16px; text-align: center;
}
.empty-state .empty-text {
  font-size: 0.85rem; color: var(--text-muted); font-weight: 500;
}
.empty-state .empty-sub {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; opacity: .7;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 0.85rem; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
}
.section-title .title-count {
  font-size: 0.7rem; color: var(--text-muted); font-weight: 500;
}

/* ===== Scroll to Top ===== */
.scroll-top-btn {
  position: fixed;
  /* FAB(추가 버튼, bottom 80px·높이 54px) 위로 올려 가려지지 않게 */
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 88px);
  right: 14px; width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: var(--primary); color: #fff;
  font-size: 1rem; cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(16px);
  transition: all var(--transition-md); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.scroll-top-btn.visible { opacity: 1; transform: translateY(0); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface); color: var(--text);
  padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-size: 0.82rem; z-index: 300;
  opacity: 0; transition: all var(--transition-md); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Calendar ===== */
.mini-calendar {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cal-header .cal-title { font-size: 0.88rem; font-weight: 700; }
.cal-nav-btn {
  width: 28px; height: 28px; border: none;
  background: var(--bg-input); color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); font-size: 0.7rem;
}
.cal-nav-btn:hover { background: var(--primary-50); color: var(--primary); }
[data-theme="dark"] .cal-nav-btn:hover { background: rgba(37,99,235,.15); color: var(--primary-light); }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px;
}
.cal-weekday {
  text-align: center; font-size: 0.6rem; color: var(--text-muted);
  font-weight: 600; padding: 3px 0;
}
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition); color: var(--text-secondary); position: relative;
}
.cal-day.today {
  background: var(--primary-50); color: var(--primary); font-weight: 700;
}
[data-theme="dark"] .cal-day.today {
  background: rgba(37,99,235,.15); color: var(--primary-light);
}
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-day.has-event::after {
  content: ''; position: absolute; bottom: 2px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.cal-day.selected.has-event::after { background: #fff; }
.cal-day.other-month { opacity: .25; }

/* ===== Inventory Stock Bar ===== */
.stock-bar {
  width: 100%; height: 5px; background: var(--bg-input);
  border-radius: 3px; overflow: hidden; margin-top: 6px;
}
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.stock-bar-fill.safe { background: var(--success); }
.stock-bar-fill.low { background: var(--warning); }
.stock-bar-fill.critical { background: var(--danger); }

/* ===== Login Screen ===== */
#login-screen {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,235,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,.08) 0%, transparent 50%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity .3s ease, visibility .3s ease;
}
#login-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 28px 28px;
  width: 340px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-logo-wrap {
  text-align: center; margin-bottom: 24px;
}
.login-logo-wrap .logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md); margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.login-logo-wrap .logo-badge svg { width: 24px; height: 24px; color: #fff; }
.login-logo-wrap .title {
  font-size: 1.2rem; font-weight: 800; color: var(--text);
  letter-spacing: -.02em; line-height: 1.2;
}
.login-logo-wrap .subtitle {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 4px;
}
.login-form {
  width: 100%; display: flex; flex-direction: column; gap: 12px;
}
.login-form .form-group { display: flex; flex-direction: column; gap: 4px; }
.login-form .form-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-secondary);
}
/* 사번·비밀번호·API 모두 동일 디자인(흰 배경) — C1/C3 */
.login-form input {
  width: 100%; padding: 9px 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); color: #0f172a; font-size: 0.9rem;
  transition: border var(--transition), box-shadow var(--transition);
}
.login-form input::placeholder { color: #94a3b8; }
.login-form input:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.login-options { display: flex; justify-content: space-between; align-items: center; }
.login-adv-btn {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--text-secondary); font-size: 0.78rem; font-weight: 600;
}
.login-adv-btn:hover { color: var(--primary); }
.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 0.78rem; cursor: pointer;
}
.checkbox-label input { accent-color: var(--primary); width: 14px; height: 14px; }
.login-btn {
  width: 100%; padding: 10px;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); font-size: 0.9rem; font-weight: 700;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
  letter-spacing: -.01em;
}
.login-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  transform: translateY(-1px);
}
.login-btn:active { transform: translateY(0); }
.login-error {
  margin-top: 8px; color: var(--danger);
  font-size: 0.78rem; text-align: center; min-height: 1.2em;
}
.login-divider {
  text-align: center; color: var(--text-muted); font-size: 0.68rem;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  z-index: 11000;
  display: flex; align-items: center; justify-content: center;
  opacity: 1; visibility: visible;
  transition: opacity var(--transition-md), visibility var(--transition-md);
}
.modal-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal {
  background: var(--surface); width: 90%; max-width: 380px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border);
  transform: translateY(-12px) scale(.98);
  transition: transform var(--transition-md);
}
.modal-overlay:not(.hidden) .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-subtle);
}
.modal-header h2 {
  font-size: 0.92rem; font-weight: 700; margin: 0; color: var(--text);
}
.modal-close {
  background: transparent; border: none;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 1rem; transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-input); color: var(--text); }
.modal-body { padding: 16px; overflow-y: auto; max-height: 70vh; }
.modal-footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Buttons */
.btn-primary {
  padding: 10px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); text-align: center;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  padding: 10px; background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); text-align: center;
}
.btn-outline:hover { background: var(--bg-input); }

/* Form Elements in Modal */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.form-control {
  width: 100%; padding: 8px 10px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: #0f172a; font-size: 0.85rem; outline: none;
}
.form-control::placeholder { color: #94a3b8; }
.form-control:focus { border-color: var(--primary); }

/* User Management */
.add-user-form {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
}
.add-user-form input, .add-user-form select {
  padding: 8px 10px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.82rem; flex: 1; min-width: 120px;
}
.add-user-form select { min-width: 100px; }
.add-user-form button {
  padding: 8px 12px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.82rem; white-space: nowrap;
  flex: 1; min-width: 80px; max-width: 100%;
}
.user-list-header {
  font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.user-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.user-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: var(--bg-card); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.user-item-info { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.user-item-role {
  font-size: 0.65rem; padding: 1px 6px; border-radius: var(--radius-full);
  background: var(--bg-input); color: var(--text-muted); font-weight: 600;
}
.user-item-role.admin {
  background: var(--primary-100); color: var(--primary);
}
[data-theme="dark"] .user-item-role.admin {
  background: rgba(37,99,235,.15); color: var(--primary-light);
}
.btn-delete-user {
  background: none; border: none; color: var(--danger);
  font-size: 0.78rem; cursor: pointer; padding: 2px 6px;
  border-radius: var(--radius-sm); transition: background var(--transition);
}
.btn-delete-user:hover { background: var(--danger-light); }
[data-theme="dark"] .btn-delete-user:hover { background: rgba(220,38,38,.12); }

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .page { padding: 14px 20px; }
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) {
  .page { max-width: 540px; margin: 0 auto; padding: 16px; }
  .bottom-nav {
    max-width: 540px; left: 50%; transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ===== Utility ===== */
.text-success { color: var(--success); }
.text-warn { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 더보기 우측 드로어 (보조 모듈 메뉴) ── */
.more-drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 199; }
.more-drawer-overlay.hidden { display: none; }
.more-drawer {
  position: fixed; top: 0; right: 0; height: 100%;
  width: 80%; max-width: 300px;
  background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .25s ease;
  z-index: 200; display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,.3);
}
.more-drawer.open { transform: translateX(0); }
.more-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 16px 16px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.more-user { min-width: 0; }
.more-user-name { font-size: 0.98rem; font-weight: 700; color: var(--text); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-user-team { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 이미지 뷰어 (첨부 사진 전체화면) ===== */
.img-viewer {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 8px) 10px calc(var(--safe-bottom) + 8px);
}
.img-viewer.hidden { display: none; }
.img-viewer img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 4px;
}
.img-viewer-close {
  position: fixed; top: calc(var(--safe-top) + 10px); right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16); color: #fff; border: none;
  font-size: 20px; line-height: 40px; text-align: center; cursor: pointer; z-index: 401;
}
.more-menu { padding: 8px; overflow-y: auto; }
.more-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 14px 12px; margin-bottom: 4px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 0.9rem; text-align: left; cursor: pointer;
}
.more-menu-item:active { background: var(--surface-hover); }
.more-menu-item.disabled { opacity: .5; }
.more-menu-section { font-size: 0.72rem; color: var(--text-muted); padding: 12px 8px 4px; }
