:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --panel: #fff;
  --panel-2: #f3f6fa;
  --border: #dce3ed;
  --text: #18273e;
  --muted: #586a80;
  --accent: #2159cb;
  --accent-dim: #eaf1ff;
  --ok: #08795d;
  --ok-dim: #e3f5ed;
  --danger: #b73742;
  --danger-dim: #fff0f0;
  --warn: #95600c;
  --warn-dim: #fff2d8;
  --nav: #14243d;
  --mono: "Cascadia Code", Consolas, "SFMono-Regular", "Microsoft YaHei", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--sans); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #4286e2; outline-offset: 2px; }
a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.mono, code { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon { height: 18px; width: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand-symbol { display: block; width: 37px; height: 37px; position: relative; flex: none; border-radius: 10px; background: #427ef1; box-shadow: inset 0 0 0 1px #ffffff38; }
.brand-symbol::before { content: ""; position: absolute; inset: 8px; border: 3px solid #fff; border-radius: 5px 9px 5px 9px; }
.brand-symbol::after { content: ""; position: absolute; width: 11px; height: 3px; left: 21px; top: 25px; background: #b8d9ff; transform: rotate(45deg); border-radius: 1px; }
.brand-wordmark { font: 740 21px/1.02 var(--sans); letter-spacing: -.8px; }
.brand-wordmark span { display: block; font: 500 10px/1.5 var(--sans); letter-spacing: .55px; opacity: .74; margin-top: 3px; }

.login-screen { height: 100vh; height: 100dvh; overflow: auto; display: grid; place-items: safe center; padding: 20px; background: linear-gradient(150deg, #12243c, #1b3455 65%, #253e60); }
.login-card { width: min(100%, 410px); padding: 34px; background: #fff; border-radius: 17px; box-shadow: 0 20px 80px #07132654; }
.login-card .brand { margin-bottom: 30px; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
.login-card p { margin: 6px 0 22px; }
.login-card form { display: grid; gap: 9px; }
.login-card form label { font-weight: 650; }
.login-card .btn { margin-top: 8px; }
.form-error { color: var(--danger); }
.form-error:empty { margin: 0; }

.app-shell { display: flex; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.sidebar { flex: 0 0 216px; width: 216px; height: 100%; min-height: 0; display: flex; flex-direction: column; color: #f2f6ff; background: var(--nav); }
.sidebar-head { padding: 28px 21px 24px; border-bottom: 1px solid #ffffff15; }
.nav { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow-y: auto; gap: 21px; padding: 24px 13px; }
.nav-group { display: grid; gap: 3px; }
.nav-label { padding: 0 12px 5px; color: #9aaec8; font-size: 11px; font-weight: 650; }
.nav-btn { display: flex; align-items: center; gap: 11px; border: 0; border-radius: 7px; background: transparent; color: #d2def0; min-height: 40px; padding: 8px 11px; text-align: left; white-space: nowrap; }
.nav-btn .icon { width: 17px; height: 17px; color: #a3b6d0; }
.nav-btn:hover, .sidebar-foot .btn:hover:not(:disabled) { background: #213653; color: #fff; }
.nav-btn.active { background: #2a4570; color: #fff; font-weight: 650; box-shadow: inset 3px 0 #75a4ff; }
.nav-btn.active .icon { color: #aecaff; }
.sidebar .badge { margin-left: auto; padding: 0 6px; min-width: 21px; font-size: 10px; background: #30445f; color: #dce8fa; }
.sidebar .badge.danger { color: #ffd3d6; background: #593746; }
.sidebar .badge.warn { color: #ffe4b3; background: #4a413a; }
.mobile-navigation, .page-selection span { display: none; }
.page-selection { display: inline-flex; align-items: center; }
.sidebar-foot { display: grid; gap: 3px; padding: 12px 13px 18px; border-top: 1px solid #ffffff1c; }
.sidebar-foot .btn { justify-content: flex-start; gap: 11px; padding: 8px 11px; color: #d0def1; border-color: transparent; background: transparent; }
.sidebar-foot .icon { width: 16px; height: 16px; }

.main { --gutter: clamp(18px, 2.65vw, 44px); display: grid; grid-template-rows: auto minmax(0, 1fr); flex: 1; min-width: 0; min-height: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 21px var(--gutter) 19px; border-bottom: 1px solid var(--border); background: #fff; }
.page-heading { min-width: 0; }
.workspace-context { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 550; }
.workspace-context .icon { width: 14px; height: 14px; color: var(--accent); }
.topbar h2 { margin: 4px 0 0; font-size: clamp(22px, 2.1vw, 30px); font-weight: 680; line-height: 1.27; letter-spacing: -.6px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
#last-refresh { font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.view { width: min(100%, 1800px); min-width: 0; min-height: 0; margin-inline: auto; padding: 18px var(--gutter); }
.content-view { display: flex; flex-direction: column; gap: 17px; overflow: auto; overscroll-behavior: contain; }
.content-view > *, .drawer-body > * { flex-shrink: 0; }
.list-view { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; }
.list-view > [data-list-scroll] { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.list-view > .card-list { align-content: start; padding: 1px; }
.list-view > .table-wrap { max-height: none; align-self: start; max-block-size: 100%; }
.list-view > :is(.toolbar, .release-tools) { max-height: 32dvh; overflow: auto; overscroll-behavior: contain; }
.list-view > .list-pagination { align-self: end; }
.table-wrap thead th { position: sticky; top: 0; z-index: 1; }
.table-wrap thead th:last-child { z-index: 2; }
.release-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 8px; }
.release-tool { min-width: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.release-tool > summary { padding: 10px 12px; color: var(--text); font-weight: 650; font-size: 13px; cursor: pointer; }
.release-tool > summary::marker { color: var(--accent); }
.release-tool-body { padding: 0 12px 12px; }
.release-tool-body p { font-size: 12px; }
.release-tool .upload-grid, .release-tool #auto-ota-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.release-tool input, .release-tool select { width: 100%; }
.release-tool input[type=checkbox] { width: 16px; }
.release-tool .btn { white-space: normal; }
.release-notes-cell, .release-filename { max-width: clamp(140px, 20vw, 300px); }
.data-table td:is(.release-notes-cell, .release-filename) { white-space: normal; overflow-wrap: anywhere; }
.release-notes-preview { font: 12px/1.55 var(--sans); }
.release-notes-open { margin-left: 5px; }
.release-notes-full { white-space: pre-wrap; overflow-wrap: anywhere; flex-shrink: 0; }

input:not([type=checkbox]), select, textarea { min-width: 0; padding: 8px 10px; color: var(--text); background: #fff; border: 1px solid #c8d3e1; border-radius: 6px; }
input::placeholder, textarea::placeholder { color: #69798d; opacity: 1; }
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color: #6191de; outline: 2px solid #c4d8fc; outline-offset: 0; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; margin: 0; }
input[type=file] { max-width: 100%; font-size: 12px; }
input::file-selector-button { border: 0; border-right: 1px solid var(--border); padding: 3px 10px 3px 0; margin-right: 8px; color: var(--accent); background: transparent; cursor: pointer; }
textarea { width: 100%; resize: vertical; }
.btn, .chip, .list-pagination button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 36px; padding: 6px 13px; border: 1px solid #c6d2e2; border-radius: 6px; background: #fff; color: #263c58; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.btn:hover:not(:disabled), .chip:hover, .list-pagination button:hover:not(:disabled) { border-color: #8eadd2; background: #f1f6ff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1649ae; border-color: #1649ae; }
.btn.danger, .chip.danger { background: var(--danger-dim); border-color: #efc4c8; color: var(--danger); }
.btn.danger:hover:not(:disabled), .chip.danger:hover { background: #fce1e3; border-color: #e49da5; }
.btn.ghost { color: var(--accent); background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--accent-dim); border-color: transparent; }
.btn.small, .chip, .list-pagination button { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.btn .icon { width: 15px; height: 15px; }
.btn.full { width: 100%; }
.btn:disabled, .list-pagination button:disabled { opacity: .5; }

.panel, .kpi, .item-card, .toolbar, .list-pagination { min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.panel { padding: 19px 20px; }
.panel.compact { padding: 17px; }
.panel h3, .panel h4, .panel legend { margin: 0 0 14px; color: var(--text); font-size: 15px; font-weight: 670; }
.panel h4 { font-size: 14px; }
.panel-head, .chart-heading { display: flex; align-items: center; }
.panel-head { justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.panel-head h3 { margin: 0; }
.chart-heading { gap: 8px; }
.chart-heading .icon { color: #6885a7; width: 17px; height: 17px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; display: grid; gap: 4px; padding: 16px 18px; font: inherit; text-align: left; color: var(--text); }
.kpi:hover { border-color: #91b1dc; box-shadow: 0 2px 7px #263e5e0d; }
.kpi-label { font-weight: 620; font-size: 13px; padding-right: 32px; }
.kpi-icon { position: absolute; right: 15px; top: 14px; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-dim); color: var(--accent); }
.metric-ok .kpi-icon { background: var(--ok-dim); color: var(--ok); }
.metric-danger .kpi-icon { background: var(--danger-dim); color: var(--danger); }
.metric-warn .kpi-icon { background: var(--warn-dim); color: var(--warn); }
.kpi-icon .icon { width: 16px; height: 16px; stroke-width: 1.85; }
.kpi-val { font: 660 clamp(28px, 3vw, 39px)/1.16 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -1.5px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.bar-list { display: grid; gap: 11px; }
.bar-list p, #overview-recent-errors > p, .card-list > .muted { margin: 0; padding: 17px 12px; text-align: center; font-size: 13px; }
.bar-list p { background: #f7f9fc; border-radius: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(78px, 26%) 1fr minmax(26px, auto); gap: 12px; align-items: center; font-size: 12px; }
.bar-row > span:first-child { overflow-wrap: anywhere; }
.bar-track { height: 7px; background: #edf1f6; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: #4b7bd6; border-radius: inherit; }
#overview-sources .bar-fill { background: #ba7655; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; padding: 2px 7px; background: #edf1f7; color: #475b73; font: 600 11px/1.55 var(--sans); font-variant-numeric: tabular-nums; }
.badge.ok { background: var(--ok-dim); color: var(--ok); }
.badge.danger { background: var(--danger-dim); color: var(--danger); }
.badge.warn, .chip.warn { background: var(--warn-dim); color: var(--warn); }
.badge.accent { background: var(--accent-dim); color: var(--accent); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: #159572; }
.dot.off { background: #8292a5; }
.dot.revoked { background: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 12px 14px; }
.toolbar input[type=search] { flex: 1 1 190px; max-width: 440px; }
.toolbar select { max-width: 100%; }
.toolbar-right, .row-actions, .cmd-bar, .quick-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar-right { margin-left: auto; }
.toolbar-right .muted { font-size: 12px; }
.table-wrap { padding: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #b9c6d7 #f3f6fa; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.data-table th, .data-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #e7ecf3; white-space: nowrap; }
.data-table th { color: #485c75; font-weight: 650; background: #f5f7fb; }
.data-table td { background: #fff; }
.data-table tr:hover td { background: #f7faff; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.row-actions { display: table-cell; }
.data-table td.row-actions button + button { margin-left: 5px; }
.device-table-wrap th { position: sticky; top: 0; z-index: 1; }
.device-table-wrap th:first-child, .device-table-wrap td:first-child { width: 36px; text-align: center; }
.device-table-wrap tr:has(.dev-check:checked) td { background: #eff5ff; }
.data-table th:last-child, .data-table td:last-child { position: sticky; right: 0; box-shadow: -1px 0 #dce3ed; }
.device-table-wrap th:last-child { z-index: 2; }
.card-list { display: grid; gap: 10px; }
.item-card { padding: 14px 16px; }
.item-head, .item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.item-head { justify-content: space-between; gap: 8px 14px; }
.item-meta, .item-head .muted { font-size: 12px; }
.item-meta { min-width: 0; overflow-wrap: anywhere; }
.item-msg { margin-top: 8px; font: 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: #293d57; }
#overview-recent-errors .item-card { padding: 12px 0; margin: 0 !important; border: 0; border-top: 1px solid #e6ecf3; border-radius: 0; }
.item-detail { margin-top: 10px; }
.item-detail summary { font-size: 12px; color: var(--accent); cursor: pointer; }
.terminal { background: #162338; color: #e5edf9; border: 1px solid #273953; border-radius: 7px; padding: 12px; margin: 6px 0 0; font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; }
.list-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px 15px; padding: 10px 14px; color: var(--muted); font-size: 12px; }
.list-pagination:empty { display: none; }
.pagination-summary { margin-right: auto; }
.pagination-size, .pagination-controls { display: inline-flex; align-items: center; gap: 6px; }
.pagination-size select { padding: 4px 7px; min-height: 31px; }
.pagination-page { color: var(--text); font-variant-numeric: tabular-nums; }
.list-pagination [aria-current="page"] { color: var(--accent); background: var(--accent-dim); border-color: #c1d6fa; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; background: #0d1b3099; }
.drawer, .modal { min-width: 0; display: flex; flex-direction: column; background: var(--bg); box-shadow: 0 15px 60px #0a192c36; }
.drawer { width: min(760px, 100%); height: 100%; }
.modal { margin: auto; width: min(680px, calc(100% - 28px)); max-height: 88vh; max-height: 88dvh; border-radius: 12px; overflow: hidden; }
.drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; background: #fff; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.drawer-head .btn { width: 32px; color: var(--muted); }
.drawer-head .muted { font-size: 12px; }
.drawer-body { min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 13px; padding: 16px 20px; }
.drawer-body p { margin: 0; overflow-wrap: anywhere; }
.form-grid, .upload-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid label, #webhook-fields label { display: grid; align-content: start; gap: 5px; color: var(--muted); font-size: 12px; }
.form-grid .checkbox-label, .checkbox-label, #webhook-fields label:has(input[type=checkbox]) { display: flex; align-items: center; align-self: center; gap: 8px; color: var(--text); }
.span-2 { grid-column: span 2; }
.quick-chips, .cmd-bar { margin-bottom: 9px; }
.chip { min-height: 28px; font-weight: 500; }
.upload-grid { grid-template-columns: minmax(130px, 1.2fr) 1fr 1.2fr auto; align-items: center; }
#auto-ota-form { grid-template-columns: max-content minmax(180px, 1fr) auto; }
#webhook-form { width: 100%; max-width: 760px; }
#webhook-fields { display: grid; min-width: 0; gap: 16px; margin: 0; padding: 0; border: 0; }
#webhook-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#webhook-save { justify-self: start; }
#webhook-status:empty, #rel-status:empty { display: none; }

@media (max-width: 1100px) {
  .sidebar { width: 186px; flex-basis: 186px; }
  .sidebar-head { padding-inline: 16px; }
  .nav { padding-inline: 9px; }
  .nav-btn { gap: 8px; }
  .kpi-grid { gap: 10px; }
  .kpi { padding: 13px; }
  .kpi-icon { top: 12px; right: 10px; }
  .upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { width: 100%; height: auto; position: relative; display: grid; grid-template-columns: 1fr auto; }
  .sidebar-head { border: 0; padding: 10px 16px; }
  .sidebar .brand-symbol { width: 31px; height: 31px; border-radius: 8px; }
  .sidebar .brand-symbol::before { inset: 6px; }
  .sidebar .brand-symbol::after { left: 18px; top: 21px; }
  .sidebar .brand-wordmark { font-size: 17px; }
  .sidebar .brand-wordmark span { font-size: 9px; margin-top: 1px; }
  .sidebar-foot { grid-row: 1; grid-column: 2; display: flex; align-items: center; border: 0; padding: 6px 8px; }
  .sidebar-foot .btn { width: auto; padding-inline: 7px; gap: 4px; }
  .nav { display: none; }
  .mobile-navigation { grid-row: 2; grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #1a2f4b; color: #d1dff1; font-size: 12px; }
  .mobile-navigation select { flex: 1; min-height: 34px; padding: 5px 8px; background: #243c5b; border-color: #526883; color: #fff; font-weight: 600; }
  .mobile-navigation option, .mobile-navigation optgroup { background: #fff; color: var(--text); }
  .main { --gutter: 16px; }
  .topbar { padding-block: 13px; }
  .view { padding-block: 12px; gap: 10px; }
  .toolbar-right { margin-left: 0; }
}
@media (max-width: 620px) {
  .main { --gutter: 12px; }
  .topbar h2 { font-size: 22px; }
  .topbar-actions { gap: 7px; }
  #last-refresh { max-width: 110px; font-size: 10px; overflow-wrap: anywhere; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-val { font-size: 30px; }
  .two-col, .form-grid, #webhook-filters, .upload-grid, #auto-ota-form { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .panel, .panel.compact { padding: 14px; }
  .table-wrap { padding: 0; }
  .data-table td, .data-table th { padding: 8px; }
  .toolbar { padding: 9px; gap: 7px; }
  .toolbar input[type=search] { flex-basis: 100%; max-width: none; }
  .toolbar select { flex: 1 1 100px; }
  .toolbar-right { width: 100%; flex-wrap: wrap; gap: 6px; }
  .list-pagination { padding: 9px; gap: 8px; }
  .pagination-controls { flex-wrap: wrap; }
  .drawer-head, .drawer-body { padding: 13px 12px; }
  .item-card { padding: 12px; }
  .row-actions > input { min-width: 100px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .kpi, .nav-btn { transition: background-color .15s ease, border-color .15s ease; }
}
.pagination-page { display: inline-flex; align-items: center; gap: 4px; }
.pagination-page input { width: 4em; min-height: 31px; padding: 3px 4px; text-align: center; }
@media (max-width: 380px) {
  .sidebar { grid-template-columns: minmax(0, 1fr) auto; }
  .sidebar-head { padding-inline: 9px; }
  .sidebar .brand { gap: 6px; }
  .sidebar-foot { gap: 0; padding-inline: 4px; }
  .sidebar-foot .btn { padding-inline: 5px; }
  .sidebar-foot .icon { display: none; }
  .kpi { padding-inline: 10px; }
}
.sidebar-foot .btn.ghost { color: #b8c9df; }
.sidebar-foot .btn.ghost:hover:not(:disabled) { background: #213653; color: #fff; }
@media (max-width: 620px) {
  .topbar { display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; }
  .page-heading { display: contents; }
  .workspace-context { grid-row: 1; grid-column: 1; }
  .topbar-actions { grid-row: 1; grid-column: 2; }
  .topbar h2 { grid-row: 2; grid-column: 1 / -1; margin: 0; }
  #last-refresh { white-space: nowrap; }
}

/* On phones each row carries its own labels. Keep the device select-all control above the cards. */
@media (max-width: 600px) {
  .mobile-records { border: 0; border-radius: 0; background: transparent; }
  .mobile-records table, .mobile-records tbody, .device-table-wrap thead, .device-table-wrap thead tr { display: block; }
  .mobile-records tbody { display: grid; gap: 9px; }
  .task-table-wrap thead, .release-table-wrap thead, .device-table-wrap th:not(:first-child) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .device-table-wrap th:first-child { position: static; display: block; width: auto; text-align: left; padding: 0; border: 0; background: transparent; }
  .page-selection { gap: 8px; min-height: 34px; padding: 0 4px 5px; cursor: pointer; }
  .page-selection span { display: inline; }
  .mobile-records tbody tr { display: grid; align-items: center; gap: 7px 8px; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 9px; }
  .mobile-records .data-table td { min-width: 0; width: auto; padding: 0; border: 0; background: transparent; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .mobile-records .data-table tr:hover td { background: transparent; }
  .mobile-records .data-table td:last-child { position: static; box-shadow: none; }
  .mobile-records .data-table td[colspan] { grid-area: auto / 1 / auto / -1; }
  .mobile-records .data-table td::before { color: var(--muted); font: 11px/1.6 var(--sans); margin-right: 5px; }
  .mobile-records .data-table tr:has(td[colspan]) { grid-template: 1fr / 1fr; }
  .mobile-records .data-table td[colspan]::before { content: none; }
  .mobile-records td a { overflow-wrap: anywhere; }
  .mobile-records td:last-child .btn { min-height: 34px; }
  .task-table-wrap tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "device status" "type exit" "summary summary" "date action";
  }
  #tasks-tbody td:nth-child(1) { grid-area: date; font-size: 11px; }
  #tasks-tbody td:nth-child(2) { grid-area: device; }
  #tasks-tbody td:nth-child(2) a { font-size: 13px; font-weight: 650; }
  #tasks-tbody td:nth-child(3) { grid-area: type; }
  #tasks-tbody td:nth-child(4) { grid-area: status; justify-self: end; }
  #tasks-tbody td:nth-child(5) { grid-area: exit; justify-self: end; color: var(--muted); }
  #tasks-tbody td:nth-child(5)::before { content: "退出码"; }
  #tasks-tbody td:nth-child(6) { grid-area: summary; max-width: none !important; padding: 7px 9px; background: #f3f6fa; border-radius: 5px; line-height: 1.55; white-space: pre-wrap; }
  #tasks-tbody td:nth-child(6)::before { content: "摘要"; }
  #tasks-tbody td:nth-child(7) { grid-area: action; justify-self: end; }
  .device-table-wrap tbody tr {
    grid-template-columns: 20px minmax(0, 1fr) minmax(0, .75fr) auto;
    grid-template-areas: "check device device state" "contact contact contact contact" "version version group group" "signal signal usage usage" "access access issues issues" "recent recent recent action";
  }
  .device-table-wrap tbody tr:has(.dev-check:checked) { background: #eef4ff; border-color: #8eb0e7; }
  #devices-tbody td:nth-child(1) { grid-area: check; }
  #devices-tbody td:nth-child(2) { grid-area: state; justify-self: end; font-weight: 650; }
  #devices-tbody td:nth-child(3) { grid-area: device; font-size: 13px; font-weight: 650; }
  #devices-tbody td:nth-child(4) { grid-area: contact; padding-bottom: 6px; border-bottom: 1px solid #e8edf4; }
  #devices-tbody td:nth-child(5) { grid-area: group; }
  #devices-tbody td:nth-child(5)::before { content: "分组"; }
  #devices-tbody td:nth-child(6) { grid-area: version; }
  #devices-tbody td:nth-child(6)::before { content: "版本"; }
  #devices-tbody td:nth-child(7) { grid-area: signal; }
  #devices-tbody td:nth-child(7)::before { content: "输出"; }
  #devices-tbody td:nth-child(8) { grid-area: usage; }
  #devices-tbody td:nth-child(8)::before { content: "温度 / 内存"; }
  #devices-tbody td:nth-child(9) { grid-area: access; }
  #devices-tbody td:nth-child(9)::before { content: "远控"; }
  #devices-tbody td:nth-child(10) { grid-area: issues; }
  #devices-tbody td:nth-child(10)::before { content: "未解决报错"; }
  #devices-tbody td:nth-child(11) { grid-area: recent; font-size: 11px; }
  #devices-tbody td:nth-child(11)::before { content: "最近在线"; }
  #devices-tbody td:nth-child(12) { grid-area: action; justify-self: end; }
  .release-table-wrap tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "version visibility" "file file" "notes notes" "hash size" "date date" "actions actions";
  }
  #releases-tbody td:nth-child(1) { grid-area: version; }
  #releases-tbody td:nth-child(2) { grid-area: file; max-width: none; font-weight: 600; }
  #releases-tbody td:nth-child(3) { grid-area: hash; }
  #releases-tbody td:nth-child(3)::before { content: "SHA-256"; }
  #releases-tbody td:nth-child(4) { grid-area: size; justify-self: end; }
  #releases-tbody td:nth-child(5) { grid-area: visibility; justify-self: end; }
  #releases-tbody td:nth-child(6) { grid-area: notes; max-width: none; padding: 6px 8px; background: #f3f6fa; border-radius: 5px; }
  #releases-tbody td:nth-child(6)::before { content: "更新说明"; }
  #releases-tbody td:nth-child(7) { grid-area: date; font-size: 11px; }
  #releases-tbody td:nth-child(7)::before { content: "上传时间"; }
  #releases-tbody td:nth-child(8) { grid-area: actions; display: flex; justify-content: flex-end; }
  #devices-tbody td[colspan], #tasks-tbody td[colspan], #releases-tbody td[colspan] { grid-area: auto / 1 / auto / -1; justify-self: stretch; }
}


@media (max-width: 620px) {
  .release-tool > summary { padding: 8px; font-size: 12px; }
  .release-tools:has(details[open]) { grid-template-columns: minmax(0, 1fr); }
  .release-tools { gap: 5px; }
  .release-tool .upload-grid, .release-tool #auto-ota-form { grid-template-columns: minmax(0, 1fr); }
  .view { padding-block: 8px; }
  .list-view { gap: 7px; }
}
@media (max-height: 540px) {
  .topbar { padding-block: 6px; }
  .topbar h2 { font-size: 20px; }
  .workspace-context { display: none; }
  .view { padding-block: 5px; gap: 5px; }
  .list-view > :is(.toolbar, .release-tools) { max-height: 23dvh; }
  .toolbar, .list-pagination { padding: 4px 7px; gap: 4px 7px; }
  .pagination-controls { gap: 4px; }
  .sidebar-head { padding-block: 8px; }
  .sidebar-foot { padding-block: 4px; }
}
@media (max-height: 540px) and (max-width: 800px) {
  .sidebar { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .sidebar .brand-wordmark, .mobile-navigation > span { display: none; }
  .sidebar-head { padding: 4px 8px; }
  .sidebar-foot { grid-column: 3; }
  .mobile-navigation { grid-row: 1; grid-column: 2; padding: 3px 2px; background: transparent; }
  .topbar { display: flex; }
  .topbar-actions { margin-left: auto; }
}

#release-upload-form #rel-notes { grid-column: 1 / -1; }
@media (max-height: 360px) {
  .topbar { padding-block: 3px; }
  .topbar h2 { min-width: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #last-refresh { display: none; }
  .list-view > :is(.toolbar, .release-tools) { max-height: 17dvh; }
  .view { padding-block: 3px; gap: 3px; }
  .sidebar-foot { padding-block: 0; }
  .list-pagination { padding-block: 2px; row-gap: 2px; }
  .list-pagination button, .pagination-size select, .pagination-page input { min-height: 23px; padding: 2px 5px; line-height: 1.2; font-size: 11px; }
}
