:root {
  --green: #0f6b3c;
  --green-dark: #0a4d2a;
  --green-light: #e7f4ec;
  --ink: #1c211d;
  --muted: #5c6b60;
  --line: #dde5de;
  --amber: #c9a227;
  --red: #b3352c;
  --red-light: #fdeceb;
  --amber-light: #fdf6e3;
  --bg: #f4f6f4;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(28, 33, 29, .08), 0 6px 18px rgba(28, 33, 29, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
header > div:first-child, nav, .wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand b { color: var(--green); }
nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
nav .chip { background: var(--green-light); color: var(--green-dark); border-radius: 20px; padding: 4px 12px; font-size: .85rem; }

/* ---------- layout ---------- */
.main-wrap { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card .sub { color: var(--muted); margin: 0 0 16px; font-size: .92rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input, select, button { font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="file"] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.secondary { background: #eef1ee; color: var(--ink); }
.btn.secondary:hover { background: #e2e7e2; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #93291f; }
.btn.small { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
.textlink { color: var(--green); background: none; border: 0; cursor: pointer; text-decoration: underline; padding: 0; }

.err { background: var(--red-light); color: var(--red); border-radius: 10px; padding: 10px 12px; margin: 12px 0; font-size: .9rem; }
.hint { color: var(--muted); font-size: .88rem; }
.form-note { text-align: center; margin-top: 18px; font-size: .92rem; }

/* ---------- join code ---------- */
.joincode {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--green-light); border: 1px dashed var(--green);
  border-radius: 12px; padding: 14px 16px;
}
.joincode .code { font-weight: 700; letter-spacing: 3px; font-size: 1.1rem; color: var(--green-dark); }

/* ---------- sections ---------- */
.sec { margin-top: 26px; }
.sec-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-title h3 { margin: 0; font-size: 1.02rem; }
.sec-title .count { color: var(--muted); font-weight: 600; }

/* ---------- voucher cards ---------- */
.vlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.vchar {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
.vchar.k-outu { border-color: #e7c9c6; background: #fffbfa; }
.vchar.k-scad { border-color: #e9e0b8; background: #fffdf4; }
.vchar .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 1px; word-break: break-all; }
.vchar .meta { font-size: .82rem; color: var(--muted); }
.vchar .meta b { color: var(--ink); }
.vchar .tag { align-self: flex-start; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; border-radius: 8px; padding: 3px 8px; }
.tag.ok { background: var(--green-light); color: var(--green-dark); }
.tag.used { background: var(--red-light); color: var(--red); }
.tag.exp { background: var(--amber-light); color: var(--amber); }
.tag.dup { background: #e9efff; color: #3457d5; }
.card.warn { border-color: #f0c36d; background: #fffaf0; }
.card.warn .sub + .dup-line { border-top: 1px dashed var(--line); padding-top: 8px; }
.card.warn .dup-line { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .85rem; margin-top: 8px; }
.vchar .actions { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.vchar .who { font-size: .8rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.barc-wrap { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.barc-wrap .barcode { display: block; width: 100%; height: auto; }

.empty { text-align: center; color: var(--muted); padding: 22px 10px; background: #fbfcfa; border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- owner panel ---------- */
.req-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.req-item:last-child { border-bottom: 0; }
.req-item .who b { display: block; }
.req-item .who span { color: var(--muted); font-size: .85rem; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--green); border-radius: 12px; padding: 26px 16px; text-align: center;
  color: var(--green-dark); background: var(--green-light); cursor: pointer; transition: background .15s;
}
.dropzone.drag { background: #d4ecd9; }
.dropzone .big { font-size: 1.05rem; font-weight: 600; }
.filefocus { position: absolute; left: -9999px; }

/* ---------- parsed preview ---------- */
table.preview { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 10px; }
table.preview th, table.preview td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.preview th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 24, 21, .55); display: flex; align-items: center; justify-content: center;
  z-index: 40; padding: 16px;
}
.modal { background: #fff; border-radius: var(--radius); max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 6px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }

@media (max-width: 560px) {
  .main-wrap { padding: 16px 12px 60px; }
  .card { padding: 16px; }
  .vlist { grid-template-columns: 1fr; }
}