/* ==========================================================================
   MAGIX WEB-AR — Control Centre design system
   Brand tokens: Ice Silver #DDE3E8 · Deep Aubergine #3A0F34 · Marigold #EAAA00
   One consistent system for navigation, forms, buttons, cards, tables,
   dialogs, toasts, upload slots and the placement editor.
   ========================================================================== */

:root {
  --ice: #dde3e8;
  --aubergine: #3a0f34;
  --marigold: #eaaa00;

  --bg: var(--ice);
  --surface: #ffffff;
  --surface-2: #f4f7f9;
  --surface-3: #eef2f5;
  --text: #241420;
  --muted: #6b5a68;
  --line: #d6dde3;
  --line-strong: #c3ccd4;

  --primary: var(--aubergine);
  --accent: var(--marigold);
  --good: #1f9d6b;
  --warn: #b7791f;
  --danger: #c93b3b;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  --radius-xs: 9px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 1px 2px rgba(58, 15, 52, 0.06);
  --shadow: 0 10px 30px rgba(58, 15, 52, 0.08);
  --shadow-lg: 0 26px 60px rgba(58, 15, 52, 0.16);

  --sidebar-w: 278px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Author `display` rules outrank the UA [hidden] rule, so make it explicit. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--aubergine); letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 27px; font-weight: 750; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0 0 var(--s-3); }
a { color: var(--aubergine); }

.muted { color: var(--muted); }
.clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-4);
  color: #fff;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(234, 170, 0, 0.22) 0%, transparent 60%),
    linear-gradient(180deg, #3f1140 0%, var(--aubergine) 55%, #2c0b28 100%);
}

.brand { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-2); }
.brand__logo { border-radius: 10px; background: #fff2; padding: 2px; }
.brand__text { display: flex; flex-direction: column; }
.brand__text strong { font-size: 15px; letter-spacing: 0.04em; }
.brand__text span { font-size: 11.5px; color: rgba(255, 255, 255, 0.6); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav__group { margin: var(--s-4) 0 var(--s-2); padding: 0 var(--s-3); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: rgba(255, 255, 255, 0.42); }
.nav__item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-3);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav__item:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.nav__item.is-active {
  background: var(--marigold);
  color: var(--aubergine);
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(234, 170, 0, 0.28);
}
.nav__item svg { flex: 0 0 auto; }
.nav__badge { margin-left: auto; font-size: 11px; font-weight: 700; background: rgba(255,255,255,0.16); border-radius: 999px; padding: 1px 8px; }

.sidebar__foot { display: flex; flex-direction: column; gap: var(--s-2); }
.who { padding: 0 var(--s-2); font-size: 12px; color: rgba(255, 255, 255, 0.7); }
.who strong { display: block; color: #fff; font-size: 13px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  background: rgba(221, 227, 232, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--aubergine); }
.crumbs strong { color: var(--aubergine); }
.topbar__actions { margin-left: auto; display: flex; gap: var(--s-2); }

.view { padding: var(--s-6) var(--s-6) var(--s-7); max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.page-head__text { flex: 1; min-width: 240px; }
.page-head__text p { margin: var(--s-2) 0 0; color: var(--muted); }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
  animation: rise 0.42s var(--ease);
}
.panel + .panel { margin-top: var(--s-4); }
.panel__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.panel__head h2, .panel__head h3 { flex: 1; min-width: 160px; }
.panel--tight { padding: var(--s-4); }

.grid { display: grid; gap: var(--s-4); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }

/* ------------------------------------------------------------------- stats */
.stat {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-sm);
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--marigold), rgba(234, 170, 0, 0.25));
}
.stat__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 600; }
.stat__value { font-size: 30px; font-weight: 780; color: var(--aubergine); line-height: 1.15; margin-top: var(--s-2); }
.stat__note { font-size: 12.5px; color: var(--muted); margin-top: var(--s-1); }

