:root {
  --fund-primary: #1677ff;
  --fund-primary-hover: #4096ff;
  --fund-text: rgba(0, 0, 0, 0.88);
  --fund-text-secondary: rgba(0, 0, 0, 0.65);
  --fund-text-muted: rgba(0, 0, 0, 0.45);
  --fund-border: #d9d9d9;
  --fund-border-light: #f0f0f0;
  --fund-fill: #fafafa;
  --fund-page: #f5f5f5;
  --fund-success: #52c41a;
  --fund-success-bg: #f6ffed;
  --fund-success-border: #b7eb8f;
  --fund-danger: #ff4d4f;
  --fund-cycle: #1677ff;
  --fund-term: #52c41a;
  --fund-grace: #ff4d4f;
  --fund-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  min-height: 100%;
  background: var(--fund-page);
  color: var(--fund-text);
  font-family: var(--fund-font);
  font-size: 14px;
  line-height: 1.5714285714;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* Prototype chrome */
.proto-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--fund-border-light);
}
.proto-bar-label {
  color: var(--fund-text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.proto-states {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.proto-chip {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--fund-border);
  border-radius: 6px;
  background: #fff;
  color: var(--fund-text);
  cursor: pointer;
}
.proto-chip:hover { border-color: var(--fund-primary-hover); color: var(--fund-primary); }
.proto-chip.is-active {
  border-color: var(--fund-primary);
  background: #e6f4ff;
  color: var(--fund-primary);
  font-weight: 500;
}
.proto-note {
  margin-left: auto;
  color: var(--fund-text-muted);
  font-size: 12px;
}
.proto-version {
  flex: none;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--fund-border-light);
  border-radius: 4px;
  color: var(--fund-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* FUND shell */
.fund-shell {
  min-height: calc(100vh - 45px);
  background: var(--fund-page);
}
.fund-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--fund-border-light);
}
.fund-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.fund-brand span { color: var(--fund-primary); }
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fund-text-muted);
  font-size: 14px;
}
.crumb b { color: var(--fund-text); font-weight: 500; }
.fund-utils {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--fund-text-secondary);
}
.fund-body { padding: 16px 24px 32px; }
.page-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 32px;
  border-bottom: 1px solid var(--fund-border-light);
  margin-bottom: 16px;
}
.tab {
  position: relative;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--fund-text);
  cursor: pointer;
}
.tab:hover { color: var(--fund-primary); }
.tab.is-active {
  color: var(--fund-primary);
  font-weight: 500;
}
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--fund-primary);
}

.panel {
  background: #fff;
  border-radius: 8px;
  padding: 16px 16px 8px;
  margin-bottom: 16px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}
.filter-item label {
  color: var(--fund-text-secondary);
  font-size: 13px;
}
.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.table-wrap {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}
table.data th {
  background: var(--fund-fill);
  font-weight: 500;
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--fund-border-light);
  white-space: nowrap;
}
table.data td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--fund-border-light);
  color: var(--fund-text);
}
.status-ok {
  display: inline-flex;
  padding: 0 8px;
  height: 22px;
  align-items: center;
  border-radius: 4px;
  background: var(--fund-success-bg);
  border: 1px solid var(--fund-success-border);
  color: var(--fund-success);
  font-size: 12px;
}
.link-btn {
  border: 0;
  background: none;
  color: var(--fund-primary);
  padding: 0;
  cursor: pointer;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 0 0;
  color: var(--fund-text-muted);
  font-size: 13px;
}
.pager-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 64px 16px;
  color: var(--fund-text-muted);
}
.pager-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--fund-border);
  border-radius: 6px;
  background: #fff;
  color: var(--fund-text-muted);
}
.pager-btn:disabled { opacity: 0.45; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 15px;
  border-radius: 6px;
  border: 1px solid var(--fund-border);
  background: #fff;
  color: var(--fund-text);
  cursor: pointer;
  transition: all .2s;
}
.btn:hover { border-color: var(--fund-primary-hover); color: var(--fund-primary); }
.btn-primary {
  background: var(--fund-primary);
  border-color: var(--fund-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--fund-primary-hover); border-color: var(--fund-primary-hover); color: #fff; }
.btn-file { color: var(--fund-primary); border-color: var(--fund-primary); }

/* Controls */
.control, select.control {
  width: 100%;
  height: 32px;
  padding: 4px 11px;
  border: 1px solid var(--fund-border);
  border-radius: 6px;
  background: #fff;
  color: var(--fund-text);
  outline: none;
}
select.control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2300000080' d='M1.2 1.2L6 6l4.8-4.8'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.control::placeholder, textarea.control::placeholder { color: #bfbfbf; }
.control:hover, select.control:hover { border-color: var(--fund-primary-hover); }
.control:focus, select.control:focus, textarea.control:focus {
  border-color: var(--fund-primary);
  box-shadow: 0 0 0 2px rgba(5, 145, 255, 0.1);
}
.control.is-error { border-color: var(--fund-danger); }
.control:disabled { background: var(--fund-fill); color: var(--fund-text-muted); }
textarea.control {
  height: auto;
  min-height: 76px;
  padding: 8px 11px;
  resize: vertical;
}
.affix {
  display: flex;
  align-items: center;
}
.affix .control { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.affix-addon {
  height: 32px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  border: 1px solid var(--fund-border);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: var(--fund-fill);
  color: var(--fund-text-secondary);
}
.desc {
  display: grid;
  grid-template-columns: 120px 1fr 120px 1fr;
  border: 1px solid var(--fund-border-light);
  border-radius: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}
.desc-item {
  display: contents;
}
.desc dt {
  background: var(--fund-fill);
  color: var(--fund-text-secondary);
  padding: 10px 12px;
  border-bottom: 1px solid var(--fund-border-light);
  border-right: 1px solid var(--fund-border-light);
}
.desc dd {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--fund-border-light);
  border-right: 1px solid var(--fund-border-light);
}
.desc dt:nth-of-type(even),
.desc dd:nth-of-type(even) { border-right: 0; }
.desc dt:nth-last-of-type(-n+2),
.desc dd:nth-last-of-type(-n+2) { border-bottom: 0; }
.hint-text { margin-top: 4px; color: var(--fund-text-muted); font-size: 12px; }

/* Modal */
.mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  overflow: auto;
}
.modal {
  width: 640px;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 72px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12);
}
.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--fund-border-light);
  font-size: 16px;
  font-weight: 600;
  flex: none;
}
.icon-btn {
  width: 22px;
  height: 22px;
  border: 0;
  background: none;
  color: var(--fund-text-muted);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { color: var(--fund-text); }
.modal-bd {
  padding: 20px 24px 8px;
  overflow: auto;
  flex: 1;
}
.modal-ft {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--fund-border-light);
  flex: none;
}

