:root {
  color-scheme: light;
  --smiled-blue: #169bd5;
  --smiled-blue-dark: #087fb5;
  --ink: #18232c;
  --muted: #64727e;
  --line: #dce5eb;
  --soft: #f4f8fb;
  --success: #167347;
  --success-soft: #eaf7f0;
  --danger: #b52a38;
  --danger-soft: #fff0f1;
  --shadow: 0 20px 55px rgba(18, 52, 70, 0.12);
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #eef4f7; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(22, 155, 213, 0.13), transparent 34rem),
    linear-gradient(180deg, #f9fcfd 0, #eef4f7 100%);
}

button, textarea { font: inherit; }

.hidden { display: none !important; }

.page-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 max(26px, env(safe-area-inset-bottom));
}

.brand { display: flex; align-items: baseline; gap: 15px; margin: 0 0 18px 3px; }
.brand-word { color: var(--smiled-blue); font-family: Georgia, "Times New Roman", serif; font-size: 42px; font-weight: 700; letter-spacing: -3px; line-height: 1; }
.brand-word span { font-size: 1.03em; }
.brand-word sup { font-family: Arial, sans-serif; font-size: 11px; letter-spacing: 0; margin-left: 2px; vertical-align: top; }
.brand-caption { color: #27343d; font-size: 13px; font-weight: 800; letter-spacing: 0.16em; }

.panel {
  border: 1px solid rgba(192, 208, 217, 0.85);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.loading-panel, .state-panel { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 14px; padding: 44px; text-align: center; }
.loading-panel p, .state-panel p { margin: 0; color: var(--muted); line-height: 1.55; }
.spinner { width: 38px; height: 38px; border: 4px solid #d8e7ee; border-top-color: var(--smiled-blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.state-icon { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 50%; font-size: 28px; font-weight: 800; }
.error-icon { color: var(--danger); background: var(--danger-soft); }
.state-panel h1 { margin: 4px 0 0; font-size: 24px; }
.support-text { margin-top: 8px !important; font-size: 14px; }
.support-text a { color: var(--smiled-blue-dark); font-weight: 700; }

.content-panel { overflow: hidden; }
.document-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 30px 34px 25px; border-top: 6px solid var(--smiled-blue); }
.eyebrow { margin: 0 0 8px; color: var(--smiled-blue-dark); font-size: 12px; font-weight: 800; letter-spacing: 0.11em; }
.document-heading h1 { margin: 0; font-size: clamp(22px, 3.5vw, 31px); letter-spacing: -0.02em; line-height: 1.18; }
.status-badge { flex: 0 0 auto; padding: 9px 13px; border: 1px solid #acd9ec; border-radius: 999px; color: #08719f; background: #edf8fc; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-badge.success { border-color: #a9d8c1; color: var(--success); background: var(--success-soft); }
.status-badge.danger { border-color: #efbdc2; color: var(--danger); background: var(--danger-soft); }
.status-badge.expired { border-color: #d5dadd; color: #58656d; background: #f2f4f5; }

.party-block { margin: 0 34px; padding: 19px 21px; border-left: 4px solid var(--smiled-blue); background: var(--soft); }
.party-block span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.party-block strong { display: block; font-size: clamp(17px, 2.6vw, 21px); line-height: 1.32; overflow-wrap: anywhere; }
.party-block small { display: block; margin-top: 5px; color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 26px 34px 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.summary-grid > div { min-width: 0; padding: 15px 16px; border-right: 1px solid var(--line); }
.summary-grid > div:last-child { border-right: 0; }
.summary-grid dt { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.summary-grid dd { margin: 0; font-size: 14px; font-weight: 750; line-height: 1.35; overflow-wrap: anywhere; }
.summary-grid .amount-cell { background: #f4fafc; }
.summary-grid .amount-cell dd { color: #0877a6; font-size: 18px; }

.explanation { margin: 25px 34px 0; color: #43515b; font-size: 15px; line-height: 1.65; }
.send-note { margin: 13px 34px 0; padding: 12px 14px; border-radius: 9px; color: #41525c; background: #f3f6f8; font-size: 14px; line-height: 1.5; }
.response-actions { display: grid; grid-template-columns: 1fr 1fr 1.18fr; gap: 12px; padding: 27px 34px 20px; }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; padding: 11px 16px; font-weight: 800; text-decoration: none; text-align: center; cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease; }
.button:focus-visible, .icon-button:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22, 155, 213, 0.28); outline-offset: 2px; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.65; transform: none; }
.button-agree { color: #fff; background: var(--success); box-shadow: 0 7px 18px rgba(22, 115, 71, 0.18); }
.button-disagree { color: #fff; background: var(--danger); box-shadow: 0 7px 18px rgba(181, 42, 56, 0.17); }
.button-document { border-color: #b9dce9; color: #076d98; background: #eef8fc; }
.button-primary { color: #fff; background: var(--smiled-blue-dark); }
.button-secondary { border-color: #ccd8de; color: #34434c; background: #fff; }

.final-state { margin: 27px 34px 19px; padding: 17px 18px; border: 1px solid #aed8c3; border-radius: 11px; color: var(--success); background: var(--success-soft); }
.final-state.danger { border-color: #efbdc2; color: var(--danger); background: var(--danger-soft); }
.final-state strong, .final-state span { display: block; }
.final-state span { margin-top: 5px; color: #45545e; font-size: 14px; line-height: 1.45; }
.security-note { display: flex; align-items: flex-start; gap: 9px; margin: 0 34px 31px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.security-mark { display: grid; flex: 0 0 20px; height: 20px; place-items: center; border-radius: 50%; color: #fff; background: var(--smiled-blue); font-weight: 900; }

footer { display: flex; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 0 4px; color: #65747d; font-size: 11px; line-height: 1.5; }
footer strong { color: #41515a; }

dialog { width: min(520px, calc(100% - 28px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 25px 80px rgba(11, 35, 48, 0.3); }
dialog::backdrop { background: rgba(19, 34, 43, 0.56); backdrop-filter: blur(2px); }
#response-form { padding: 25px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.dialog-header h2 { margin: 0; font-size: 21px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: #596770; background: #f0f4f6; font-size: 25px; cursor: pointer; }
#dialog-description { margin: 16px 0 0; color: #4e5c65; line-height: 1.55; }
.note-field { display: block; margin-top: 18px; }
.note-field span, .note-field small { display: block; }
.note-field span { margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.note-field small { margin-top: 5px; color: var(--muted); }
.note-field textarea { width: 100%; resize: vertical; border: 1px solid #bfccd3; border-radius: 9px; padding: 11px 12px; color: var(--ink); line-height: 1.45; }
.form-error { margin: 13px 0 0; color: var(--danger); font-size: 13px; font-weight: 700; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 22px; }

@media (max-width: 720px) {
  .page-shell { width: min(100% - 20px, 600px); padding-top: 18px; }
  .brand { margin-left: 3px; gap: 10px; }
  .brand-word { font-size: 35px; }
  .brand-caption { font-size: 10px; }
  .panel { border-radius: 15px; }
  .document-heading { display: block; padding: 24px 20px 19px; }
  .status-badge { display: inline-block; margin-top: 16px; }
  .party-block { margin: 0 20px; padding: 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; margin: 20px 20px 0; }
  .summary-grid > div { border-bottom: 1px solid var(--line); }
  .summary-grid > div:nth-child(2) { border-right: 0; }
  .summary-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .explanation, .send-note { margin-left: 20px; margin-right: 20px; }
  .response-actions { grid-template-columns: 1fr; padding: 22px 20px 16px; }
  .final-state { margin: 22px 20px 16px; }
  .security-note { margin: 0 20px 23px; }
  footer { display: block; text-align: center; }
  footer span { display: block; margin-top: 3px; }
}

@media (max-width: 420px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid > div { border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .summary-grid > div:last-child { border-bottom: 0 !important; }
  .dialog-actions { grid-template-columns: 1fr; }
  #confirm-button { grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

