:root {
  color-scheme: dark;
  --bg: #0D121F;
  --card: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.68);
  --cyan: #22d3ee;
  --danger: #f07178;
  --ok: #3dd68c;
  --warn: #f0a05a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 12px 16px 28px;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.top h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.grow { flex: 1; }

.icon-btn, .btn, .btn-ghost, .text-btn {
  min-height: 44px;
  border-radius: 12px;
  border: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: var(--cyan);
  padding: 0;
}

.icon-btn.ok { color: var(--ok); }
.icon-btn.danger { color: var(--danger); }
.row .icon-btn {
  flex: 0 0 44px;
  width: 44px;
  height: auto;
  align-self: stretch;
  min-height: 44px;
}

.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: currentColor; }

.btn, .btn-ghost, .text-btn {
  padding: 12px 16px;
}

.btn {
  background: var(--cyan);
  color: #041016;
  font-weight: 700;
  width: 100%;
}

.btn:disabled, .btn-ghost:disabled, .icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.orange { background: var(--warn); }
.btn.danger { background: var(--danger); color: white; }
.btn.ok { background: var(--ok); }

.btn-ghost {
  background: var(--card);
  color: var(--text);
  width: 100%;
  border: 1px solid var(--line);
}

[hidden] { display: none !important; }

.stack { display: grid; gap: 12px; }

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

.card h2, .section-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
}

label.field { display: grid; gap: 6px; font-size: 0.92rem; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
}

textarea { min-height: 88px; resize: vertical; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: #ff8d8d; margin: 0; }

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.banner.warn {
  background: rgba(240, 160, 90, 0.16);
  border: 1px solid rgba(240, 160, 90, 0.45);
}

.banner.info {
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.list { display: grid; gap: 10px; }

.row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.row-main {
  flex: 1;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  padding: 12px 14px;
}

.row-main strong { display: block; }
.row-main span { color: var(--muted); font-size: 0.88rem; }

.mini {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 10px;
}

.mini.danger { color: var(--danger); }

.swipe { overflow: hidden; }
.swipe .behind {
  display: flex;
  gap: 8px;
}
.ident { color: var(--cyan); font-weight: 800; margin-right: 6px; }

.dock {
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(transparent, var(--bg) 28%);
}

.links { display: flex; gap: 16px; justify-content: center; }
.links a, a.link, .link-btn { color: var(--cyan); }

.link-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
}

.legal {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

.legal a { color: rgba(255, 255, 255, 0.45); font-size: 0.78rem; }

.logo {
  text-align: center;
  margin: 18px 0 8px;
}

.logo h1 { margin: 8px 0 0; font-size: 2rem; }
.mark {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
}
.mark svg { width: 40px; height: 40px; fill: currentColor; }

.pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.pair.one { grid-template-columns: 1fr auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
}
.chip.on { background: var(--cyan); color: #041016; border-color: transparent; font-weight: 700; }
.chip.photo.on { background: #1f9d55; color: white; }
.chip.pdf.on { background: #2f6fed; color: white; }

.attr {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.doc { display: grid; gap: 8px; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-actions .mini { flex: 1; }

canvas.preview {
  width: 100%;
  height: auto;
  background: white;
  border-radius: 8px;
  image-rendering: pixelated;
}

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv b { font-weight: 650; text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  background: #1c2638;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 30;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 40;
  display: none;
  pointer-events: none;
  place-items: end center;
  padding: 16px;
}

.modal.is-open {
  display: grid;
  pointer-events: auto;
}

.modal[hidden], .toast[hidden] { display: none; }

.pdf-sheet {
  width: min(480px, 100%);
  height: min(78vh, 640px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.pdf-pages {
  overflow: auto;
  min-height: 0;
  background: #e8edf5;
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.pdf-pages canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

.pdf-pages canvas + canvas {
  margin-top: 8px;
}

.dialog {
  width: min(480px, 100%);
  background: #151c2c;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  margin-bottom: env(safe-area-inset-bottom);
}

.menu {
  display: grid;
  gap: 8px;
}

#qr-reader { border-radius: 12px; overflow: hidden; }
#qr-reader video { width: 100%; border-radius: 12px; }

.hint {
  background: rgba(34, 211, 238, 0.08);
  border-radius: 12px;
  padding: 12px;
}

.hint p { margin: 0; }

.noscript {
  max-width: 480px;
  margin: 24px auto;
  padding: 0 16px;
}

.file-btn { position: relative; overflow: hidden; }
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