.section-title {
  margin: 8px 0 16px;
  font-size: 16px;
  font-weight: 600;
}
.form-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.form-label { color: var(--fund-text); }
.req::before {
  content: "*";
  color: var(--fund-danger);
  margin-right: 4px;
}
.merchant-card {
  background: var(--fund-fill);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: grid;
  gap: 8px;
}
.merchant-row {
  display: flex;
  gap: 24px;
}
.merchant-row span { color: var(--fund-text-muted); }
.merchant-row b { font-weight: 400; color: var(--fund-text); }
.subhead {
  margin: 0 0 12px;
  color: var(--fund-text-secondary);
  font-weight: 500;
}
.inline-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.radio-row {
  display: flex;
  gap: 24px;
  height: 32px;
  align-items: center;
}
.radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.radio input { accent-color: var(--fund-primary); }
.char-count {
  text-align: right;
  color: var(--fund-text-muted);
  font-size: 12px;
  margin-top: -8px;
  margin-bottom: 16px;
}
.file-help { color: var(--fund-text-muted); font-size: 12px; margin-top: 8px; }
.month-end-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.month-end-row .control { flex: 1; }
.last-day-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--fund-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.last-day-btn.is-on {
  border-color: var(--fund-primary);
  color: var(--fund-primary);
  background: #e6f4ff;
}

/* Preview */
.preview {
  margin: 4px 0 20px;
  padding: 12px 16px 16px;
  background: var(--fund-fill);
  border: 1px solid var(--fund-border-light);
  border-radius: 6px;
}
.preview-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-weight: 500;
}
.preview-hd .info {
  width: 14px;
  height: 14px;
  color: var(--fund-text-muted);
}
.preview-empty { color: var(--fund-text-muted); font-size: 13px; }
.preview-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 12px;
}
.fact-label {
  display: block;
  color: var(--fund-text-muted);
  font-size: 12px;
  margin-bottom: 2px;
}
.fact-value {
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.fact-value.due { color: var(--fund-primary); }
.preview-rule {
  padding: 8px 10px;
  background: #fff;
  border-radius: 4px;
  color: var(--fund-text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}
.timeline {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8e8e8;
}
.timeline span { display: block; height: 100%; }
.tl-cycle { background: var(--fund-cycle); }
.tl-term { background: var(--fund-term); }
.tl-grace { background: var(--fund-grace); }
.timeline-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fund-text-secondary);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-cycle { background: var(--fund-cycle); }
.dot-term { background: var(--fund-term); }
.dot-grace { background: var(--fund-grace); }

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .preview-facts, .inline-2 { grid-template-columns: 1fr; }
  .proto-note { display: none; }
}
