:root {
    --bg: #0f1417;
    --panel-bg: #171e24;
    --panel-border: #263038;
    --text: #dce4ea;
    --text-dim: #8a97a3;
    --accent: #3ea6ff;
    --ok: #35c46a;
    --warn: #e0a63a;
    --bad: #e05b4f;
    --row-hover: #1f2830;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    flex: 0 0 auto;
}

.topbar h1 { font-size: 16px; margin: 0; }
.brand { display: flex; align-items: center; line-height: 0; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-title {
    margin-left: 14px;
    padding-left: 14px;
    border-left: 1px solid var(--panel-border);
    font-size: 18px;
    font-weight: 400;
    letter-spacing: .01em;
    color: var(--text);
    line-height: 28px;
    white-space: nowrap;
}
.topbar { gap: 12px; }
@media (max-width: 560px) { .brand-title { display: none; } }
.topbar:has(.brand) { padding-top: 6px; padding-bottom: 6px; }

.conn-status { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }

.dot {
    width: 9px; height: 9px; border-radius: 50%;
    display: inline-block;
    background: var(--bad);
}
.dot-online { background: var(--ok); }
.dot-offline { background: var(--bad); }
.dot-nofix { background: var(--warn); }

.layout {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.map-pane { flex: 1 1 auto; position: relative; }
#map { position: absolute; inset: 0; background: #1a2126; }

.side-pane {
    width: 380px;
    min-width: 260px;
    max-width: 720px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.resize-handle {
    flex: 0 0 auto;
    width: 6px;
    cursor: col-resize;
    background: var(--panel-border);
    touch-action: none;
}
.resize-handle:hover,
.resize-handle.dragging {
    background: var(--accent);
}

body.resizing-side-pane {
    cursor: col-resize;
    user-select: none;
}

/* Same idea as .resize-handle, for the message log's top edge. */
.trailer-id-sub { font-size: 11px; color: var(--text-dim); }

.alias-editor { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 12px; }
.alias-editor[hidden] { display: none; }
.alias-editor label { font-size: 12px; color: var(--text-dim); }
.alias-editor input { flex: 1 1 140px; min-width: 0; }
.alias-editor .status-line { flex-basis: 100%; min-height: 0; }

.log-controls { display: flex; align-items: center; gap: 12px; }
.log-filter-toggle {
    display: flex; align-items: center; gap: 5px;
    font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none;
}
.log-filter-toggle input { padding: 0; margin: 0; }
.log-search { width: 190px; padding: 3px 8px; font-size: 12px; }
#messageLog mark { background: rgba(224, 166, 58, .35); color: inherit; border-radius: 2px; padding: 0 1px; }
.log-filter-name { color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 600; margin-left: 6px; }

.resize-handle-h {
    flex: 0 0 auto;
    height: 6px;
    cursor: row-resize;
    background: var(--panel-border);
    touch-action: none;
}
.resize-handle-h:hover,
.resize-handle-h.dragging {
    background: var(--accent);
}

body.resizing-log-pane {
    cursor: row-resize;
    user-select: none;
}

.panel {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    padding: 10px 12px;
}

.tab-bar {
    display: flex;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    flex: 0 0 auto;
}

.tab-btn {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 9px 8px;
    color: var(--text-dim);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.panel-header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 0; }

.badge {
    background: var(--accent);
    color: #071018;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--text-dim); font-weight: 500; padding: 4px 6px; border-bottom: 1px solid var(--panel-border); }
td { padding: 5px 6px; border-bottom: 1px solid #1c252b; vertical-align: middle; }
tbody tr:hover { background: var(--row-hover); cursor: pointer; }

.stacked-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.stacked-form label, .ota-push label, .iorules-panel label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.checkbox-line { flex-direction: row !important; align-items: center; gap: 6px !important; }

input, select, button {
    font: inherit;
    background: #0f1417;
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 6px 8px;
}

.btn { cursor: pointer; }
.btn-primary { background: var(--accent); color: #071018; border: none; font-weight: 600; }
.btn-danger { background: var(--bad); color: #1a0906; border: none; font-weight: 600; }
.btn-small { padding: 3px 8px; font-size: 11.5px; }
.btn-ghost { background: transparent; border: none; color: var(--text-dim); font-size: 16px; line-height: 1; }
.btn-ghost:hover { color: var(--text); }

.status-line { font-size: 12px; color: var(--text-dim); min-height: 14px; display: block; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--bad); }

.ota-push { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--panel-border); }

#otaRadarOptions { display: flex; flex-direction: column; gap: 8px; }

.log-pane {
    flex: 0 0 160px;
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#messageLog {
    flex: 1;
    overflow-y: auto;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 11.5px;
    color: var(--text-dim);
}

#messageLog .log-line { padding: 2px 0; border-bottom: 1px solid #1a2227; }
#messageLog .log-line .t { color: var(--accent); }
#messageLog .log-line .topic { color: var(--text); }

/* Divider between this session's live lines and stored history below it. */
.log-history-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0; margin: 4px 0;
    border-top: 1px dashed var(--panel-border); border-bottom: 1px dashed var(--panel-border);
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
.log-history-bar .status-line { display: inline; min-height: 0; }
#messageLog .log-line.log-hist .t { color: var(--text-dim); }

.hint { font-size: 11.5px; color: var(--text-dim); margin: 0 0 10px; }

.manual-control-panel label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }

#mcFields { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.mc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-row .mc-label { flex-direction: row !important; align-items: center; gap: 6px; color: var(--text); font-size: 12.5px; margin: 0; }
.mc-row .mc-value { width: 80px; }
.mc-row .mc-value:disabled { opacity: .4; }

.mc-flush { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--panel-border); }
.mc-inputs { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--panel-border); }
.mc-inputs table { margin-top: 8px; }

.iorules-panel .firmware-table { margin: 8px 0 14px; }
.iorules-panel .firmware-table tbody tr { cursor: pointer; }
#ioRuleEditor { margin-top: 12px; padding: 10px; border: 1px solid var(--panel-border); border-radius: 4px; background: var(--bg); }
#ioRuleEditor .panel-header { margin-bottom: 10px; }
#ioRuleEditor .btn { margin-right: 6px; margin-bottom: 8px; }

.detail-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0 0 12px; font-size: 12.5px; }

.detail-devices-table tbody tr:hover { cursor: default; }
.detail-panel dt { color: var(--text-dim); }
.detail-panel dd { margin: 0; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-bg); color: var(--text); }

