:root {
  --ink: #30292a;
  --muted: #786f70;
  --line: #eadfda;
  --surface: #ffffff;
  --canvas: #fcf8f6;
  --accent: #e96657;
  --accent-dark: #c95146;
  --soft: #fff0eb;
  --success: #2f9a83;
  --danger: #c95146;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.35; }
label { display: grid; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 10px 11px; color: var(--ink); outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233, 102, 87, .13); }
.eyebrow { color: var(--accent-dark); font-size: 12px; font-weight: 750; letter-spacing: 0; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.55; }
.primary-button, .secondary-button, .quiet-button, .icon-button, .file-button { min-height: 38px; border: 1px solid transparent; border-radius: 6px; font-weight: 700; }
.primary-button { border-color: var(--accent); background: var(--accent); color: #fff; padding: 0 16px; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button, .file-button { border-color: var(--line); background: #fff; color: var(--ink); padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; }
.quiet-button { border: 0; background: transparent; color: var(--muted); padding: 0 10px; }
.icon-button { width: 38px; border-color: var(--line); background: #fff; color: var(--ink); font-size: 22px; line-height: 1; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #fff8f5; }
.login-panel { width: min(100%, 390px); display: grid; gap: 18px; padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 36px rgba(80, 54, 48, .09); }
.login-panel .muted { margin-top: -8px; }
.form-error { min-height: 18px; color: var(--danger); font-size: 13px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { display: flex; min-height: 100vh; flex-direction: column; border-right: 1px solid var(--line); background: #fff; padding: 22px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.navigation { display: grid; gap: 4px; }
.nav-item { border: 0; border-radius: 6px; background: transparent; padding: 11px 12px; text-align: left; color: var(--muted); font-size: 14px; font-weight: 700; }
.nav-item:hover { background: var(--soft); color: var(--accent-dark); }
.nav-item.active { background: var(--soft); color: var(--accent-dark); }
.logout-button { margin-top: auto; text-align: left; }
.workspace { padding: 30px; overflow: auto; }
.topbar, .section-head, .panel-heading, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar { margin-bottom: 24px; }
.view { display: none; }
.view.active-view { display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel, .record-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.stat-card { padding: 18px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 28px; }
.panel { padding: 20px; }
.split-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.summary-note { min-width: 220px; border-left: 3px solid var(--accent); padding-left: 14px; color: var(--muted); line-height: 1.6; }
.section-head { margin-bottom: 16px; }
.tabs { display: flex; gap: 7px; flex-wrap: wrap; }
.tab { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 0 12px; color: var(--muted); font-weight: 700; }
.tab.active { border-color: var(--accent); background: var(--soft); color: var(--accent-dark); }
.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.record-card { display: grid; gap: 12px; min-height: 185px; padding: 17px; }
.record-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-title h2 { overflow-wrap: anywhere; }
.status { border-radius: 99px; padding: 3px 8px; background: #edf8f5; color: var(--success); font-size: 12px; font-weight: 750; white-space: nowrap; }
.status.inactive { background: #f2eeee; color: var(--muted); }
.record-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.danger-button { min-height: 34px; border: 1px solid #f0c6c1; border-radius: 6px; background: #fff7f6; color: var(--danger); padding: 0 12px; font-weight: 700; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, .75fr); gap: 18px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .panel-heading, .form-grid > button { grid-column: 1 / -1; }
.full-width { grid-column: 1 / -1; }
.toggle-row { display: flex; align-items: center; gap: 8px; padding-top: 28px; }
.toggle-row input { width: auto; }
.donation-summary { min-height: 180px; }
.summary-amount { margin-top: 18px; font-size: 30px; font-weight: 800; }
.summary-stack { display: grid; gap: 9px; margin-top: 14px; color: var(--muted); font-size: 14px; }
.table-panel { margin-top: 18px; }
.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 750; }
td select { min-width: 118px; padding: 7px 8px; }
.user-list { display: grid; gap: 10px; margin-top: 16px; }
.user-row { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 2fr) auto; gap: 16px; align-items: start; border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.message-list { display: grid; gap: 8px; }
.message { display: flex; justify-content: space-between; gap: 12px; border-left: 3px solid var(--soft); padding-left: 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.tool-panel { min-height: 220px; }
.tool-panel h2 { margin-top: 6px; }
.tool-panel .muted { margin-top: 10px; }
.tool-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.upload-result { grid-column: 1 / -1; overflow-wrap: anywhere; color: var(--success); font-size: 13px; }
.editor-dialog { width: min(720px, calc(100vw - 28px)); border: 0; border-radius: 8px; padding: 0; box-shadow: 0 18px 60px rgba(53, 40, 38, .28); }
.editor-dialog::backdrop { background: rgba(38, 28, 26, .44); }
.editor-dialog form { display: grid; gap: 15px; padding: 22px; }
#editor-json { background: #2a2423; border-color: #2a2423; color: #f9efea; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: min(360px, calc(100vw - 40px)); transform: translateY(16px); border-radius: 6px; background: #30292a; padding: 12px 14px; color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.empty { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 8px; padding: 34px; color: var(--muted); text-align: center; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 13px; }
  .brand { padding: 0 6px 10px; }
  .navigation { grid-template-columns: repeat(5, minmax(0, 1fr)); overflow-x: auto; }
  .nav-item { padding: 9px 7px; font-size: 12px; text-align: center; white-space: nowrap; }
  .logout-button { display: none; }
  .workspace { padding: 20px 14px; }
  .stat-grid, .two-column { grid-template-columns: 1fr 1fr; }
  .split-panel { align-items: flex-start; flex-direction: column; }
  .summary-note { min-width: 0; }
}

@media (max-width: 540px) {
  .stat-grid, .two-column, .form-grid { grid-template-columns: 1fr; }
  .form-grid .panel-heading, .form-grid > button, .full-width { grid-column: auto; }
  .section-head, .topbar { align-items: flex-start; flex-direction: column; }
  .user-row { grid-template-columns: 1fr; }
}
