:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d9e2ec;
  --brand: #0f6e56;
  --brand-soft: #e6f4ef;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #dceee7 0, transparent 28%),
    linear-gradient(180deg, #eef2f5 0%, var(--bg) 40%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.layout {
  min-height: 100vh;
}

.sidebar {
  background: #102a28;
  color: #e8f2ef;
  padding: 20px 18px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.brand-sub {
  color: #9db8b2;
  font-size: 0.85rem;
  margin-bottom: 28px;
}

.nav a {
  display: block;
  padding: 8px 14px;
  border-radius: 10px;
  margin-bottom: 3px;
  color: #d7e7e2;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav .group {
  margin: 14px 8px 6px;
  font-size: 0.75rem;
  color: #7f9b95;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.content {
  margin-left: 240px;
  padding: 28px;
}

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

h1 {
  margin: 0;
  font-size: 1.8rem;
}

.hint {
  color: var(--muted);
  margin: 6px 0 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat .label { color: var(--muted); font-size: 0.9rem; }
.stat .value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 700;
}

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

.form-grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: #334155;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #c5d0db;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid #9ed0c0;
  border-color: var(--brand);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}

.btn.secondary {
  background: #e8eef3;
  color: #243b53;
}

.btn.danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.msg {
  background: var(--brand-soft);
  color: #0b4f3d;
  border: 1px solid #b7e0d1;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 0.82rem;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #ffedd5; color: #9a3412; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e5e7eb; color: #4b5563; }

.topbar-compact { margin-bottom: 12px; }
.stats-ar, .stats-compact { margin-bottom: 12px; }
.stats-compact .stat { padding: 14px; }
.stat.emphasize { border-color: #9ed0c0; background: linear-gradient(180deg, #f3faf7, #fff); }
.stat.danger-stat { border-color: #fecaca; }
.stat.warn-stat { border-color: #fde68a; }
.stat-dim {
  opacity: 0.45;
  filter: grayscale(0.25);
}
.stat-sub { margin-top: 6px; color: var(--muted); font-size: 0.85rem; }
.stat-sub a { color: var(--brand); text-decoration: underline; }

.aging-stat .value { display: none; }
.aging-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin-top: 8px;
}
.aging-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}
.aging-grid strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.filter-card { padding: 10px 12px; margin-bottom: 12px; }
.filter-compact { box-shadow: none; }
.filter-inline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}
.filter-inline select {
  width: 200px;
  flex: 0 0 200px;
  padding: 8px 10px;
}
.filter-inline input[name="q"] {
  flex: 1;
  min-width: 140px;
  padding: 8px 10px;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.table-card { padding: 12px 14px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e8eef3;
  vertical-align: middle;
  line-height: 1.25;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #fff;
}
.data-table .num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.data-table .ops,
.data-table th.ops {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}
.data-table .mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  color: #52606d;
}
.data-table .remain-cell { font-weight: 700; color: #0f4c3a; }
.data-table .muted { color: #9aa5b1; }
.data-table .empty { text-align: center; color: var(--muted); padding: 24px; }
.data-table .link-name {
  color: #0f6e56;
  font-weight: 600;
  border-bottom: 1px solid transparent;
}
.data-table .link-name:hover { border-bottom-color: #0f6e56; }

tr.age-early { background: #fffbeb; }
tr.age-30 { background: #fff7ed; }
tr.age-90 { background: #fef2f2; }
tr.age-bad { background: #fee2e2; }
tr.row-done { opacity: 0.55; }

.btn-receive {
  background: #0f6e56;
}
.more-menu {
  display: inline-block;
  position: relative;
  margin-left: 4px;
}
.more-menu > summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  color: #7b8794;
  user-select: none;
}
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary:hover { background: #eef2f6; }
.more-menu__panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 140px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.more-menu__panel form { margin: 0; }

@media (max-width: 1100px) {
  .filter-inline { flex-wrap: wrap; }
  .filter-inline select { flex: 1 1 180px; width: auto; }
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

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

.quick-links a {
  display: block;
  padding: 18px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.quick-links a strong { display: block; margin-bottom: 6px; }
.quick-links a span { color: var(--muted); font-size: 0.9rem; }

.import-fold {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}

.import-fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  user-select: none;
  background: linear-gradient(180deg, #fbfcfd 0%, #f5f7f9 100%);
}

.import-fold > summary::-webkit-details-marker { display: none; }

.import-fold__title {
  font-weight: 650;
  color: #243b53;
}

.import-fold__meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.import-fold__chev {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid #7b8a99;
  border-bottom: 2px solid #7b8a99;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.import-fold[open] > summary {
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.import-fold[open] .import-fold__chev {
  transform: rotate(225deg);
  margin-top: 4px;
}

.import-fold[open] .import-fold__meta {
  display: none;
}

.import-fold__body {
  padding: 14px 16px 16px;
}

.import-fold__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.import-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
}

.import-form input[type="file"] {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  background: #f8fafc;
}

.import-fold-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 18px;
}

@media (max-width: 980px) {
  .sidebar { position: relative; inset: auto; width: auto; height: auto; }
  .grid-2, .stats, .form-grid, .quick-links { grid-template-columns: 1fr; }
  .content { margin-left: 0; padding: 16px; }
}
