:root {
  --bg: #f4f4f2; --card: #fff; --fg: #1d1d1f; --muted: #6b6b70; --line: #e3e3e0;
  --accent: #e0a800; --accent-fg: #1d1d1f; --red: #c62828; --green: #2e7d32;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: #8a5a00; }
code { background: #f0f0ec; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
h1 { font-size: 26px; margin: 0 0 18px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 12px 24px; background: #1d1d1f; }
.top .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 17px; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.top nav a { color: #ccc; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { background: #333; color: #fff; }
.top nav a.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.top nav .logout { margin-left: auto; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 380px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0; margin-bottom: 10px; }
.card:not(.flush) .card-head { padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid2.wide-left { grid-template-columns: 1.6fr 1fr; }
.screen-page { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 900px) { .grid2, .grid2.wide-left, .screen-page { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .5; }
td.img { width: 56px; padding-right: 0; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; vertical-align: middle; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.hint.pad { padding: 0 16px 14px; }
.tag { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: #f3e7c4; color: #6d4c00; padding: 1px 7px; border-radius: 10px; margin-left: 4px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
code.url { display: inline-block; word-break: break-all; user-select: all; }

.status { font-size: 13px; }
.status::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #aaa; }
.status.on::before { background: var(--green); }
.status.on { color: var(--green); font-weight: 600; }

/* forms */
.form label, .form fieldset { display: block; margin-bottom: 12px; }
label { font-size: 13px; font-weight: 600; color: #444; }
input:not([type=checkbox]):not([type=file]):not([type=color]), select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  font: inherit; font-weight: 400; color: var(--fg); background: #fff;
  border: 1px solid #ccc; border-radius: 6px;
}
input[type=file] { display: block; margin-top: 4px; font-weight: 400; }
input[type=color] { display: block; margin-top: 4px; width: 60px; height: 38px; border: 1px solid #ccc; border-radius: 6px; padding: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 120px; }
.row > .grow { flex: 3 1 240px; }
.w-sm { max-width: 120px; }
.w-md { max-width: 180px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 12px; }
.checks.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.current-img { display: flex; align-items: center; gap: 12px; margin: -4px 0 12px; }
.current-img .preview { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.actions { display: flex; gap: 8px; margin-top: 6px; }

button, .btn {
  display: inline-block; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none;
  padding: 7px 14px; border-radius: 6px; border: 1px solid #ccc; background: #fff; color: var(--fg); cursor: pointer;
}
button:hover, .btn:hover { background: #f2f2f0; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.primary:hover { background: #c99700; }
.small { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--red); border-color: #e6b8b8; }
button.danger:hover { background: #fdeeee; }
.pill { border-radius: 20px; padding: 3px 11px; font-size: 12px; background: #eee; border-color: #ddd; color: #555; }
.pill.red { background: #fdeaea; border-color: #f2b8b8; color: var(--red); }
.pill.green { background: #e8f5e9; border-color: #b9dcbb; color: var(--green); }
form.inline { display: inline; }
.danger-zone { text-align: right; margin: -6px 0 18px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: 20px; text-decoration: none; color: var(--fg); background: #e8e8e4; font-size: 14px; }
.tabs a.active { background: #1d1d1f; color: #fff; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.flash.error { background: #fdeaea; color: #8e1c1c; border-color: #f2c4c4; }

.preview-card { position: sticky; top: 16px; }
.preview-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; }
.preview-frame.portrait { aspect-ratio: 9 / 16; max-width: 340px; margin: 0 auto; }
.preview-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------------------------------------------------------------- platform additions */
.top .logo { color: var(--accent); }
.top .tenant-name { color: #aaa; font-weight: 400; margin-left: 10px; padding-left: 10px; border-left: 1px solid #444; }
.top nav .spacer { flex: 1; }
button.link { background: none; border: 0; color: #ccc; padding: 6px 12px; font-weight: 400; cursor: pointer; }
button.link:hover { color: #fff; background: none; }
.locale-switch button.link { color: var(--muted); }
.locale-switch button.link:disabled { color: var(--fg); font-weight: 600; cursor: default; }
.locale-switch { text-align: center; padding: 0 0 30px; }
.acting { background: #fff4cc; border-bottom: 1px solid #e8d48a; padding: 8px 24px; font-size: 14px; display: flex; gap: 12px; align-items: center; }
.card.narrow-wide { max-width: 720px; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.inline-form { align-items: center; gap: 8px; flex-wrap: nowrap; }
.inline-form input, .inline-form select { margin-top: 0; }
.tag.red { background: #fdeaea; color: var(--red); }
.code-input { font-size: 26px !important; letter-spacing: .2em; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace !important; }

fieldset.translated .row > label { flex: 1 1 200px; position: relative; }
fieldset.translated .lang { position: absolute; right: 10px; top: 13px; font-size: 11px; color: var(--muted); font-weight: 700; pointer-events: none; }
fieldset.translated input { padding-right: 36px; }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.pick { position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fafaf8; margin: 0; }
.pick input { position: absolute; opacity: 0; }
.pick img { width: 100%; height: 100%; object-fit: cover; }
.pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pick:has(input:focus-visible) { outline: 2px solid #1d1d1f; }
.pick.none span { font-size: 12px; color: var(--muted); font-weight: 400; }
.badge-video { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-tile { padding: 0; margin: 0; overflow: hidden; }
.media-tile img, .media-tile .placeholder { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #eee; }
.media-tile .placeholder { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.media-tile .placeholder.error { color: var(--red); background: #fdeaea; }
.media-tile figcaption { padding: 10px 12px; display: grid; gap: 6px; }
.media-tile .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload { max-width: 720px; }

@media (max-width: 700px) {
  .top { padding: 10px 16px; }
  .top nav .spacer { display: none; }
  main { padding: 18px 16px 50px; }
  td, th { padding: 8px; }
}

/* players: agent health, screenshot and remote control */
tr.has-detail td { border-bottom: 0; }
tr.device-detail td { padding-top: 0; }
.device-agent { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.device-agent .grow { flex: 1 1 260px; }
.device-agent .actions { flex-wrap: wrap; margin: 8px 0 4px; }
.screenshot-link { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.screenshot { width: 192px; max-height: 192px; object-fit: contain; background: #000; border: 1px solid var(--line); border-radius: 6px; }
