:root {
  --ink: #102033;
  --muted: #647386;
  --paper: #f4f7fb;
  --white: #ffffff;
  --line: #d9e2ee;
  --blue: #255f99;
  --teal: #0b8f88;
  --green: #467a3d;
  --gold: #b28024;
  --red: #be3a34;
  --violet: #6954a5;
  --shadow: 0 16px 44px rgba(16, 32, 51, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Noto Sans TC", "PingFang TC", Arial, sans-serif;
  line-height: 1.55;
}

.bi-header {
  min-height: 48vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: 72px clamp(20px, 6vw, 88px) 44px;
  color: var(--white);
  background:
    linear-gradient(rgba(10, 21, 34, 0.78), rgba(10, 21, 34, 0.56)),
    url("https://images.unsplash.com/photo-1551288049-bebda4e38f71?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
}

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

.bi-header .eyebrow {
  color: #8be5df;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin-bottom: 14px;
  font-size: clamp(46px, 7vw, 86px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.18;
  letter-spacing: 0;
}

.lede {
  max-width: 860px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 21px;
}

.header-actions {
  display: grid;
  gap: 10px;
}

button,
.header-actions a {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

button:hover,
.header-actions a:hover {
  border-color: var(--teal);
  color: var(--teal);
}

main {
  padding: 26px clamp(16px, 5vw, 72px) 72px;
}

.control-band,
.status-strip,
.panel,
.sync-panel {
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px;
  border-left: 6px solid var(--teal);
}

.sync-panel[hidden] {
  display: none;
}

.sync-panel h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

.sync-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sync-actions a {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  display: inline-grid;
  place-items: center;
}

.sync-actions a:hover {
  border-color: var(--teal);
  color: var(--teal);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

select,
input[type="file"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

input[type="file"] {
  padding: 9px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 16px;
  color: var(--muted);
  font-weight: 800;
}

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

.kpi {
  min-height: 132px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
}

.kpi strong {
  font-size: 34px;
  line-height: 1;
}

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

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  margin-bottom: 16px;
}

.secondary {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
}

.panel {
  padding: 22px;
}

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

.chart-stage {
  min-height: 430px;
  display: grid;
  align-items: center;
}

.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 72px;
  gap: 12px;
  align-items: center;
  margin: 13px 0;
}

.bar-label {
  color: var(--muted);
  font-weight: 900;
}

.bar-track {
  height: 28px;
  background: #e3ebf4;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.line-svg,
.donut-svg {
  width: 100%;
  min-height: 390px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.heat-cell {
  min-height: 112px;
  padding: 14px;
  color: var(--white);
  display: grid;
  align-content: space-between;
}

.heat-cell strong {
  font-size: 20px;
}

.heat-cell span {
  font-size: 13px;
  font-weight: 900;
}

.decision-output {
  display: grid;
  gap: 12px;
}

.decision {
  padding: 15px;
  background: var(--paper);
  border-left: 5px solid var(--teal);
}

.decision strong {
  display: block;
  margin-bottom: 6px;
}

.table-wrap {
  overflow: auto;
  max-height: 430px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: var(--white);
}

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

th {
  position: sticky;
  top: 0;
  background: #edf3f8;
  color: var(--ink);
  z-index: 1;
}

.row-count {
  color: var(--muted);
  font-weight: 900;
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.schema-grid span {
  padding: 8px 10px;
  background: var(--paper);
  color: var(--muted);
  font-weight: 900;
}

.schema-note {
  margin-top: 18px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .bi-header,
  .dashboard-layout,
  .secondary,
  .sync-panel {
    grid-template-columns: 1fr;
  }

  .control-band,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .control-band,
  .kpi-grid,
  .heatmap,
  .schema-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .status-strip {
    display: grid;
  }
}

@media print {
  .header-actions,
  .control-band,
  .status-strip,
  #exportCsv {
    display: none;
  }

  body {
    background: var(--white);
  }

  .panel,
  .kpi {
    box-shadow: none;
  }
}
