:root {
  --bg: #eef4f8;
  --surface: #ffffff;
  --surface-soft: #f6f9fc;
  --border: #d9e2ea;
  --border-strong: #b7c6d4;
  --text: #101827;
  --text-muted: #5f6f82;
  --accent-water: #0f6fde;
  --accent-dam: #0f9f8f;
  --accent-weather: #e08700;
  --warning: #f59e0b;
  --danger: #dc2626;
  --ok: #0f9f8f;
  --radius: 8px;
  --shadow: 0 10px 26px rgba(20, 37, 54, 0.08);
}

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

body {
  width: 760px;
  min-height: 540px;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1458d4;
  color: #fff;
}

.header__title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header__icon {
  font-size: 1.2rem;
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: #ffffff;
  color: #1458d4;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
  text-decoration: none;
}

.detail-btn:hover {
  background: #f0f6ff;
}

.detail-btn--map {
  min-width: 82px;
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  box-shadow: none;
}

.detail-btn--map:hover {
  background: rgba(255, 255, 255, 0.22);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.icon-btn:active {
  transform: rotate(90deg);
}

.icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "status water"
    "weather dam";
  gap: 12px;
  padding: 12px 18px 12px;
}

.panel,
.card {
  min-height: 185px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

#status-card {
  grid-area: status;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

#water-level-card {
  grid-area: water;
  border-color: #9fc5ee;
  background: linear-gradient(180deg, #ffffff 0%, #f5faff 100%);
}

#weather-card {
  grid-area: weather;
  min-height: 275px;
  border-color: #efc777;
  background: linear-gradient(180deg, #ffffff 0%, #fffaf0 100%);
}

#dam-card {
  grid-area: dam;
  display: flex;
  flex-direction: column;
  min-height: 275px;
  border-color: #8fcfc6;
  background: linear-gradient(180deg, #ffffff 0%, #f4fbfa 100%);
}

.panel__header,
.card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.panel__eyebrow,
.card__badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0;
}

.panel__eyebrow {
  background: #e6f0ff;
  color: #1458d4;
}

.card__badge--water {
  background: #e6f0ff;
  color: var(--accent-water);
}

.card__badge--dam {
  background: #def8f4;
  color: var(--accent-dam);
}

.card__badge--weather {
  background: #fff3db;
  color: var(--accent-weather);
}

.panel h2,
.card h2 {
  font-size: 0.98rem;
  font-weight: 800;
}

.card__location {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid #dfe8f0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.card__value {
  font-size: 2rem;
  font-weight: 850;
  line-height: 1.05;
  color: var(--text);
}

.card__value--loading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card__value--error {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--danger);
}

