:root {
  --navy: #10253f;
  --navy2: #14385c;
  --card: #ffffff;
  --line: rgba(16, 37, 63, 0.1);
  --text: #172033;
  --muted: #6b7280;
  --blue: #0284c7;
  --sky: #38bdf8;

  --normal: #10b981;
  --average: #f59e0b;
  --poor: #ef4444;

  --shadow: 0 12px 28px rgba(16, 37, 63, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(56, 189, 248, 0.18),
      transparent 32%
    ),
    linear-gradient(135deg, #f6fbff 0%, #eef8ff 100%);
}

/* 기본 레이아웃 */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}
/* 좌측 네비게이션 패널 */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  color: white;
  background: linear-gradient(180deg, var(--navy), var(--navy2));
  overflow: hidden;
  box-shadow: 8px 0 24px rgba(16, 37, 63, 0.14);
}

.sidebar-toggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font-size: 20px;
  margin-bottom: 16px;
}

/* 로고 */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--sky), var(--blue));
  font-size: 24px;
  font-weight: 900;
  flex: 0 0 auto;

  overflow: hidden;
}

.brand-mark img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
}
.brand p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 13px 14px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  color: white;
  background: rgba(56, 189, 248, 0.25);
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.upload-box {
  margin-top: 24px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.13);
}

.upload-box label {
  display: block;
  font-weight: 900;
  margin-bottom: 10px;
}
.upload-box input {
  width: 100%;
  font-size: 12px;
}
.upload-box small {
  display: block;
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

/* 등급산정 범례 */
.legend {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
}

.normal {
  background: var(--normal);
}
.average {
  background: var(--average);
}
.poor {
  background: var(--poor);
}

/* 네비게이션 패널 접힘상태 */
body.sidebar-collapsed .app-shell {
  grid-template-columns: 82px 1fr;
}
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .upload-box,
body.sidebar-collapsed .legend {
  display: none;
}
body.sidebar-collapsed .sidebar {
  padding-left: 18px;
  padding-right: 18px;
}
body.sidebar-collapsed .brand {
  justify-content: center;
}
body.sidebar-collapsed .nav-button {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.main {
  padding: 30px;
  min-width: 0;
}

/* 상단 헤더 및 필터 영역 */
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 12px;
}

.hero h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
}

.hero-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
  font-weight: 800;
  color: var(--text);
}

/* 데이터 없음 안내영역 */
.empty-state {
  margin: 18px 0;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(2, 132, 199, 0.28);
}

.empty-state.loaded {
  display: none;
}
.empty-icon {
  font-size: 30px;
}
.empty-state h3 {
  margin: 0;
  font-size: 16px;
}
.empty-state p {
  margin: 4px 0 0;
  color: var(--muted);
}

body.no-data #section-summary,
body.no-data #section-liquid,
body.no-data #section-table {
  display: none;
}

.status-strip {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.status-pill {
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(16, 37, 63, 0.08);
}

/* KPI 요약 카드 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  padding: 20px;
  min-height: 150px;
  border-radius: 24px;
  background: white;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.75);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 5px;
  background: linear-gradient(90deg, var(--sky), var(--blue));
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.kpi-card strong {
  display: block;
  margin: 14px 0 8px;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.kpi-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.4;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 22px;
  border-radius: 28px;
  background: white;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.75);
  min-width: 0;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title h3 {
  margin: 0;
  font-size: 18px;
}
.panel-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
/* 수위 달성 카드 */
.liquid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 18px;
  max-height: 500px;
  overflow: auto;
  padding-right: 4px;
}
.liquid-card {
  min-height: 210px;
  padding: 18px 14px;
  border-radius: 26px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96),
    rgba(247, 252, 255, 0.94)
  );
  border: 1px solid rgba(14, 165, 233, 0.1);
  box-shadow:
    0 12px 24px rgba(16, 37, 63, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 12px;
}
.liquid-title {
  width: 100%;
  font-size: 14px;
  line-height: 1.3;
  color: #1f3148;
  font-weight: 900;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.liquid-sub {
  color: #7a8797;
  font-size: 12px;
  text-align: center;
}
.liquid-meter {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(14, 165, 233, 0.14);
  background: radial-gradient(
    circle at 35% 22%,
    rgba(255, 255, 255, 1),
    rgba(248, 252, 255, 0.97) 48%,
    rgba(241, 248, 252, 0.95)
  );
  box-shadow:
    inset 0 0 18px rgba(14, 165, 233, 0.08),
    inset 0 -14px 28px rgba(14, 165, 233, 0.08),
    0 10px 22px rgba(16, 37, 63, 0.065);
  overflow: hidden;
}

/* 하이라이트 */
.liquid-meter::before {
  content: "";
  position: absolute;
  left: 14%;
  top: 10%;
  width: 42%;
  height: 58%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 30% 25%,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(255, 255, 255, 0.34) 28%,
    rgba(255, 255, 255, 0.12) 48%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: rotate(-22deg);
  z-index: 2;
  pointer-events: none;
}

/* 물 채우기 애니메이션 */
.liquid-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: var(--level);
  transition: height 1.15s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: height;
}
.liquid-fill.water-normal {
  background: linear-gradient(
    180deg,
    rgba(186, 230, 253, 0.82) 0%,
    rgba(125, 211, 252, 0.68) 48%,
    rgba(56, 189, 248, 0.62) 100%
  );
}
/* 100% 이상 달성시 진한 농도로 표현 */
.liquid-fill.water-over {
  background: linear-gradient(
    180deg,
    rgba(96, 199, 242, 0.92) 0%,
    rgba(14, 165, 233, 0.84) 48%,
    rgba(2, 132, 199, 0.78) 100%
  );
}

.liquid-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 950;
  color: #17324d;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  z-index: 3;
}

.status-list {
  display: grid;
  gap: 10px;
}

.info-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.info-title {
  font-weight: 900;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.info-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.badge,
.grade-chip {
  display: inline-block;
  color: white;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.grade-chip.normal {
  background: var(--normal);
}
.grade-chip.average {
  background: var(--average);
}
.grade-chip.poor {
  background: var(--poor);
}

.grade-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.table-panel {
  margin-top: 18px;
}
.table-wrap {
  height: 420px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1320px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:nth-child(-n + 3),
td:nth-child(-n + 3) {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f9ff;
  color: var(--muted);
  font-size: 12px;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover {
  color: var(--blue);
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

#section-summary,
#section-liquid,
#section-table {
  scroll-margin-top: 24px;
}

/* 반응형 레이아웃 */
@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 960px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .content-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-filter {
    justify-content: stretch;
  }
  select {
    flex: 1 1 160px;
  }
}