/* ------------------------------------------------------------------- cards */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.card--link { cursor: pointer; text-decoration: none; color: inherit; }
.card--link:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card__row { display: flex; align-items: center; gap: var(--s-3); }
.card__thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); flex: 0 0 auto; }
.card__icon {
  width: 38px; height: 38px; border-radius: var(--radius-xs);
  display: grid; place-items: center; flex: 0 0 auto;
  background: rgba(234, 170, 0, 0.16); color: var(--aubergine);
}
.card__title { font-weight: 650; color: var(--aubergine); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--aubergine); color: #fff; box-shadow: 0 8px 20px rgba(58, 15, 52, 0.18); }
.btn--accent { background: var(--marigold); color: var(--aubergine); font-weight: 750; box-shadow: 0 8px 20px rgba(234, 170, 0, 0.22); }
.btn--ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn--ghost:hover { color: var(--aubergine); background: var(--surface-2); }
.btn--danger { background: transparent; color: var(--danger); border-color: #efc9c9; }
.btn--danger:hover { background: #fde8e8; }
.btn--small { padding: 7px 12px; font-size: 13px; }
.btn--tiny { padding: 4px 9px; font-size: 12px; border-radius: var(--radius-xs); }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; width: 38px; height: 38px; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(234, 170, 0, 0.45); border-radius: var(--radius-xs); }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field > label { font-size: 13px; font-weight: 600; color: var(--aubergine); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.field__error { font-size: 12.5px; color: var(--danger); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--aubergine);
  box-shadow: 0 0 0 3px rgba(234, 170, 0, 0.3);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: 14px; }
.check input { width: auto; }

.inline-alert {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: var(--s-4);
  border: 1px solid transparent;
}
.inline-alert--error { background: #fde8e8; color: #8f2626; border-color: #f3cccc; }
.inline-alert--warn { background: #fdf1de; color: #7a5512; border-color: #f0dcb4; }
.inline-alert--ok { background: #e3f6ee; color: #146b48; border-color: #c6ebdb; }
.inline-alert--info { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650;
  background: var(--surface-3); color: var(--muted);
}
.pill--published { background: #e3f6ee; color: var(--good); }
.pill--draft { background: #fdf1de; color: var(--warn); }
.pill--complete { background: #e3f6ee; color: var(--good); }
.pill--incomplete { background: #fde8e8; color: var(--danger); }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); background: var(--surface-2); padding: 10px 12px; font-weight: 700;
}
th:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
th:last-child { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ empty */
.empty { text-align: center; padding: var(--s-7) var(--s-5); color: var(--muted); }
.empty__icon { width: 52px; height: 52px; margin: 0 auto var(--s-3); color: var(--line-strong); }
.empty h3 { margin-bottom: var(--s-2); }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--radius-sm); }
.skeleton--line { height: 14px; margin-bottom: var(--s-2); }
.skeleton--card { height: 92px; }

/* --------------------------------------------------------------- uploads */
.slots { display: grid; gap: var(--s-4); }
.slot {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--s-4);
  background: var(--surface-2);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.slot:hover { border-color: var(--marigold); }
.slot.is-busy { border-style: solid; border-color: var(--marigold); }
.slot.is-set { border-style: solid; border-color: var(--line); background: #fff; }
.slot__label { display: flex; align-items: center; gap: var(--s-2); font-weight: 650; color: var(--aubergine); margin-bottom: var(--s-2); }
.slot__body { display: flex; gap: var(--s-4); align-items: center; }
.slot__preview { width: 108px; height: 108px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); flex: 0 0 auto; }
.slot__preview--video { width: 160px; height: 90px; }
.slot__meta { flex: 1; min-width: 0; }
.slot__name { font-size: 13.5px; font-weight: 600; }
.slot__size { font-size: 12px; color: var(--muted); }
.progress { width: 100%; height: 8px; margin-top: var(--s-2); }
progress { width: 100%; height: 8px; appearance: none; border-radius: 999px; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--marigold); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--marigold); }

/* ------------------------------------------------------- gallery editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-4); align-items: start; }
.stage-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s-4); box-shadow: var(--shadow-sm); }
.stage {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
  touch-action: none;
  user-select: none;
}
.stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.stage__hint { position: absolute; inset: auto 0 0 0; padding: 8px 12px; font-size: 12px; color: #fff; background: linear-gradient(180deg, transparent, rgba(58,15,52,.72)); }
.box {
  position: absolute;
  border: 2px solid var(--marigold);
  background: rgba(234, 170, 0, 0.16);
  border-radius: 6px;
  cursor: move;
  box-shadow: 0 2px 10px rgba(58, 15, 52, 0.18);
}
.box__tag {
  position: absolute; top: -22px; left: -2px;
  background: var(--marigold); color: var(--aubergine);
  font-size: 10.5px; font-weight: 750; padding: 1px 7px; border-radius: 5px; white-space: nowrap;
}
.box__handle {
  position: absolute; right: -7px; bottom: -7px; width: 16px; height: 16px;
  background: var(--marigold); border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.box.is-selected { border-color: #fff; box-shadow: 0 0 0 3px rgba(234, 170, 0, 0.7); }
.entry-list { display: flex; flex-direction: column; gap: var(--s-3); }
.entry-card { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-3); background: #fff; }
.entry-card.is-selected { border-color: var(--marigold); box-shadow: 0 0 0 3px rgba(234,170,0,.18); }
.entry-card__head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.entry-card__head strong { flex: 1; min-width: 0; }
.entry-card__thumbs { display: flex; gap: var(--s-2); }
.entry-card__thumbs img, .entry-card__thumbs video { width: 68px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.order-dot { font-size: 11px; font-weight: 700; background: var(--surface-3); border-radius: 6px; padding: 2px 7px; color: var(--muted); }

/* ------------------------------------------------------------- steps/QR */
.steps { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.step { font-size: 12.5px; font-weight: 650; padding: 5px 12px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.step.is-active { background: var(--marigold); color: var(--aubergine); }
.step.is-done { background: rgba(58, 15, 52, 0.1); color: var(--aubergine); }
.qr-card { display: flex; gap: var(--s-5); align-items: center; flex-wrap: wrap; }
.qr-card canvas, .qr-card img { width: 200px; height: 200px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; padding: 8px; }
.link-row { display: flex; gap: var(--s-2); align-items: center; }
.link-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); z-index: 200; align-items: center; }
.toast { padding: 11px 16px; border-radius: var(--radius-sm); color: #fff; background: var(--aubergine); box-shadow: var(--shadow-lg); font-size: 14px; max-width: min(520px, 92vw); animation: pop 0.28s var(--ease); }
.toast--success { background: #157a52; }
.toast--error { background: #a52e2e; }
.toast--info { background: var(--aubergine); }

/* --------------------------------------------------------------- overlay */
.scrim { position: fixed; inset: 0; background: rgba(30, 10, 27, 0.5); backdrop-filter: blur(3px); z-index: 30; }
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(30, 10, 27, 0.55); backdrop-filter: blur(4px); z-index: 100; padding: var(--s-4); }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: 88vh; overflow: auto; padding: var(--s-5); animation: pop 0.3s var(--ease); }
.modal__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.modal__head h2 { flex: 1; }

/* ----------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: var(--s-5);
  background: radial-gradient(60% 50% at 15% 10%, rgba(234, 170, 0, 0.2), transparent 60%),
              radial-gradient(60% 50% at 85% 90%, rgba(58, 15, 52, 0.16), transparent 60%), var(--ice); }
.login-card { width: min(430px, 100%); background: #fff; border-radius: var(--radius-xl); padding: var(--s-6); box-shadow: var(--shadow-lg); }
.login-card__logo { display: block; margin-bottom: var(--s-4); border-radius: 14px; }
.login-card h1 { margin-bottom: var(--s-2); }
.login-card p { color: var(--muted); }
.login-card form { margin-top: var(--s-5); }
.login-card__note { margin-top: var(--s-5); font-size: 12.5px; }

/* ---------------------------------------------------------------- motion */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform 0.26s var(--ease); }
  .sidebar.is-open { transform: none; }
  .topbar__menu { display: inline-flex; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
  .view { padding: var(--s-4) var(--s-3) var(--s-6); }
  .topbar { padding: var(--s-2) var(--s-3); }
  .panel { padding: var(--s-4); border-radius: var(--radius); }
  .page-head { flex-direction: column; }
  .qr-card { justify-content: center; text-align: center; }
  th.col-hide-sm, td.col-hide-sm { display: none; }
}
