:root {
  --ink: #18252b;
  --muted: #64727a;
  --line: #d8e2e7;
  --soft: #f3f7f8;
  --input: #fff6c9;
  --blue: #2364aa;
  --teal: #167c80;
  --red: #c0392b;
  --green: #2d7d46;
  --amber: #ba7b00;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #eef3f5;
}

.app-header {
  min-height: 96px;
  padding: 22px 32px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  color: white;
  background:
    linear-gradient(90deg, rgba(18, 48, 59, 0.92), rgba(22, 124, 128, 0.82)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='160' viewBox='0 0 900 160'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.22'%3E%3Cpath d='M0 120C150 80 210 125 350 84S580 18 900 56'/%3E%3Cpath d='M0 56C170 28 280 92 420 62S650 10 900 30'/%3E%3Cpath d='M80 150C170 76 320 145 480 90S710 86 840 25'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
}

.app-header p,
.section-head p {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.section-head p {
  color: var(--muted);
}

button,
select,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #9eb5c0;
}

button.primary {
  background: #f5c84c;
  border-color: #f5c84c;
  color: #1d2c31;
  font-weight: 700;
}

.sync-button {
  background: #dcefed;
  border-color: #b7d9d5;
  color: #17484a;
  font-weight: 700;
}

.header-actions,
.inline-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-sync-status {
  flex-basis: 100%;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  text-align: right;
}

.header-select {
  max-width: 160px;
}

main {
  padding: 20px 24px 32px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

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

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #f8fbfc;
  border-bottom: 0;
}

.tab.active {
  background: white;
  color: var(--teal);
  font-weight: 700;
}

.panel {
  display: none;
  background: white;
  border: 1px solid var(--line);
  border-top: 0;
  padding: 18px;
}

.panel.active {
  display: block;
}

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

.section-head.compact {
  margin-top: 6px;
  margin-bottom: 10px;
}

.split-grid,
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

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

.chart-grid.two {
  grid-template-columns: minmax(420px, 0.95fr) minmax(380px, 1.05fr);
}

.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfe;
}

.chart-title {
  font-weight: 700;
  margin-bottom: 10px;
}

canvas {
  width: 100%;
  height: 320px;
  display: block;
}

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

.compact-table {
  max-height: 330px;
}

.fixed-height {
  height: 320px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  text-align: right;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #dcecf2;
  color: #173b46;
  font-weight: 700;
  text-align: center;
}

.sort-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: #173b46;
  font-weight: 700;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.sort-header:hover {
  border: 0;
  color: var(--teal);
}

.data-table td:first-child,
.data-table th:first-child {
  text-align: left;
}

.data-table input,
.data-table select {
  width: 100%;
  min-width: 72px;
  border: 0;
  background: transparent;
  padding: 3px 2px;
  text-align: right;
  color: var(--ink);
}

.data-table input[type="text"],
.data-table select {
  text-align: left;
}

.editable {
  background: var(--input);
}

.muted-cell {
  background: var(--soft);
  color: var(--muted);
}

.danger {
  background: #ffe4df;
  color: var(--red);
  font-weight: 700;
}

.ok {
  color: var(--green);
  font-weight: 700;
}

.warn {
  color: var(--amber);
  font-weight: 700;
}

label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.app-header label {
  color: rgba(255, 255, 255, 0.86);
}

select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: white;
  color: var(--ink);
}

.header-input {
  width: 140px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
}

.header-year-input {
  width: 86px;
}

.compact-input {
  width: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
}

.data-table th .header-name-input {
  min-width: 110px;
  max-width: 180px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 4px 6px;
  background: transparent;
  color: #173b46;
  font-weight: 700;
  text-align: center;
}

.data-table th .header-name-input:focus {
  background: white;
  border-color: #8fb4c0;
  outline: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 10px 14px;
  background: #173b46;
  color: white;
  border-radius: 7px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-header,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-strip,
  .split-grid,
  .chart-grid.two {
    grid-template-columns: 1fr;
  }

  .header-sync-status {
    text-align: left;
  }
}
