:root {
  --plum: #2b1550; --plum-2: #3d2170; --saffron: #ff8a35; --saffron-d: #e97716; --gold: #f4c66a;
  --bg: #f6f1e8; --card: #fff; --line: #e8dfd0; --line-2: #f0e9db; --text: #2a1f33; --muted: #766a7c;
  --danger: #c0392b; --danger-bg: #fbe3e6; --ok: #1e8e4e; --ok-bg: #ddf3e4; --warn: #9a6200; --warn-bg: #fdf0d5;
  --radius: 12px; --shadow: 0 1px 2px rgba(43,21,80,.06), 0 4px 16px rgba(43,21,80,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--plum-2); }
code { background: var(--line-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; } .gap-s { gap: 6px; } .mt { margin-top: 14px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* buttons & fields */
button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid transparent; border-radius: 999px; padding: 8px 16px; font-weight: 600; background: var(--saffron); color: #fff; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--saffron-d); }
.btn.secondary { background: #fff; color: var(--plum); border-color: #d9cfe6; } .btn.secondary:hover { background: #f7f3fc; }
.btn.ghost { background: transparent; color: var(--plum); } .btn.ghost:hover { background: rgba(43,21,80,.07); }
.btn.danger { background: var(--danger); } .btn.danger:hover { background: #a53125; }
.btn.danger.secondary { background: #fff; color: var(--danger); border-color: #efc4c0; } .btn.danger.secondary:hover { background: var(--danger-bg); }
.btn.small { padding: 4px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible, .tcard:focus-visible { outline: 3px solid rgba(255,138,53,.45); outline-offset: 1px; }
label.f { display: block; font-weight: 600; font-size: 13px; }
label.f > .hint { font-weight: 400; }
label.f > :is(input, select, textarea) { margin-top: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
input[type=color] { padding: 2px; height: 36px; min-width: 52px; cursor: pointer; }
input[type=file] { display: none; }
textarea { resize: vertical; }
.check { display: inline-flex; gap: 7px; align-items: center; font-weight: 500; cursor: pointer; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }

/* shell */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side { background: var(--plum); color: #fff; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 14px; display: flex; gap: 8px; align-items: center; }
.brand b { color: var(--gold); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #e6dcf6; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.09); }
.nav a.active { background: rgba(255,255,255,.17); color: #fff; font-weight: 700; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.14); margin: 8px 6px; }
.side .foot { margin-top: auto; padding: 8px 10px; font-size: 12px; color: #bfaedc; }
.side .foot .btn { width: 100%; margin-top: 8px; }
.main { padding: 22px 26px 60px; min-width: 0; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); max-width: 70ch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card > h2 + .hint { margin-top: 2px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--plum), #5a2a8a); }
.login .card { width: min(420px, 100%); padding: 26px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }

/* toasts, banners */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--plum); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: pop .18s ease-out; }
.toast.error { background: var(--danger); } .toast.ok { background: #1c6b3f; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--warn-bg); color: var(--warn); }
.banner.error { background: var(--danger-bg); color: var(--danger); } .banner.ok { background: var(--ok-bg); color: var(--ok); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eee; color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--danger-bg); color: var(--danger); } .pill.info { background: #e8e0fa; color: var(--plum-2); }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--saffron); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; } td.actions .btn { margin-left: 4px; }
img.thumb { display: block; object-fit: cover; border-radius: 8px; background: #eee; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow); }
.stat .n { font-size: 27px; font-weight: 700; color: var(--plum); line-height: 1.15; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; margin: 8px 0 4px; }
.bars .bar { flex: 1; background: linear-gradient(var(--saffron), #ffb26b); border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; }
.bars .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.bar-labels { display: flex; gap: 8px; } .bar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: baseline; }

/* toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 260px; } .toolbar select { width: auto; max-width: 210px; }
.bulkbar { position: sticky; top: 0; z-index: 5; background: var(--plum); color: #fff; padding: 9px 14px; border-radius: 12px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.bulkbar .btn.secondary { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; } .bulkbar .btn.secondary:hover { background: rgba(255,255,255,.22); }
.bulkbar .btn.danger { background: #e2574a; }

/* template grid */
.tgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tcard { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; color: inherit; }
.tcard:hover { border-color: #cdbfe6; box-shadow: var(--shadow); }
.tcard.selected { border-color: var(--saffron); box-shadow: 0 0 0 2px rgba(255,138,53,.35); }
.tcard .pic { aspect-ratio: 4 / 5; background: #e9e2f2 center / cover no-repeat; position: relative; }
.tcard .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tcard.off .pic img { opacity: .45; filter: grayscale(.6); }
.tcard .sel { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,.92); border: 1.5px solid #cdbfe6; display: grid; place-items: center; font-size: 15px; font-weight: 700; color: #fff; z-index: 2; cursor: pointer; padding: 0; }
.tcard.selected .sel { background: var(--saffron); border-color: var(--saffron); }
.tcard .badge { position: absolute; top: 8px; right: 8px; z-index: 2; }
.tcard .meta { padding: 8px 10px 10px; }
.tcard .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard .meta .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* dialogs */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(20,8,40,.4); color: var(--text); overflow: hidden; }
dialog.wide { width: min(940px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20,8,40,.5); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); margin: 0; }
.dlg-head { padding: 16px 20px 10px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.dlg-body { padding: 6px 20px 16px; overflow: auto; flex: 1; }
.dlg-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: #fcfaf6; }
.editor { display: grid; grid-template-columns: 250px 1fr; gap: 20px; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }

/* live card preview (4:5) */
.preview-wrap { position: sticky; top: 0; align-self: start; }
.cardprev { width: 100%; aspect-ratio: 4 / 5; border-radius: 12px; background: #3b2a60 center / cover no-repeat; position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 8%; box-shadow: var(--shadow); container-type: inline-size; }
.cardprev.empty { background-image: repeating-linear-gradient(45deg, #4a3578, #4a3578 12px, #42306f 12px, #42306f 24px); }
.cardprev .t { display: flex; flex-direction: column; gap: 3cqw; width: 100%; }
.cardprev .h { font-weight: 800; font-size: 8.75cqw; line-height: 1.15; overflow-wrap: anywhere; }
.cardprev .m { font-size: 4.7cqw; line-height: 1.4; overflow-wrap: anywhere; }
.cardprev .s { font-size: 4.4cqw; font-weight: 600; margin-top: 2cqw; }
.cardprev .ghost { opacity: .5; font-style: italic; }
.drop { border: 2px dashed #cdbfe6; border-radius: 14px; padding: 26px 16px; text-align: center; background: #fbf9ff; cursor: pointer; }
.drop.over { border-color: var(--saffron); background: #fff6ee; }
.drop strong { display: block; font-size: 15px; }
.uplist { display: grid; gap: 6px; margin-top: 12px; max-height: 260px; overflow: auto; }
.uprow { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 10px; }
.uprow img { width: 34px; height: 42px; object-fit: cover; border-radius: 6px; background: #eee; }
.uprow .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); vertical-align: -2px; margin-right: 4px; }

/* festival images / storage grids */
.igrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.icard { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.icard .pic { aspect-ratio: 16 / 10; background: #eee; } .icard .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icard .pic.none { display: grid; place-items: center; color: var(--muted); font-size: 13px; background: repeating-linear-gradient(45deg, #f4efe6, #f4efe6 10px, #efe8db 10px, #efe8db 20px); }
.icard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.icard .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 16px; }

/* small screens */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  /* The menu becomes a strip under the title: it scrolls sideways instead of wrapping. */
  .side { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; padding: 10px 12px; }
  .brand { padding: 0; }
  .side .foot { margin: 0; padding: 0; grid-column: 2; grid-row: 1; }
  .side .foot .hint { display: none; } .side .foot .btn { margin: 0; width: auto; }
  .nav { grid-column: 1 / -1; grid-row: 2; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav .sep { display: none; } .nav .ico { display: none; }
  .nav a { padding: 6px 12px; white-space: nowrap; }
  #account { display: none; } /* on a phone, change your password from the Admins tab */
  .main { padding: 16px 12px 60px; }
  .tgrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
