:root {
  --canvas: #f4f5f4;
  --surface: #ffffff;
  --surface-soft: #f8f9f8;
  --ink: #202326;
  --muted: #6f7472;
  --line: #dfe2e0;
  --sidebar: #202326;
  --sidebar-muted: #aeb3b0;
  --primary: #e84545;
  --primary-dark: #c93636;
  --green: #238767;
  --green-soft: #e5f3ed;
  --amber: #a56818;
  --amber-soft: #fff2d8;
  --red-soft: #fbe8e8;
  --radius: 6px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
svg { width: 17px; height: 17px; stroke-width: 1.8; }
h1, h2, h3, p { margin: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 188px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 12px 14px; color: white; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; color: white; background: var(--primary); border-radius: var(--radius); font-size: 16px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; }
.brand small { margin-top: 3px; color: var(--sidebar-muted); font-size: 10px; }
.navigation { display: grid; gap: 4px; margin-top: 18px; }
.nav-button { height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 11px; border: 0; border-radius: 5px; color: var(--sidebar-muted); background: transparent; text-align: left; font-size: 12px; }
.nav-button:hover { color: white; background: rgba(255,255,255,.06); }
.nav-button.active { color: white; background: #34383a; box-shadow: inset 3px 0 0 var(--primary); }
.server-state { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.server-state strong, .server-state small { display: block; }
.server-state strong { font-size: 11px; }
.server-state small { margin-top: 3px; color: var(--sidebar-muted); font-size: 9px; }
.state-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--amber); }
.server-state.connected .state-dot { background: #47bf92; }
.server-state.error .state-dot { background: #f06d6d; }

.main-content { min-width: 0; padding: 0 24px 32px; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; }
.topbar h1 { margin-top: 4px; font-size: 20px; line-height: 1.2; }
.top-actions, .section-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.user-session { min-width: 0; display: flex; align-items: center; gap: 8px; margin-right: 2px; padding-right: 10px; border-right: 1px solid var(--line); }
.user-session > svg { width: 20px; height: 20px; color: var(--muted); }
.user-session div { min-width: 0; max-width: 150px; }
.user-session strong, .user-session small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-session strong { font-size: 10px; }
.user-session small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.logout-button { flex: none; }
.pairing-dialog { width: min(390px, calc(100vw - 28px)); }
.pairing-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.pairing-qr-panel { display: grid; justify-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pairing-qr { width: 220px; height: 220px; object-fit: contain; border: 1px solid var(--line); background: white; }
.pairing-expiry { margin: 10px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
.pairing-fallback { margin: 10px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
.pairing-fallback strong { display: block; margin-top: 4px; color: var(--ink); font: 700 24px ui-monospace, Consolas, monospace; letter-spacing: 2px; }
.button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 700; white-space: nowrap; }
.button:hover { border-color: #b6bbb8; }
.button.primary { color: white; border-color: var(--primary); background: var(--primary); }
.button.primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.button.dark { color: white; border-color: #34383a; background: #34383a; }
.button.quiet { background: var(--surface); }
.button[aria-disabled="true"] { pointer-events: none; opacity: .48; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); }
.icon-button:hover { border-color: #aeb4b1; background: var(--surface-soft); }

.status-strip { min-height: 66px; display: flex; align-items: center; gap: 0; border-bottom: 1px solid var(--line); }
.status-strip > div { min-width: 106px; display: flex; align-items: baseline; gap: 8px; padding: 0 20px; border-right: 1px solid var(--line); }
.status-strip > div:first-child { padding-left: 0; }
.status-strip span { color: var(--muted); font-size: 11px; }
.status-strip strong { font-size: 22px; }
.status-strip p { margin-left: auto; color: var(--muted); font-size: 10px; }
body.admin-view-active .status-strip { display: none; }
body.admin-view-active #refreshButton,
body.admin-view-active #stopAllButton,
body.admin-view-active #startAllButton,
body.admin-view-active #pairDeviceButton,
body.admin-view-active #openImportButton { display: none; }

.view { display: none; padding-top: 18px; }
.view.active { display: block; }
.panel { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.release-admin-layout { display: grid; grid-template-columns: minmax(0, 720px); gap: 14px; align-items: start; }
.release-admin-layout.admin-enabled { grid-template-columns: minmax(430px, 720px) minmax(520px, 1fr); }
.release-primary-column { min-width: 0; display: grid; gap: 14px; }
.release-card { min-width: 0; }
.release-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.release-card-head strong, .release-card-head small { display: block; }
.release-card-head strong { font-size: 18px; }
.release-card-head small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.release-card > p { max-width: 620px; margin-top: 14px; color: var(--muted); white-space: pre-wrap; line-height: 1.6; font-size: 12px; }
.release-meta { display: flex; flex-wrap: wrap; gap: 18px; margin: 16px 0 0; }
.release-meta dt { color: var(--muted); font-size: 10px; }
.release-meta dd { max-width: 420px; margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; font: 10px Consolas, monospace; }
.release-qr { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 10px; }
.release-qr img { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--line); }
#adminReleasePanel { min-width: 0; }
.release-history-panel { min-width: 0; position: sticky; top: 18px; }
.release-history-table-wrap { max-height: calc(100vh - 190px); }
.admin-table.release-history-table { min-width: 0; table-layout: fixed; }
.release-history-table th:nth-child(1) { width: 37%; }
.release-history-table th:nth-child(2) { width: 14%; }
.release-history-table th:nth-child(3) { width: 29%; }
.release-history-table th:nth-child(4) { width: 20%; }
.release-history-table td:nth-child(3) { white-space: nowrap; }
.release-history-table .row-actions { justify-content: flex-start; }
.section-bar { min-height: 46px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-bar h2 { font-size: 14px; }
.section-bar p { margin-top: 4px; color: var(--muted); font-size: 10px; }
select, input[type="number"] { height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); outline: 0; }
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,69,69,.1); }
.log-filter-controls { display: flex; align-items: center; gap: 8px; }
#logDeviceCodeFilter { width: 190px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); font: 11px Consolas, monospace; text-transform: uppercase; outline: 0; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 240px)); gap: 8px; align-items: start; justify-content: start; }
.device-card { position: relative; min-width: 0; aspect-ratio: 9 / 16; overflow: hidden; border: 1px solid #d3d8d5; border-radius: 10px; color: white; background: #101312; box-shadow: 0 1px 3px rgba(23,28,26,.08); }
.device-card.clickable { cursor: pointer; }
.device-card.clickable:hover { border-color: #aeb7b2; box-shadow: 0 5px 18px rgba(23,28,26,.14); }
.device-card:not(.empty-slot)::before { content: ""; position: absolute; z-index: 1; inset: 0 0 auto; height: 86px; pointer-events: none; background: linear-gradient(180deg, rgba(8,11,10,.72), rgba(8,11,10,.28) 58%, transparent); }
.device-card:not(.empty-slot)::after { content: ""; position: absolute; z-index: 1; inset: auto 0 0; height: 150px; pointer-events: none; background: linear-gradient(0deg, rgba(5,8,7,.16), rgba(5,8,7,.06) 62%, transparent); }
.device-card img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.device-card .device-frame { object-fit: contain; background: #111; }
.device-card.offline img { filter: grayscale(.8) brightness(.72); }
.slot-head { position: absolute; z-index: 3; top: 7px; left: 7px; max-width: calc(100% - 84px); min-height: 29px; display: flex; align-items: center; gap: 5px; padding: 0 8px; overflow: hidden; border: 1px solid rgba(255,255,255,.16); border-radius: 7px; color: #fff; background: rgba(18,22,20,.72); box-shadow: 0 3px 12px rgba(0,0,0,.12); backdrop-filter: blur(8px); }
.slot-head strong, .slot-head .connection-label, .slot-head .profile-role-badge { flex: none; white-space: nowrap; }
.slot-head strong { font-size: 10px; font-weight: 800; letter-spacing: .2px; }
.slot-head .connection-label { color: rgba(255,255,255,.72); font-size: 9px; font-weight: 500; }
.slot-head .profile-role-badge { margin-left: 1px; padding-left: 5px; border-left: 1px solid rgba(255,255,255,.18); color: #ffc4c4; font-size: 9px; }
.device-code-badge { position: absolute; z-index: 3; top: 41px; left: 8px; display: flex; align-items: center; gap: 5px; max-width: calc(100% - 16px); padding: 3px 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; color: rgba(255,255,255,.9); background: rgba(18,22,20,.58); backdrop-filter: blur(7px); }
.device-code-badge span { flex: none; color: rgba(255,255,255,.55); font-size: 8px; }
.device-code-badge code { overflow: hidden; text-overflow: ellipsis; font: 8px ui-monospace, Consolas, monospace; letter-spacing: .25px; }
.slot-head .state-dot { background: #a6aaa8; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.device-card.online .slot-head .state-dot, .device-card.running .slot-head .state-dot { background: #48d29f; }
.device-card.attention .slot-head .state-dot { background: #ffb342; }
.device-run { position: absolute; z-index: 4; top: 7px; right: 7px; width: 29px; height: 29px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.24); border-radius: 7px; color: white; background: rgba(18,22,20,.72); backdrop-filter: blur(8px); }
.device-run:hover { background: var(--primary); border-color: var(--primary); }
.device-run:disabled { cursor: not-allowed; opacity: .45; }
.device-run svg { width: 14px; height: 14px; }
.device-node-check { position: absolute; z-index: 4; top: 7px; right: 41px; width: 29px; height: 29px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.24); border-radius: 7px; color: white; background: rgba(18,22,20,.72); backdrop-filter: blur(8px); }
.device-node-check:hover { background: var(--primary); border-color: var(--primary); }
.device-node-check svg { width: 14px; height: 14px; }
.device-status-panel { position: absolute; z-index: 3; left: 7px; right: 7px; bottom: 7px; display: grid; gap: 7px; padding: 9px; overflow: hidden; border: 1px solid rgba(255,255,255,.2); border-radius: 9px; color: #fff; background: rgba(12,16,14,.52); box-shadow: 0 5px 18px rgba(0,0,0,.16); backdrop-filter: blur(6px) saturate(1.08); }
.device-metrics { display: grid; grid-template-columns: .72fr .72fr 1.22fr 1.22fr; }
.device-metrics > div { min-width: 0; padding: 0 6px; border-right: 1px solid rgba(255,255,255,.11); }
.device-metrics > div:first-child { padding-left: 0; }
.device-metrics > div:last-child { padding-right: 0; border-right: 0; }
.device-metrics span, .device-metrics strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-metrics span { color: rgba(255,255,255,.5); font-size: 7px; line-height: 1.25; }
.device-metrics strong { margin-top: 3px; color: #f7faf8; font-size: 10px; font-weight: 700; line-height: 1.15; }
.device-context-row { min-width: 0; display: flex; align-items: center; gap: 8px; }
.node-check-state { min-width: 0; flex: none; display: inline-flex; align-items: center; gap: 4px; color: #d5dad7; font-size: 8px; white-space: nowrap; }
.node-check-state i { width: 5px; height: 5px; flex: none; border-radius: 50%; background: #8a918d; }
.node-check-state em, .device-remark em { color: rgba(255,255,255,.46); font-style: normal; }
.node-check-state strong { font-size: 8px; font-weight: 600; }
.device-status-panel[data-node-status="passed"] .node-check-state i { background: #4ed09e; }
.device-status-panel[data-node-status="passed"] .node-check-state strong { color: #8ee0c1; }
.device-status-panel[data-node-status="running"] .node-check-state i,
.device-status-panel[data-node-status="partial"] .node-check-state i { background: #ffb451; }
.device-status-panel[data-node-status="running"] .node-check-state strong,
.device-status-panel[data-node-status="partial"] .node-check-state strong { color: #ffd18e; }
.device-status-panel[data-node-status="failed"] .node-check-state i,
.device-status-panel[data-node-status="not_on_xhs"] .node-check-state i,
.device-status-panel[data-node-status="ui_dump_failed"] .node-check-state i { background: #ee7070; }
.device-status-panel[data-node-status="failed"] .node-check-state strong,
.device-status-panel[data-node-status="not_on_xhs"] .node-check-state strong,
.device-status-panel[data-node-status="ui_dump_failed"] .node-check-state strong { color: #ffaaaa; }
.device-remark { min-width: 0; flex: 1; display: flex; align-items: center; gap: 4px; overflow: hidden; color: rgba(255,255,255,.92); font-size: 8px; }
.device-remark strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; font-weight: 600; }
.device-remark.empty strong { color: rgba(255,255,255,.48); font-weight: 400; }
.device-foot { min-width: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.11); }
.device-foot > div { min-width: 0; flex: 1; }
.device-foot .task-caption, .device-foot strong, .device-foot small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-foot .task-caption { color: rgba(255,255,255,.46); font-size: 7px; }
.device-foot strong { margin-top: 2px; color: #fff; font-size: 9px; font-weight: 700; }
.device-foot small { margin-top: 2px; color: rgba(255,255,255,.62); font-size: 8px; }
.action-label { flex: none; padding: 4px 6px; border: 1px solid rgba(255,255,255,.18); border-radius: 5px; color: rgba(255,255,255,.86); background: rgba(255,255,255,.07); font-size: 8px; font-weight: 600; }
.empty-slot { border-color: #d5d9d7; background: #eceeed; }
.empty-slot img { opacity: .18; filter: grayscale(.5); }
.empty-slot::after { content: ""; position: absolute; inset: 0; background: rgba(245,247,246,.56); }
.empty-label { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; color: #707774; font-size: 10px; font-weight: 700; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { height: 39px; padding: 0 12px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; }
td { height: 48px; padding: 7px 12px; border-bottom: 1px solid #eceeec; font-size: 11px; }
.task-select-column { width: 38px; padding-right: 4px; padding-left: 8px; text-align: center; }
.task-select { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.task-action-label { color: var(--ink); font-size: 10px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
td code { font: 11px Consolas, monospace; }
.status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 4px; color: var(--muted); background: #eef0ef; font-size: 9px; font-weight: 700; }
.status-badge.completed { color: var(--green); background: var(--green-soft); }
.status-badge.failed { color: var(--primary-dark); background: var(--red-soft); }
.status-badge.running, .status-badge.claimed { color: var(--amber); background: var(--amber-soft); }
.row-button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 4px; color: var(--muted); background: transparent; }
.row-button:hover { color: var(--ink); background: #eceeec; }
.row-button.danger:hover { color: var(--primary-dark); background: var(--red-soft); }
.row-button:disabled { cursor: wait; opacity: .45; }
.row-button svg { width: 15px; height: 15px; }
.row-actions { display: flex; align-items: center; gap: 2px; }
.release-current-row { background: #f4fbf7; }
.cell-subline { display: block; max-width: 250px; margin-top: 3px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.admin-table { min-width: 940px; }
.admin-metrics { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)); gap: 1px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); }
.admin-metrics > div { min-height: 62px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px; background: var(--surface); }
.admin-metrics span { color: var(--muted); font-size: 10px; }
.admin-metrics strong { font-size: 21px; }
.admin-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.compact-field { width: min(360px, 100%); height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.compact-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,69,69,.1); }
.compact-field svg { width: 15px; color: var(--muted); }
.compact-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.license-table code { white-space: nowrap; }
.status-badge.license-unused { color: var(--muted); background: #eef0ef; }
.status-badge.license-active { color: var(--green); background: var(--green-soft); }
.status-badge.license-expired { color: var(--amber); background: var(--amber-soft); }
.status-badge.license-disabled { color: var(--primary-dark); background: var(--red-soft); }
.empty-table { min-height: 180px; display: none; place-items: center; align-content: center; gap: 8px; color: var(--muted); }
.empty-table.show { display: grid; }
.empty-table svg { width: 24px; height: 24px; }
.empty-table strong { font-size: 11px; }

.log-list { border-top: 1px solid var(--line); }
.log-row { min-height: 48px; display: grid; grid-template-columns: 142px minmax(150px, 1fr) minmax(220px, 2fr) minmax(150px, 1fr); align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 11px; }
.log-row > * { min-width: 0; }
.log-row time, .log-row small { color: var(--muted); }
.log-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .log-message { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.log-row.error strong { color: var(--primary-dark); }

.settings-form { max-width: 760px; }
.settings-form fieldset { margin: 0; padding: 18px 0 22px; border: 0; border-bottom: 1px solid var(--line); }
.settings-form legend { margin-bottom: 14px; padding: 0; font-size: 12px; font-weight: 800; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-grid label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.field-grid label > input { width: 100%; }
.range-input { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) 28px; align-items: center; }
.range-input input:first-child { border-radius: 5px 0 0 5px; }
.range-input input:nth-of-type(2) { border-radius: 0; }
.range-input b, .range-input em { height: 34px; display: grid; place-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 10px; font-style: normal; }
.range-input em { border-right: 1px solid var(--line); border-radius: 0 5px 5px 0; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 18px; }
.settings-help { margin: 10px 0 0; color: var(--muted); font-size: 10px; }
.settings-help-warn { margin: 0 0 12px; padding: 8px 10px; border-left: 3px solid #f0b429; background: rgba(240, 180, 41, 0.08); color: #a06800; font-size: 10px; line-height: 1.6; }
.settings-wide-field { display: block; margin-top: 16px; }
.settings-wide-field > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.settings-wide-field > textarea { width: 100%; box-sizing: border-box; }

.device-drawer { position: fixed; z-index: 20; top: 0; right: 0; width: min(500px, 100%); height: 100vh; overflow: auto; padding: 18px; border-left: 1px solid var(--line); background: var(--surface); box-shadow: -14px 0 36px rgba(28,31,29,.14); transform: translateX(102%); transition: transform .18s ease; }
.device-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; z-index: 19; inset: 0; background: rgba(22,24,23,.38); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.drawer-head span { color: var(--primary); font-size: 10px; font-weight: 800; }
.drawer-head h2 { margin-top: 4px; font-size: 16px; }
.focused-screen { position: relative; width: min(100%, 320px); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border: 4px solid #202326; border-radius: 8px; background: #111; }
.focused-screen img, .focused-screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #111; }
.focused-screen video { display: none; }
.focused-screen.streaming video { display: block; }
.stream-state { position: absolute; z-index: 2; left: 8px; bottom: 8px; padding: 4px 6px; border-radius: 4px; color: white; background: rgba(24,26,25,.72); font-size: 9px; }
.device-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.device-details div { min-width: 0; }
.device-details dt { color: var(--muted); font-size: 9px; }
.device-details dd { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 700; }
.device-remark-form { padding: 12px 0; border-bottom: 1px solid var(--line); }
.device-remark-form label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.device-remark-form label span { font-size: 10px; font-weight: 800; }
.device-remark-form label small { color: var(--muted); font-size: 9px; }
.device-remark-form > div { display: flex; gap: 7px; }
.device-remark-form input { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; outline: 0; }
.device-remark-form .button { flex: none; }
.drawer-actions { display: flex; padding: 14px 0; }
.drawer-actions .button { width: 100%; }
.drawer-actions { flex-wrap: wrap; gap: 7px; }
.drawer-actions .button { flex: 1 1 100%; }
.drawer-actions .button.danger { color: var(--primary-dark); border-color: #f0bcbc; background: var(--red-soft); }
.drawer-actions .button.danger:hover { color: #fff; border-color: var(--primary); background: var(--primary); }
.profile-role-badge { margin-left: auto; color: var(--primary); font-size: 9px; font-weight: 800; }
.profile-switcher { padding: 12px 0; border-bottom: 1px solid var(--line); }
.profile-switcher-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.profile-switcher-head strong { font-size: 10px; }
.profile-switcher-head span { color: var(--muted); font-size: 9px; }
.profile-switcher-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.profile-switcher-item { display: flex; flex: 1 1 45%; min-width: 0; gap: 5px; }
.profile-switcher-item .button { flex: 1 1 auto; min-width: 0; }
.profile-check-button { flex: 0 0 auto; min-width: 76px; }
.profile-detect-button { width: 100%; margin-top: 8px; }
.detected-profile-list { display: grid; gap: 6px; margin-top: 8px; }
.detected-profile-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); background: var(--surface); font-size: 10px; }
.detected-profile-row.selected { border-color: #b9dfd0; background: var(--green-soft); }
.detected-profile-main { min-width: 0; display: grid; grid-template-columns: 46px 72px minmax(0, 1fr); align-items: center; gap: 6px; }
.detected-profile-row strong { color: var(--primary); }
.detected-profile-row span, .detected-profile-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detected-profile-action { flex: none; }
.profile-switch-button { min-height: 28px; padding: 0 8px; font-size: 10px; }
.profile-switch-button svg { width: 13px; height: 13px; }
.profile-current-label { color: var(--green); font-size: 10px; }
.detected-profile-empty { margin-top: 8px; padding: 8px; border: 1px dashed var(--line); color: var(--muted); font-size: 10px; }
.drawer-log-section { padding-top: 4px; }
.drawer-log-section h3 { margin-bottom: 8px; font-size: 11px; }
.drawer-logs { display: grid; }
.drawer-log { padding: 8px 0; border-top: 1px solid #eceeec; font-size: 10px; }
.drawer-log time { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

dialog { width: min(520px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); box-shadow: 0 18px 60px rgba(28,31,29,.22); }
dialog::backdrop { background: rgba(22,24,23,.46); }
dialog form { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.dialog-head h2 { margin-top: 4px; font-size: 17px; }
.input-field > span { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 800; }
textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 5px; outline: 0; font: 12px/1.6 Consolas, monospace; }
.action-mode { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 14px 0 0; padding: 0; border: 0; }
.action-mode legend { margin-bottom: 7px; font-size: 10px; font-weight: 800; }
.action-mode label { position: relative; }
.action-mode input { position: absolute; opacity: 0; }
.action-mode span { height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 10px; cursor: pointer; }
.action-mode input:checked + span { color: var(--primary-dark); border-color: var(--primary); background: var(--red-soft); font-weight: 800; }
.dialog-error { min-height: 18px; margin-top: 8px; color: var(--primary-dark); font-size: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.dialog-subtitle { margin-top: 5px; color: var(--muted); font-size: 10px; }
.generated-result-body { display: grid; gap: 8px; }
.generated-code-list { min-height: 160px; box-sizing: border-box; background: var(--surface-soft); }
.generated-result-hint { margin: 0; color: var(--muted); font-size: 10px; }
.admin-form-grid { display: grid; gap: 12px; }
.admin-form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.release-apk-metadata { margin: -5px 0 0; color: var(--muted); font-size: 10px; }
.admin-form-grid input,
dialog > form > .input-field input { width: 100%; height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); outline: 0; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 20px; min-width: 220px; max-width: calc(100vw - 24px); padding: 10px 13px; border-radius: 5px; color: white; background: #202326; opacity: 0; transform: translate(-50%, 16px); transition: .18s ease; pointer-events: none; text-align: center; font-size: 11px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.node-check-report { display: grid; gap: 7px; }
.node-check-summary { display: grid; gap: 5px; padding: 11px; border-radius: 5px; background: var(--surface-soft); }
.node-check-summary.ok { border-left: 3px solid var(--green); }
.node-check-summary.bad { border-left: 3px solid var(--amber); }
.node-check-summary strong { font-size: 13px; }
.node-check-summary span, .node-check-summary p { color: var(--muted); font-size: 10px; }
.node-check-row { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 10px; }
.node-check-row.ok { border-color: #b9dfd0; background: var(--green-soft); }
.node-check-row.bad { border-color: #ead0a8; background: var(--amber-soft); }
.node-check-row span { color: var(--muted); line-height: 1.4; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(230px, 30vw) minmax(0, 1fr); background: var(--surface); }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 36px; color: white; background: var(--sidebar); }
.auth-brand .brand { align-self: flex-start; padding: 0; border: 0; }
.auth-brand .brand-mark { width: 40px; height: 40px; }
.auth-brand .brand strong { font-size: 15px; }
.auth-brand .brand small { font-size: 11px; }
.auth-brand-copy { max-width: 260px; padding-bottom: 6vh; }
.auth-brand-copy h1 { font-size: 25px; line-height: 1.35; }
.auth-brand-copy p { margin-top: 12px; color: var(--sidebar-muted); font-size: 12px; line-height: 1.8; }
.auth-brand-foot { color: var(--sidebar-muted); font-size: 10px; }
.auth-main { display: grid; place-items: center; min-width: 0; padding: 32px; background: var(--canvas); }
.auth-panel { width: min(390px, 100%); padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.auth-panel-head h2 { font-size: 20px; }
.auth-panel-head p { margin-top: 7px; color: var(--muted); font-size: 11px; }
.auth-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; margin: 22px 0 18px; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.auth-tabs.single { grid-template-columns: 1fr; }
.auth-tab { height: 34px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.auth-tab[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(32,35,38,.12); }
.auth-form { display: grid; gap: 14px; }
.auth-form[hidden] { display: none; }
.auth-field { display: grid; gap: 7px; color: var(--ink); font-size: 10px; font-weight: 700; }
.auth-field input { width: 100%; height: 39px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); outline: 0; }
.auth-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,69,69,.1); }
.auth-submit { width: 100%; min-height: 39px; margin-top: 2px; }
.auth-message { min-height: 18px; color: var(--primary-dark); font-size: 10px; line-height: 1.5; }
.auth-message.success { color: var(--green); }

@media (max-width: 1180px) {
  .device-grid { grid-template-columns: repeat(4, minmax(128px, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; }
  .brand { justify-content: center; padding: 0 0 14px; }
  .brand > div { display: none; }
  .nav-button { justify-content: center; padding: 0; }
  .nav-button span { display: none; }
  .server-state div { display: none; }
  .server-state { justify-content: center; padding: 12px 0 0; }
  .main-content { padding: 0 14px 24px; }
  .topbar { align-items: flex-start; padding: 14px 0; }
  .top-actions { justify-content: flex-end; }
  .top-actions .button span { display: none; }
  .top-actions .button { width: 34px; padding: 0; }
  .user-session div { max-width: 100px; }
  .device-grid { grid-template-columns: repeat(3, minmax(112px, 1fr)); }
  .status-strip > div { min-width: 82px; padding: 0 10px; }
  .status-strip p { display: none; }
  .log-row { grid-template-columns: 118px minmax(0, 1fr); grid-template-areas: "time message" "device task"; align-items: start; row-gap: 4px; }
  .log-row time { grid-area: time; }
  .log-row .log-device { grid-area: device; }
  .log-row .log-message { grid-area: message; }
  .log-row .log-task { grid-area: task; }
}

@media (max-width: 1320px) {
  .release-admin-layout.admin-enabled { grid-template-columns: minmax(0, 720px); }
  .release-history-panel { position: static; }
  .release-history-table-wrap { max-height: none; }
}

@media (max-width: 560px) {
  .auth-page { display: block; background: var(--canvas); }
  .auth-brand { min-height: auto; padding: 18px 20px; }
  .auth-brand .brand { justify-content: flex-start; }
  .auth-brand .brand > div { display: block; }
  .auth-brand-copy, .auth-brand-foot { display: none; }
  .auth-main { display: block; min-height: calc(100vh - 76px); padding: 20px 14px; }
  .auth-panel { width: 100%; max-width: 390px; margin: 4vh auto 0; padding: 22px 18px; }
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; width: 100%; height: 54px; flex-direction: row; align-items: center; padding: 7px 10px; }
  .brand { min-height: 0; padding: 0; border: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .navigation { display: flex; gap: 2px; margin: 0 0 0 auto; }
  .nav-button { width: 38px; height: 38px; }
  .server-state { display: none; }
  .main-content { padding: 0 10px 20px; }
  .topbar { min-height: 64px; }
  .topbar h1 { font-size: 17px; }
  .top-actions .button.quiet { display: none; }
  .user-session { display: none; }
  .status-strip { min-height: 56px; }
  .status-strip > div { min-width: 0; flex: 1; display: grid; gap: 1px; padding: 0 8px; }
  .status-strip > div:first-child { padding-left: 2px; }
  .status-strip strong { font-size: 18px; }
  .section-bar { align-items: center; }
  .section-actions { justify-content: flex-end; }
  .section-actions .button span { display: none; }
  .section-actions .button { width: 34px; padding: 0; }
  .device-grid { grid-template-columns: repeat(2, minmax(116px, 1fr)); gap: 6px; }
  .field-grid { grid-template-columns: 1fr; }
  .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-filter-row { align-items: stretch; flex-direction: column; }
  .compact-field { width: 100%; }
  .admin-form-grid.two-columns { grid-template-columns: 1fr; }
  .release-history-table-wrap { overflow: visible; }
  .admin-table.release-history-table { display: block; width: 100%; }
  .release-history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .release-history-table tbody { display: grid; }
  .release-history-table tbody tr { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "version status actions" "time time time"; align-items: center; column-gap: 8px; padding: 9px 10px; border-bottom: 1px solid #eceeec; }
  .release-history-table tbody tr:last-child { border-bottom: 0; }
  .release-history-table td { width: auto; height: auto; min-width: 0; padding: 0; border: 0; }
  .release-history-table td:nth-child(1) { grid-area: version; }
  .release-history-table td:nth-child(2) { grid-area: status; }
  .release-history-table td:nth-child(3) { grid-area: time; margin-top: 5px; color: var(--muted); font-size: 9px; }
  .release-history-table td:nth-child(4) { grid-area: actions; }
  .release-history-table .status-badge { white-space: nowrap; }
  .log-row { grid-template-columns: 98px minmax(0, 1fr); grid-template-areas: "time message"; row-gap: 0; }
  .log-row small { display: none; }
  .log-row .log-message { display: block; }
}
