:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #d8e1ec;
    --text: #152033;
    --muted: #66758a;
    --primary: #0877d8;
    --primary-dark: #075fae;
    --danger: #c93434;
    --warning: #b7791f;
    --ok: #15803d;
    --shadow: 0 16px 40px rgba(25, 42, 70, .12);
}

* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    padding: 9px 14px;
}

button:hover {
    background: var(--primary-dark);
}

button.ghost {
    background: #e8f1fb;
    color: var(--primary-dark);
}

button.secondary {
    background: #e8f1fb;
    color: var(--primary-dark);
}

button.compact {
    margin-left: 8px;
    padding: 7px 10px;
}

button.danger {
    background: var(--danger);
}

button.ghost-danger {
    background: #fdecec;
    color: var(--danger);
}

button.ghost-danger:hover {
    background: #fbd6d6;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 9px 10px;
}

textarea {
    min-height: 360px;
    resize: vertical;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 13px;
}

.shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 16px;
    background: #101827;
    color: #dbe7f5;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 8px;
    background: #0c86ee;
    color: #fff;
    font-weight: 700;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: #9fb0c5;
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 4px;
    margin-top: 28px;
}

.nav a {
    border-radius: 7px;
    color: #c9d7e8;
    padding: 10px 12px;
    text-decoration: none;
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.logout {
    position: absolute;
    right: 16px;
    bottom: 20px;
    left: 16px;
}

.logout button {
    width: 100%;
    background: rgba(255, 255, 255, .1);
    color: #dbe7f5;
}

.main {
    min-width: 0;
    padding: 24px 28px 42px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.topbar p,
.topbar h1 {
    margin: 0;
}

.topbar p {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.topbar h1 {
    font-size: 22px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status {
    color: var(--muted);
    min-width: 7em;
    text-align: right;
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

.grid {
    display: grid;
    gap: 14px;
}

.grid.cards {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.card,
.table-wrap,
.section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 1px rgba(30, 48, 80, .04);
}

.card {
    padding: 16px;
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.resource-monitor {
    margin-top: 18px;
    padding: 2px 0 0;
}

.resource-monitor-heading,
.resource-chart-heading,
.resource-metric-top,
.resource-monitor-actions,
.resource-range,
.resource-legend-row,
.drawer-actions {
    display: flex;
    align-items: center;
}

.resource-monitor-heading,
.resource-chart-heading {
    justify-content: space-between;
    gap: 14px;
}

.resource-chart-heading > div:last-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-monitor-heading h2,
.resource-chart-heading h3 {
    margin: 0;
}

.resource-monitor-heading p,
.resource-chart-heading span,
.resource-metric p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.resource-monitor-actions,
.resource-range,
.resource-legend-row,
.drawer-actions {
    gap: 8px;
}

.resource-settings-button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--primary-dark);
    padding: 0;
}

.resource-settings-button:hover {
    background: #e8f1fb;
}

.resource-settings-button .preview-icon {
    width: 18px;
    height: 18px;
}

.maintenance-notice-button {
    color: #a95712;
}

.maintenance-notice-button:hover {
    background: #fff4e5;
}

.resource-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.resource-metric {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.resource-metric-top {
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.resource-metric strong {
    display: block;
    margin-top: 8px;
    font-size: 25px;
}

.resource-meter {
    height: 6px;
    overflow: hidden;
    margin-top: 11px;
    border-radius: 99px;
    background: #e8eef5;
}

.resource-meter i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.resource-metric-memory .resource-meter i {
    background: var(--ok);
}

.resource-metric-disk .resource-meter i {
    background: var(--warning);
}

.resource-metric-heap .resource-meter i {
    background: #9b4dca;
}

.resource-chart-panel {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.resource-range-button,
.resource-legend {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--muted);
    padding: 6px 10px;
}

.resource-range-button.active,
.resource-range-button:hover {
    border-color: #9fc4e8;
    background: #e8f1fb;
    color: var(--primary-dark);
}

.resource-history-chart {
    min-height: 250px;
    margin-top: 12px;
}

.resource-chart-wrap {
    position: relative;
    width: 100%;
    user-select: none;
}

.resource-chart-wrap svg {
    display: block;
    width: 100%;
    height: 250px;
    overflow: hidden;
    touch-action: pan-y;
}

.resource-grid-line {
    stroke: #e5ebf2;
    stroke-width: 1;
}

.resource-axis-label {
    fill: var(--muted);
    font-size: 10px;
}

.resource-time-grid-line {
    stroke: #eef2f6;
    stroke-width: 1;
}

.resource-line {
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.resource-chart-cursor {
    display: none;
    stroke: var(--primary-dark);
    stroke-width: 1;
    stroke-dasharray: 4 3;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.resource-chart-hit-area {
    fill: transparent;
    cursor: crosshair;
    outline: none;
}

.resource-history-chart.dragging,
.resource-history-chart.dragging .resource-chart-hit-area {
    cursor: grabbing;
}

.resource-chart-tooltip {
    display: none;
    position: absolute;
    top: 18px;
    left: 0;
    z-index: 2;
    min-width: 145px;
    max-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 5px 16px rgba(24, 52, 78, .14);
    color: var(--text);
    font-size: 11px;
    pointer-events: none;
    transform: translateX(8px);
}

.resource-chart-tooltip[data-side="left"] {
    transform: translateX(calc(-100% - 8px));
}

.resource-chart-tooltip time {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.resource-chart-tooltip > div {
    display: grid;
    gap: 3px;
}

.resource-chart-tooltip span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.resource-chart-tooltip i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.resource-chart-tooltip strong {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.resource-chart-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.resource-chart-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.resource-chart-tool {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--primary-dark);
}

.resource-chart-tool:hover,
.resource-chart-tool:focus-visible {
    border-color: #9fc4e8;
    background: #e8f1fb;
}

.resource-chart-tool .preview-icon {
    width: 15px;
    height: 15px;
}

.resource-legend-row {
    flex-wrap: wrap;
    margin-top: 4px;
}

.resource-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    padding: 4px 6px;
}

.resource-legend i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.resource-legend:not(.active) {
    opacity: .45;
}

.resource-alert-settings {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.config-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.config-section-heading > .badge {
    flex: 0 0 auto;
    white-space: nowrap;
}

.jvm-runtime-row {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.jvm-runtime-row label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.jvm-runtime-row input {
    width: 120px;
}

.jvm-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jvm-percent {
    color: var(--muted);
}

.jvm-runtime-row > .muted {
    margin-bottom: 9px;
}

.resource-alert-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 16px;
}

.resource-alert-recipients {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    color: var(--muted);
}

.resource-alert-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--text);
}

.resource-alert-row span {
    color: var(--muted);
}

.resource-alert-row input[type="checkbox"],
.checkbox-row input[type="checkbox"] {
    width: auto;
    margin-right: 5px;
}

.maintenance-notice-field {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: var(--muted);
}

.maintenance-notice-field textarea {
    min-height: 96px;
    resize: vertical;
}

.maintenance-notice-field input {
    width: min(100%, 180px);
}

.maintenance-notice-warning {
    margin: 16px 0 0;
    border-left: 3px solid var(--warning);
    background: #fff8ec;
    color: #87500f;
    padding: 10px 12px;
}

.drawer-actions {
    flex-wrap: wrap;
    margin-top: 16px;
}

.resource-monitor-unavailable {
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.section {
    margin-top: 16px;
    padding: 16px;
}

.device-log-controls {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(220px, 0.8fr) minmax(300px, 1.2fr) minmax(160px, 0.45fr);
    align-items: end;
    gap: 16px;
}

.device-log-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.device-log-controls label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.device-log-mode {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}

.device-log-mode legend {
    padding: 0 4px;
    color: var(--muted);
    font-size: 12px;
}

.device-log-mode label {
    display: flex;
    align-items: center;
    grid-template-columns: auto 1fr;
    color: var(--text);
}

.device-log-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    grid-column: 1 / -1;
}

.device-log-active-summary {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto minmax(260px, 1.2fr);
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid #a8d5c2;
    border-radius: 6px;
    background: #f4fbf7;
}

.device-log-active-summary.idle {
    grid-template-columns: 1fr;
    border-color: var(--line);
    background: #f8fafc;
}

.device-log-summary-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.device-log-summary-main span,
.device-log-title p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.device-log-summary-main strong,
.device-log-title h2 {
    overflow: hidden;
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-log-summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.device-log-summary-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
    color: var(--muted);
    font-size: 12px;
}

.device-log-active-summary.idle p {
    margin: 0;
    color: var(--muted);
}

.device-log-head {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1.4fr);
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.device-log-title {
    min-width: 0;
}

.device-log-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
    color: var(--muted);
    font-size: 12px;
}

.device-log-history-grid,
.device-log-settings-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 12px;
}

.device-log-history-grid label,
.device-log-settings-grid label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.device-log-history-grid .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    color: var(--text);
    text-decoration: none;
}

.device-log-history-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 6px 0 10px;
    color: var(--muted);
    font-size: 12px;
}

.device-log-console-wrap {
    overflow: hidden;
    border: 1px solid #233246;
    border-radius: 6px;
    background: #101827;
}

.device-log-settings-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
    margin-bottom: 0;
}

.device-log-danger-group {
    border: 1px solid #efb4b4;
    background: #fffafa;
}

.device-log-danger-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.device-log-console {
    overflow: auto;
    height: min(62vh, 680px);
    min-height: 360px;
    margin: 0;
    border: 0;
    background: transparent;
    color: #dbe7f5;
    padding: 14px;
    font: 12px/1.65 Consolas, "SFMono-Regular", monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.section h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

.stats-dashboard {
    display: grid;
    gap: 16px;
}

.stats-hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 18px;
    overflow: hidden;
    border: 1px solid #cfe0f3;
    border-radius: 12px;
    background:
            radial-gradient(circle at 18% 20%, rgba(59, 130, 246, .18), transparent 28%),
            linear-gradient(135deg, #ffffff 0%, #eef7ff 58%, #e8f5ff 100%);
    box-shadow: var(--shadow);
    padding: 22px;
}

.stats-hero p,
.stats-hero h2,
.stats-hero span,
.stats-rate span,
.stats-rate strong,
.stats-rate em {
    display: block;
    margin: 0;
}

.stats-hero p {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.stats-hero h2 {
    margin-top: 6px;
    font-size: 26px;
}

.stats-hero span {
    margin-top: 6px;
    color: var(--muted);
}

.stats-rate {
    min-width: 190px;
    border: 1px solid rgba(8, 119, 216, .18);
    border-radius: 12px;
    background: rgba(255, 255, 255, .72);
    padding: 16px 18px;
    text-align: right;
}

.stats-rate span,
.stats-rate em {
    color: var(--muted);
    font-size: 12px;
}

.stats-rate strong {
    margin: 4px 0;
    color: var(--primary-dark);
    font-size: 42px;
    line-height: 1.1;
}

.stats-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stats-metric {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 1px 1px rgba(30, 48, 80, .04);
    padding: 14px;
}

.stats-metric span,
.stats-metric em {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.stats-metric strong {
    display: block;
    overflow: hidden;
    margin: 5px 0 2px;
    color: var(--text);
    font-size: 25px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.stats-grid-secondary {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stats-chart {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 1px 1px rgba(30, 48, 80, .04);
    padding: 16px;
}

.stats-chart header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.stats-chart h2 {
    margin: 0;
    font-size: 16px;
}

.stats-chart header span {
    border-radius: 999px;
    background: #eef5ff;
    color: var(--primary-dark);
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 700;
}

.stats-bar-row + .stats-bar-row {
    margin-top: 10px;
}

.stats-bar-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.stats-bar-label span {
    overflow: hidden;
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-bar-label strong {
    color: var(--muted);
    font-size: 12px;
}

.stats-bar-track {
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: #eef2f7;
}

.stats-bar-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4f9cf9, #0c86ee);
}

.stats-chart-green .stats-bar-track i {
    background: linear-gradient(90deg, #35d399, #0f9f6e);
}

.stats-chart-amber .stats-bar-track i {
    background: linear-gradient(90deg, #fbbf24, #d97706);
}

.stats-chart-purple .stats-bar-track i {
    background: linear-gradient(90deg, #a78bfa, #6d5dfc);
}

.stats-chart-blue .stats-bar-track i {
    background: linear-gradient(90deg, #38bdf8, #0877d8);
}

.stats-chart-slate .stats-bar-track i {
    background: linear-gradient(90deg, #94a3b8, #475569);
}

.stats-kv-panel .table-wrap {
    border: 0;
    box-shadow: none;
}

.stats-kv-panel th {
    display: none;
}

.stats-kv-panel td {
    padding: 8px 0;
}

.stats-kv-panel td:last-child {
    color: var(--text);
    font-weight: 700;
    text-align: right;
}

.stats-detail {
    margin-top: 0;
}

.stats-detail h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(180px, 320px) auto;
    gap: 10px;
    margin-bottom: 12px;
}

.audit-filters {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover {
    background: #f3f8fe;
}

tr.selectable.active-row,
tr.selectable:hover {
    background: #eef7ff;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    background: #edf2f7;
    color: var(--muted);
    padding: 2px 8px;
    font-size: 12px;
}

.badge.ok {
    background: #e9f7ee;
    color: var(--ok);
}

.badge.warn {
    background: #fff5df;
    color: var(--warning);
}

.badge.danger {
    background: #fdecec;
    color: var(--danger);
}

.badge.muted {
    background: #eef2f6;
    color: var(--muted);
}

.gateway-id {
    color: var(--text);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 12px;
}

.gateway-note {
    margin: 0 0 12px;
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.drawer {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: flex-end;
    background: rgba(10, 18, 32, .36);
    z-index: 20;
}

.drawer.open {
    display: flex;
}

.drawer-panel {
    position: relative;
    width: min(760px, 92vw);
    height: 100%;
    overflow: auto;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 24px;
}

.icon-button {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    padding: 0;
}

.kv {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 7px 12px;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
    word-break: break-word;
}

.kv .inline-select {
    display: inline-block;
    width: min(100%, 380px);
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.muted {
    color: var(--muted);
}

.preview-layout {
    display: grid;
    grid-template-columns: minmax(340px, 520px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.preview-side .section:first-child {
    margin-top: 0;
}

.preview-side,
.preview-main {
    min-width: 0;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.preview-toolbar strong {
    display: block;
}

.preview-toolbar span {
    color: var(--muted);
    font-size: 12px;
}

.segmented {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.segmented button {
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    padding: 7px 10px;
}

.segmented button.active {
    background: var(--primary);
    color: #fff;
}

.phone-preview {
    width: min(100%, 393px);
    overflow: hidden;
    border: 1px solid rgba(12, 22, 38, .18);
    border-radius: 16px;
    background: var(--preview-bg);
    color: var(--preview-text);
    box-shadow: var(--shadow);
    margin: 0 auto;
}

.phone-preview-wide {
    width: min(100%, 720px);
}

.phone-preview-auto {
    width: 100%;
}

.preview-statusbar {
    display: flex;
    justify-content: space-between;
    color: var(--preview-muted);
    font-size: 11px;
    padding: 8px 14px 0;
}

.preview-live-status {
    overflow: hidden;
    max-width: 52%;
    color: var(--preview-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-live-status.stale {
    color: #f59e0b;
}

.preview-control-mode {
    flex: 0 0 auto;
}

.preview-control-mode button {
    min-width: 58px;
}

.preview-appbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 8px;
}

.preview-appbar span,
.preview-appbar em {
    color: var(--preview-muted);
    font-size: 12px;
    font-style: normal;
}

.preview-appbar strong {
    display: block;
    overflow: hidden;
    max-width: 260px;
    color: var(--preview-text);
    font-size: 19px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-devices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 10px;
}

.device-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 999px;
    background: var(--preview-surface);
    color: var(--preview-text);
    padding: 3px 8px;
    font-size: 11px;
}

.device-pill em {
    color: var(--preview-primary);
    font-style: normal;
}

.preview-tabs {
    display: flex;
    overflow-x: auto;
    background: var(--tab-bg, var(--preview-primary));
    min-height: 48px;
}

.preview-tabs button {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    border-radius: 0;
    background: transparent;
    color: var(--tab-inactive, rgba(255, 255, 255, .78));
    font-size: 14px;
    line-height: 1;
    padding: 0 8px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-tabs button.active {
    color: var(--tab-active, #fff);
}

.preview-tabs button.active::after {
    position: absolute;
    right: 10px;
    bottom: 0;
    left: 10px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--tab-color);
    content: "";
}

.dashboard-surface {
    position: relative;
    min-height: 216px;
    background: var(--preview-bg);
}

.dash-widget {
    position: absolute;
    overflow: hidden;
    color: var(--preview-text);
    container-type: inline-size;
}

.dash-widget.is-on {
    outline: 1px solid var(--preview-primary);
    outline-offset: -1px;
}

.dash-widget.widget-bg {
    border: 1px solid var(--preview-line);
    border-radius: 4px;
    background: var(--preview-surface);
    padding: 6px;
}

.dash-widget.widget-flat {
    padding: 4px 5px;
}

.device-tiles-widget {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
    width: 100%;
    height: 100%;
    padding-right: 2px;
}

.device-tile {
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--preview-line);
    border-radius: 6px;
    background: rgba(255, 255, 255, .045);
}

.device-tile > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 28px;
    border-bottom: 1px solid var(--preview-line);
    padding: 0 8px;
    font-size: 10px;
}

.device-tile > header strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-tile > header span {
    flex: 0 0 auto;
}

.device-tile-dashboard {
    position: relative;
    min-height: 72px;
    background: rgba(4, 9, 16, .22);
}

.device-tiles-empty {
    display: grid;
    height: 100%;
    place-items: center;
    color: var(--preview-muted);
    font-size: 10px;
}

.widget-title {
    overflow: hidden;
    color: var(--preview-muted);
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.value-widget {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 100%;
}

.value-widget.with-icon {
    justify-content: center;
}

.value-widget .preview-icon {
    width: 18px;
    height: 18px;
}

.value-copy {
    min-width: 0;
    text-align: center;
}

.value-copy strong {
    display: block;
    overflow: hidden;
    color: var(--widget-color);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-small .value-copy strong {
    font-size: 18px;
}

.font-large .value-copy strong {
    font-size: 26px;
}

.value-copy span {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: var(--preview-muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-widget-digit4-display[style*="height:66px"] .value-widget.with-icon,
.dash-widget-labeled-value-display[style*="height:66px"] .value-widget.with-icon {
    grid-template-columns: 1fr;
    grid-template-rows: 17px minmax(0, 1fr);
    gap: 0;
}

.dash-widget-digit4-display[style*="height:66px"] .value-widget.with-icon .preview-icon,
.dash-widget-labeled-value-display[style*="height:66px"] .value-widget.with-icon .preview-icon {
    justify-self: center;
    width: 16px;
    height: 16px;
}

.button-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 7px;
    background: var(--button-bg);
    color: var(--button-fg);
    text-align: center;
    padding: 4px 6px;
}

.button-widget .preview-icon {
    width: 18px;
    height: 18px;
    color: var(--button-fg) !important;
}

.button-widget strong {
    overflow: hidden;
    max-width: 100%;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-small .button-widget strong {
    font-size: 12px;
}

.font-large .button-widget strong {
    font-size: 18px;
}

.button-widget span {
    overflow: hidden;
    max-width: 100%;
    color: currentColor;
    font-size: 10px;
    opacity: .72;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.button-widget.edge-pill {
    border-radius: 999px;
}

.button-widget.edge-sharp {
    border-radius: 2px;
}

.button-widget.edge-text {
    background: transparent;
}

.timer-widget,
.graph-widget,
.terminal-widget,
.generic-widget {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 6px;
    width: 100%;
    height: 100%;
}

.timer-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.timer-times div {
    border: 1px solid var(--preview-line);
    border-radius: 5px;
    padding: 5px;
}

.timer-times span {
    display: block;
    color: var(--preview-muted);
    font-size: 10px;
}

.timer-times strong {
    color: var(--widget-color);
    font-size: clamp(15px, 12cqw, 24px);
}

.text-input-widget {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 4px;
    width: 100%;
    height: 100%;
}

.text-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: center;
    gap: 6px;
}

.text-input-field {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 5px;
    min-width: 0;
    height: 34px;
    border: 1px solid var(--widget-color);
    border-radius: 5px;
    padding: 0 7px;
}

.text-input-field span {
    overflow: hidden;
    color: var(--widget-color);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-input-field .preview-icon {
    width: 16px;
    height: 16px;
}

.text-send {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
}

.text-send .preview-icon {
    width: 18px;
    height: 18px;
}

.graph-widget {
    position: relative;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    min-width: 0;
    min-height: 0;
    border-radius: 5px;
    background: rgba(255, 255, 255, .075);
    padding: 7px;
}

.graph-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.graph-periods {
    display: inline-flex;
    overflow-x: auto;
    max-width: 72%;
    border: 1px solid var(--preview-line);
    border-radius: 6px;
}

.graph-periods button {
    flex: 0 0 auto;
    min-width: 32px;
    height: 24px;
    border-radius: 0;
    background: transparent;
    color: var(--preview-muted);
    padding: 0 6px;
    font-size: 9px;
    line-height: 1.15;
}

.graph-periods button.active {
    background: var(--preview-primary);
    color: #fff;
}

.graph-plot {
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 72px;
}

.graph-head span {
    border: 1px solid var(--preview-line);
    border-radius: 999px;
    color: var(--preview-muted);
    font-size: 9px;
    line-height: 1.1;
    padding: 3px 6px;
}

.graph-widget svg {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    touch-action: pan-y;
}

.graph-widget polyline {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
}

.graph-grid path {
    fill: none;
    stroke: rgba(255, 255, 255, .08);
    stroke-width: 1;
}

.graph-grid-line {
    fill: none;
    stroke: rgba(255, 255, 255, .10);
    stroke-width: 1;
}

.graph-axis {
    fill: var(--preview-muted);
    font-size: 8px;
    letter-spacing: 0;
    pointer-events: none;
}

.graph-axis-x {
    text-anchor: middle;
}

.graph-axis-y {
    text-anchor: end;
}

.graph-crosshair {
    stroke: #f8fafc;
    stroke-dasharray: 3 3;
    stroke-width: 1;
    pointer-events: none;
}

.graph-tooltip {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    overflow: hidden;
    width: min(190px, calc(100% - 16px));
    max-height: calc(100% - 16px);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 6px;
    background: rgba(8, 15, 25, .94);
    color: #f8fafc;
    padding: 7px;
    font-size: 9px;
    pointer-events: none;
}

.graph-tooltip[hidden] {
    display: none;
}

.graph-tooltip time,
.graph-tooltip div {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.graph-tooltip time {
    display: block;
    margin-bottom: 4px;
    color: #94a3b8;
}

.graph-tooltip i {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.graph-tooltip span {
    overflow: hidden;
    flex: 1 1 auto;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-tooltip strong {
    flex: 0 0 auto;
}

.graph-empty {
    display: grid;
    min-height: 72px;
    place-items: center;
    color: var(--preview-muted);
    font-size: 10px;
    text-align: center;
}

.graph-status {
    overflow: hidden;
    min-height: 12px;
    color: var(--preview-muted);
    font-size: 9px;
    line-height: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    overflow: hidden;
    color: var(--preview-muted);
    font-size: 10px;
}

.graph-legend button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    height: 20px;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    padding: 0 3px;
    font-size: 10px;
}

.graph-legend button.muted {
    opacity: .42;
}

.graph-legend i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.preview-live-readout {
    position: absolute;
    right: 4px;
    bottom: 3px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: calc(100% - 8px);
    min-height: 14px;
    border-radius: 4px;
    background: rgba(7, 12, 20, .72);
    color: #e2e8f0;
    padding: 1px 4px;
    font-size: 9px;
    pointer-events: none;
}

.preview-live-readout span,
.preview-control-status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-control-status:empty {
    display: none;
}

.preview-control-surface {
    display: none;
}

.preview-mode-control .preview-control-surface {
    position: absolute;
    inset: 4px;
    z-index: 4;
    display: grid;
    overflow: auto;
    place-items: center;
    border: 1px solid var(--preview-line);
    border-radius: 6px;
    background: rgba(8, 15, 25, .94);
    padding: 6px;
}

.preview-widget-control,
.preview-input-control button,
.preview-player-control button,
.preview-joystick-control button {
    min-width: 34px;
    min-height: 28px;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 10px;
}

.preview-input-control,
.preview-player-control,
.preview-joystick-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.preview-input-control input,
.preview-input-control select,
.preview-input-control textarea,
.preview-joystick-control input {
    min-width: 0;
    height: 30px;
    border-color: var(--preview-line);
    border-radius: 4px;
    background: rgba(255, 255, 255, .10);
    color: var(--preview-text);
    padding: 3px 6px;
    font-size: 10px;
}

.preview-input-control input,
.preview-input-control select,
.preview-input-control textarea {
    flex: 1 1 auto;
}

.preview-input-control textarea {
    height: 48px;
    resize: none;
}

.preview-joystick-control {
    flex-wrap: wrap;
}

.preview-joystick-control input {
    flex: 1 1 72px;
}

.control-pending {
    color: #38bdf8;
}

.control-success {
    color: #4ade80;
}

.control-error {
    color: #f87171;
}

.terminal-widget pre {
    overflow: hidden;
    margin: 0;
    border-left: 3px solid;
    border-radius: 4px;
    background: rgba(0, 0, 0, .22);
    color: var(--preview-text);
    font: 12px/1.35 Consolas, "SFMono-Regular", monospace;
    padding: 7px;
    white-space: pre-wrap;
}

.level-widget,
.gauge-widget {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

.level-track {
    position: relative;
    width: 34%;
    max-width: 46px;
    height: 58%;
    overflow: hidden;
    border: 1px solid var(--preview-line);
    border-radius: 5px;
    background: rgba(255, 255, 255, .08);
}

.level-track div {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
}

.level-widget strong {
    color: var(--widget-color);
    font-size: 18px;
}

.gauge-arc {
    position: relative;
    display: grid;
    width: min(120px, 72%);
    aspect-ratio: 1;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--gauge-color) var(--gauge-deg), rgba(255, 255, 255, .16) 0);
}

.gauge-arc::before {
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--preview-bg);
    content: "";
}

.gauge-arc strong {
    position: relative;
    color: var(--widget-color);
    font-weight: 700;
    z-index: 1;
}

.generic-widget strong {
    overflow: hidden;
    font-size: clamp(18px, 15cqw, 30px);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-widget[style*="height:66px"] .generic-widget {
    grid-template-rows: 12px minmax(18px, 1fr) 15px;
    gap: 2px;
}

.dash-widget[style*="height:66px"] .generic-widget strong {
    font-size: 18px;
    line-height: 1.1;
}

.generic-widget small,
.timer-widget small {
    overflow: hidden;
    color: var(--preview-muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-empty {
    position: absolute;
    inset: 24px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--preview-line);
    border-radius: 8px;
    color: var(--preview-muted);
}

.preview-empty {
    display: grid;
    min-height: 260px;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    text-align: center;
}

.danger-zone {
    border-color: #f2b8b8;
    background: #fffafa;
}

.drawer-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -4px 0 14px;
}

.danger-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.security-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.security-grid .section {
    margin-top: 0;
}

.security-form {
    margin-top: 16px;
}

.security-checks {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.security-checks li {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 10px 12px;
}

.security-grid label {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
    color: var(--muted);
}

.totp-setup {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    margin-top: 14px;
    padding: 14px;
}

.totp-setup textarea {
    min-height: 84px;
    font-size: 12px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background: #edf3f9;
}

.login-shell {
    width: min(420px, calc(100vw - 28px));
}

.login-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-brand {
    margin-bottom: 22px;
}

.login-card h1 {
    margin: 0;
    font-size: 24px;
}

.login-card p {
    margin: 8px 0 22px;
    color: var(--muted);
}

.login-card label {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    color: var(--muted);
}

.login-card .checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.checkbox-row input {
    width: auto;
}

.login-card button {
    width: 100%;
    margin-top: 4px;
}

.form-message,
.empty,
.error {
    margin-top: 12px;
    color: var(--muted);
}

.error {
    color: var(--danger);
}

@media (max-width: 860px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 15;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        height: auto;
        padding: 10px 12px;
        box-shadow: 0 3px 14px rgba(5, 12, 24, .2);
    }

    .brand {
        gap: 8px;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
    }

    .nav {
        display: flex;
        min-width: 0;
        gap: 3px;
        margin-top: 0;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav a {
        flex: 0 0 auto;
        padding: 7px 9px;
        white-space: nowrap;
    }

    .logout {
        position: static;
        margin: 0;
    }

    .logout button {
        width: auto;
        padding: 8px 10px;
        white-space: nowrap;
    }

    .main {
        padding: 18px;
    }

    .topbar,
    .filters,
    .audit-filters,
    .stats-hero,
    .stats-grid,
    .preview-toolbar,
    .two-col,
    .preview-layout {
        grid-template-columns: 1fr;
        display: grid;
    }

    .device-log-controls {
        grid-template-columns: 1fr;
    }

    .device-log-active-summary {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .device-log-summary-meta {
        justify-content: flex-start;
    }

    .device-log-history-grid,
    .device-log-settings-grid {
        grid-template-columns: 1fr;
    }

    .device-log-head {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .device-log-meta {
        justify-content: flex-start;
    }

    .stats-rate {
        min-width: 0;
        text-align: left;
    }

    .toolbar {
        margin-top: 12px;
        justify-content: start;
    }

    .resource-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .resource-monitor-heading,
    .resource-chart-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .resource-monitor-actions {
        width: 100%;
        justify-content: space-between;
    }

    .resource-range {
        width: 100%;
    }

    .resource-range-button {
        flex: 1;
    }

    .resource-chart-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .resource-chart-tools {
        order: 2;
    }

    .preview-toolbar .segmented {
        width: 100%;
    }

    .preview-toolbar .segmented button {
        flex: 1 1 0;
        min-width: 0;
    }

    .preview-main {
        order: -1;
    }

    .graph-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .graph-periods {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 520px) {
    .brand > div:last-child {
        display: none;
    }

    .sidebar {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 6px;
        padding: 8px;
    }

    .nav a {
        padding: 7px 8px;
    }

    .logout button {
        padding: 7px 8px;
    }

    .resource-metrics {
        grid-template-columns: 1fr;
    }

    .resource-alert-row {
        grid-template-columns: minmax(0, 1fr) 92px;
    }

    .resource-chart-tooltip {
        min-width: 125px;
        max-width: 180px;
        padding: 7px 8px;
    }

    .jvm-runtime-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .jvm-runtime-row > .muted {
        margin-bottom: 0;
    }

    .main {
        padding: 10px;
    }

    .preview-layout {
        gap: 10px;
    }

    .preview-toolbar {
        gap: 8px;
        margin-bottom: 8px;
    }

    .preview-toolbar > div:first-child {
        display: none;
    }

    .phone-preview {
        border-radius: 8px;
    }

    .preview-appbar {
        align-items: flex-start;
        gap: 8px;
        padding: 10px 12px 8px;
    }

    .preview-appbar > div {
        min-width: 0;
    }

    .preview-appbar strong {
        max-width: min(64vw, 210px);
        font-size: 17px;
    }

    .preview-appbar em {
        flex: 0 0 auto;
        font-size: 11px;
    }

    .preview-devices {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 12px 8px;
    }

    .device-pill {
        flex: 0 0 auto;
    }

    .graph-tooltip {
        top: 4px;
        right: 4px;
        width: min(160px, calc(100% - 8px));
        max-height: calc(100% - 8px);
    }

    .preview-input-control,
    .preview-player-control {
        gap: 3px;
    }

    .preview-input-control button,
    .preview-player-control button,
    .preview-joystick-control button {
        padding: 3px 5px;
    }
}
