:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #647086;
  --line: #dce2ea;
  --accent: #176b5b;
  --accent-strong: #0c4d41;
  --warn-bg: #fff7db;
  --warn-text: #6e5400;
  --shadow: 0 14px 34px rgba(20, 34, 61, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

button {
  height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  height: 32px;
  padding: 0 12px;
  background: #eef3f5;
  color: var(--accent-strong);
}

.secondary-button:hover {
  background: #dce8e6;
}

.query-panel {
  display: grid;
  grid-template-columns: 150px 150px minmax(270px, 1fr) minmax(220px, 1fr) minmax(150px, 0.8fr) 96px;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  background: #fff;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 107, 91, 0.14);
}

.date-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.project-field {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.project-field legend {
  grid-column: 1 / -1;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.project-actions {
  display: flex;
  align-items: start;
  gap: 8px;
}

.project-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  min-width: 0;
}

.project-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.project-option input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
}

.project-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.project-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #f8fafb;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.project-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
  line-height: 1.5;
  white-space: pre-line;
}

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

.summary-grid article {
  min-height: 88px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.summary-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  letter-spacing: 0;
}

.summary-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.table-section {
  margin-top: 18px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.section-title span {
  max-width: 640px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #eef3f5;
  color: #344054;
  font-weight: 800;
}

td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.project-group-row td {
  padding: 10px 12px;
  background: #f2f7f5;
  color: var(--accent-strong);
  font-weight: 800;
}

.project-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.project-group-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.project-group-item .group-indent {
  width: 48px;
  background: #fbfcfd;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .toolbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title span {
    text-align: left;
  }

  .query-panel,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .project-field {
    grid-template-columns: 1fr;
  }
}
