:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f9faf9;
  --text: #18201f;
  --muted: #687572;
  --line: #d9e0de;
  --line-strong: #b9c7c3;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #dff4f1;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --green: #15803d;
  --green-soft: #e7f6ec;
  --amber: #b45309;
  --amber-soft: #fff4dd;
  --red: #b42318;
  --red-soft: #ffe8e5;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
  --radius: 8px;
  --sidebar: 232px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}

a {
  color: var(--accent);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(245, 247, 248, 0) 44%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0;
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fbfcfc;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}

.brand {
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-title {
  font-size: 17px;
  font-weight: 760;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

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

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #33413e;
  background: transparent;
  text-align: left;
}

.nav button:hover {
  background: var(--surface-soft);
}

.nav button.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 720;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-title {
  min-width: 0;
}

.topbar-title strong {
  display: block;
  font-size: 15px;
}

.topbar-title span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 22px;
}

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

.page-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.section {
  margin-top: 16px;
}

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

.panel + .panel {
  margin-top: 16px;
}

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

.panel-title h3 {
  margin: 0;
  font-size: 16px;
}

.panel-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  min-height: 92px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.metric .label {
  color: var(--muted);
  font-size: 12px;
}

.metric .value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 760;
}

.metric .hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--line-strong);
}

.btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.danger {
  color: var(--red);
  border-color: #f2b8b2;
  background: var(--red-soft);
}

.btn.ghost {
  background: transparent;
}

.btn.compact {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge.neutral {
  color: #475451;
  background: #eef2f1;
}

.badge.info {
  color: #1d4ed8;
  background: var(--blue-soft);
}

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

.badge.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.danger {
  color: var(--red);
  background: var(--red-soft);
}

.notice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.notice.warning {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.notice.danger {
  border-left-color: var(--red);
  background: #fff7f6;
}

.notice.success {
  border-left-color: var(--green);
  background: #f3fbf6;
}

.notice strong {
  display: block;
  margin-bottom: 3px;
}

.notice p {
  margin: 0;
  color: var(--muted);
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #40504d;
  font-size: 12px;
  font-weight: 760;
}

tbody tr:hover {
  background: #fbfdfc;
}

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

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

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.field {
  min-width: 0;
}

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

.step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--muted);
}

.step.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 760;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 20, 20, 0.22);
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: 520px;
  max-width: 96vw;
  height: 100vh;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.drawer-head h3 {
  margin: 0;
  font-size: 18px;
}

.allocation-row {
  display: grid;
  grid-template-columns: 1fr 1fr 90px 92px 40px;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.progress {
  height: 9px;
  overflow: hidden;
  background: #e7ecea;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.progress.over span {
  background: var(--red);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(10, 20, 20, 0.28);
  padding: 24px;
}

.modal {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal.large {
  width: min(1100px, 98vw);
}

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

.bar-row {
  display: grid;
  grid-template-columns: 126px minmax(180px, 1fr) 110px;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

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

.bar {
  height: 100%;
  min-width: 2px;
  background: var(--accent);
}

.bar.alt {
  background: var(--blue);
}

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

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

.quick-actions .btn {
  min-height: 48px;
  justify-content: flex-start;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.status-item:last-child {
  border-bottom: 0;
}

.kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.report-frame {
  width: 100%;
  height: 620px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

@media (max-width: 1280px) {
  body {
    min-width: 980px;
  }

  .filters {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .grid.cols-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media print {
  body {
    min-width: 0;
    background: #fff;
  }

  .sidebar,
  .topbar,
  .page-head,
  .btn,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel,
  .metric,
  .table-wrap {
    break-inside: avoid;
    border-color: #cfd8d5;
  }
}
