/* Manager styles: Main's palette (zinc + emerald), landscape-first layout (two columns on tablet landscape/desktop, one column on tablet portrait, a note instead of the app on phones), 44 px touch targets, 100dvh and safe-area insets. */
:root {
  --zinc-200: #e4e4e7; --zinc-300: #d4d4d8; --zinc-400: #a1a1aa; --zinc-500: #71717a; --zinc-700: #3f3f46; --zinc-800: #27272a; --zinc-900: #18181b; --zinc-950: #09090b;
  --emerald-300: #6ee7b7; --emerald-400: #34d399; --emerald-600: #059669; --emerald-700: #047857;
  --red: #f87171; --red-bg: rgba(248, 113, 113, 0.12); --amber: #fbbf24; --amber-bg: rgba(251, 191, 36, 0.12); --blue: #60a5fa;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100dvh; background: var(--zinc-950); color: #fff; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 16px; -webkit-tap-highlight-color: transparent; }
a { color: var(--emerald-300); }
h1 { margin: 0.2rem 0; font-size: 1.6rem; }
h2 { margin: 0 0 0.4rem; font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem; }
h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.muted { color: var(--zinc-400); }
.small { font-size: 0.85rem; }
.grow { flex: 1; }
.right { display: flex; justify-content: flex-end; }
[hidden] { display: none !important; }

/* ----- phone note vs app ----- */
.phone-note { display: none; }
@media (max-width: 699px), (orientation: landscape) and (max-height: 500px) {
  .phone-note { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); text-align: center; }
  .phone-note .panel { max-width: 360px; }
  .phone-logo { width: 7rem; }
  .app { display: none !important; }
  #toasts { display: none; }
}

/* ----- top bar ----- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); background: rgba(9, 9, 11, 0.95); border-bottom: 1px solid var(--zinc-800); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 0.5rem; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; min-height: 44px; }
.brand img { width: 4.5rem; }
.mainnav { display: flex; gap: 0.25rem; }
.mainnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.9rem; border-radius: 0.6rem; color: var(--zinc-300); text-decoration: none; font-weight: 600; }
.mainnav a.on { background: var(--zinc-800); color: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.env-banner, .ro-banner { margin: 0.75rem auto 0; max-width: 1100px; padding: 0.7rem 1rem; border-radius: 0.75rem; background: var(--amber-bg); border: 1px solid var(--amber); color: var(--amber); font-weight: 600; }
.ro-banner { margin: 0 0 0.75rem; }

/* ----- page ----- */
.page { max-width: 1100px; margin: 0 auto; padding: 1rem max(16px, env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.page-head p { margin: 0.2rem 0 0; }
.panel { background: var(--zinc-900); border: 1px solid var(--zinc-800); border-radius: 1rem; padding: 1rem 1.1rem; margin-bottom: 0.9rem; }
.panel > .muted:first-of-type { margin-top: 0; }
.sub-panel { border: 1px solid var(--zinc-700); border-radius: 0.8rem; padding: 0.8rem; margin: 0.6rem 0; background: var(--zinc-950); }
.sub-head { display: flex; align-items: center; justify-content: space-between; }

/* two columns on tablet landscape / desktop: forms (max ~720) + side panel */
.layout2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; max-width: 680px; margin: 0 auto; }
.layout2 .side { order: -1; }
@media (min-width: 900px) and (min-height: 501px) and (orientation: landscape) {
  .layout2 { grid-template-columns: minmax(0, 720px) minmax(260px, 1fr); max-width: none; align-items: start; }
  .layout2 .side { order: 0; position: sticky; top: 76px; }
}
.side-graphic { width: 100%; max-height: 140px; object-fit: cover; border-radius: 0.6rem; margin-bottom: 0.6rem; }
@media not ((min-width: 900px) and (min-height: 501px) and (orientation: landscape)) {
  .side .side-graphic { display: none; }
  .side .facts { grid-template-columns: auto 1fr auto 1fr; }
}

/* ----- forms ----- */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.6rem 0; min-width: 0; }
.label { font-size: 0.85rem; font-weight: 700; color: var(--zinc-300); }
.hint { font-size: 0.8rem; color: var(--zinc-500); }
.error { font-size: 0.85rem; color: var(--red); min-height: 0; }
.error:empty { display: none; }
input[type='text'], input[type='url'], input[type='number'], input[type='datetime-local'], input[type='password'], select, textarea {
  width: 100%; min-height: 44px; padding: 0.55rem 0.7rem; border-radius: 0.6rem; border: 1px solid var(--zinc-700); background: var(--zinc-950); color: #fff; font: inherit; color-scheme: dark;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--emerald-400); outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }
.invalid { border-color: var(--red) !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--emerald-600); flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 44px; padding: 0 1.1rem; border-radius: 0.7rem; border: 2px solid transparent; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; color: #fff; white-space: nowrap; }
.btn.small { min-height: 44px; padding: 0 0.8rem; font-size: 0.9rem; }
.btn.big { min-height: 56px; padding: 0 1.6rem; font-size: 1.1rem; }
.btn.primary { background: var(--emerald-700); border-color: var(--emerald-600); }
.btn.primary:active { transform: scale(0.98); }
.btn.secondary { background: var(--zinc-800); border-color: var(--zinc-700); }
.btn.ghost { background: transparent; color: var(--zinc-300); }
.btn.ghost:hover { background: var(--zinc-800); }
.btn.danger { color: var(--red); }
.btn[disabled], .btn.disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--emerald-300); outline-offset: 2px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.image-field { display: flex; align-items: center; gap: 0.8rem; }
.image-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.thumb { width: 88px; height: 66px; object-fit: cover; border-radius: 0.5rem; border: 1px solid var(--zinc-700); background: var(--zinc-950); flex: none; }
.thumb.empty { display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--zinc-500); }

