:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #637083;
  --line: #d8dee8;
  --blue: #1f5eff;
  --blue-dark: #1747bd;
  --green: #168a4a;
  --red: #c2413b;
  --soft-blue: #edf3ff;
  --soft-green: #eaf7ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

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

button.primary:hover {
  background: var(--blue-dark);
}

button.ghost {
  background: transparent;
}

button.danger {
  border-color: #f0c2bf;
  color: var(--red);
}

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

textarea {
  min-height: 82px;
  resize: vertical;
}

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

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 16px 50px rgba(21, 31, 45, 0.08);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

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

.sidebar {
  background: #17202d;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand strong {
  font-size: 17px;
}

.brand span,
.account small {
  color: rgba(255, 255, 255, 0.68);
}

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

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
}

.nav button.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.account {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

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

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

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

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric strong {
  font-size: 22px;
}

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

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

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

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4fa;
  color: #334155;
  font-weight: 700;
}

tr:hover td {
  background: #fafcff;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--soft-blue);
  color: var(--blue-dark);
  white-space: nowrap;
}

.pill.green {
  background: var(--soft-green);
  color: var(--green);
}

.detail {
  display: grid;
  gap: 12px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.detail-section p,
.detail-section li {
  line-height: 1.6;
}

.detail-section ul {
  margin: 0;
  padding-left: 18px;
}

.meta-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.meta-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.breakdown-wrap {
  max-height: 680px;
}

.breakdown-table {
  min-width: 720px;
  table-layout: fixed;
}

.breakdown-table th {
  width: 190px;
}

.breakdown-table td {
  white-space: normal;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.contact-sheet {
  margin: 12px 0 0;
}

.contact-sheet img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
}

.message {
  min-height: 22px;
  color: var(--muted);
}

.message.error {
  color: var(--red);
}

.message.ok {
  color: var(--green);
}

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

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .grid,
  .admin-grid,
  .metrics {
    grid-template-columns: 1fr;
  }
}
