:root {
  --navy: #14204a;
  --navy-deep: #0c1533;
  --green: #1b8a3e;
  --green-deep: #136b2f;
  --paper: #f2f4f8;
  --card: #ffffff;
  --line: #d3d9e4;
  --muted: #586276;
  --ink: #14204a;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #9a4a07;
  --amber-soft: #fff4e5;
  --green-soft: #e7f5ec;
  --radius-s: 8px;
  --radius-m: 14px;
  --font: 'Atkinson Hyperlegible', 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1122;
    --card: #141c33;
    --line: #2b3657;
    --muted: #a7b0c4;
    --ink: #eef1f8;
    --red-soft: #3a1714;
    --amber-soft: #3a2710;
    --green-soft: #12301f;
    --red: #ff8a80;
    --amber: #ffb866;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .75em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

/* ---------- Gift-wrap header: navy paper, green ribbon, bow ---------- */
.wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  color: #fff;
  background-color: var(--navy);
  background-image:
    radial-gradient(circle at 12% 30%, rgba(255,255,255,.10) 0 2px, transparent 3px),
    radial-gradient(circle at 38% 75%, rgba(255,255,255,.08) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 64% 22%, rgba(255,255,255,.09) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 68%, rgba(255,255,255,.07) 0 1.5px, transparent 2.5px);
  background-size: 140px 70px;
  border-bottom: 6px solid var(--green);
  padding-top: env(safe-area-inset-top, 0px);
}
.wrap::before {           /* vertical ribbon */
  content: '';
  position: absolute;
  top: 0; bottom: -6px;
  right: 56px;
  width: 14px;
  background: var(--green);
}
.wrap::after {            /* the bow */
  content: '';
  position: absolute;
  bottom: -14px;
  right: 49px;
  width: 28px;
  height: 18px;
  background:
    radial-gradient(ellipse at 25% 50%, var(--green-deep) 0 45%, transparent 47%),
    radial-gradient(ellipse at 75% 50%, var(--green-deep) 0 45%, transparent 47%);
}
.wrap-inner {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 88px 14px 16px;
}
.wrap-title { flex: 1; min-width: 0; }
.wrap-title h1 { font-size: 1.2rem; margin: 0; }
.who { margin: 0; font-size: .85rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { font-size: 1.5rem; }
.icon-btn, .link-btn {
  background: none; border: 0; color: #fff; cursor: pointer; padding: 8px; min-height: 44px;
}
.icon-btn { font-size: 2rem; line-height: 1; padding: 0 8px; }
.link-btn { text-decoration: underline; font-size: .9rem; }

/* ---------- Page ---------- */
.page { max-width: 600px; margin: 0 auto; padding: 22px 16px 48px; }
.page.wide { max-width: 960px; }
.cheer {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 4px 0 18px;
}
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px;
  margin-bottom: 14px;
}
.card.flagged { border: 2px solid var(--amber); }
.card h3 { margin-bottom: .25em; }
.card > h3 { margin-top: 22px; }
.card > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* ---------- Status ---------- */
.status {
  display: inline-block;
  font-size: .82rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.status.go { background: var(--green-soft); color: var(--green); border-color: transparent; }
.status.wait { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.status.stop { background: var(--red-soft); color: var(--red); border-color: transparent; }

.notice { border-radius: var(--radius-s); padding: 12px 14px; margin-bottom: 14px; }
.notice.info { background: var(--green-soft); }
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.error { background: var(--red-soft); color: var(--red); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--card);
}
textarea { min-height: 90px; resize: vertical; }
input[type='checkbox'] { width: 24px; min-height: 24px; height: 24px; accent-color: var(--green); }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.secret-wrap { display: flex; gap: 8px; }
.secret-wrap input { flex: 1; letter-spacing: .15em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px 20px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--navy);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.go { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (prefers-color-scheme: dark) {
  .btn { border-color: var(--line); }
  .btn.primary { background: #2a3a78; border-color: #2a3a78; }
}

/* ---------- Tabs (Super Admin) ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 18px; padding-bottom: 4px; }
.tabs a {
  white-space: nowrap; text-decoration: none; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-weight: 700; font-size: .95rem;
}
.tabs a[aria-current='page'] { background: var(--navy); color: #fff; border-color: var(--navy); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); }

/* ---------- Photos ---------- */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb {
  width: 92px; height: 92px; border-radius: var(--radius-s); object-fit: cover;
  border: 1px solid var(--line); background: var(--paper); cursor: zoom-in;
}
.thumb.pending { display: grid; place-items: center; font-size: .8rem; color: var(--muted); cursor: default; }

/* ---------- Camera & dialogs ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 28, .72);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .overlay { align-items: center; } }
.dialog {
  background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: var(--radius-m) var(--radius-m) 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) { .dialog { border-radius: var(--radius-m); } }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.camera { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.camera video, .camera img { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #000; }
.camera .bar {
  display: flex; gap: 12px; justify-content: space-between; align-items: center;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.camera .bar .btn, .cam-spacer { flex: 1; }
.shutter {
  width: 76px; height: 76px; flex: 0 0 76px; border-radius: 50%; border: 5px solid #fff;
  background: var(--green); cursor: pointer;
}
.viewer { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer-bar { padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 80; max-width: calc(100% - 32px); pointer-events: none;
}
#toast div {
  background: var(--navy-deep); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700;
  border: 2px solid var(--green); margin-top: 8px; text-align: center;
}
#toast div.error { border-color: var(--red); }

/* ---------- Login ---------- */
.login-hero { text-align: left; margin: 12px 0 22px; }
.login-hero h2 { font-size: 2rem; margin-bottom: .2em; }

@media (prefers-reduced-motion: no-preference) {
  .pop { animation: pop .35s ease-out; }
  @keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
}
