/* Хвоя: хвойная зелень, смола и светлая бумага. Шрифты системные: на роутере нет интернета. */
:root {
  --paper: #edf1ea;
  --surface: #ffffff;
  --ink: #14241b;
  --muted: #4c5e52;
  --line: #c9d3c8;
  --pine: #1d4632;
  --on-pine: #edf1ea;
  --needle: #7fa48a;
  --resin: #d4932a;
  --danger: #a3321f;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1913;
    --surface: #17251d;
    --ink: #e3ebe4;
    --muted: #a3b5a8;
    --line: #2c3f33;
    --pine: #21503a;
    --needle: #6f9a7c;
    --resin: #e4a642;
    --danger: #f08a73;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--text);
}
main, .top {
  max-width: 30rem;
  margin: 0 auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
main { padding-bottom: 3rem; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: 14px;
}
.top form { margin: 0; }
.brand {
  font: 700 1.25rem/1 var(--round);
  color: var(--pine);
  text-decoration: none;
}

h1 {
  font: 700 2rem/1.1 var(--round);
  letter-spacing: -0.015em;
  margin: 1.25rem 0 1rem;
  text-wrap: balance;
}
h2 {
  font: 700 1.25rem/1.2 var(--round);
  margin: 0 0 0.5rem;
}
p { margin: 0 0 1rem; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.94rem; }
a { color: var(--pine); text-underline-offset: 0.15em; }
@media (prefers-color-scheme: dark) { a, .brand { color: var(--needle); } }

/* Карта со штампами: отметка «пробивает» карту насквозь до цвета страницы. */
.card {
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.25rem 1rem;
  background: var(--pine);
  color: var(--on-pine);
  border-radius: 22px;
}
.holes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.hole {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed var(--needle);
  display: grid;
  place-items: center;
}
.hole.punched {
  border: 0;
  background: var(--paper);
  box-shadow: inset 0 3px 5px rgb(0 0 0 / 0.28);
}
.hole.gift {
  border: 2px solid var(--resin);
  color: var(--resin);
}
.hole.gift svg { width: 52%; height: 52%; }
.ready .hole.gift {
  background: var(--resin);
  color: var(--pine);
  animation: glow 1.6s ease-out 1;
}
@keyframes glow {
  from { box-shadow: 0 0 0 0 rgb(212 147 42 / 0.7); }
  to { box-shadow: 0 0 0 14px rgb(212 147 42 / 0); }
}
.status {
  font: 600 1.15rem/1.3 var(--round);
  margin: 0;
}
.ready .status { color: var(--resin); }

/* Формы */
.form { display: grid; gap: 0.4rem; margin-bottom: 1.25rem; }
label { font-weight: 600; margin-top: 0.6rem; }
.optional { font-weight: 400; color: var(--muted); }
input {
  font: inherit;
  font-size: 1.25rem;
  width: 100%;
  min-height: 54px;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}
input:focus { border-color: var(--pine); outline: none; }
input.pin {
  max-width: 11rem;
  font-size: 1.6rem;
  letter-spacing: 0.6em;
  text-align: center;
}

button, .button {
  font: 600 1.1rem/1.2 var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  border: 0;
  border-radius: 14px;
  background: var(--pine);
  color: var(--on-pine);
  text-decoration: none;
  cursor: pointer;
}
button:active, .button:active { transform: translateY(1px); }
.button.secondary {
  background: transparent;
  color: var(--pine);
  border: 2px solid var(--pine);
}
@media (prefers-color-scheme: dark) { .button.secondary { color: var(--needle); border-color: var(--needle); } }
button.quiet, a.quiet {
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 1rem;
}
:focus-visible { outline: 3px solid var(--resin); outline-offset: 2px; }
input:focus-visible { outline: 3px solid var(--resin); outline-offset: 1px; }

.error {
  color: var(--danger);
  font-weight: 600;
  margin: 0.4rem 0 0;
}
.notice {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--resin);
  background: var(--surface);
  border-radius: 0 12px 12px 0;
  font-weight: 600;
}

/* QR-код */
.qr { margin: 2rem 0; }
.qr img {
  display: block;
  width: min(240px, 70vw);
  height: auto;
  margin: 1rem 0 0.25rem;
  padding: 10px;
  background: #fff; /* QR всегда на белом, иначе сканеры путаются в тёмной теме */
  border-radius: 16px;
  image-rendering: pixelated;
}

/* История */
.history ul { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.history time { color: var(--muted); }
.history small { display: block; text-align: right; color: var(--muted); }

/* Кнопки бариста: крупные, на всю ширину, по две в ряд */
.buy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0 0 2rem;
}
.buy button {
  flex-direction: column;
  min-height: 84px;
  margin: 0;
  font: 700 1.35rem/1.15 var(--round);
}
.buy small { font: 500 0.85rem/1.2 var(--text); color: var(--resin); margin-top: 0.25rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Администрирование */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.25rem 0 0;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}
.tabs a {
  padding: 0.6rem 0.8rem;
  margin-bottom: -2px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--pine); }
@media (prefers-color-scheme: dark) { .tabs a[aria-current="page"] { border-bottom-color: var(--needle); } }

.block { margin: 2rem 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; }
.report { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.report th, .report td { padding: 0.55rem 0.3rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.report th[scope="row"], .report thead td { text-align: left; font-weight: 500; }
.report thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.report th:first-child { padding-left: 0; text-align: left; }
.report td:last-child, .report th:last-child { padding-right: 0; }
.report th[scope="row"] { color: var(--muted); }

.chart { display: block; width: 100%; height: auto; margin-top: 0.5rem; }
.chart .bar { fill: var(--pine); }
.chart .bar-free { fill: var(--resin); }
.chart .axis { stroke: var(--line); }
.chart text { font: 9px var(--text); fill: var(--muted); text-anchor: middle; }
.chart .bar-value { fill: var(--ink); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chart .bar { fill: var(--needle); } }

.staff-list { list-style: none; margin: 1rem 0; padding: 0; }
.staff-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.staff-list li.off .who { opacity: 0.6; }
.staff-list .who p { margin: 0; }
.row-actions { display: flex; gap: 0.5rem; }
.row-actions form { margin: 0; }
button.small { min-height: 44px; margin: 0; padding: 0.4rem 0.9rem; font-size: 0.95rem; }
button.secondary { background: transparent; color: var(--pine); border: 2px solid var(--pine); }
button.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
@media (prefers-color-scheme: dark) { button.secondary { color: var(--needle); border-color: var(--needle); } }

.password {
  font: 600 1.5rem/1.3 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  margin: 0.25rem 0 0.5rem;
  user-select: all;
}
.notice p:last-child { margin-bottom: 0; }
.notice .hint { font-weight: 400; }

fieldset.choices { border: 0; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
fieldset.choices legend { font-weight: 600; padding: 0; margin-bottom: 0.4rem; }
label.choice { display: flex; gap: 0.6rem; align-items: center; margin: 0; font-weight: 400; min-height: 44px; }
label.choice input { width: 1.3rem; height: 1.3rem; min-height: 0; margin: 0; accent-color: var(--pine); }

.links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 2rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.links a { min-height: 44px; display: inline-flex; align-items: center; }
