:root {
  --bg: #e9edf0;
  --sheet: #ffffff;
  --ink: #3d444a;
  --label: #4a5258;
  --muted: #8b939a;
  --line: #e6eaee;
  --gold: #c6a422;
  --gold-dark: #b8961c;
  --under: #1a7356;
  --over: #b4332a;
  --hero: #eef6f8;
  --focus: #1f7a5c;
  --tier: #f4f7f9;
  --shadow: 0 10px 28px rgba(48, 64, 78, 0.06);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  min-height: 100vh;
  padding: 28px 16px 40px;
}

.sheet {
  max-width: 1180px;
  margin: 0 auto;
  background: var(--sheet);
  border: 1px solid #e3e8ec;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 32px 18px;
}

.masthead h1 {
  margin: 0;
  color: var(--gold);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.masthead {
  border-bottom: 3px solid var(--gold);
  margin-bottom: 22px;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.columns > .panel { height: 100%; }

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 14px;
}

.panel h2 {
  margin: 0 0 16px;
  color: var(--gold);
  font-size: 22px;
  font-weight: 700;
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.field label {
  color: var(--label);
  font-size: 14.5px;
  line-height: 1.35;
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid #d5d9de;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 15px;
  text-align: right;
}

input::placeholder { color: #b0b6bc; text-align: left; }

input:focus {
  outline: 2px solid var(--focus);
  border-color: var(--focus);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error {
  margin: 4px 0 0;
  color: var(--over);
  font-size: 14px;
  line-height: 1.4;
}

.hero {
  background: var(--hero);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  padding: 12px 16px 14px;
  margin-bottom: 6px;
}

.hero-label {
  margin: 0;
  color: var(--label);
  font-size: 14.5px;
}

.hero-value {
  margin: 4px 0 0;
  color: var(--gold);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.stats { margin: 0; }

.stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 2px;
  border-bottom: 1px solid #eef1f4;
}

.stats dt {
  margin: 0;
  color: var(--label);
  font-size: 14.5px;
  flex: 1;
  min-width: 0;
}

.stats dd {
  margin: 0;
  color: var(--gold);
  font-weight: 700;
  font-size: 15.5px;
  text-align: right;
  white-space: nowrap;
  flex: none;
}

.stats dd.is-under { color: var(--under); }
.stats dd.is-over { color: var(--over); }

.fit-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #e7f6ef;
  color: var(--under);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}

.tiers { margin-top: 18px; }

.tier-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.tier {
  background: var(--tier);
  border: 1px solid #e3e7eb;
  border-radius: 8px;
  min-height: 48px;
  padding: 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #3f464c;
  font-size: 14px;
  line-height: 1.3;
}

.tier.is-active {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #fff;
  font-weight: 700;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.mail {
  display: inline-block;
  background: var(--gold);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14.5px;
  border-radius: 8px;
  padding: 11px 16px;
}

.mail:hover { background: var(--gold-dark); }

.mail.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.print-note {
  margin: 18px 0 6px;
  text-align: center;
  color: #b0b6bc;
  font-size: 13px;
}

@media (max-width: 900px) {
  body {
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .sheet {
    padding: 18px 14px 16px;
    border-radius: 12px;
  }

  .masthead { margin-bottom: 16px; }
  .masthead h1 { font-size: 26px; }
  .subtitle { font-size: 14px; }

  .columns { grid-template-columns: 1fr; gap: 14px; }
  .panel { padding: 16px 14px 12px; }
  .panel h2 { font-size: 20px; margin-bottom: 12px; }

  .field {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 14px;
  }

  input {
    height: 48px;
    font-size: 16px;
    text-align: left;
    padding: 0 14px;
  }

  .hero { padding: 14px; }
  .hero-value { font-size: 24px; }

  .stats div { padding: 12px 0; gap: 12px; }
  .stats dt { font-size: 15px; }
  .stats dd { font-size: 16px; }

  .tier-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tier { min-height: 52px; font-size: 13px; padding: 8px 6px; }

  .actions { justify-content: stretch; margin-top: 14px; }
  .mail {
    width: 100%;
    text-align: center;
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  body { padding: 8px 8px calc(20px + env(safe-area-inset-bottom)); }
  .sheet { padding: 14px 12px 12px; }
  .tier { font-size: 13px; min-height: 56px; }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }

  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  html, body {
    background: #fff;
    margin: 0;
    padding: 0;
    min-height: 0;
  }

  .sheet {
    box-shadow: none;
    border: none;
    border-radius: 0;
    max-width: none;
    width: auto;
    margin: 0;
    padding: 0;
  }

  .masthead { margin-bottom: 4mm; border-bottom-width: 1.5pt; }
  .masthead h1 { font-size: 16pt; }
  .subtitle { margin: 1mm 0 2mm; font-size: 9pt; }

  .columns {
    display: grid;
    grid-template-columns: 1fr 1fr !important;
    gap: 4mm;
  }

  .columns > .panel { height: auto; }
  .panel { padding: 3mm; border-radius: 2mm; break-inside: avoid; }
  .panel h2 { font-size: 12pt; margin-bottom: 2mm; }

  .field {
    grid-template-columns: minmax(0, 1fr) 24mm !important;
    gap: 2mm;
    margin-bottom: 1.4mm;
  }

  .field label {
    font-size: 7.5pt;
    line-height: 1.15;
    white-space: nowrap;
  }

  input {
    height: 5.5mm;
    font-size: 8pt;
    text-align: right;
    padding: 0 1mm;
    border: none;
    border-bottom: 0.3pt solid #c5c9ce;
    border-radius: 0;
    background: transparent;
  }

  input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

  .hint { margin-top: 1mm; font-size: 7.5pt; }
  .error { display: none !important; }

  .hero { padding: 2mm 3mm; margin-bottom: 1mm; border-left-width: 2.5pt; }
  .hero-label { font-size: 8pt; }
  .hero-value { font-size: 13pt; margin-top: 0.5mm; }

  .stats div { padding: 1mm 0; gap: 2mm; }
  .stats dt, .stats dd { font-size: 8pt; }
  .stats dd { white-space: nowrap; }

  .tiers { margin-top: 4mm; }
  .tier-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5mm;
  }
  .tier {
    min-height: 0;
    padding: 1.5mm 1mm;
    font-size: 7.5pt;
    border-radius: 1.5mm;
  }

  .fit-note { margin-top: 2mm; padding: 1.5mm 2mm; font-size: 8pt; }
  .actions, .print-note, noscript { display: none !important; }
}
