*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f2ede6;
  --surface: #faf8f4;
  --white:   #ffffff;
  --navy:    #0f1f38;
  --navy2:   #1c3252;
  --mid:     #7a8699;
  --line:    #e2dbd0;
  --green:   #1a6b47;
  --red:     #b0341e;
  --lim:     #1a5c8a;
  --pap:     #3EA7E0;
  --lar:     #1a7f72;
  --fam:     #E39204;
}

body { font-family: 'Outfit', sans-serif; background: var(--bg); color: var(--navy); min-height: 100vh; }

.w { max-width: 1360px; margin: 0 auto; padding: 44px 22px 72px; }

/* HEADER */
.overline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.overline-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lar); flex-shrink: 0; }
.overline-text { font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--mid); }
.page-title { font-family: 'Cormorant Garamond', serif; font-size: clamp(28px, 5vw, 46px); font-weight: 600; line-height: 1.1; color: var(--navy); margin-bottom: 12px; }
.page-title em { font-style: italic; color: var(--lar); }
.page-sub { font-size: 18px; color: #364153; line-height: 1.7; max-width: 100%; font-weight: 400; margin-bottom: 32px; font-family: "Mulish",sans-serif; }

/* DISTRICT TABS */
.district-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.dtab {
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 16px 14px;
  cursor: pointer;
  transition: all .2s;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.dtab::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--tab-color);
  transform: scaleX(0);
  transition: transform .22s ease;
  transform-origin: left;
}
.dtab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(15,31,56,.1); }
.dtab.active { border-color: var(--tab-color); box-shadow: 0 4px 18px rgba(15,31,56,.1); }
.dtab.active::after { transform: scaleX(1); }
.dtab-color-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tab-color); display: inline-block; margin-bottom: 8px; }
.dtab-name { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.dtab.active .dtab-name { color: var(--tab-color); }
.dtab-val { font-family: 'Mulish', serif; font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1; margin-bottom: 3px; }
.dtab-chg { font-size: 11px; font-weight: 500; }
.dtab-chg.up { color: var(--green); } .dtab-chg.down { color: var(--red); } .dtab-chg.flat { color: var(--mid); }
/* Faded style when another tab is selected */
.dtab.faded { opacity: .45; }

/* CONTROLS */
.ctrl-bar {
  background: var(--white); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
  box-shadow: 0 1px 6px rgba(15,31,56,.05);
}
.ctrl-group { display: flex; align-items: center; gap: 7px; }
.ctrl-lbl { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--mid); margin-right: 2px; }
.rbtn, .tbtn {
  padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 5px;
  background: transparent; font-family: 'Mulish', sans-serif; font-size: 14px !important;
  font-weight: 500; color: var(--mid); cursor: pointer; transition: all .15s;
}
.rbtn:hover, .tbtn:hover { border-color: var(--navy); color: var(--navy); }
.rbtn.active, .tbtn.active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; font-size: 14px; font-family: 'Mulish', sans-serif; }

/* CHART CARD */
.chart-card {
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: 0 2px 24px rgba(15,31,56,.07); margin-bottom: 18px;
}
.chart-head {
  padding: 22px 28px 16px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
}
.chart-district { font-family: 'Mulish', sans-serif; font-size: 22px; font-weight: 700; margin-bottom: 2px; transition: color .2s; }
.chart-subtitle { font-size: 16px; color: var(--mid); }
.chart-desc { font-size: 14px; color: var(--mid); font-style: italic; margin-top: 4px; font-family: 'Mulish', sans-serif; }

/* Legend inside chart head */
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; cursor: pointer; padding: 3px 0; transition: opacity .15s; }
.leg-item.faded { opacity: .3; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.chart-area { padding: 18px 28px 22px; position: relative; min-height: 380px; }
#mainChart { display: block !important; width: 100% !important; height: 340px !important; max-width: 100% !important; max-height: none !important; }
.chart-card canvas { display: block !important; height: 340px !important; max-height: none !important; }

/* KPI STRIP */
.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.kpi { padding: 16px 22px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: none; }
.kpi-lbl { font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--mid); margin-bottom: 7px; }
.kpi-val { font-family: 'Mulish', sans-serif; font-size: 26px; font-weight: 700; line-height: 1; margin-bottom: 2px; }
.kpi-val.up { color: var(--green); } .kpi-val.down { color: var(--red); } .kpi-val.flat { color: var(--mid); }
.kpi-sub { font-size: 11px; color: var(--mid); font-weight: 300; }

/* TABLE */
.table-card { background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 24px rgba(15,31,56,.07); margin-bottom: 14px; }
.table-bar { padding: 14px 22px; background: var(--navy); display: flex; justify-content: space-between; align-items: center; }
.table-bar-title { font-family: 'Mulish', sans-serif; font-size: 16px; font-weight: 700; color: #fff; }
.table-bar-sub { font-size: 11px; color: rgba(255,255,255,.45); font-weight: 300; }
.tscroll { max-height: 100%; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; background: #f0ebe1; padding: 9px 18px; text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mid); border-bottom: 1px solid var(--line); }
tbody td { padding: 9px 18px; font-size: 13px; border-bottom: 1px solid #f0ebe1; color: var(--navy); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf8f4; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.cup { text-align: right; color: var(--green); font-weight: 600; font-size: 12px; }
.cdn { text-align: right; color: var(--red);   font-weight: 600; font-size: 12px; }
.cfl { text-align: right; color: var(--mid);   font-size: 12px; }

/* CUSTOM */
.district-tabs button { background: none !important; }

/* FOOTER */
.footer { font-size: 11px; color: var(--mid); line-height: 1.75; padding-top: 16px; border-top: 1px solid var(--line); font-weight: 300; }
.footer strong { font-weight: 600; color: var(--navy2); }

@media (max-width: 680px) {
  .district-tabs { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: none; }
  .kpi:nth-child(3), .kpi:nth-child(4) { border-top: 1px solid var(--line); }
  .kpi:nth-child(4) { border-right: none; }
  #mainChart { height: 250px !important; }
  .ctrl-bar { flex-direction: column; align-items: flex-start; }
}