:root {
  --paper: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #16213A;
  --muted: #5E6A80;
  --line: #D3DAE4;
  --pass: #F6C744;
  --pass-ink: #16213A;
  --alert: #D9363E;
  --ok: #1F8A5B;
  --focus: #2F6FED;
  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --text: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1726;
    --surface: #162034;
    --ink: #E6EBF3;
    --muted: #93A0B5;
    --line: #263247;
    --alert: #FF6B70;
    --ok: #4CC38A;
    --focus: #7AA5FF;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.55 var(--text);
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
img, svg { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 6vw, 52px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; font-weight: 500; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- frame */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.brand { font-family: var(--display); font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: -0.02em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 64px; }

/* corner banner: days left */
.days-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--pass);
  color: var(--pass-ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
.days-pill b { font-family: var(--display); font-size: 17px; }
.days-pill.is-low, .days-pill.is-expired { background: var(--alert); color: #fff; }
.days-pill.is-unlimited { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* ---------- controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font: 600 16px/1 var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.12); }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.secondary:hover { box-shadow: inset 0 0 0 1.5px var(--ink); filter: none; }
.btn.danger { background: var(--alert); color: #fff; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.wide { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }

label.field { display: grid; gap: 6px; font-weight: 500; font-size: 15px; }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 400 17px/1.3 var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--focus); }
textarea { min-height: 72px; resize: vertical; }

.notice {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface);
  border-left: 5px solid var(--ok);
}
.notice.warn { border-left-color: var(--alert); }
.notice.info { border-left-color: var(--pass); }
.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- landing */
.landing { display: grid; gap: 40px; padding-top: clamp(24px, 6vw, 72px); }
.landing-hero h1 { max-width: 11ch; }
.landing-hero p { margin-top: 18px; max-width: 46ch; font-size: 19px; color: var(--muted); }
.signup {
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 22px;
  background: var(--surface);
  max-width: 460px;
}
.signup .names { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts { display: grid; gap: 10px; max-width: 46ch; padding: 0; margin: 0; list-style: none; }
.facts li { padding-left: 22px; position: relative; }
.facts li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 10px; height: 10px; border-radius: 50%; background: var(--pass); box-shadow: 0 0 0 2px var(--ink) inset; }
@media (min-width: 880px) {
  .landing { grid-template-columns: 1.15fr 0.85fr; align-items: start; }
  .landing-side { padding-top: 12px; }
}

