:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #3f9a3c;
  --yellow-bg: #fff8dc;
  --yellow-line: #e5b500;
  --orange-bg: #fff0e6;
  --orange-line: #f97316;
  --red-bg: #fff1f2;
  --red-line: #dc2626;
  --red-text: #b91c1c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #eef2f7;
}

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

.login-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-brand img,
.brand img {
  width: 96px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #edf0f4;
  border-radius: 6px;
}

.login-brand h1,
.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-brand p,
.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-panel label + label {
  margin-top: 14px;
}

.primary-btn,
.ghost-btn,
.file-btn,
.icon-btn,
.tab-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

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

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

.ghost-btn,
.file-btn {
  color: #344054;
  background: #fff;
  border-color: #cfd6e2;
}

.ghost-btn:hover,
.file-btn:hover {
  background: #f8fafc;
}

.login-panel .primary-btn {
  width: 100%;
  margin-top: 20px;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red-text);
  font-size: 13px;
}

.app-page {
  min-height: 100vh;
}

.topbar {
  min-height: 76px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.user-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.readonly-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #027a48;
  border: 1px solid #abefc6;
  padding: 4px 11px;
  font-weight: 700;
}

.ghost-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  background: #fff;
  color: #344054;
  padding: 7px 12px;
  text-decoration: none;
}

.ghost-link:hover {
  background: #f8fafc;
}

.main {
  padding: 22px 24px 36px;
}

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

.stats-grid.public-stats {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 84px;
}

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

.stat-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
}

.stat-card.warning {
  border-left: 4px solid var(--yellow-line);
}

.stat-card.danger {
  border-left: 4px solid var(--red-line);
}

.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  display: grid;
  gap: 12px;
}

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

.tab-btn {
  background: #f4f6f9;
  color: #344054;
  border-color: #d7dee9;
}

.tab-btn.active {
  background: #e8f0ff;
  color: var(--primary-dark);
  border-color: #9bbcff;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)) auto;
}

.filters.board-filters {
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

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

th,
td {
  border-bottom: 1px solid #e6eaf0;
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
  z-index: 1;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody tr.alert-yellow {
  background: var(--yellow-bg);
}

tbody tr.alert-orange {
  background: var(--orange-bg);
}

tbody tr.alert-danger {
  background: var(--red-bg);
}

tbody tr.alert-danger td:first-child {
  border-left: 4px solid var(--red-line);
}

tbody tr.alert-orange td:first-child {
  border-left: 4px solid var(--orange-line);
}

tbody tr.alert-yellow td:first-child {
  border-left: 4px solid var(--yellow-line);
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

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

.remaining-danger {
  color: var(--red-text);
  font-weight: 800;
}

.progress-cell {
  min-width: 118px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #e5eaf2;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-bar {
  height: 100%;
  background: var(--green);
}

.progress-bar.danger {
  background: var(--red-line);
}

.status-pill {
  display: inline-flex;
  min-width: 72px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
  color: #344054;
}

.status-pill.warning {
  background: #fff3bf;
  color: #8a5a00;
}

.status-pill.danger {
  background: #fee2e2;
  color: var(--red-text);
}

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

.row-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid #cfd6e2;
  background: #fff;
  color: #344054;
}

.row-actions .danger-btn {
  border-color: #fecaca;
  color: var(--red-text);
}

.empty-state {
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
}

.modal-panel {
  position: relative;
  width: min(820px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-panel.small-modal {
  width: min(520px, calc(100vw - 28px));
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.icon-btn {
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: #fff;
  border-color: #cfd6e2;
  font-size: 22px;
  line-height: 1;
}

.form-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.one-col {
  grid-template-columns: 1fr;
}

.wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 41px;
  align-self: end;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 80;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .stats-grid.public-stats {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

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

@media (max-width: 760px) {
  .topbar,
  .brand,
  .login-brand,
  .user-tools {
    align-items: flex-start;
  }

  .topbar {
    position: static;
    flex-direction: column;
  }

  .main {
    padding: 14px;
  }

  .stats-grid,
  .filters,
  .stats-grid.public-stats,
  .filters.board-filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .brand h1,
  .login-brand h1 {
    font-size: 20px;
  }
}
