:root {
  color-scheme: light;
  --paper: #f7f8fa;
  --white: #ffffff;
  --ink: #16191d;
  --muted: #5d6670;
  --quiet: #89919a;
  --line: #dfe4e8;
  --line-dark: #cbd2d8;
  --blue: #1769e0;
  --blue-dark: #0b4fae;
  --blue-pale: #eaf2ff;
  --teal: #0b8f87;
  --teal-pale: #e8f6f4;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(23, 34, 45, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.65 "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(23, 105, 224, .3); outline-offset: 2px; }
[hidden] { display: none !important; }

header {
  min-height: 64px;
  padding: 0 max(20px, calc((100% - 1100px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
header a { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-weight: 700; }
header a:last-child { color: var(--muted); font-size: 13px; }
header a:hover { color: var(--blue); }
header img { width: 32px; height: 32px; border-radius: 50%; }

main { width: min(1100px, calc(100% - 32px)); margin: 0 auto 72px; }
.hero { padding: 72px 0 38px; }
.hero.compact { padding-bottom: 24px; }
.eyebrow { margin: 0; color: var(--blue-dark); font: 700 11px/1.3 "Cascadia Mono", Consolas, monospace; letter-spacing: .12em; }
.hero h1 { max-width: 900px; margin: 18px 0; font-size: clamp(42px, 7vw, 76px); line-height: 1.04; letter-spacing: -.02em; text-wrap: balance; }
.hero.compact h1 { font-size: clamp(38px, 6vw, 64px); }
.hero em { color: var(--blue); font-style: normal; }
.hero > p:last-child { max-width: 760px; margin: 0; color: var(--muted); font-size: 18px; text-wrap: pretty; }

.panel {
  margin-bottom: 28px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0; font-size: 24px; line-height: 1.25; }
.panel h3 { margin: 18px 0 8px; font-size: 15px; }
.muted { color: var(--muted); }

.tabs { display: flex; gap: 4px; margin: -26px -26px 24px; padding: 0 18px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button {
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.tabs button:hover { color: var(--blue); }
.tabs button.active { border-color: var(--blue); color: var(--blue); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 6px; margin: 10px 0; color: #3e474f; font-size: 13px; font-weight: 650; }
input, textarea, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
}
input:hover, textarea:hover, select:hover { border-color: #aeb8c1; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); outline: 3px solid rgba(23, 105, 224, .12); }
textarea { min-height: 116px; resize: vertical; }

button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #bac5cf;
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
button:hover { border-color: var(--blue); }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .58; }
.primary { border-color: var(--blue); background: var(--blue); color: var(--white); }
.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); box-shadow: 0 8px 20px rgba(23, 105, 224, .18); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

.drop {
  margin: 20px 0 14px;
  padding: 22px;
  border: 1px dashed #aeb8c1;
  border-radius: 6px;
  background: #fbfcfd;
  text-align: center;
}
.drop.dragging { border-color: var(--blue); background: var(--blue-pale); }
.drop > * { display: block; margin: 7px auto; }
.drop input { max-width: 420px; padding: 7px; background: var(--white); }
.drop small { max-width: 660px; color: var(--muted); font-weight: 400; }
#previews { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.preview { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #eef2f5; font-size: 12px; }
.preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview button { min-height: auto; padding: 2px 5px; border: 0; background: transparent; color: var(--danger); font-size: 11px; }
.preview .thumbnail { flex: 0 0 72px; width: 72px; height: 60px; padding: 0; overflow: hidden; }
.thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview > span { min-width: 0; }
#receiptHistory, .status, .case-row, .attachment-item span { overflow-wrap: anywhere; }
.attachment-item span { min-width: 0; max-width: 100%; }
.preview-dialog img { background: #101820; }

.consent { display: flex; grid-template-columns: none; align-items: flex-start; gap: 9px; font-weight: 500; }
.consent input { width: 17px; min-height: 17px; margin-top: 3px; }
.status { min-height: 24px; margin: 12px 0 0; color: var(--muted); }
.status.error { color: var(--danger); }
.status.success { color: var(--teal); }

.payment-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr);
  gap: 32px;
  align-items: center;
  margin: 0 0 24px;
  padding: 22px;
  border: 1px solid #cce9e5;
  border-radius: 6px;
  background: var(--teal-pale);
}
.payment-panel h2 { margin: 8px 0; }
.payment-panel p:last-child { margin: 0; color: var(--muted); }
.payment-grid { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.payment-grid figure { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); text-align: center; }
.payment-grid img { width: 156px; height: 156px; object-fit: contain; }
.payment-grid figcaption { margin-top: 7px; color: var(--muted); font-size: 12px; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-heading h2 { margin-top: 7px; }
.section-heading > p { max-width: 560px; margin: 0; color: var(--muted); }
.lookup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.lookup label { margin: 0; }
.lookup-result { margin-top: 18px; }
.receipt-card { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.receipt-card h3 { margin: 0 0 6px; }
.message-list { display: grid; gap: 8px; margin-top: 14px; }
.message { padding: 10px 12px; border-radius: 5px; background: var(--blue-pale); }
.message.admin { background: var(--teal-pale); }
.message small { display: block; margin-bottom: 4px; color: var(--quiet); }
.reply-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

.admin-login { display: grid; grid-template-columns: minmax(280px, 1fr) auto; gap: 8px 14px; align-items: end; }
.admin-login label { margin: 0; }
.admin-login .status { grid-column: 1 / -1; }
.admin-layout { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.7fr); gap: 22px; align-items: start; }
.admin-list, .admin-editor { margin-bottom: 0; }
.admin-list { position: sticky; top: 86px; }
.row-list { display: grid; gap: 8px; }
.case-row { display: grid; gap: 4px; width: 100%; text-align: left; }
.case-row.active { border-color: var(--blue); background: var(--blue-pale); }
.case-row small { color: var(--muted); font-weight: 500; }
.original-feedback { padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-row, .attachment-item { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 5px; }
.attachment-row span { margin-right: auto; overflow-wrap: anywhere; }
.attachment-row button,
.attachment-item button { min-height: 34px; padding: 5px 9px; font-size: 12px; }
fieldset { margin: 22px 0; padding: 18px; border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 8px; font-weight: 750; }
.preview-dialog { width: min(92vw, 1100px); max-width: none; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #101820; color: var(--white); }
.preview-dialog::backdrop { background: rgb(4 10 16 / 78%); }
.preview-dialog img { display: block; width: 100%; max-height: 78vh; object-fit: contain; }
.preview-dialog > button { float: right; margin: 0 0 8px 8px; }
.preview-dialog .muted { clear: both; margin: 8px 0 0; }

@media (max-width: 820px) {
  .payment-panel, .admin-layout { grid-template-columns: 1fr; }
  .admin-list { position: static; }
  .payment-grid { justify-content: flex-start; }
}

@media (max-width: 700px) {
  header { min-height: 58px; }
  main { width: min(100% - 24px, 1100px); margin-bottom: 40px; }
  .hero { padding: 48px 0 28px; }
  .hero h1 { font-size: clamp(38px, 12vw, 58px); }
  .hero > p:last-child { font-size: 16px; }
  .panel { padding: 18px; margin-bottom: 18px; }
  .tabs { margin: -18px -18px 20px; padding-left: 8px; }
  .grid, .lookup, .admin-login { grid-template-columns: 1fr; }
  .wide, .admin-login .status { grid-column: auto; }
  .section-heading { display: grid; gap: 10px; align-items: start; }
  .payment-grid { flex-wrap: wrap; }
  .payment-grid img { width: min(38vw, 156px); height: min(38vw, 156px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