.radars-panel .subhead { font-size: 13px; margin: 14px 0 6px; color: var(--text); }
.radars-panel .firmware-table { margin: 8px 0; }
.rs-group-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 10px 0 4px; }
.rs-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.rs-row label { display: flex; flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 12.5px; margin: 0; }
.rs-row input[type=number] { width: 80px; }
.rs-row input[type=number]:disabled { opacity: .4; }
.rs-unit { color: var(--text-dim); }
/* A setting the current radar firmware ignores - see "unused" in config.js. */
.rs-unused, .rs-row.rs-unused label { color: var(--text-dim); }
.rs-unused { opacity: .6; }
.rs-unused-tag { font-size: 11px; font-style: italic; }
#radarSettingsBtn { margin-top: 8px; }
/* A radar that's offline / no longer in the controller's list. */
tr.dev-gone td { color: var(--text-dim); }
tr.dev-gone td .status-line { display: inline; }
.table-scroll { overflow-x: auto; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
.table-scroll tbody tr { cursor: default; }
.rs-group-row td { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); background: var(--bg); }

tbody tr.selected { background: rgba(62,166,255,.16); box-shadow: inset 3px 0 0 var(--accent); }
tbody tr.selected:hover { background: rgba(62,166,255,.22); }
.sel-trailer { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }
.sel-trailer-name { color: var(--accent); }
.sel-trailer-name.none { color: var(--text-dim); font-weight: normal; font-style: italic; }
