:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  font-family: "Noto Sans KR", "Pretendard", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #eef2ff 0%, var(--bg) 35%, #f8fafc 100%);
  color: var(--text);
}

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.app-title h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-strong);
}

.select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px 20px 32px;
}

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.nav {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.nav-link {
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.nav-link.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: var(--accent);
}

.filter-panel {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-list {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.filter-group {
  display: grid;
  gap: 6px;
}

.filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-search {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.filter-options {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  background: #fff;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}

.filter-group label {
  font-size: 13px;
  color: var(--muted);
}

.filter-group select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.content {
  display: grid;
  gap: 16px;
}

.screen-root {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 60%);
  pointer-events: none;
}

.top3-card {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.empty-state {
  display: grid;
  gap: 8px;
  text-align: center;
  justify-items: center;
  padding: 32px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card .value {
  font-size: 28px;
  font-weight: 700;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.chart {
  height: 240px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
}

.top3-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.kpi-row .card .label {
  color: var(--muted);
  font-size: 13px;
}

.kpi-row .card .value {
  font-size: 32px;
  font-weight: 700;
  color: #dc2626;
}

.top3-grid .card .label {
  color: var(--muted);
  font-size: 13px;
}

.top3-grid .card .value {
  font-size: 24px;
  font-weight: 700;
}

.pivot-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}

.pivot-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.pivot-table th,
.pivot-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.pivot-table .sticky-col {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
}

.pivot-table th.sticky-col {
  z-index: 3;
}

.pivot-table .metric-col {
  background: #fef9c3;
}

.table-wrap {
  overflow: auto;
  max-height: 360px;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #cbd5f5;
  border-radius: 999px;
}

.spacer td {
  padding: 0;
  border: none;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: var(--accent);
  font-size: 12px;
}

.badge.pass {
  background: #dcfce7;
  color: #166534;
}

.badge.fail {
  background: #fee2e2;
  color: #991b1b;
}

.login-card {
  max-width: 420px;
  margin: 0 auto;
}

.login-card input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  display: none;
  z-index: 30;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent);
  font-size: 12px;
}

.chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.side-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 360px;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  padding: 16px;
  z-index: 40;
  overflow: auto;
}

.side-panel.open {
  transform: translateX(0);
}

.side-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.side-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 30;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 12px;
}

.chip.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chip button {
  border: none;
  background: transparent;
  cursor: pointer;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.step {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.step.active {
  background: #eef2ff;
  color: var(--accent);
  border-color: #c7d2fe;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.banner {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}

.banner.warning {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}

.banner.success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}

.modal[hidden] { display: none; }

.modal-content {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  width: min(640px, 90vw);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 15;
}

.overlay[hidden] { display: none; }

.skeleton {
  background: linear-gradient(90deg, #e5e7eb, #f3f4f6, #e5e7eb);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
  height: 16px;
}

@keyframes shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: min(320px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .kpi-grid,
  .charts,
  .top3-grid,
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header {
    grid-template-columns: auto 1fr;
  }
  .header-actions {
    grid-column: 1 / -1;
  }
  .kpi-grid,
  .charts,
  .top3-grid,
  .kpi-row {
    grid-template-columns: 1fr;
  }
  .sidebar {
    top: auto;
    bottom: 0;
    height: 70vh;
    width: 100%;
    transform: translateY(100%);
    border-radius: 16px 16px 0 0;
  }
  .sidebar.open {
    transform: translateY(0);
  }
}
