:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #fff;
  --ink: #202328;
  --muted: #5f6875;
  --line: #d9dee5;
  --accent: #b51c29;
  --accent-ink: #fff;
  --soft: #f8f9fb;
  --focus: #2375db;
  --bad-bg: #fff0f0;
  --bad-ink: #9c1724;
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); cursor: pointer; min-height: 38px; font-weight: 600; }
button:hover:not(:disabled) { background: var(--soft); border-color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.12); background: var(--accent); }
button.subtle { border-color: transparent; font-size: .85rem; padding-left: 0; color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--focus); text-underline-offset: 3px; }
h1, h2, p { margin: 0 0 .65rem; }
h1 { font-size: 1.12rem; }
h2 { font-size: 1rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar > div { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.topbar img { object-fit: contain; max-height: 42px; background: #202328; padding: 5px 8px; border-radius: 4px; }
.topbar h1 { margin: 0; }
.topbar nav { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: .85rem; }
.tag { display: inline-block; padding: .15rem .45rem; background: var(--soft); border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: .72rem; font-weight: 600; vertical-align: middle; }
main { padding: 1rem; max-width: 1560px; margin: auto; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 1rem; border-radius: 10px; min-width: 0; }
.narrow { max-width: 440px; margin: 2rem auto; }
.narrow form { display: grid; gap: .8rem; }
.narrow p { color: var(--muted); }
.notice { padding: .8rem 1rem; margin: .8rem 1rem 0; background: var(--surface); border: 1px solid var(--focus); border-radius: 7px; overflow-wrap: anywhere; }
.notice.bad { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-ink); }
.recipient-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.recipient-panel p { margin-bottom: 0; overflow-wrap: anywhere; }
.recipient-panel .inline { flex-shrink: 0; }
#conversationId { max-width: 135px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.review-column { display: grid; gap: 1rem; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .7rem; margin-bottom: .7rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.hint, label > span, small { font-size: .82rem; color: var(--muted); }
.hint { margin: .5rem 0 .8rem; }
.error-text { color: var(--bad-ink); }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .87rem; font-weight: 550; min-width: 0; }
label > span { font-weight: 400; }
input:not([type="checkbox"]), select, textarea { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .55rem .65rem; width: 100%; min-height: 39px; min-width: 0; }
input:disabled, select:disabled, textarea:disabled { background: var(--soft); color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; margin: .1rem 0; flex-shrink: 0; }
.check { flex-direction: row; align-items: flex-start; gap: .55rem; padding-top: .35rem; }
.check > span { color: var(--ink); font-size: inherit; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: .9rem 0 .2rem; margin: 1.15rem 0 0; min-width: 0; }
legend { font-weight: 700; font-size: .95rem; padding: 0 .6rem 0 0; }
.import-box { padding: .8rem; border: 1px dashed var(--muted); border-radius: 7px; background: var(--soft); }
.import-box input { background: var(--surface); }
.inline { display: flex; align-items: flex-end; gap: .5rem; }
.inline label { flex: 1; }
.benefits { display: grid; gap: .4rem; margin: .8rem 0; }
.benefits .check { padding: .4rem .2rem; border-bottom: 1px solid var(--line); }
.benefits small { margin-left: auto; text-align: right; white-space: nowrap; font-size: .7rem; }
.prices { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem .8rem; margin: .8rem 0; }
.prices dt { overflow-wrap: anywhere; }
.prices dd { margin: 0; font-variant-numeric: tabular-nums; }
.total { display: flex; justify-content: space-between; gap: .75rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .8rem 0; font-size: 1.1rem; }
.total strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
#message { resize: vertical; line-height: 1.5; font-weight: 400; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; }
.review-check { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: .75rem; margin: .5rem 0; font-weight: 500; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .75rem 0; }
.actions button { flex: 1 1 auto; }
.send-box { padding-top: .9rem; border-top: 1px solid var(--line); margin-top: .9rem; }
.send-box button { margin: 0 .3rem .5rem 0; }
#savedInfo, #sendStatus { font-size: .85rem; overflow-wrap: anywhere; }
#sendStatus { font-weight: 600; margin: .4rem 0 0; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; gap: .35rem; padding: .65rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.history li button { text-align: left; }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem; width: min(95vw, 520px); max-height: 94vh; }
dialog::backdrop { background: #0009; }
#pdfDialog { width: min(95vw, 1000px); height: 92vh; }
#pdfFrame { width: 100%; height: calc(100% - 85px); border: 1px solid var(--line); border-radius: 5px; background: #ddd; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #15181d; --surface: #1e232a; --ink: #e9edf3; --muted: #a8b1c0; --line: #3b4450; --accent: #c92736; --soft: #262d36; --focus: #83b9ff; --bad-bg: #381f26; --bad-ink: #ffadb6; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .recipient-panel { flex-direction: column; align-items: stretch; }
  .recipient-panel .inline { align-self: flex-start; }
  .review-column { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  main { padding: .6rem; }
  .panel { padding: .8rem; border-radius: 7px; }
  .topbar { padding: .6rem; align-items: flex-start; }
  .topbar > div { gap: .4rem; }
  .topbar img { width: 100px; }
  .topbar nav { gap: .5rem; }
  #userName { max-width: 130px; overflow-wrap: anywhere; }
  .fields { grid-template-columns: minmax(0, 1fr); gap: .7rem; }
  .benefits small { white-space: normal; min-width: 50px; }
  .section-head { align-items: flex-start; }
  .notice { margin: .6rem .6rem 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