.choice-list, .game-list, .prize-list { display: flex; flex-direction: column; gap: 0.5rem; }
.choice { display: flex; align-items: center; gap: 0.7rem; min-height: 48px; padding: 0.4rem 0.7rem; border-radius: 0.7rem; border: 1px solid var(--zinc-700); background: var(--zinc-950); cursor: pointer; }
.choice.on, .prize-row.on .choice { border-color: var(--emerald-600); }
.game-row, .prize-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.game-row .max, .prize-row .max { display: flex; flex-direction: column; width: 8.5rem; }
.tag { margin-left: auto; font-size: 0.75rem; color: var(--zinc-400); border: 1px solid var(--zinc-700); border-radius: 999px; padding: 0.1rem 0.5rem; }
.icon-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.icon-sm.ph { display: inline-flex; align-items: center; justify-content: center; background: var(--zinc-800); font-weight: 800; }
details.inline-new { margin-top: 0.8rem; border-top: 1px dashed var(--zinc-700); padding-top: 0.6rem; }
details.inline-new summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--emerald-300); }
.warn-box { background: var(--amber-bg); border: 1px solid var(--amber); color: var(--amber); border-radius: 0.6rem; padding: 0.6rem 0.8rem; }

/* banner preview (M9) */
.banner-preview { position: relative; overflow: hidden; height: 64px; border-radius: 0.6rem; background: linear-gradient(90deg, #0b3b2e, #065f46); border: 1px solid var(--emerald-600); display: flex; align-items: center; }
.bp-inner { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.9rem; white-space: nowrap; font-weight: 800; font-size: 1.1rem; }
.bp-inner img { height: 48px; border-radius: 0.3rem; }
.type-scroll .bp-inner, .type-text_scroll .bp-inner { animation: bp-scroll 8s linear infinite; }
.type-blink .bp-inner { animation: bp-blink 1s steps(2, start) infinite; }
.bp-timer { position: absolute; right: 0.5rem; top: 0.3rem; font-size: 0.7rem; color: var(--emerald-300); }
@keyframes bp-scroll { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
@keyframes bp-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .bp-inner { animation: none !important; } }

.qr-wrap { display: flex; gap: 1rem; align-items: flex-start; }
.qr { width: 150px; height: 150px; border-radius: 0.6rem; background: #fff; flex: none; }
.qr.empty { display: inline-flex; align-items: center; justify-content: center; background: var(--zinc-950); border: 1px dashed var(--zinc-700); color: var(--zinc-500); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; margin: 0.6rem 0; font-size: 0.9rem; }
.facts dt { color: var(--zinc-400); }
.facts dd { margin: 0; }

/* stepper */
.stepper { list-style: none; display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.35rem; padding: 0; margin: 0 0 1rem; }
.stepper li > * { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-height: 56px; padding: 0.35rem 0.2rem; border-radius: 0.7rem; text-decoration: none; color: var(--zinc-400); text-align: center; font-size: 0.78rem; }
.stepper .num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--zinc-800); color: var(--zinc-300); font-weight: 800; }
.stepper li.done .num { background: var(--emerald-700); color: #fff; }
.stepper li.current > * { background: var(--zinc-900); color: #fff; outline: 2px solid var(--emerald-600); }
.stepper li.current .num { background: var(--emerald-400); color: var(--zinc-950); }
.stepper li.todo { opacity: 0.55; }
.stepper a:hover { background: var(--zinc-900); }
@media (max-width: 899px), (orientation: portrait) { .stepper .sname { font-size: 0.7rem; } }
.wizard-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.8rem 0; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--zinc-950) 30%); padding-bottom: max(0.8rem, env(safe-area-inset-bottom)); }
.wizard-foot > div { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 0.3rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: 2px; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.9rem; border-radius: 0.7rem; background: var(--zinc-900); border: 1px solid var(--zinc-800); color: var(--zinc-300); text-decoration: none; font-weight: 600; white-space: nowrap; }
.tabs a.on { background: var(--emerald-700); border-color: var(--emerald-600); color: #fff; }

/* review */
.summary { display: flex; flex-direction: column; gap: 0.4rem; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.5rem 0; border-bottom: 1px solid var(--zinc-800); }
.sum-title { display: block; font-size: 0.8rem; color: var(--zinc-400); font-weight: 700; }
.sum-val { display: block; }
.issues { margin: 0.8rem 0; }
.issue { margin: 0.35rem 0; padding: 0.5rem 0.7rem; border-radius: 0.6rem; }
.issue.block { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.issue.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.5); }
.issue.ok { background: rgba(52, 211, 153, 0.12); color: var(--emerald-300); border: 1px solid var(--emerald-600); }
.issue a { color: inherit; font-weight: 700; }
.ready-action { display: flex; justify-content: flex-end; }
.ready-box { display: flex; align-items: center; gap: 1rem; color: var(--emerald-300); }

