/* BBZU Admin — calm, clear, works on the phone.
   Spacing scale: 4 · 8 · 12 · 16 · 24 · 32 · 48 px (--s1 … --s7) */
:root {
  --red: #e2001a; --red-deep: #b30015; --red-soft: #fdecee;
  --ink: #151111; --ink-2: #221c1c;
  --bg: #f5f3f0; --card: #fff; --line: #e6e1db; --line-strong: #cfc8c1;
  --text: #1c1717; --muted: #6b6360; --ok: #1f7a3d; --ok-soft: #e8f5ec; --warn: #8a5300; --warn-soft: #fff6dc;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.05);
  --focus: 0 0 0 3px rgb(226 0 26 / 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.boot { padding: var(--s7); text-align: center; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- login ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); background: radial-gradient(90% 60% at 50% 0%, #3a0a10, #151111 70%); }
.auth-card { width: min(100%, 400px); background: var(--card); border-radius: 18px; padding: var(--s6) var(--s5); box-shadow: 0 20px 60px rgb(0 0 0 / 0.4); display: grid; gap: var(--s4); }
.auth-card img.logo { display: block; width: 150px; margin: 0 auto; }
.auth-card h1 { font-size: 1.1rem; text-align: center; margin: 0; color: var(--muted); font-weight: 600; }
.auth-card .qr { display: block; margin: 0 auto; width: 200px; height: 200px; image-rendering: pixelated; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; background: var(--bg); padding: var(--s2) var(--s3); border-radius: 6px; word-break: break-all; text-align: center; margin: 0; }
.err { color: var(--red); font-size: 0.9rem; margin: 0; min-height: 1.2em; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s3); height: 56px; padding: 0 var(--s4); background: var(--ink); color: #fff; }
.top .brand { display: flex; align-items: center; gap: var(--s2); font-weight: 800; text-decoration: none; color: #fff; }
.top .brand img { height: 26px; }
.top .brand span { font-size: 0.95rem; opacity: 0.8; font-weight: 600; }
.top .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: rgb(255 255 255 / 0.12); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5dd18a; }
.pill--draft { background: #f7c948; color: #3a2a00; }
.pill--draft::before { background: #8a5300; }
.pill .short { display: none; }
.menu-btn { display: none; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 56px); }
nav.side { background: var(--card); border-right: 1px solid var(--line); padding: var(--s4) var(--s3) var(--s6); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
nav.side h4 { margin: var(--s5) var(--s3) var(--s2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
nav.side h4:first-child { margin-top: 0; }
nav.side a { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 7px var(--s3); border-radius: var(--r-sm); text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.93rem; }
nav.side a:hover { background: var(--bg); }
nav.side a[aria-current="page"] { background: var(--ink); color: #fff; }
nav.side .dot { width: 8px; height: 8px; border-radius: 50%; background: #f0b400; flex: none; }
nav.side .who { margin: var(--s5) var(--s3) var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
nav.side .who b { display: block; color: var(--text); }
main { padding: var(--s6) clamp(var(--s4), 3vw, var(--s7)) 120px; width: 100%; max-width: 1080px; }
.scrim { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { position: fixed; top: 56px; left: 0; bottom: 0; width: min(86vw, 300px); height: auto; z-index: 40; transform: translateX(-105%); transition: transform 0.25s ease; box-shadow: 0 0 40px rgb(0 0 0 / 0.25); }
  body.menu-open nav.side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 56px 0 0 0; z-index: 35; background: rgb(0 0 0 / 0.35); }
  .menu-btn { display: inline-flex; }
  main { padding-top: var(--s5); }
}
@media (max-width: 560px) {
  .top { gap: var(--s2); padding: 0 var(--s3); }
  .top .brand span { display: none; }
  .pill .long { display: none; }
  .pill .short { display: inline; }
  .top .btn { padding: 0 var(--s3); min-height: 36px; font-size: 0.85rem; }
}
@media (prefers-reduced-motion: reduce) { nav.side { transition: none; } }

/* ---------- page header ---------- */
.crumb { margin: 0 0 var(--s2); font-size: 0.88rem; }
.crumb a { text-decoration: none; font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); }
.page-head h1 { font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem); line-height: 1.15; margin: 0 0 var(--s1); letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--muted); max-width: 64ch; }
.page-head .row { flex: none; }
h2.sec { font-size: 1.05rem; margin: var(--s6) 0 var(--s3); }

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: var(--s5); margin-bottom: var(--s4); }
.card > h2 { font-size: 1.05rem; margin: 0 0 var(--s3); }
.card-note { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); margin-bottom: var(--s4); font-weight: 600; }
.card-note--ok { background: var(--ok-soft); color: var(--ok); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 var(--s4); border-radius: var(--r-sm); border: 1px solid transparent; background: var(--red); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color 0.15s; }
.btn:hover { background: var(--red-deep); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn--ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn--ghost:hover { background: rgb(0 0 0 / 0.05); }
.top .btn--ghost { border-color: rgb(255 255 255 / 0.45); }
.top .btn--ghost:hover { background: rgb(255 255 255 / 0.12); }
.btn--quiet { background: var(--card); color: var(--text); border-color: var(--line-strong); }
.btn--quiet:hover { background: var(--bg); }
.btn--danger { background: var(--card); color: var(--red); border-color: #f0b9c0; }
.btn--danger:hover { background: var(--red-soft); }
.btn--sm { min-height: 34px; padding: 0 var(--s3); font-size: 0.86rem; }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: #f2dfae; }

/* ---------- lists ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.toolbar .search { flex: 1 1 220px; max-width: 340px; margin-left: auto; }
.list { display: grid; gap: var(--s2); }
.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s4); align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); transition: border-color 0.15s, box-shadow 0.15s; }
.item:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.item .open { color: inherit; text-decoration: none; min-width: 0; }
.item .open:hover b { color: var(--red); }
.item b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: block; color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .thumb { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--ink); display: block; }
.item .thumb--contain { object-fit: contain; background: #ece9e5; padding: 4px; }
.item .thumb--empty { display: grid; place-items: center; color: var(--muted); background: var(--bg); font-weight: 800; }
.item .acts { display: flex; gap: var(--s1); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { background: var(--bg); }
.icon-btn[disabled] { opacity: 0.3; cursor: default; }
.icon-btn--danger:hover { background: var(--red-soft); border-color: #f0b9c0; color: var(--red); }
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--muted); background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--r); }
@media (max-width: 560px) { .item { grid-template-columns: auto minmax(0, 1fr); } .item .acts { grid-column: 1 / -1; justify-content: flex-end; } .item .thumb { width: 48px; height: 48px; } }

/* ---------- forms ---------- */
.form { display: grid; gap: var(--s5); }
.form-section { display: grid; gap: var(--s4); }
.form-section + .form-section { padding-top: var(--s5); border-top: 1px solid var(--line); }
.form-section > h3 { margin: 0; font-size: 0.95rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4) var(--s5); }
.span2 { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-weight: 700; font-size: 0.92rem; margin-bottom: 6px; }
.field .req { color: var(--red); margin-left: 2px; }
.field .hint { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; line-height: 1.4; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff; transition: border-color 0.15s, box-shadow 0.15s; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: #b9b0a8; }
.input:focus { outline: none; border-color: var(--red); box-shadow: var(--focus); }
.check { display: flex; align-items: flex-start; gap: var(--s2); font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--red); flex: none; }
.sub { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); display: grid; gap: var(--s3); background: #faf9f7; }
.sub-item { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s4); background: #fff; display: grid; gap: var(--s3); }
.sub-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-weight: 700; font-size: 0.9rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s2); }
.tags:empty { display: none; }
.tag { display: inline-flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: 0.88rem; }
.tag button { border: 0; background: none; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 0 6px; color: var(--muted); }
.tag button:hover { color: var(--red); }
.img-field { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); background: #faf9f7; }
.img-field img { width: 112px; height: 84px; object-fit: contain; background: #ece9e5; border-radius: 6px; }
.img-field .ph { width: 112px; height: 84px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 0.8rem; }
.html-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.choices .check { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; font-weight: 500; }
.role-cards { display: grid; gap: var(--s2); }
.role-card { display: grid; grid-template-columns: auto 1fr; gap: var(--s3); align-items: start; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; }
.role-card:has(input:checked) { border-color: var(--red); box-shadow: var(--focus); }
.role-card input { margin-top: 3px; accent-color: var(--red); width: 18px; height: 18px; }
.role-card b { display: block; }
.role-card span { color: var(--muted); font-size: 0.86rem; }
.savebar { position: sticky; bottom: 0; z-index: 10; margin: var(--s5) calc(-1 * var(--s2)) 0; padding: var(--s3) var(--s2); background: rgb(245 243 240 / 0.92); backdrop-filter: blur(6px); border-top: 1px solid var(--line); display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.savebar .state { margin-left: auto; font-size: 0.85rem; color: var(--muted); }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.5); display: grid; place-items: center; padding: var(--s4); }
.modal-box { background: var(--card); border-radius: 16px; width: min(100%, 880px); max-height: 88vh; overflow: auto; padding: var(--s5); box-shadow: 0 30px 80px rgb(0 0 0 / 0.35); }
.modal-box--sm { width: min(100%, 460px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s5); flex-wrap: wrap; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2); }
.lib button { border: 2px solid transparent; border-radius: var(--r-sm); padding: 0; background: #ece9e5; cursor: pointer; overflow: hidden; text-align: left; }
.lib button:hover, .lib button:focus-visible { border-color: var(--red); }
.lib img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.lib span { display: block; font-size: 0.7rem; color: var(--muted); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; }
.toast { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r-sm); box-shadow: 0 10px 30px rgb(0 0 0 / 0.3); max-width: min(92vw, 540px); font-size: 0.93rem; }
.toast--err { background: var(--red-deep); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; line-height: 1; margin-bottom: 6px; }
.stat span { color: var(--muted); font-size: 0.86rem; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.quick a { display: flex; gap: var(--s3); align-items: center; padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: inherit; font-weight: 700; }
.quick a:hover { border-color: var(--red); }
.quick a i { font-style: normal; font-size: 1.3rem; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
ul.plain li { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
table.log { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
table.log td, table.log th { text-align: left; padding: 10px var(--s3); border-bottom: 1px solid var(--line); font-size: 0.88rem; vertical-align: top; }
table.log th { background: #faf9f7; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.textgroup { margin-bottom: var(--s4); }
.textgroup > h2 { font-size: 1rem; }

/* ---------- social media graphics ---------- */
.sm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
@media (max-width: 900px) { .sm-grid { grid-template-columns: 1fr; } }
.sm-preview { background: #ece9e5; border-radius: var(--r); padding: var(--s4); display: grid; place-items: center; }
.sm-preview canvas { width: 100%; max-width: 420px; height: auto; border-radius: 6px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.2); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.pick-list { display: grid; gap: 6px; max-height: 340px; overflow: auto; padding-right: 4px; }

/* fixes after the visual check */
main:focus, main:focus-visible { outline: none; box-shadow: none; }
.top .menu-btn { display: none; }
@media (max-width: 860px) { .top .menu-btn { display: inline-flex; } }
.field .role-card { font-weight: 400; margin: 0; }
.role-card span { display: block; font-weight: 400; margin-top: 2px; }
.top .btn .short { display: none; }
@media (max-width: 560px) {
  .top .btn .long { display: none; }
  .top .btn .short { display: inline; }
  .top .btn { padding: 0 10px; }
}
