/* PlayMateX panel — styled to match the app (dark, rounded, spacious).
   Palette mirrors the app: Bg #0A0A0D, card #161619, chip #1B1B1F, text #F5F5F7 / #A8A8B0.
   The brand accent (buttons/links) is injected per-deployment by brand_style() (--accent). */
:root { --accent: #E11414; --bg: #0A0A0D; --card: #161619; --chip: #1B1B1F; --line: #23232a; --text: #F5F5F7; --muted: #A8A8B0; --dim: #8A8B94; --ok: #15803d; --warn: #f59e0b; --bad: #ef4444; }
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Wide enough that the box / line / log tables fit without a sideways scroll on a desktop monitor (Ian, 2026-09-09);
   .tscroll still catches narrower screens. */
.wrap { min-height: 100vh; max-width: 1800px; margin: 0 auto; padding: 0 24px 72px; }
.acts select { max-width: 220px; padding: 6px 28px 6px 8px; font-size: 12.5px; margin: 0; }

/* ---------- header / nav ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 20px 2px 18px; margin-bottom: 24px; border-bottom: 1px solid #1e1e24;
}
header b { font-size: 19px; font-weight: 800; letter-spacing: .2px; display: flex; align-items: center; white-space: nowrap; }
nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; white-space: nowrap; }
nav a:hover { color: var(--text); background: #16161b; }
nav a.on { color: var(--text); background: var(--chip); }
.who { color: var(--dim); font-size: 13px; margin-left: 8px; }
.pill { display: inline-block; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; margin-left: 4px; vertical-align: 1px; }
.pill.warn { background: #b45309; }
nav a.attn { color: #fcd34d; }
nav a.attn:hover, nav a.attn.on { color: #fde68a; }
tr.confirm td:first-child { border-left: 3px solid #f59e0b; }

h1 { font-size: 19px; font-weight: 800; margin: 0 0 16px; letter-spacing: .2px; }
h1 .muted { font-weight: 600; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 20px; overflow-x: auto; }
.card.narrow { max-width: 400px; margin: 12vh auto 40px; }
.card.narrow label { text-align: left; }
.card.narrow button { width: 100%; margin-top: 4px; }
.narrow0 { max-width: 560px; }
.sub { border: 1px solid #222833; border-radius: 12px; padding: 16px 16px 2px; margin-bottom: 14px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.rowhead h1 { margin: 0; display: flex; align-items: center; gap: 10px; }

/* ---------- forms ---------- */
label { display: block; margin: 0 0 16px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 7px; padding: 11px 14px;
  background: #0E0E11; border: 1px solid #2a2a32; border-radius: 12px;
  color: var(--text); font-size: 14.5px; font-family: inherit; line-height: 1.4;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #55565d; }
input[type="color"] { height: 46px; width: 120px; padding: 4px 6px; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23A8A8B0' stroke-width='2'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.grid .wide { grid-column: 1 / -1; }
label.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; color: var(--text); font-size: 14px; line-height: 1.45; margin-bottom: 14px; }
label.check input { margin-top: 2px; flex: 0 0 auto; }
label.check b { color: var(--text); }

/* ---------- buttons ---------- */
button, a.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 24px;
  padding: 11px 20px; font-size: 14px; font-weight: 800; cursor: pointer; text-decoration: none;
  letter-spacing: .2px; line-height: 1.3; white-space: nowrap; transition: filter .12s, transform .06s;
}
button:hover, a.btn:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.ok { background: #16a34a; }
button.danger { background: #b91c1c; }
button.ghost, a.btn.ghost { background: #26262c; color: var(--text); }
button.small, a.btn.small { padding: 6px 12px; font-size: 12.5px; border-radius: 16px; font-weight: 700; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.acts { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.acts form { display: inline; margin: 0; }
form.inline { display: flex; gap: 6px; align-items: center; margin: 0; }
form.inline select { margin: 0; padding: 6px 30px 6px 10px; font-size: 13px; min-width: 200px; max-width: 260px; background-position: right 10px center; }

/* ---------- search bar ---------- */
.search { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; }
.search input, .search select { margin: 0; }
.search input { flex: 1; }
.search select { width: auto; min-width: 170px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #1e1e24; vertical-align: middle; }
th { color: var(--dim); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody tr:hover { background: #101014; }
td.nowrap, .nowrap { white-space: nowrap; }
td .tiny { display: block; margin-top: 2px; }
.ellip { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

code {
  background: #0E0E11; padding: 3px 8px; border-radius: 7px; font-size: 12.5px;
  color: var(--text); font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; white-space: nowrap;
}
code.brk { white-space: normal; word-break: break-all; }
.muted { color: var(--dim); }
.tiny { color: var(--dim); font-size: 11.5px; font-weight: 600; letter-spacing: .3px; }
a { color: var(--accent); }
td a { font-weight: 700; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ---------- status ---------- */
.flash { background: #10240f; border: 1px solid #1f6b2e; color: #86efac; padding: 13px 16px; border-radius: 12px; margin-bottom: 20px; }
.err   { background: #2a1010; border: 1px solid #7f1d1d; color: #fca5a5; padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; }
.maint { background: #2e2410; border: 1px solid #a16207; color: #fcd34d; padding: 13px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 600; }
.maint a { color: #fde68a; }
.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.badge.active { background: #10240f; color: #86efac; }
.badge.suspended { background: #2e2410; color: #fcd34d; }
.badge.revoked { background: #2a1010; color: #fca5a5; }
.badge.muted { background: var(--chip); color: var(--muted); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; text-decoration: none; color: inherit; }
.stat:hover { border-color: #33333c; }
.stat.warn { border-color: #b45309; }
.stat.warn .n { color: #f59e0b; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols2 .card { margin-bottom: 0; }
.cols2 + .card { margin-top: 16px; }
.cols2 table td { padding: 8px 6px; vertical-align: middle; }
@media (max-width: 900px) { .cols2 { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(3, 1fr); } }
.stat .n { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--dim); font-size: 12.5px; font-weight: 600; margin-top: 4px; white-space: nowrap; }

/* ---------- line page ---------- */
.pinbox { background: #0E0E11; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 0 0 20px; }
.pin { display: inline-block; font: 800 34px/1.1 "SF Mono", ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; border: 2px solid var(--accent); border-radius: 12px; padding: 10px 18px; margin: 8px 0; color: #fff; background: var(--card); }
.kv { gap: 0 28px; margin-top: 4px; }
.kv > div { padding: 10px 0; border-bottom: 1px solid #1e1e24; }
.kv > div > div:last-child { margin-top: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) {
  .wrap { padding: 0 14px 48px; }
  .card { padding: 18px; border-radius: 14px; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .search { flex-wrap: wrap; }
  .search input { flex: 1 1 100%; }
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  form.inline select { min-width: 150px; }
}
.acts { flex-wrap: wrap; row-gap: 6px; }
.grid > button { width: auto; }

/* ---- polish pass (tables + forms) ---- */
th, td { padding: 10px 10px; }
code { font-size: 12px; padding: 3px 7px; }
.grid > button, .grid > .btnrow { justify-self: start; width: auto; grid-column: 1 / -1; }
form.inline { flex-wrap: wrap; row-gap: 6px; }
form.inline select { min-width: 150px; max-width: 190px; }
.acts { flex-wrap: wrap; row-gap: 6px; }
.acts button.small { padding: 6px 11px; }
td .badge { vertical-align: middle; }
td.assign { min-width: 260px; }
td.assign > div { margin-top: 6px; }
.card { overflow: visible; }
.tscroll { overflow-x: auto; }
td.nowrap .tiny { white-space: normal; }
code.brk { display: block; padding: 10px 12px; line-height: 1.5; margin-top: 6px; }

/* ---------- audit pass 2026-09-09: contrast, focus, print, classes for former inline styles ---------- */
::placeholder { color: #7a7b84; opacity: 1; }
td a, .cols2 a, table a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(255,255,255,.25); text-underline-offset: 3px; }
td a:hover, table a:hover { text-decoration-color: var(--accent); }
button.ok { background: var(--ok); }
button.danger.ghost { background: var(--chip); color: var(--bad); border: 1px solid #3a2222; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat .l { white-space: normal; }
.linkbtn { background: none; border: 0; padding: 0; margin: 0; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--text); }
form.i { display: inline; }
.h-sub { font-size: 12px; }
.mt6 { margin-top: 6px; } .mt12 { margin-top: 12px; }
.keyblock { font-size: 11px; }
.warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
th.sorted a { color: var(--text); }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--text); }
.notef { display: flex; gap: 6px; align-items: center; }
.notef input { width: 150px; min-width: 110px; padding: 6px 9px; font-size: 13px; }
.renew { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -6px 0 18px; }
.renew select { width: auto; padding: 8px 32px 8px 12px; }
.stats4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .stats4 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- charts (Stats page) ---------- */
.charts .card { margin-bottom: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chart-title { font-size: 16px; font-weight: 800; }
.chart-sub { color: var(--dim); font-size: 12px; margin: 2px 0 12px; }
.chart-body { position: relative; min-height: 120px; }
.chart-body { overflow: hidden; }
.chart-body svg { display: block; overflow: hidden; }
.charts .card { overflow: hidden; }
.chart-tip { position: absolute; z-index: 5; background: #0e0e11; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.chart-tip .tip-h { color: var(--dim); margin-bottom: 4px; }
.chart-tip .tip-r { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tip .tip-r b { color: var(--text); margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; }
.legend-item { background: none; border: 0; padding: 4px 6px; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; }
.legend-item:hover { color: var(--text); background: var(--chip); }
.legend-item.off { opacity: .45; text-decoration: line-through; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 13px; }
.chart-table { width: 100%; font-variant-numeric: tabular-nums; }
.chart-table td:not(:first-child), .chart-table th:not(:first-child) { text-align: right; }
.range .btn { padding: 6px 12px; }

@media print {
  body { background: #fff; color: #000; }
  header, nav, .btnrow, button, form, .flash, .err, .card:not(.print) { display: none !important; }
  .pinbox { display: block !important; border: 1px solid #000; color: #000; background: #fff; }
  .pinbox .pin { color: #000; border-color: #000; }
  #slip { display: block !important; width: 100%; border: 0; color: #000; background: #fff; font-size: 14px; }
}

/* ---------- live log ---------- */
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 0 rgba(22,163,74,.6); animation: livepulse 2s infinite; vertical-align: middle; }
.live-dot.off { background: var(--dim); animation: none; box-shadow: none; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6); } 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.rowhead select, .rowhead input { margin: 0; width: auto; padding: 8px 12px; font-size: 13px; }
.rowhead select { padding-right: 32px; }
.logtable td { padding: 7px 10px; }
.logtable tr.fresh { background: #10240f; }
.logtable tr.k-activate td:nth-child(2) { color: var(--warn); font-weight: 700; }
.logtable tr.k-support td:nth-child(2) { color: #3987e5; font-weight: 700; }
