/* ================= Admin control centre (public/control.js) =================
   Layout and look follow the PNQA flashcards control centre, drawn with teamworkpnqa's theme tokens. */
:root { --cc-good: var(--status-done, var(--accent)); --cc-bad: var(--status-error, var(--danger, var(--accent))); --cc-line: var(--border); }

/* ---------- logo hold ring ---------- */
.pn-brand { -webkit-touch-callout: none; }
.pn-brand .pn-mark { position: relative; }
.cc-hold { position: absolute; inset: -5px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .15s; background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), color-mix(in srgb, currentColor 18%, transparent) 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); }
.cc-hold.on { opacity: 1; }
.pn-brand.cc-holding { user-select: none; -webkit-user-select: none; }

/* ---------- announcement banner + maintenance ---------- */
.cc-banners { display: flex; flex-direction: column; gap: 8px; padding: 12px 22px 0; }
.cc-banners:empty { display: none; }
.cc-ann { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); border-left-width: 4px; border-radius: 10px; padding: 10px 8px 10px 14px; font-size: 13px; }
.cc-ann.high { border-color: var(--cc-bad); }
.cc-ann.notice { border-color: var(--border); border-left-color: var(--accent); }
.cc-ann > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cc-ann b { font-weight: 600; }
.cc-ann p { margin: 2px 0 0; white-space: pre-line; color: var(--muted); line-height: 1.5; }
.cc-ann button { flex: none; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; width: 30px; height: 30px; border-radius: 7px; }
.cc-ann button:hover { background: var(--surface-2); color: var(--text); }
.cc-maint { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 20px; background: var(--surface-2); color: var(--text); }
.cc-maint > div { max-width: 460px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; }
.cc-maint h1 { margin: 0 0 10px; font-size: 22px; }
.cc-maint p { margin: 0; color: var(--muted); line-height: 1.6; white-space: pre-line; }