/* badges */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--zinc-800); color: var(--zinc-300); }
.badge.ready { background: rgba(52, 211, 153, 0.15); color: var(--emerald-300); }
.badge.draft { background: var(--amber-bg); color: var(--amber); }
.badge.active { background: rgba(96, 165, 250, 0.15); color: var(--blue); }

/* home */
.ev-group { margin-bottom: 1.2rem; }
.ev-group h2 .count { font-size: 0.8rem; background: var(--zinc-800); border-radius: 999px; padding: 0.1rem 0.5rem; color: var(--zinc-300); }
.ev-group > p { margin: 0 0 0.6rem; }
.ev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.8rem; }
@media (min-width: 900px) and (orientation: landscape) { .ev-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1300px) and (orientation: landscape) { .ev-grid { grid-template-columns: repeat(3, 1fr); } }
.ev-card { display: grid; grid-template-columns: 72px 1fr; grid-template-rows: auto auto; gap: 0.4rem 0.8rem; padding: 0.8rem; border-radius: 1rem; background: var(--zinc-900); border: 1px solid var(--zinc-800); }
.ev-graphic { width: 72px; height: 72px; object-fit: cover; border-radius: 0.7rem; }
.ev-graphic.ph { display: flex; align-items: center; justify-content: center; background: var(--zinc-800); font-size: 1.6rem; font-weight: 800; color: var(--zinc-400); }
.ev-body h3 { margin: 0; }
.ev-body p { margin: 0.2rem 0; }
.ev-actions { grid-column: 1 / -1; display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.empty { margin: 0; }

.org-list { display: grid; grid-template-columns: 1fr; gap: 0; max-width: 720px; }
@media (min-width: 900px) and (orientation: landscape) { .org-list { grid-template-columns: 1fr 1fr; gap: 0 1rem; max-width: none; } }
.org-row.new { border-style: dashed; }

#toasts { position: fixed; z-index: 50; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.4rem; width: min(92vw, 520px); }
.toast { padding: 0.75rem 1rem; border-radius: 0.7rem; background: var(--emerald-700); color: #fff; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.toast.err { background: #7f1d1d; border: 1px solid var(--red); }
.loading { padding: 2rem; text-align: center; }
.top-right .org { white-space: nowrap; }
@media (max-width: 999px) { .top-right .org { display: none; } }