.card__unit {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.card__meta,
.panel__meta {
  min-height: 17px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 7px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.trend-pill--up {
  background: #fff1f1;
  color: var(--danger);
  border-color: #ffc7c7;
}

.trend-pill--down {
  background: #eaf5ff;
  color: var(--accent-water);
  border-color: #b9dcff;
}

.trend-pill--flat {
  background: #effaf7;
  color: var(--ok);
  border-color: #bde8df;
}

.chart {
  position: relative;
  width: 100%;
  height: 72px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: linear-gradient(180deg, #fff 0%, #f7fbff 100%);
  overflow: visible;
}

#dam-card .metric-row {
  border-color: #c8eee9;
  background: linear-gradient(180deg, #ffffff 0%, #effbf9 100%);
}

#dam-card .card__value {
  font-size: 2.18rem;
  color: #0f172a;
}

#dam-card .chart {
  height: 78px;
  background: linear-gradient(180deg, #ffffff 0%, #f0fbf8 100%);
}

.dam-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.detail-cell {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #c8eee9;
  border-radius: 8px;
  background: #ffffff;
}

.detail-cell span,
.detail-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-cell span {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.detail-cell strong {
  color: #0f766e;
  font-size: 0.76rem;
  font-weight: 850;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.chart__grid {
  stroke: #dbe6ef;
  stroke-width: 1;
}

.chart__line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__area {
  opacity: 0.15;
}

.chart__dot {
  pointer-events: none;
}

.chart__hit {
  fill: transparent;
  cursor: crosshair;
}

.chart__hit:hover {
  fill: rgba(17, 24, 39, 0.06);
}

.chart-tooltip {
  position: absolute;
  z-index: 8;
  max-width: calc(100% - 16px);
  padding: 7px 10px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translateY(2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.chart-tooltip--visible {
  opacity: 1;
  transform: translateY(0);
}

.chart__label {
  fill: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.chart__empty {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.status-item__label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-item strong {
  font-size: 0.86rem;
  text-align: right;
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 4px;
}

.weather-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 8px 6px;
  background: #ffffff;
  border: 1px solid #f1d79b;
  border-radius: 8px;
  text-align: center;
}

.weather-item__label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

.weather-item__value {
  font-size: 0.95rem;
  font-weight: 850;
}

.weather-hourly {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  height: 148px;
  margin-top: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}

.weather-hourly__label {
  display: grid;
  grid-template-rows: 19px 25px repeat(5, 14px);
  align-items: center;
  padding: 6px 5px 18px 7px;
  background: #f5f9fd;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 800;
  white-space: nowrap;
}

.weather-hourly__scroll {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  padding-bottom: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: #94a3b8 #e8eef5;
  scrollbar-width: auto;
  scrollbar-gutter: stable;
}

.weather-hourly__scroll::-webkit-scrollbar {
  height: 14px;
}

.weather-hourly__scroll::-webkit-scrollbar-track {
  background: #e8eef5;
}

.weather-hourly__scroll::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
  border: 2px solid #e8eef5;
}

.weather-hourly__col {
  display: grid;
  grid-template-rows: 19px 25px repeat(5, 14px);
  align-items: center;
  justify-items: center;
  min-width: 56px;
  min-height: 126px;
  padding: 6px 4px;
  border-right: 1px dotted #cbd5e1;
  font-size: 0.63rem;
  white-space: nowrap;
}

.weather-hourly__col:hover {
  background: #eef6ff;
}

.weather-hourly__time {
  color: #0f172a;
  font-weight: 800;
}

.weather-hourly__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 25px;
}

.weather-symbol {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 24px;
}

.weather-symbol__sun {
  position: absolute;
  left: 3px;
  top: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffc928;
  box-shadow: 0 0 0 3px rgba(255, 201, 40, 0.2), 0 0 10px rgba(255, 168, 0, 0.5);
}

.weather-symbol__cloud {
  position: absolute;
  left: 7px;
  top: 9px;
  width: 21px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef4fb, #9fb1c4);
  box-shadow: -6px 2px 0 -1px #c9d5df, 5px 1px 0 -2px #dbe5ed;
}

.weather-symbol__cloud::before,
.weather-symbol__cloud::after {
  content: "";
  position: absolute;
  bottom: 5px;
  border-radius: 50%;
  background: inherit;
}

.weather-symbol__cloud::before {
  left: 3px;
  width: 10px;
  height: 10px;
}

.weather-symbol__cloud::after {
  right: 3px;
  width: 8px;
  height: 8px;
}

.weather-symbol__cloud--small {
  display: none;
}

.weather-symbol__rain {
  display: none;
  position: absolute;
  left: 10px;
  top: 20px;
  width: 3px;
  height: 7px;
  border-radius: 999px;
  background: #1597ff;
  box-shadow: 7px 1px 0 #1597ff, 14px 0 0 #1597ff;
  transform: rotate(14deg);
}

.weather-symbol__bolt {
  display: none;
  position: absolute;
  left: 15px;
  top: 15px;
  width: 8px;
  height: 13px;
  background: #ffd12a;
  clip-path: polygon(45% 0, 100% 0, 62% 42%, 100% 42%, 25% 100%, 45% 55%, 8% 55%);
}

.weather-symbol__snow,
.weather-symbol__fog {
  display: none;
}

.weather-symbol--sun .weather-symbol__cloud,
.weather-symbol--sun .weather-symbol__cloud--small {
  display: none;
}

.weather-symbol--cloud .weather-symbol__sun,
.weather-symbol--fog .weather-symbol__sun,
.weather-symbol--rain .weather-symbol__sun,
.weather-symbol--drizzle .weather-symbol__sun,
.weather-symbol--storm .weather-symbol__sun,
.weather-symbol--snow .weather-symbol__sun {
  display: none;
}

.weather-symbol--partly .weather-symbol__cloud {
  background: linear-gradient(180deg, #f8fbff, #b8c7d6);
}

.weather-symbol--drizzle .weather-symbol__rain,
.weather-symbol--rain .weather-symbol__rain {
  display: block;
}

.weather-symbol--drizzle .weather-symbol__rain {
  opacity: 0.7;
  height: 5px;
}

.weather-symbol--storm .weather-symbol__rain,
.weather-symbol--storm .weather-symbol__bolt {
  display: block;
}

.weather-symbol--snow .weather-symbol__snow {
  display: block;
  position: absolute;
  left: 10px;
  top: 17px;
  color: #3aa7ff;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 9px 1px 0 #3aa7ff;
}

.weather-symbol--fog .weather-symbol__fog {
  display: block;
  position: absolute;
  left: 4px;
  top: 17px;
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: #9aa8b5;
  box-shadow: 0 5px 0 #c1ccd6;
}

.weather-hourly__temp {
  color: #006eb8;
  font-weight: 900;
}

.weather-hourly__cell {
  color: #111827;
  font-weight: 700;
}

.weather-hourly__empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auto-refresh {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto 64px;
  align-items: center;
  gap: 10px;
  margin: 0 18px 10px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.76rem;
}

.auto-refresh__toggle,
.auto-refresh__interval,
.auto-refresh__range {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
}

.auto-refresh__interval {
  justify-content: flex-end;
  color: var(--text-muted);
}

.auto-refresh__range {
  justify-content: flex-end;
  color: var(--text-muted);
}

.auto-refresh input[type="number"] {
  width: 70px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-weight: 800;
}

.quick-intervals {
  display: flex;
  align-items: center;
  gap: 5px;
}

.quick-intervals button {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.quick-intervals button:hover {
  color: #1458d4;
  border-color: #9fc5ee;
  background: #f4f9ff;
}

.auto-refresh select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-weight: 800;
}

.auto-refresh__save {
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: #1458d4;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.auto-refresh__save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.footer a {
  color: #1458d4;
  font-weight: 700;
  text-decoration: none;
}

.footer__links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer a:hover {
  text-decoration: underline;
}

.banner {
  margin: 0 18px 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7df;
  border: 1px solid #f3cc69;
  font-size: 0.76rem;
  line-height: 1.45;
}

.banner--hidden {
  display: none;
}

.banner a {
  color: #a65f00;
  font-weight: 800;
}

@media (max-width: 760px) {
  body {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
  }

  .header {
    position: sticky;
    z-index: 20;
    top: 0;
    padding: 10px max(10px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }

  .header h1 { font-size: 0.98rem; }
  .header__icon,
  #detail-btn { display: none; }

  .detail-btn,
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .dashboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "status"
      "water"
      "weather"
      "dam";
    padding: 10px;
  }

  .panel,
  .card {
    min-height: 210px;
  }

  #weather-card,
  #dam-card {
    min-height: 300px;
  }

  .status-grid,
  .weather-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .auto-refresh {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-inline: 10px;
  }

  .auto-refresh__interval,
  .auto-refresh__range {
    justify-content: flex-start;
  }

  .quick-intervals {
    flex-wrap: wrap;
  }

  .auto-refresh__save {
    min-height: 40px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding-inline: 12px;
  }

  .banner {
    margin-inline: 10px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "status water"
      "weather dam";
  }
}
