:root {
  --paper: #e4ddd0;
  --sheet: #f6f3ec;
  --ink: #1c1916;
  --muted: #6a635b;
  --line: #d4cdc1;
  --stamp: #1e3f34;
  --warn: #f3e4cf;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

a { color: var(--stamp); }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: calc(16px + env(safe-area-inset-top)) 28px 8px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-family: "Times New Roman", Times, serif;
  font-size: 30px;
  line-height: 1;
}

.brand i {
  display: inline-block;
  width: 16px;
  height: 11px;
  margin-right: 8px;
  background: var(--stamp);
  vertical-align: 3px;
}

.out {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 4px 28px 10px;
  border-bottom: 1px solid var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

nav a {
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 4px;
}

nav a.on { border-bottom: 2px solid var(--stamp); }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 28px calc(72px + env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 34px;
  font-weight: 400;
}

h2 {
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead, .hint { color: var(--muted); }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  padding: 18px 20px 22px;
  margin-top: 14px;
  max-width: 100%;
}

.narrow { max-width: 420px; width: 100%; margin-left: auto; margin-right: auto; }

body.gate { min-height: 100vh; }
body.gate .top { display: none; }
body.gate main {
  min-height: 100vh;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.gate-card { margin-top: 0; text-align: center; }
.gate-card .mark { margin: 0 0 22px; }
.gate-card .mark img {
  display: block;
  width: min(100%, 280px);
  height: auto;
  margin: 0 auto;
}
.gate-card .flash { margin: 0 0 16px; text-align: center; }
.gate-card label { text-align: left; }
.gate-card h1 { margin-bottom: 8px; font-size: 32px; }
.gate-card .lead, .gate-card .hint { text-align: center; }
.gate-card .qrbox { margin: 8px auto; }
.copyline { display: grid; gap: 8px; margin: 0 0 16px; }
.copyline button { width: 100%; }
.copykey {
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.04em;
}
.gate-card .keygrid {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  justify-content: center;
  gap: 8px 14px;
  margin: 0 0 18px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
}
.gate-card form + form { margin-top: 8px; }
.gate-card button { width: 100%; }

.headrow, .actions, .downloads {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.actions, .downloads { justify-content: flex-start; margin-top: 16px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}

.stack { display: grid; gap: 12px; }

label, legend {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
}

input, select { accent-color: var(--stamp); }

input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 8px;
  background: #fff;
  border: 1px solid #c8c0b3;
  font-size: 16px;
}

textarea { min-height: 120px; resize: vertical; }

button, .downloads a {
  background: var(--stamp);
  color: #f6f3ec;
  border: 1px solid var(--stamp);
  min-height: 44px;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.ghost, .downloads a.ghost, a.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  color: var(--ink);
}

.check input { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }

.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
}

.room {
  display: grid;
  grid-template-columns: minmax(180px, 320px) 110px;
  gap: 8px;
  margin-bottom: 8px;
}

.coefs {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}


table.smeta, table.totals {
  width: 100%;
  border-collapse: collapse;
}

table.smeta th {
  padding: 6px;
  border-bottom: 1px solid var(--ink);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  font-weight: 700;
}

table.smeta td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.smeta input, table.smeta select { padding: 4px 6px; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

tr.sub td { font-weight: 700; border-bottom: 1px solid var(--ink); }

tr.gap td { background: var(--warn); }

.totals {
  width: min(340px, 100%);
  margin: 14px 0 0 auto;
}

.totals th, .totals td {
  padding: 4px 0;
  text-align: right;
  font-weight: 400;
}

.totals .grand th, .totals .grand td {
  border-top: 1px solid var(--ink);
  font-weight: 700;
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
}

.flash { margin: 0 0 12px; }
.flash.error { color: #7a2e24; }

.files { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

img, svg { max-width: 100%; }

.logo { height: 52px; width: auto; max-width: 100%; }

.price-row label {
  margin: 0;
  color: inherit;
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.price-row .cap { display: none; }

.price-table { display: grid; gap: 8px; }

.price-row {
  display: grid;
  grid-template-columns: 0.7fr 0.8fr 1.4fr 0.45fr 0.55fr 0.7fr 1fr 0.8fr;
  gap: 6px;
}

@media (max-width: 860px) {
  .grid, .checks { grid-template-columns: 1fr; }
  .coefs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room { grid-template-columns: minmax(0, 1fr) 96px; }
  .price-row {
    grid-template-columns: 1fr;
    padding: 10px;
    border: 1px solid var(--line);
    background: #fff;
  }
  .price-row .cap {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .price-row label {
    margin: 0;
    color: inherit;
    font-size: inherit;
    letter-spacing: 0;
    text-transform: none;
  }
  .top, nav, main { padding-left: 16px; padding-right: 16px; }
  .headrow { align-items: flex-start; }
  h1 { font-size: 30px; }
  .brand { font-size: 26px; }
}

@media (max-width: 760px) {
  nav a { padding-top: 10px; padding-bottom: 10px; }
  table.lines, table.register { display: block; }
  table.lines thead, table.register thead { display: none; }
  table.lines tbody, table.register tbody,
  table.lines tr, table.register tr,
  table.lines td, table.register td { display: block; width: auto; }
  table.lines tr, table.register tr {
    margin: 0 0 12px;
    padding: 8px 10px 10px;
    border: 1px solid var(--line);
    background: #fff;
  }
  table.lines td, table.register td { border: 0; padding: 6px 0; }
  table.lines td::before, table.register td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  table.lines td[data-label=""]::before,
  table.register td[data-label=""]::before { content: none; }
  table.lines td[data-label=""]:empty,
  table.register td[data-label=""]:empty { display: none; }
  table.lines tr.sub, table.register tr.sub { background: transparent; border: 0; padding-left: 0; padding-right: 0; }
  table.lines .num, table.register .num { text-align: left; }
  table.lines button, table.register button, table.register form { width: 100%; }
  .downloads, .actions { width: 100%; }
  .downloads a, .actions button { flex: 1 1 140px; }
  .sheet { padding: 14px 12px 16px; }
}

.qrbox {
  width: max-content;
  max-width: 100%;
  margin: 8px auto 16px;
  background: #fff;
  padding: 12px;
}

.qrbox img {
  display: block;
  width: auto;
  max-width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.06em;
  font-size: 16px;
}

.codes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 18px;
  letter-spacing: 0.04em;
}

@media (max-width: 520px) {
  .coefs, .room { grid-template-columns: 1fr; }
  .out { width: 100%; justify-content: space-between; }
  .codes { grid-template-columns: 1fr; }
}
