:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5d6972;
  --line: #d9e1e6;
  --panel: #ffffff;
  --soft: #f4f7f8;
  --brand: #0f6674;
  --brand-strong: #0a4c57;
  --accent: #b85c38;
  --good: #2f7d5c;
  --warn: #b7791f;
  font-family:
    "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef3f5;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #b8cbd1;
  background: #e7f1f3;
  color: var(--brand-strong);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.upload-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.upload-panel {
  padding: 16px;
  position: sticky;
  top: 16px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 260px;
  border: 1.5px dashed #9eb4bc;
  border-radius: 8px;
  background: #f8fbfc;
  padding: 24px;
  text-align: center;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}

.dropzone.dragging {
  border-color: var(--brand);
  background: #edf8fa;
}

.dropzone input {
  display: none;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.dropzone h2 {
  font-size: 18px;
  line-height: 1.3;
}

.dropzone p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.file-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.meta-row span {
  color: var(--muted);
}

.meta-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}

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

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-strong);
}

.ghost-button {
  color: var(--brand-strong);
  background: #fff;
  border-color: #a7bdc4;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.results-panel {
  min-width: 0;
  padding: 16px;
}

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

.kpi {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

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

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 18px 0 0;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  background: transparent;
  padding: 12px 14px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.tab.active {
  color: var(--brand-strong);
  border-bottom-color: var(--brand);
}

.tab-panel {
  display: none;
  padding-top: 16px;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 18px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.section-head input {
  width: min(360px, 100%);
  border: 1px solid #b8c7cc;
  border-radius: 7px;
  min-height: 38px;
  padding: 0 12px;
}

.chart-table-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1fr);
  gap: 16px;
}

.bar-chart {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfe;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 13px;
  background: #dfe8eb;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid #e4ebee;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #dcecf0;
  color: #10232b;
  font-size: 12px;
}

tbody tr:hover {
  background: #f7fafb;
}

.action-table table {
  min-width: 1120px;
}

.detail-table table {
  min-width: 1040px;
}

.empty-state {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    position: static;
  }

  .kpi-grid,
  .chart-table-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 1440px);
    padding: 12px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 0 0 auto;
  }
}
