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

:root {
  --bg:          #F3EEE8;
  --bg-card:     #FDFAF7;
  --bg-detail:   #F0EAE3;
  --bg-hover:    #EBE4DC;
  --border:      #D4CBC2;
  --text:        #3C3530;
  --text-sub:    #8A807A;
  --text-faint:  #AEA6A0;
  --red:         #B57272;
  --green:       #789B8A;
  --blue:        #7B8FAA;
  --grid:        #E5DDD5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
}

h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}

.group-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 32px 0 8px;
}

/* ── City list ─────────────────────────────────────────────── */
.city-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.city-row {
  border-bottom: 1px solid var(--border);
}
.city-row:last-child { border-bottom: none; }

.city-header {
  display: flex;
  align-items: center;
  padding: 13px 18px;
  cursor: pointer;
  gap: 20px;
  user-select: none;
  transition: background 0.12s;
}
.city-header:hover          { background: var(--bg-hover); }
.city-row.open .city-header { background: var(--bg-hover); }

.city-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}
.city-name .cn {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}
.city-name .en {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-sub);
}

.city-time {
  color: var(--text-sub);
  font-size: 0.8rem;
  min-width: 50px;
  font-variant-numeric: tabular-nums;
}

.city-temp {
  font-size: 1rem;
  font-weight: 500;
  color: var(--blue);
  min-width: 60px;
  font-variant-numeric: tabular-nums;
}
.city-temp.loading { color: var(--text-faint); font-size: 0.8rem; }

/* source badge */
.source-badge {
  font-size: 0.65rem;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.poly-link {
  font-size: 0.72rem;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.poly-link:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.expand-icon {
  color: var(--text-faint);
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}
.city-row.open .expand-icon { transform: rotate(180deg); }

/* ── Expanded detail ───────────────────────────────────────── */
.city-detail {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-detail);
  padding: 16px 18px 20px;
}
.city-detail.open { display: block; }

.chart-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: var(--text-sub);
}
.legend-line {
  width: 22px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}
.l-yesterday { background: #A89898; }
.l-actual    { background: #789B8A; }
.l-forecast  { background: transparent;
               border-top: 2px dashed #789B8A;
               height: 0; }

/* ── Scroll wrapper ────────────────────────────────────────── */
.detail-scroll { overflow-x: auto; overflow-y: visible; }

.chart-wrap {
  width: 1440px;
  height: 220px;
  position: relative;
}

/* ── Data table ────────────────────────────────────────────── */
.data-table {
  width: 1440px;
  border-collapse: collapse;
  margin-top: 3px;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  text-align: center;
  padding: 5px 2px;
  font-size: 0.69rem;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

/* sticky label column */
.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  padding-left: 8px;
  width: 64px;
  min-width: 64px;
  color: var(--text-sub);
  background: var(--bg-detail);
  font-weight: 600;
  font-size: 0.67rem;
  position: sticky;
  left: 0;
  z-index: 2;
}

.data-table thead th {
  background: #EBE4DC;
  color: var(--text-sub);
  font-weight: 500;
  font-size: 0.67rem;
}
.data-table thead th:first-child { background: var(--bg-detail); }


/* ── Color classes ─────────────────────────────────────────── */
/* Use .data-table prefix to beat the .data-table td specificity */
.data-table .red          { color: var(--red);   font-weight: 600; }
.data-table .green        { color: var(--green); font-weight: 600; }
.data-table .fc           { background: #F5F0EA; color: var(--text-sub); }
.data-table .fc.red       { color: #C08888;      font-weight: 600; }
.data-table .fc.green     { color: #8EAB9C;      font-weight: 600; }
