/* Admin CMS — calm, dense, readable. Light surfaces for long editing sessions. */
:root {
  --a-bg: #F6F5F2; --a-card: #FFFFFF; --a-ink: #16161A; --a-muted: #62616A; --a-line: #E6E3DD;
  --a-brand: #E31B23; --a-brand-ink: #FFFFFF; --a-accent: #FFC20E; --a-ok: #0F8A5F; --a-err: #C62828; --a-warn: #A66A00;
  --a-side: #0B0B0F; --a-side-ink: #D9D8DE; --a-r: 12px;
  --a-font: 'Inter', system-ui, sans-serif; --a-mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body.admin { margin: 0; background: var(--a-bg); color: var(--a-ink); font: 15px/1.55 var(--a-font); }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
.icon { width: 18px; height: 18px; flex: none; }
.mono { font-family: var(--a-mono); }
.small { font-size: .85rem; }
.a-muted { color: var(--a-muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -50px; background: var(--a-accent); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--a-brand); outline-offset: 2px; }

/* Shell */
body.admin:not(.a-login) { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.a-side { min-width: 0; background: var(--a-side); color: var(--a-side-ink); padding: 16px; }
.a-brand { display: flex; gap: 12px; align-items: center; padding: 4px 4px 16px; }
.a-brand small { display: block; color: #8C8B94; font-size: .78rem; }
.a-brand strong { color: #fff; }
.a-logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--a-brand); color: #fff; font-weight: 800; }
.a-side nav { display: flex; gap: 4px; overflow-x: auto; }
.a-side ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.a-nav-h { display: none; }
.a-side a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; text-decoration: none; white-space: nowrap; color: var(--a-side-ink); }
.a-side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.a-side a[aria-current="page"] { background: rgba(227,27,35,.18); color: #fff; box-shadow: inset 3px 0 0 var(--a-brand); }
@media (min-width: 1000px) {
  body.admin:not(.a-login) { grid-template-columns: 248px minmax(0, 1fr); }
  .a-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .a-side nav { display: block; overflow: visible; }
  .a-side ul { display: grid; gap: 2px; }
  .a-nav-h { display: block; margin: 18px 12px 6px; font: 500 .7rem/1 var(--a-mono); letter-spacing: .14em; text-transform: uppercase; color: #6F6E78; }
}
.a-main { min-width: 0; }
.a-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--a-line); background: var(--a-card); position: sticky; top: 0; z-index: 5; }
.a-user { display: flex; align-items: center; gap: 12px; }
.a-user form { margin: 0; }
.a-role { text-transform: capitalize; color: var(--a-muted); }
.a-content { padding: clamp(16px, 3vw, 32px); max-width: 1180px; }
.a-content:focus { outline: none; }

/* Type & blocks */
h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.02em; margin: 4px 0 6px; line-height: 1.15; }
.a-h3 { font-size: 1.05rem; margin: 0 0 12px; }
.a-eyebrow { margin: 0; font: 500 .72rem/1 var(--a-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--a-brand); }
.a-back { display: inline-block; margin-bottom: 4px; color: var(--a-muted); text-decoration: none; font-size: .9rem; }
.a-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.a-head p { max-width: 70ch; margin: 4px 0 0; }
.a-card { background: var(--a-card); border: 1px solid var(--a-line); border-radius: var(--a-r); padding: clamp(16px, 2.5vw, 24px); margin-bottom: 16px; }
.a-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.a-row form { margin: 0; }
.a-row-between { justify-content: space-between; }
.a-grid-2 { display: grid; gap: 0 20px; }
@media (min-width: 760px) { .a-grid-2 { grid-template-columns: 1fr 1fr; } }
.a-hr { border: 0; border-top: 1px solid var(--a-line); margin: 20px 0; }
.a-pre { white-space: pre-wrap; margin: 8px 0 0; }
.a-right { text-align: right; }

/* Buttons */
.a-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--a-line); background: var(--a-card); color: var(--a-ink); font: 600 .9rem/1 var(--a-font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color 140ms, border-color 140ms, transform 120ms; }
.a-btn:hover { border-color: #CFCBC3; background: #FBFAF8; }
.a-btn:active { transform: scale(.98); }
.a-btn-primary { background: var(--a-brand); border-color: var(--a-brand); color: var(--a-brand-ink); }
.a-btn-primary:hover { background: #C8141B; border-color: #C8141B; }
.a-btn-ghost { background: transparent; }
.a-btn-danger { color: var(--a-err); border-color: #F1C9C9; background: transparent; }
.a-btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.a-btn-block { width: 100%; }
.a-icon-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--a-line); background: var(--a-card); cursor: pointer; }
.a-icon-btn:disabled { opacity: .35; cursor: default; }
.a-order { display: flex; gap: 4px; }
.a-order form { margin: 0; }
.a-pill { border: 1px solid var(--a-line); border-radius: 999px; padding: 4px 12px; background: #F1EFEA; font: 600 .8rem/1.2 var(--a-font); cursor: pointer; color: var(--a-muted); }
.a-pill.is-on { background: #E3F4EC; border-color: #BFE3D1; color: var(--a-ok); }
.a-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #F1EFEA; color: var(--a-muted); font: 500 .75rem/1.5 var(--a-mono); margin: 1px 2px 1px 0; text-transform: capitalize; }
.a-tag-ok { background: #E3F4EC; color: var(--a-ok); }
.a-tag-warn { background: #FFF4D6; color: var(--a-warn); }
.a-tag-err { background: #FDE7E7; color: var(--a-err); }
.a-tag-brand { background: #FDE8E9; color: var(--a-brand); }

/* Forms */
.a-form { display: grid; gap: 0; }
.a-field { display: grid; gap: 6px; margin-bottom: 16px; }
.a-field > label, .a-inline { font-weight: 600; font-size: .9rem; }
.a-help { margin: 0; font-size: .82rem; color: var(--a-muted); }
.a-ai { display: grid; gap: 8px; justify-items: start; margin: -4px 0 16px; }
.a-ai-out { width: 100%; display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--a-line); border-radius: 10px; background: #FBFAF8; font-size: .9rem; }
.a-ai-out.is-err { color: var(--a-err); border-style: solid; }
.a-ai-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; }
.a-ai-row strong { grid-column: 1 / -1; font-size: .8rem; color: var(--a-muted); }
.a-ai-row p { margin: 0; }
.a-reel { display: grid; gap: 10px; }
.a-reel-out { display: grid; gap: 10px; justify-items: start; }
.a-reel-video { width: min(100%, 270px); aspect-ratio: 9 / 16; background: #111; border-radius: 12px; }
.a-help.is-err { color: var(--a-err); }
.admin input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), .admin select, .admin textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid #D9D5CD; background: #fff; color: var(--a-ink); font: inherit;
}
.admin textarea { resize: vertical; }
.admin .a-rich { font-family: var(--a-mono); font-size: .85rem; }
.admin input:focus, .admin select, .admin textarea:focus { border-color: #B9B4AA; }
.admin input:focus, .admin textarea:focus, .admin select:focus { outline: none; border-color: var(--a-brand); box-shadow: 0 0 0 3px rgba(227,27,35,.14); }
.a-row input, .a-row select { width: auto; flex: 1 1 220px; }
.a-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.a-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--a-brand); }
.a-color { display: flex; gap: 8px; align-items: center; }
.a-color input[type="color"] { width: 46px; height: 42px; padding: 2px; border: 1px solid #D9D5CD; border-radius: 10px; background: #fff; }
.a-color input.mono { max-width: 140px; }
.a-image { display: grid; gap: 10px; }
.a-image-preview { width: 100%; max-width: 320px; aspect-ratio: 4 / 3; border-radius: 10px; border: 1px dashed #CFCBC3; background: repeating-conic-gradient(#F1EFEA 0 25%, #fff 0 50%) 0 0 / 16px 16px; display: grid; place-items: center; overflow: hidden; color: var(--a-muted); }
.a-field-image .a-image-preview img { width: 100%; height: 100%; object-fit: contain; }
.a-image-preview span { display: flex; gap: 6px; align-items: center; font-size: .85rem; }
.a-image-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.a-image-actions label { cursor: pointer; }
.a-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 8px; }
.a-flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: #E3F4EC; color: #0B5E41; border: 1px solid #BFE3D1; }
.a-flash-err { background: #FDE7E7; color: #8E1C1C; border-color: #F4C7C7; }
.a-test-result { margin: 12px 0 0; font-weight: 600; }
.a-test-result.is-ok { color: var(--a-ok); }
.a-test-result.is-err { color: var(--a-err); }
.a-details summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; gap: 8px; }
.a-details[open] summary { margin-bottom: 12px; }

/* Tables */
.a-table-wrap { overflow-x: auto; }
.a-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.a-table th { text-align: left; font: 500 .72rem/1.2 var(--a-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--a-muted); padding: 10px 10px; border-bottom: 1px solid var(--a-line); white-space: nowrap; }
.a-table td { padding: 10px; border-bottom: 1px solid #F0EDE7; vertical-align: middle; }
.a-table tr:last-child td { border-bottom: 0; }
.a-table a { text-decoration: none; }
.a-table a:hover strong { color: var(--a-brand); }
.a-table td form { margin: 0; }
.a-hours th[scope="row"] { font: 600 .9rem var(--a-font); text-transform: none; letter-spacing: 0; color: var(--a-ink); }
.a-thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: #F1EFEA; display: grid; place-items: center; color: #B3AFA6; }

/* Dashboard */
.a-stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.a-stat { display: grid; gap: 4px; text-decoration: none; margin: 0; }
.a-stat-n { font-size: 2rem; font-weight: 600; letter-spacing: -.03em; }
.a-stat-warn .a-stat-n { color: var(--a-err); }
.a-progress { height: 8px; border-radius: 8px; background: #F1EFEA; overflow: hidden; margin-bottom: 12px; }
.a-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--a-brand), var(--a-accent)); }
.a-checklist { list-style: none; margin: 0; padding: 0; }
.a-checklist li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid #F0EDE7; }
.a-checklist small { display: block; color: var(--a-muted); }
.a-tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #D9D5CD; display: grid; place-items: center; }
.a-checklist .is-ok .a-tick { background: var(--a-ok); border-color: var(--a-ok); color: #fff; }
.a-checklist .is-ok .a-tick .icon { width: 14px; height: 14px; }
.a-message.is-unread { border-left: 4px solid var(--a-brand); }

/* Login */
.a-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(60% 60% at 80% 0%, rgba(227,27,35,.18), transparent 60%), #0B0B0F; }
.a-login-card { width: min(400px, 100%); background: var(--a-card); border-radius: 18px; padding: 32px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); }
.a-login-card h1 { margin-bottom: 20px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Appearance (theme / fonts / mode + live preview) ---------- */
.a-content:has(.ap-wrap) { max-width: none; }
.ap-wrap { display: grid; gap: 16px; align-items: start; }
@media (min-width: 1200px) { .ap-wrap { grid-template-columns: minmax(420px, 1fr) minmax(420px, 1.15fr); } }
.ap-options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ap-modes { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ap-group-label { margin: 14px 0 8px; font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
.ap-group-label:first-of-type { margin-top: 4px; }
.ap-express { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.ap-express > div { flex: 1 1 280px; }
.ap-express .a-help { margin: 4px 0 0; }
.ap-opt { position: relative; display: grid; gap: 8px; padding: 10px; border: 1.5px solid var(--a-line); border-radius: var(--a-r); background: var(--a-card); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ap-opt:hover { border-color: #CFCBC3; }
.ap-opt input { position: absolute; opacity: 0; pointer-events: none; }
.ap-opt:has(input:checked) { border-color: var(--a-brand); box-shadow: 0 0 0 3px rgba(227, 27, 35, .14); }
.ap-opt:has(input:focus-visible) { outline: 2px solid var(--a-brand); outline-offset: 2px; }
.ap-opt:has(input:checked)::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--a-brand); color: #fff; font: 700 .7rem/1 var(--a-font); }
.ap-opt-text { display: grid; gap: 2px; line-height: 1.25; }
.ap-opt-text strong { font-size: .92rem; }
.ap-opt-text small { color: var(--a-muted); font-size: .78rem; }
.ap-theme-swatch { position: relative; display: block; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .08); }
.ap-theme-card { position: absolute; left: 10px; bottom: 10px; width: 56%; height: 38px; border-radius: 6px; display: flex; gap: 6px; align-items: center; padding: 0 8px; }
.ap-theme-card i { display: block; width: 16px; height: 16px; border-radius: 50%; }
.ap-theme-swatch b { position: absolute; right: 10px; top: 8px; font: 800 1.3rem/1 var(--a-font); }
.ap-theme-custom { background: conic-gradient(#E31B23, #FFC20E, #1DA851, #2F6FED, #9B51E0, #E31B23); }
.ap-font-sample { display: grid; gap: 4px; min-height: 72px; align-content: center; padding: 8px 10px; border-radius: 8px; background: #F6F5F2; overflow: hidden; }
.ap-font-sample b { font-size: 1.45rem; line-height: 1.05; white-space: nowrap; }
.ap-font-sample span { font-size: .82rem; color: var(--a-muted); white-space: nowrap; }
.ap-mode { grid-template-columns: 40px 1fr; align-items: center; }
.ap-mode-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: #F1EFEA; }
.ap-fine { margin-top: 14px; }
.ap-colors { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ap-custom-fonts, .ap-3d { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--a-line); }
.ap-3d input[type="range"] { width: 100%; accent-color: var(--a-brand); }
.ap-actions { position: sticky; bottom: 12px; z-index: 3; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .25); }
.ap-status { color: var(--a-muted); }
.ap-preview { position: sticky; top: 72px; display: grid; gap: 10px; background: var(--a-card); border: 1px solid var(--a-line); border-radius: var(--a-r); padding: 10px; }
.ap-preview-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ap-seg { display: inline-flex; border: 1px solid var(--a-line); border-radius: 999px; padding: 2px; background: #F1EFEA; }
.ap-seg-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font: 600 .8rem/1 var(--a-font); color: var(--a-muted); cursor: pointer; }
.ap-seg-btn[aria-pressed="true"] { background: var(--a-card); color: var(--a-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.ap-page { width: auto; flex: 1 1 120px; }
.ap-stage { position: relative; height: min(78vh, 900px); min-height: 420px; overflow: hidden; border-radius: 8px; background: #111; display: flex; justify-content: center; }
.ap-stage iframe { flex: none; border: 0; transform-origin: top center; background: #000; }
.ap-loading { position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .7); color: #fff; font: 600 .75rem/1.4 var(--a-font); }
@media (max-width: 1199px) { .ap-preview { position: static; } .ap-stage { height: 70vh; } }

[hidden] { display: none !important; }