/* ---------- shared controls ---------- */
.cc-root, .cc-dlg { font-family: inherit; color: var(--text); }
.cc-root .btn, .cc-dlg .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 13px; line-height: 1.2; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.cc-root .btn:hover, .cc-dlg .btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.cc-root .btn.primary, .cc-dlg .btn.primary { background: var(--accent-strong, var(--accent)); border-color: var(--accent-border, var(--accent)); color: var(--accent-contrast, var(--surface)); }
.cc-root .btn.bad, .cc-dlg .btn.bad { background: var(--cc-bad, var(--danger)); border-color: var(--cc-bad, var(--danger)); color: var(--accent-contrast, var(--surface)); }
.cc-root .btn.small { padding: 5px 9px; font-size: 12px; }
.cc-root .btn:disabled, .cc-dlg .btn:disabled { opacity: .55; cursor: default; }
.cc-root .iconbtn { border: 1px solid transparent; background: none; color: var(--text); width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; font-size: 18px; }
.cc-root .iconbtn:hover { background: var(--surface-2); border-color: var(--border); }
.cc-root input, .cc-root textarea, .cc-root select, .cc-dlg input, .cc-dlg textarea, .cc-dlg select { font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.cc-root input[type=checkbox], .cc-dlg input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
.cc-root :focus-visible, .cc-dlg :focus-visible { outline: 2px solid var(--focus, var(--accent)); outline-offset: 2px; }

/* ---------- control centre frame ---------- */
.cc-root { position: fixed; inset: 0; z-index: 1000; background: var(--surface-2); display: flex; animation: cc-in .18s ease-out; }
@keyframes cc-in { from { transform: translateY(6px); } }
.cc { flex: 1; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.cc-nav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.cc-co { display: flex; align-items: center; gap: 10px; padding: 2px 4px 14px; }
.cc-co img { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.cc-co b { font-weight: 650; font-size: 14px; display: block; }
.cc-co small { color: var(--muted); font-size: 11px; }
.cc-nav button { display: flex; gap: 11px; align-items: center; border: 0; background: none; color: var(--text); border-radius: 8px; padding: 9px 10px; text-align: left; font: inherit; font-size: 13.5px; cursor: pointer; }
.cc-nav button:hover { background: var(--surface-2); }
.cc-nav button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.cc-nav .ic { width: 18px; height: 18px; flex: none; color: var(--muted); }
.cc-nav button[aria-current="true"] .ic { color: var(--accent-text, var(--accent)); }
.cc-nav .cc-count { margin-left: auto; font-size: 11px; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 99px; background: var(--accent-strong, var(--accent)); color: var(--accent-contrast, var(--surface)); }
.cc-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cc-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.cc-top .cc-menu { display: none; }
.cc-crumb { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-crumb b { color: var(--text); font-weight: 600; }
.cc-crumb span { padding: 0 5px; }
.cc-me { text-align: right; line-height: 1.25; max-width: 240px; }
.cc-me b { display: block; font-weight: 500; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.cc-me small { color: var(--muted); font-size: 11px; }
.cc-timer { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.cc-page { flex: 1; min-height: 0; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; outline: none; }
.cc-page > * { flex: none; }
.cc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.cc-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 3px; }
.cc-stat b { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cc-stat span { color: var(--muted); font-size: 12.5px; }
.cc-stat small { color: var(--muted); font-size: 11px; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.cc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.cc-card h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 600; }
.cc-card p { margin: 0 0 10px; }
.cc-note, .cc-empty-text { color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.cc-bars { width: 100%; display: block; }
.cc-bars rect { fill: var(--accent); }
.cc-bars g:hover rect { opacity: .6; }
.cc-bars text { font-size: 11px; fill: var(--muted); }
.cc-ol { margin: 0; padding: 0; list-style: none; }
.cc-ol li { display: flex; gap: 12px; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cc-ol li:last-child { border: 0; }
.cc-ol span { min-width: 0; overflow-wrap: anywhere; }
.cc-ol b { font-weight: 500; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.cc-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cc-tools h2 { margin: 0; flex: 1 1 200px; font-size: 19px; font-weight: 650; }
.cc-tools h2 small { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.cc-tools input[type=search] { flex: 0 1 240px; }
.cc-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.cc-seg button { border: 0; background: none; color: var(--text); font: inherit; font-size: 12.5px; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.cc-seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

.cc-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.cc-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.cc-t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.cc-t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.cc-t tr:last-child td { border-bottom: 0; }
.cc-t td small { display: block; color: var(--muted); }
.cc-t td.cc-body { white-space: pre-line; max-width: 420px; }
.cc-act { text-align: right; white-space: nowrap; }
.cc-act .btn + .btn { margin-left: 6px; }
.cc-pill { display: inline-block; border: 1px solid currentColor; border-radius: 99px; padding: 1px 9px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cc-pill.ok, .cc-pill.live, .cc-pill.resolved { color: var(--cc-good); }
.cc-pill.bad, .cc-pill.open, .cc-pill.high, .cc-pill.failed { color: var(--cc-bad); }
.cc-pill.accent { color: var(--accent-text, var(--accent)); }
.cc-empty { margin: 30px auto; text-align: center; padding: 30px 20px; color: var(--muted); }
.cc-empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.cc-sk { height: 70px; border-radius: 12px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 200% 100%; animation: cc-sk 1.2s linear infinite; }
@keyframes cc-sk { to { background-position: -200% 0; } }
.cc-form { max-width: 640px; }
.cc-form label, .cc-box label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.cc-form label small, .cc-box label small { font-weight: 400; color: var(--muted); }
.cc-form label.ck, .cc-box label.ck { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.cc-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.cc-inline > label { margin-bottom: 0; }
.cc-msg { font-size: 12.5px; color: var(--muted); min-height: 1.2em; margin: 6px 0 0; }
.cc-msg.bad { color: var(--cc-bad); }

/* ---------- dialogs ---------- */
.cc-dlg { position: fixed; inset: 0; z-index: 1010; background: var(--backdrop, color-mix(in srgb, var(--text) 45%, transparent)); display: grid; place-items: center; padding: 16px; overflow: auto; animation: cc-in .12s ease-out; }
.cc-box { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; width: min(100%, 500px); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 70px color-mix(in srgb, var(--text) 30%, transparent); }
.cc-box > * { flex: none; }
.cc-box.wide { width: min(100%, 760px); }
.cc-box h2 { margin: 0; font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.cc-box p { margin: 0; font-size: 13px; line-height: 1.6; }
.cc-box textarea { resize: vertical; line-height: 1.45; }
.cc-box .cc-lock { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text, var(--accent)); font-size: 20px; }
.cc-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.cc-err { color: var(--cc-bad, var(--danger)); font-size: 13px; min-height: 1.2em; margin: 0; }
.cc-err:empty { min-height: 0; }
.cc-hist { list-style: none; margin: 0; padding: 0; }
.cc-hist li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cc-hist li > div { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.cc-hist small { display: block; color: var(--muted); }
.cc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.cc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cc-toasts { position: fixed; z-index: 1020; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.cc-toast { background: var(--text); color: var(--surface); border-radius: 10px; padding: 10px 16px; font-size: 13px; line-height: 1.4; box-shadow: 0 10px 30px color-mix(in srgb, var(--text) 30%, transparent); transition: opacity .3s, transform .3s; text-align: center; }
.cc-toast.bad { background: var(--cc-bad); color: var(--accent-contrast, var(--surface)); }
.cc-toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .cc { grid-template-columns: minmax(0, 1fr); }
  .cc-nav { position: fixed; z-index: 2; inset: 0 auto 0 0; width: 260px; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 50px color-mix(in srgb, var(--text) 35%, transparent); }
  .cc.menu .cc-nav { transform: none; }
  .cc-top .cc-menu { display: inline-grid; }
  .cc-me { display: none; }
}
@media (max-width: 720px) {
  .cc-page { padding: 12px; }
  .cc-timer { display: none; }
  .cc-banners { padding: 10px 10px 0; }
  .cc-two { grid-template-columns: 1fr; }
  .cc-page .cc-scroll { border: 0; background: none; overflow: visible; }
  .cc-page .cc-scroll .cc-t thead { display: none; }
  .cc-page .cc-scroll .cc-t tr { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
  .cc-page .cc-scroll .cc-t td { display: flex; justify-content: space-between; gap: 14px; border: 0; padding: 5px 0; text-align: right; max-width: none; }
  .cc-page .cc-scroll .cc-t td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .cc-act { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .cc-act .btn + .btn { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .cc-root, .cc-dlg, .cc-nav { animation: none; transition: none; } .cc-sk { animation: none; } }