/* ---------- the pass (signature element) */
.pass {
  position: relative;
  padding: 22px 24px 22px 40px;
  border-radius: 22px;
  background: var(--pass);
  color: var(--pass-ink);
  overflow: hidden;
}
.pass::before {
  content: "";
  position: absolute;
  left: 14px; top: 18px; bottom: 18px;
  width: 8px;
  background: radial-gradient(circle, var(--paper) 3.2px, transparent 3.6px) 0 0 / 8px 16px repeat-y;
}
.pass-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; }
.pass-count { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; }
.pass-count .n { font-family: var(--display); font-weight: 700; font-size: clamp(64px, 14vw, 96px); line-height: 0.9; letter-spacing: -0.04em; }
.pass-count .w { font-family: var(--display); font-weight: 500; font-size: 20px; }
.pass-until { font-weight: 500; }
.holes { display: grid; grid-template-columns: repeat(15, 1fr); gap: 7px; margin-top: 18px; max-width: 360px; }
.holes i { aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--pass-ink); }
.holes i.on { background: var(--pass-ink); }
.pass.is-low { --pass: #FFB4A2; }
.pass.is-expired { --pass: #E3E7EE; }
@media (prefers-color-scheme: dark) {
  .pass.is-expired { --pass: #C9CFDA; }
}
.pass-more { font-size: 14px; margin-top: 8px; }

/* ---------- cabinet */
.cabinet { display: grid; gap: 28px; }
.cabinet-hello h1 { font-size: clamp(26px, 5vw, 38px); }
.cabinet-hello p { margin-top: 8px; }
@media (min-width: 960px) {
  .cabinet { grid-template-columns: 380px 1fr; align-items: start; gap: 40px; }
  .cabinet-side { position: sticky; top: 76px; }
  .cabinet-hello { grid-column: 1 / -1; }
}
section.block { display: grid; gap: 16px; }
section.block > header { display: grid; gap: 4px; }

.device {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.device-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.device-name { font-weight: 600; font-size: 18px; }
.qr-box { display: grid; justify-items: center; gap: 10px; padding: 16px; border-radius: 14px; background: #fff; color: #16213A; }
.qr-box svg { width: min(280px, 100%); height: auto; }
.add-device { display: flex; gap: 10px; flex-wrap: wrap; }
.add-device input { flex: 1 1 200px; }

.steps { counter-reset: step; display: grid; gap: 14px; padding: 0; margin: 0; list-style: none; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: start; }
.steps > li::before {
  content: counter(step);
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 16px;
}
.steps p + p { margin-top: 4px; }
.platforms { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.pay { display: grid; gap: 14px; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.price { font-family: var(--display); font-weight: 700; font-size: 28px; }
.requisites { display: grid; gap: 4px; padding: 14px; border-radius: 14px; background: var(--paper); }
.requisites .phone { font-family: var(--display); font-weight: 500; font-size: 19px; letter-spacing: 0.01em; }
.file-drop {
  display: grid;
  gap: 4px;
  place-items: center;
  text-align: center;
  padding: 22px 16px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  cursor: pointer;
}
.file-drop:hover, .file-drop:focus-within { border-color: var(--ink); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .fn { font-weight: 600; word-break: break-all; }
.history { display: grid; gap: 6px; padding: 0; margin: 0; list-style: none; font-size: 15px; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }

.save-link { display: grid; gap: 10px; }
.link-box { display: flex; gap: 8px; flex-wrap: wrap; }
.link-box code { flex: 1 1 240px; padding: 12px 14px; border-radius: 12px; background: var(--paper); font: 500 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

details.confirm summary { list-style: none; cursor: pointer; }
details.confirm summary::-webkit-details-marker { display: none; }
details.confirm[open] summary { display: none; }
details.confirm .confirm-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- welcome & errors */
.narrow { max-width: 520px; margin: clamp(24px, 8vw, 80px) auto 0; display: grid; gap: 20px; }

/* ---------- admin */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-nav a { padding: 8px 14px; border-radius: 10px; text-decoration: none; font-weight: 500; font-size: 15px; }
.admin-nav a[aria-current=page] { background: var(--ink); color: var(--paper); }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.table-wrap { overflow-x: auto; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--paper); }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.low, .tag.expired, .tag.rejected { background: color-mix(in srgb, var(--alert) 16%, transparent); color: var(--alert); }
.tag.unlimited { background: var(--pass); color: var(--pass-ink); }
.tag.blocked { background: var(--ink); color: var(--paper); }
.panel { padding: 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 14px; }
.admin-grid { display: grid; gap: 20px; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form label.field { flex: 1 1 140px; }
.search { max-width: 320px; }

@media (prefers-reduced-motion: no-preference) {
  .pass .holes i.on { animation: punch 0.5s ease-out both; animation-delay: calc(var(--i) * 18ms); }
  @keyframes punch { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}
@media (max-width: 420px) {
  body { font-size: 16px; }
  .signup .names { grid-template-columns: 1fr; }
  .holes { gap: 5px; }
}

/* grid/flex children must be allowed to shrink below their content width */
.cabinet > *, .stack > *, .cabinet-side > *, .landing > *, .admin-grid > * { min-width: 0; }
.device-top { flex-wrap: wrap; }
.cabinet-hello h1, .landing-hero h1 { overflow-wrap: anywhere; }
.cabinet-side { display: grid; gap: 20px; align-content: start; }
