:root {
  --ink: #17231d;
  --muted: #68736c;
  --paper: #f6f6f0;
  --card: rgba(255, 255, 251, 0.88);
  --line: #dfe2d9;
  --green: #1d6b4b;
  --green-dark: #124a34;
  --green-soft: #dcecdf;
  --amber: #a65f13;
  --amber-soft: #fff0d4;
  --red: #a43d3d;
  --shadow: 0 18px 54px rgba(31, 48, 39, 0.10);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(247, 247, 241, 0.75), rgba(247, 247, 241, 1)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(30, 70, 50, 0.035) 80px);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.ambient {
  display: none;
}
.ambient-one { background: #b9dcc1; top: -170px; right: -100px; }
.ambient-two { background: #f3d3a3; bottom: -240px; left: -160px; }

.shell { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 54px 0 80px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 30px; }
.eyebrow, .section-kicker { margin: 0 0 9px; color: var(--green); letter-spacing: .14em; font-size: 12px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(36px, 5vw, 62px); letter-spacing: -.045em; line-height: 1; }
h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
h3 { margin: 0; font-size: 16px; }
.hero-copy { max-width: 650px; margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.hero-actions, .status-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button.primary { color: white; background: var(--green); box-shadow: 0 8px 24px rgba(29, 107, 75, .18); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button.ghost { color: var(--muted); background: transparent; border-color: transparent; }
.button.danger { color: var(--red); border-color: #e8c7c7; background: #fff6f6; }
.button.small { padding: 7px 11px; border-radius: 9px; font-size: 13px; }
.button.large { padding: 13px 20px; }
.button.full { width: 100%; }
.subtle { box-shadow: none; }

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  background: #183c2d;
  color: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.status-item { display: grid; gap: 4px; }
.status-label { font-size: 12px; color: #bcd2c5; }
.status-item strong { font-size: 15px; }
.status-panel .button.secondary { background: rgba(255,255,255,.09); color: white; border-color: rgba(255,255,255,.2); }

.notice { margin-top: 14px; padding: 14px 17px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.notice.warning { color: #70420d; background: var(--amber-soft); border: 1px solid #f1d9aa; }
.notice.neutral { color: #4f5f55; background: #edf1eb; border: 1px solid #dde4da; }

.account-panel { margin-top: 14px; padding: 17px; border: 1px solid #d7e0d8; border-radius: 14px; background: rgba(255,255,251,.82); }
.account-panel-heading { display: flex; justify-content: space-between; gap: 16px; }
.account-panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.account-list { display: grid; gap: 9px; margin-top: 13px; }
.account-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.account-copy { display: grid; gap: 3px; min-width: 0; }
.account-copy strong { font-size: 13px; }
.account-copy span { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; }
.account-copy .account-error { color: var(--red); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 22px; margin-top: 22px; }
.card { background: #fffffb; border: 1px solid rgba(214, 219, 208, .86); border-radius: 22px; box-shadow: 0 12px 34px rgba(31, 48, 39, .08); }
.entry-card, .cycles-card { padding: 24px; }
.section-heading, .table-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.section-heading { margin-bottom: 24px; }
.step-badge { padding: 6px 10px; color: var(--green); background: var(--green-soft); border-radius: 999px; font-size: 12px; font-weight: 800; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); color: var(--ink); background: #fff; cursor: pointer; font-size: 19px; }

.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 7px; color: #4c5c52; font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d7ddd4;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255,255,255,.92);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: #61a081; box-shadow: 0 0 0 3px rgba(41, 120, 82, .11); }

.entry-mode-tabs { display: inline-flex; gap: 4px; margin-top: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #eef1eb; }
.entry-mode-button { border: 0; border-radius: 8px; padding: 9px 14px; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; font-weight: 800; }
.entry-mode-button.active { color: var(--green-dark); background: #fff; box-shadow: 0 3px 10px rgba(30,55,40,.09); }
.entry-mode-panel[hidden] { display: none; }

.matrix-heading { align-items: flex-end; }
.matrix-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.72); }
.matrix-table { width: 100%; min-width: 1120px; border-collapse: collapse; table-layout: fixed; }
.matrix-table th, .matrix-table td { border-right: 1px solid #e4e8e1; border-top: 1px solid #e7eae3; padding: 8px; text-align: center; }
.matrix-table thead th { border-top: 0; color: #526158; background: #edf1eb; font-size: 12px; }
.matrix-table thead th:first-child { width: 95px; }
.matrix-table thead th:nth-child(2) { width: 108px; }
.matrix-table th:last-child, .matrix-table td:last-child { border-right: 0; }
.matrix-table tbody th { color: var(--ink); background: #f8f9f5; font-size: 13px; letter-spacing: .02em; }
.matrix-table small { display: block; margin-top: 3px; color: #7d8a82; font-size: 9px; }
.matrix-table input { min-width: 86px; padding: 9px 8px; text-align: right; }
.matrix-date { color: var(--muted); white-space: nowrap; font-size: 11px; }
.matrix-table tfoot th, .matrix-table tfoot td { color: var(--green-dark); background: #eef6f0; font-size: 11px; font-weight: 800; }
.matrix-note { margin: 9px 2px 0; color: var(--muted); font-size: 11px; }
.bulk-paste-box { margin: 14px 0; padding: 14px; border: 1px solid #d8e1d9; border-radius: 13px; background: #f3f6f1; }
.bulk-paste-box > label { margin-bottom: 9px; }
.bulk-paste-box textarea { min-height: 132px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; line-height: 1.55; }
.bulk-paste-actions { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.bulk-paste-actions .form-message { flex: 1; }

.table-heading { margin: 26px 0 12px; }
.table-heading p, .paste-box p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.payout-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.65); }
.payout-table { width: 100%; min-width: 500px; border-collapse: collapse; }
.payout-table th { padding: 10px 9px; text-align: left; color: #68766d; background: #eef1eb; font-size: 11px; letter-spacing: .03em; }
.payout-table td { padding: 8px; border-top: 1px solid #e7eae3; }
.payout-table input { min-width: 90px; padding: 9px 10px; }
.payout-table .store-input { min-width: 130px; }
.remove-row { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: #9d5b5b; cursor: pointer; font-size: 18px; }
.remove-row:hover { background: #fff0f0; }

.paste-box { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #f2f3ee; }
.paste-box summary { cursor: pointer; color: #3d5145; font-size: 13px; font-weight: 800; }
.paste-box textarea { margin: 10px 0; resize: vertical; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; }
.form-message { min-height: 20px; margin: 0; color: var(--green); font-size: 13px; }
.form-message.error { color: var(--red); }

.cycle-list { display: grid; gap: 12px; }
.cycle-item { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.cycle-item:hover { border-color: #9cbbab; }
.batch-summary { padding: 15px; cursor: pointer; list-style: none; }
.batch-summary::-webkit-details-marker { display: none; }
.batch-summary::marker { content: ""; }
.batch-item[open] .batch-summary { border-bottom: 1px solid var(--line); background: #fbfcf9; }
.batch-body { padding: 15px; background: #fff; }
.batch-loading { padding: 18px; text-align: center; color: var(--muted); font-size: 12px; }
.batch-payout-list { max-height: 420px; overflow: auto; overscroll-behavior: contain; }
.batch-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.cycle-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.cycle-title { font-size: 15px; font-weight: 800; }
.cycle-date { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-chip { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-chip.open { color: #7b4a0b; background: #fff0d0; }
.status-chip.completed { color: #18593e; background: #dff0e5; }
.status-chip.archived { color: #66706a; background: #e9ece8; }
.progress-track { height: 7px; margin: 14px 0 8px; overflow: hidden; border-radius: 999px; background: #e6eae4; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2b865f, #67aa7e); }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.empty-state { padding: 36px 14px; text-align: center; color: var(--muted); border: 1px dashed #cdd4cb; border-radius: 14px; }

.dialog { width: min(720px, calc(100% - 30px)); max-height: 85vh; border: 0; border-radius: 20px; padding: 24px; color: var(--ink); box-shadow: 0 30px 90px rgba(20,35,26,.25); }
.dialog::backdrop { background: rgba(18, 30, 23, .55); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.detail-stat { padding: 12px; border-radius: 11px; background: #f0f3ee; }
.detail-stat span { display: block; color: var(--muted); font-size: 11px; }
.detail-stat strong { display: block; margin-top: 5px; font-size: 14px; }
.detail-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.detail-row p { margin: 0; }
.detail-row .sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.login-overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(242,244,237,.98); }
.login-overlay[hidden] { display: none; }
.login-card { width: min(410px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 22px; background: #fffffb; box-shadow: var(--shadow); }
.login-card > p:not(.eyebrow):not(.form-message) { margin: 12px 0 24px; color: var(--muted); line-height: 1.6; }
.login-card label { margin-bottom: 12px; }

.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; max-width: 380px; padding: 12px 15px; color: #fff; background: #173f2e; border-radius: 11px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .status-panel { grid-template-columns: repeat(3, 1fr); }
  .status-actions { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1240px); padding-top: 28px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions .button { flex: 1; }
  .status-panel { grid-template-columns: 1fr 1fr; }
  .status-item:nth-child(3) { grid-column: 1 / -1; }
  .two-columns { grid-template-columns: 1fr; }
  .entry-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .entry-mode-button { padding-inline: 9px; }
  .entry-card, .cycles-card { padding: 18px; border-radius: 17px; }
  .payout-table-wrap { overflow: visible; border: 0; background: transparent; }
  .payout-table { min-width: 0; }
  .payout-table thead { display: none; }
  .payout-table tbody { display: grid; gap: 12px; }
  .payout-table tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.72);
  }
  .payout-table td { display: grid; gap: 5px; padding: 0; border: 0; }
  .payout-table td::before { color: var(--muted); font-size: 10px; font-weight: 750; }
  .payout-table td:nth-child(1) { grid-column: 1 / -1; }
  .payout-table td:nth-child(1)::before { content: "店铺 / 站点"; }
  .payout-table td:nth-child(2)::before { content: "国家"; }
  .payout-table td:nth-child(3)::before { content: "金额"; }
  .payout-table td:nth-child(4) { position: absolute; top: 7px; right: 7px; }
  .payout-table td:nth-child(4)::before { content: none; }
  .payout-table input, .payout-table select, .payout-table .store-input { min-width: 0; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-footer .button { width: 100%; }
  .detail-summary { grid-template-columns: 1fr; }
  .account-item { align-items: flex-start; }
  .bulk-paste-actions { align-items: stretch; flex-direction: column; }
  .batch-actions { align-items: stretch; flex-direction: column; }
}
