:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #667085;
  --line: #dfe3ea;
  --brand: #116a7b;
  --brand-strong: #0d5360;
  --danger: #b42318;
  --ok: #047857;
  --warn: #b54708;
  --soft: #eef8f9;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

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

button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

table.compact-table {
  font-size: 11px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px 6px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.15;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
}

.compact-table th,
.compact-table td {
  padding: 4px 5px;
  white-space: nowrap;
}

.compact-table .badge {
  padding: 1px 5px;
  font-size: 10px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #102a2f;
  color: #e7f2f3;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.side-note {
  color: #b9ced1;
  font-size: 13px;
  line-height: 1.5;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #e7f2f3;
  padding: 10px;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.nav-children {
  gap: 4px;
  padding-left: 12px;
}

.nav-children.open {
  display: grid;
}

.nav-children.closed {
  display: none;
}

.nav-child {
  font-size: 13px;
  color: #cfe1e4;
}

.main {
  padding: 22px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

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

.panel h2 {
  font-size: 17px;
  margin: 0 0 14px;
}

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

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
}

.stat-button {
  width: 100%;
  cursor: pointer;
}

.stat-button:hover {
  border-color: var(--brand);
  background: var(--soft);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 24px;
}

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

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

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}

.chart-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-card-head h3 {
  margin: 0;
  font-size: 14px;
}

.chart-card-head strong {
  font-size: 16px;
  color: var(--ink);
}

.chart-line-wrap {
  position: relative;
  height: 110px;
}

.chart-svg {
  width: 100%;
  height: 88px;
  display: block;
}

.chart-values {
  position: absolute;
  inset: 0 0 22px 0;
  pointer-events: none;
}

.chart-value {
  position: absolute;
  transform: translate(-50%, -120%);
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.chart-labels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
}

.chart-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0;
}

.chart-dot {
  fill: #fff;
  stroke-width: 2;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  background: var(--soft);
  color: var(--brand-strong);
}

.badge.ok {
  background: #ecfdf3;
  color: var(--ok);
}

.badge.warn {
  background: #fff6e8;
  color: var(--warn);
}

.badge.danger {
  background: #fef3f2;
  color: var(--danger);
}

.message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef8f9;
  color: var(--brand-strong);
}

.message.error {
  background: #fef3f2;
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: start center;
  padding: 48px 20px;
  overflow: auto;
}

.modal {
  width: min(980px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 20px 70px rgba(15, 23, 42, 0.22);
}

.settlement-modal {
  width: min(520px, 100%);
}

.settlement-stack {
  display: grid;
  gap: 12px;
}

.settlement-head,
.settlement-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfd;
}

.settlement-head strong,
.settlement-card strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

.dashboard-card {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.dashboard-card .muted {
  font-size: 10px;
  white-space: nowrap;
}

.dashboard-card strong {
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-card > div {
  min-width: 0;
}

.pager {
  margin-top: 12px;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td button.secondary,
td .secondary,
td .ghost,
td .danger {
  padding: 3px 6px;
  font-size: 11px;
  white-space: nowrap;
}

td,
th,
td span,
td strong,
td div {
  word-break: keep-all;
}

td > div,
th > div {
  white-space: nowrap;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats,
  .chart-grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
