:root {
    --bg: #0b1220;
    --bg-soft: #0e1728;
    --panel: #111c2f;
    --panel-2: #16243b;
    --panel-3: #1b2c47;
    --line: rgba(133, 166, 214, 0.16);
    --line-strong: rgba(133, 166, 214, 0.3);
    --text: #e9f0fb;
    --muted: #93a7c7;
    --faint: #667b9b;
    --accent: #38bdf8;
    --accent-deep: #0284c7;
    --on: #f59e0b;
    --on-soft: rgba(245, 158, 11, 0.16);
    --blink: #38bdf8;
    --blink-soft: rgba(56, 189, 248, 0.16);
    --ok: #34d399;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
    --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    background:
        repeating-linear-gradient(0deg, rgba(133, 166, 214, 0.045) 0 1px, transparent 1px 54px),
        repeating-linear-gradient(90deg, rgba(133, 166, 214, 0.045) 0 1px, transparent 1px 54px),
        radial-gradient(1100px 600px at 12% -10%, rgba(56, 189, 248, 0.12), transparent 55%),
        radial-gradient(900px 600px at 95% 0%, rgba(245, 158, 11, 0.08), transparent 50%),
        linear-gradient(180deg, #0b1220 0%, #0a101c 100%);
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* ---------- 登录 ---------- */

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 18px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 30px 28px 26px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(22, 36, 59, 0.96), rgba(13, 23, 39, 0.98));
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 15px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #04121f;
    background: linear-gradient(145deg, #7dd3fc, #38bdf8 55%, #0ea5e9);
    box-shadow: 0 8px 22px rgba(56, 189, 248, 0.28);
}

.brand h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: 0.3px;
}

.brand p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.login-divider {
    height: 1px;
    margin: 24px 0 20px;
    background: var(--line);
}

.field-label {
    display: block;
    margin: 14px 0 7px;
    color: var(--muted);
    font-size: 12.5px;
}

.login-card input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    outline: none;
    background: rgba(9, 17, 30, 0.7);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.login-submit {
    width: 100%;
    height: 46px;
    margin-top: 22px;
    font-size: 15px;
}

.form-error {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 13px;
}

.login-hint {
    margin: 12px 0 0;
    color: var(--faint);
    font-size: 12px;
    line-height: 1.7;
}

/* ---------- 主框架 ---------- */

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
    border-bottom: 1px solid var(--line);
    background: rgba(9, 16, 28, 0.82);
    backdrop-filter: blur(14px);
}

.brand-small .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 16px;
}

.brand-small h1 {
    font-size: 17px;
}

.brand-small p {
    font-size: 11.5px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(20, 34, 55, 0.7);
    font-size: 12px;
    white-space: nowrap;
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--faint);
}

.status-pill.online {
    color: #b8f3dd;
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(52, 211, 153, 0.1);
}

.status-pill.online .dot {
    background: var(--ok);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
}

.status-pill.offline {
    color: #ffc7c7;
    border-color: rgba(248, 113, 113, 0.28);
    background: rgba(248, 113, 113, 0.09);
}

.status-pill.offline .dot {
    background: var(--danger);
}

.status-pill.busy .dot {
    background: var(--warn);
    animation: pulse 1s infinite;
}

.user-name {
    color: var(--muted);
    font-size: 12.5px;
    padding: 0 2px;
}

.layout {
    width: min(1420px, 100%);
    margin: 0 auto;
    padding: 20px max(18px, env(safe-area-inset-left)) 28px max(18px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(165deg, rgba(21, 35, 56, 0.86), rgba(14, 24, 40, 0.92));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
    padding: 18px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 15px;
}

.card-head.wrap {
    flex-wrap: wrap;
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.card-sub {
    margin: 4px 0 0;
    color: var(--faint);
    font-size: 12px;
    line-height: 1.6;
}

.head-actions,
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- 表单与按钮 ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.form-grid.compact {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > span {
    color: var(--muted);
    font-size: 12px;
}

.field.span-2 {
    grid-column: span 2;
}

.field.grow {
    flex: 1;
}

input,
select {
    width: 100%;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    outline: none;
    background: rgba(7, 14, 25, 0.64);
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

input:disabled,
select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.compact-input {
    width: 96px;
    height: 32px;
}

.raw-input {
    flex: 1;
    height: 44px;
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.3px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.1s, filter 0.15s, border-color 0.15s, background 0.15s;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.btn.small {
    min-height: 32px;
    padding: 0 11px;
    font-size: 12px;
    border-radius: 8px;
}

.btn.primary {
    color: #041521;
    background: linear-gradient(160deg, #7dd3fc, #38bdf8);
    border-color: rgba(125, 211, 252, 0.7);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.16);
}

.btn.primary:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn.accent {
    color: #ffe7ba;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.34);
}

.btn.accent:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.2);
}

.btn.ghost {
    color: var(--muted);
    background: rgba(20, 34, 55, 0.6);
    border-color: var(--line);
}

.btn.ghost:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--line-strong);
}

.btn.danger {
    color: #ffd0d0;
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.35);
}

.btn.block {
    width: 100%;
    margin-top: 4px;
}

.inline-hint {
    margin: 13px 0 0;
    color: var(--faint);
    font-size: 12px;
}

.inline-hint.error {
    color: var(--danger);
}

/* ---------- 已打开端口标签 ---------- */
.port-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px dashed var(--line);
}

.port-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 5px 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--panel-2);
    color: var(--text);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.port-chip:hover {
    border-color: var(--accent-deep);
}

.port-chip.active {
    border-color: var(--accent);
    background: var(--blink-soft);
}

.port-chip-name {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.port-chip-meta {
    color: var(--faint);
    font-size: 11px;
    font-family: var(--mono);
}

.port-chip-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: var(--faint);
    font-size: 14px;
    line-height: 1;
    transition: background 0.16s ease, color 0.16s ease;
}

.port-chip-close:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.dirty-badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    color: #ffe6b0;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.25);
    font-size: 10.5px;
    font-weight: 500;
}

/* ---------- 通道 ---------- */

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 10px;
}

.channel {
    position: relative;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(9, 18, 31, 0.46);
    transition: border-color 0.15s, background 0.15s;
}

.channel.on {
    border-color: rgba(245, 158, 11, 0.45);
    background: linear-gradient(160deg, rgba(245, 158, 11, 0.12), rgba(9, 18, 31, 0.5));
}

.channel.blinking {
    border-color: rgba(56, 189, 248, 0.4);
}

.channel.on.blinking {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.18);
}

.channel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
}

.channel-no {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.4px;
}

.channel-state {
    font-size: 10.5px;
    color: var(--faint);
}

.channel.on .channel-state {
    color: var(--on);
}

.channel.blinking .channel-state {
    color: var(--blink);
}

.channel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.ch-btn {
    min-height: 34px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: rgba(20, 34, 55, 0.6);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.12s;
}

.ch-btn:hover:not(:disabled) {
    border-color: var(--line-strong);
    color: var(--text);
}

.ch-btn.on.active {
    color: #2a1700;
    background: linear-gradient(160deg, #fcd34d, #f59e0b);
    border-color: rgba(245, 158, 11, 0.8);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.ch-btn.blink.active {
    color: #04202e;
    background: linear-gradient(160deg, #7dd3fc, #38bdf8);
    border-color: rgba(56, 189, 248, 0.8);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

/* ---------- 周期 ---------- */

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.side-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.period-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 8px;
}

.period-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 9px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(9, 18, 31, 0.4);
}

.period-item label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
}

.period-item input {
    width: 100%;
    height: 30px;
    padding: 0 7px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12px;
    text-align: center;
}

.period-item small {
    color: var(--faint);
    font-size: 10.5px;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 9px;
}

.progress-track {
    height: 5px;
    margin-top: 14px;
    border-radius: 99px;
    background: rgba(9, 17, 30, 0.7);
    overflow: hidden;
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--on));
    transition: width 0.25s ease;
}

/* ---------- 发送与日志 ---------- */

.send-row {
    display: flex;
    gap: 9px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    width: 34px;
    height: 19px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 99px;
    appearance: none;
    position: relative;
    background: rgba(9, 17, 30, 0.8);
    transition: background 0.15s;
    flex: 0 0 auto;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--faint);
    transition: transform 0.15s, background 0.15s;
}

.switch input:checked {
    background: rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.5);
}

.switch input:checked::after {
    transform: translateX(15px);
    background: var(--accent);
}

.log-list {
    height: 300px;
    overflow: auto;
    padding: 4px 2px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(6, 12, 22, 0.6);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
}

.log-empty {
    padding: 18px;
    color: var(--faint);
    text-align: center;
    font-family: var(--font);
}

.log-line {
    display: grid;
    grid-template-columns: 92px 38px minmax(0, 1fr);
    gap: 8px;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(133, 166, 214, 0.07);
}

.log-line:last-child {
    border-bottom: 0;
}

.log-time {
    color: #5f7595;
}

.log-tag {
    color: var(--faint);
    text-transform: uppercase;
    font-size: 10.5px;
    padding-top: 1px;
}

.log-text {
    color: #c6d5ec;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.log-line.tx .log-text {
    color: #94a3b8;
}

.log-line.rx .log-text {
    color: #7ee2b8;
}

.log-line.error .log-text {
    color: #fca5a5;
}

.log-line.warn .log-text {
    color: #fcd34d;
}

.log-line.info .log-text {
    color: #a9c5e8;
}

.footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px max(18px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-right));
    border-top: 1px solid var(--line);
    color: var(--faint);
    font-size: 11.5px;
}

/* ---------- 提示 ---------- */

.toast-container {
    position: fixed;
    top: 76px;
    right: 18px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    padding: 11px 14px;
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    color: var(--text);
    background: rgba(17, 29, 47, 0.97);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    font-size: 12.5px;
    animation: toast-in 0.18s ease-out;
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.success {
    border-left-color: var(--ok);
}

.toast.warn {
    border-left-color: var(--warn);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    .side-stack {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 820px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field.span-2 {
        grid-column: span 2;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .user-name {
        margin-left: auto;
    }
}

@media (max-width: 620px) {
    body {
        font-size: 13.5px;
    }

    .layout {
        padding-top: 14px;
        gap: 13px;
    }

    .card {
        padding: 14px;
        border-radius: 14px;
    }

    .topbar {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .status-pill {
        height: 28px;
        font-size: 11.5px;
        padding: 0 9px;
    }

    .brand-small .brand-mark {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .brand-small h1 {
        font-size: 16px;
    }

    .channel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .channel {
        padding: 9px;
    }

    .ch-btn {
        min-height: 38px;
    }

    .period-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col .side-stack {
        display: flex;
    }

    .side-stack {
        display: flex;
    }

    .card-head {
        margin-bottom: 12px;
    }

    .toolbar {
        width: 100%;
    }

    .toolbar .btn {
        flex: 1 1 auto;
    }

    .send-row {
        flex-direction: column;
    }

    .raw-input {
        width: 100%;
        flex: 0 0 auto;
    }

    .send-row .btn {
        width: 100%;
        height: 42px;
    }

    .log-list {
        height: 260px;
    }

    .log-card .toolbar {
        justify-content: flex-end;
    }

    .log-card .toolbar .btn {
        flex: 0 0 auto;
    }

    .log-line {
        grid-template-columns: 74px 32px minmax(0, 1fr);
        gap: 6px;
        padding: 4px 8px;
        font-size: 11px;
    }

    .toast-container {
        top: auto;
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: 14px;
        left: 14px;
        width: auto;
    }

    .footer {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 350px) {
    .channel-grid,
    .period-grid {
        grid-template-columns: 1fr;
    }

    .status-pill {
        font-size: 10.5px;
    }

    .user-name {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- 工业风机柜布局 ---------- */

.shell {
    display: flex;
    align-items: stretch;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.sidenav {
    flex: 0 0 210px;
    width: 210px;
    position: sticky;
    top: 69px;
    align-self: flex-start;
    height: calc(100vh - 69px);
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 18px 12px 16px;
    border-right: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(14, 24, 40, 0.92), rgba(9, 16, 28, 0.72));
    overflow-y: auto;
}

.nav-caption {
    margin: 0 0 8px;
    padding: 0 12px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--faint);
    text-transform: uppercase;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 13.5px;
    text-align: left;
    transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.nav-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 0;
    transform: translateY(-50%);
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.85);
    transition: height 0.18s;
}

.nav-item:hover {
    background: rgba(56, 189, 248, 0.07);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.03));
    border-color: rgba(56, 189, 248, 0.28);
    color: #dcf4ff;
    font-weight: 500;
}

.nav-item.active::before {
    height: 18px;
}

.nav-ico {
    flex: 0 0 auto;
    opacity: 0.8;
}

.nav-item.active .nav-ico {
    opacity: 1;
}

.nav-count {
    margin-left: auto;
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--faint);
}

.nav-item.active .nav-count {
    border-color: rgba(56, 189, 248, 0.35);
    color: #9adcff;
}

.nav-plate {
    margin-top: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 10px;
    padding: 11px 12px;
    border: 1px dashed rgba(133, 166, 214, 0.22);
    border-radius: 6px;
}

.plate-k {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    color: var(--faint);
}

.plate-v {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-main {
    flex: 1 1 auto;
    min-width: 0;
}

.panel {
    animation: panelIn 0.2s ease-out;
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
}

.panel-top {
    width: min(1420px, 100%);
    margin: 0 auto;
    padding: 20px max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right));
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.panel-head h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 5px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text);
}

.panel-head h2::before {
    content: "";
    width: 3px;
    height: 14px;
    border-radius: 1px;
    background: var(--accent);
    box-shadow: 0 0 9px rgba(56, 189, 248, 0.75);
}

.panel-head p {
    margin: 0;
    max-width: 70ch;
    color: var(--muted);
    font-size: 12.5px;
}

.target-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid rgba(56, 189, 248, 0.36);
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.12);
    color: #dcf4ff;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.target-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 7px rgba(56, 189, 248, 0.9);
}

.panel .layout {
    padding-top: 13px;
}

/* ---------- 工业风细节 ---------- */

.topbar {
    border-bottom-color: rgba(56, 189, 248, 0.22);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.55), rgba(245, 158, 11, 0.45), transparent);
}

.card {
    position: relative;
}

.card::before,
.card::after {
    content: "";
    position: absolute;
    width: 13px;
    height: 13px;
    pointer-events: none;
}

.card::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid rgba(56, 189, 248, 0.55);
    border-left: 2px solid rgba(56, 189, 248, 0.55);
    border-top-left-radius: inherit;
}

.card::after {
    right: -1px;
    bottom: -1px;
    border-bottom: 2px solid rgba(245, 158, 11, 0.42);
    border-right: 2px solid rgba(245, 158, 11, 0.42);
    border-bottom-right-radius: inherit;
}

.login-card {
    position: relative;
}

.login-card::before,
.login-card::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.login-card::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid rgba(56, 189, 248, 0.6);
    border-left: 2px solid rgba(56, 189, 248, 0.6);
    border-top-left-radius: inherit;
}

.login-card::after {
    right: -1px;
    bottom: -1px;
    border-bottom: 2px solid rgba(245, 158, 11, 0.45);
    border-right: 2px solid rgba(245, 158, 11, 0.45);
    border-bottom-right-radius: inherit;
}

/* ---------- 下载中心 ---------- */

.file-list {
    display: flex;
    flex-direction: column;
}

.file-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 14px;
    padding: 11px 2px;
    border-top: 1px solid var(--line);
    transition: background 0.15s;
}

.file-row:first-child {
    border-top: none;
}

.file-row:hover {
    background: rgba(56, 189, 248, 0.05);
}

.file-ext {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 30px;
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.11);
    color: #9adcff;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.04em;
}

.file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 13.5px;
}

.file-meta {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--faint);
    white-space: nowrap;
}

.file-row .btn {
    min-height: 30px;
    padding: 0 13px;
    text-decoration: none;
}

.file-empty {
    padding: 30px 6px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    line-height: 1.7;
}

@media (max-width: 900px) {
    .shell {
        flex-direction: column;
    }

    .sidenav {
        position: static;
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
        overflow-y: hidden;
    }

    .nav-caption,
    .nav-plate {
        display: none;
    }

    .nav-item {
        width: auto;
        flex: 0 0 auto;
        min-height: 36px;
        padding: 7px 14px;
    }

    .nav-item::before {
        display: none;
    }

    .nav-item .nav-count {
        display: none;
    }

    .panel-top {
        padding-top: 15px;
    }

    .file-row {
        grid-template-columns: 40px minmax(0, 1fr) auto auto;
        gap: 10px;
    }

    .file-time {
        display: none;
    }
}

.layout.download-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

#fileDirHint {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.guide-list {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-list > div {
    padding-left: 10px;
    border-left: 2px solid rgba(56, 189, 248, 0.22);
}

.guide-list dt {
    margin-bottom: 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

.guide-list dd {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
}

@media (max-width: 1080px) {
    .layout.download-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- 导航树 ---------- */

.nav-group {
    display: block;
}

.nav-parent .nav-caret {
    margin-left: auto;
    opacity: 0.65;
    transition: transform 0.18s;
}

.nav-group.collapsed .nav-caret {
    transform: rotate(-90deg);
}

.nav-group.collapsed .nav-sub {
    display: none;
}

.nav-parent.in-path {
    color: var(--text);
}

.nav-parent.in-path::before {
    height: 18px;
}

.nav-sub {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 6px 17px;
    padding-left: 13px;
}

.nav-sub::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 7px;
    width: 1px;
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.55), rgba(133, 166, 214, 0.18));
}

.nav-leaf {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 31px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    text-align: left;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-leaf .leaf-mark {
    flex: 0 0 auto;
    width: 5px;
    height: 5px;
    border-radius: 1px;
    background: var(--faint);
}

.nav-leaf .leaf-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-leaf em {
    margin-left: auto;
    font-style: normal;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
    white-space: nowrap;
}

.nav-leaf:hover {
    background: rgba(56, 189, 248, 0.07);
    color: var(--text);
}

.nav-leaf.active {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.12);
    color: #dcf4ff;
}

.nav-leaf.active .leaf-mark {
    background: var(--accent);
    box-shadow: 0 0 7px rgba(56, 189, 248, 0.9);
}

.nav-leaf.active em {
    color: rgba(220, 244, 255, 0.72);
}

.nav-leaf.is-soon {
    opacity: 0.62;
    cursor: help;
}

.nav-leaf.is-soon .leaf-mark {
    background: transparent;
    border: 1px dashed var(--faint);
}

@media (max-width: 900px) {
    .nav-group {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 0 0 auto;
    }

    .nav-parent {
        flex: 0 0 auto;
        min-height: 0;
        padding: 4px 6px;
        border: none;
        background: none;
        color: var(--faint);
        font-size: 12px;
        pointer-events: none;
    }

    .nav-parent .nav-ico,
    .nav-parent .nav-caret,
    .nav-parent::before {
        display: none;
    }

    .nav-sub {
        flex-direction: row;
        gap: 8px;
        margin: 0;
        padding: 0;
    }

    .nav-sub::before {
        display: none;
    }

    .nav-group.collapsed .nav-sub {
        display: flex;
    }

    .nav-leaf {
        width: auto;
        flex: 0 0 auto;
        min-height: 34px;
        padding: 6px 12px;
        border-color: var(--line-strong);
        border-radius: 6px;
    }

    .nav-leaf em {
        display: none;
    }
}

/* ---------- 回路数据融合板 ---------- */

.loop-serial {
    margin-top: 14px;
    padding: 14px 16px;
}

.loop-serial-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.loop-serial-row .field {
    flex: 0 1 132px;
    min-width: 108px;
}

.loop-serial-row .field select {
    height: 34px;
    border-radius: 6px;
}

.loop-serial-row > .btn {
    min-height: 34px;
}

.loop-state {
    padding-bottom: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.loop-state.ok { color: #4ade80; }
.loop-state.warn { color: #fbbf24; }
.loop-state.err { color: #f87171; }
.loop-state.idle { color: var(--faint); }

.loop-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.loop-badge {
    padding: 3px 10px;
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.1);
    color: #9adcff;
    font-family: var(--mono);
    font-size: 12px;
}

.loop-badge.warn {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.loop-hexrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.loop-hexcap {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.loop-hexrow input {
    flex: 1 1 auto;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: rgba(7, 14, 25, 0.64);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    outline: none;
}

.loop-hexrow input:focus {
    border-color: var(--accent);
}

.loop-hexrow input::placeholder {
    color: var(--faint);
}

.loop-body {
    display: grid;
    grid-template-columns: 336px minmax(0, 1fr);
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

.loop-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.loop-group {
    padding: 12px 14px;
}

.loop-group-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 9px;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--text);
}

.loop-group-title::before {
    content: "";
    width: 2px;
    height: 11px;
    border-radius: 1px;
    background: var(--accent);
    box-shadow: 0 0 7px rgba(56, 189, 248, 0.8);
}

.loop-group-hint {
    margin: 0 0 8px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--faint);
}

.loop-group.is-off {
    opacity: 0.45;
}

.loop-group.is-muted {
    opacity: 0.55;
}

.loop-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.loop-btns .btn,
.loop-row .btn,
.loop-wide {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
}

.loop-checks {
    display: grid;
    gap: 5px 10px;
}

.loop-checks-2 {
    grid-template-columns: 1fr 1fr;
}

.loop-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--muted);
}

.loop-checks input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #38bdf8;
}

.loop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.loop-row select {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 32px;
    border-radius: 5px;
    font-size: 12px;
    padding: 0 26px 0 9px;
}

.loop-row .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.loop-row-pair > .btn {
    flex: 1 1 0;
}

.loop-tip {
    font-size: 11px;
    color: var(--faint);
    white-space: nowrap;
}

.loop-row-input input {
    width: 76px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: rgba(7, 14, 25, 0.64);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    outline: none;
}

.loop-row-input input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.loop-wide {
    width: 100%;
    margin-top: 2px;
}

.loop-center {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.loop-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.loop-tab {
    padding: 7px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: rgba(20, 34, 55, 0.5);
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}

.loop-tab em {
    margin-left: 6px;
    font-style: normal;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
}

.loop-tab:hover {
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--text);
}

.loop-tab.active {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.14);
    color: #dcf4ff;
}

.loop-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.loop-tablewrap {
    max-height: 560px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(8, 14, 24, 0.6);
}

.loop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.loop-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 6px;
    border-bottom: 1px solid var(--line-strong);
    background: #0d1726;
    color: var(--muted);
    font-weight: 500;
    font-size: 11.5px;
    white-space: nowrap;
}

.loop-table td {
    padding: 3px 6px;
    border-bottom: 1px solid rgba(133, 166, 214, 0.08);
    text-align: center;
}

.loop-table tbody tr:hover td {
    background: rgba(56, 189, 248, 0.05);
}

.loop-table .ck-id {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 56px;
    background: #0b1422;
    color: var(--accent);
    font-family: var(--mono);
}

.loop-table thead .ck-id {
    z-index: 3;
    background: #0d1726;
}

.loop-table input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #38bdf8;
}

.loop-rxhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--muted);
}

.loop-rx {
    margin: 0;
    height: 560px;
    overflow: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(8, 14, 24, 0.7);
    color: #a9c4e4;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
}

.loop-logcard {
    margin-top: 16px;
}

.loop-log {
    height: 220px;
    overflow: auto;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(8, 14, 24, 0.7);
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.55;
}

.lg-row {
    display: flex;
    gap: 8px;
}

.lg-time {
    flex: 0 0 auto;
    color: var(--faint);
}

.lg-text {
    color: var(--muted);
    word-break: break-all;
}

.lg-row.tx .lg-text { color: #93c5fd; }
.lg-row.rx .lg-text { color: #86efac; }
.lg-row.ok .lg-text { color: #4ade80; }
.lg-row.warn .lg-text { color: #fbbf24; }
.lg-row.err .lg-text { color: #f87171; }

/* ---------- 485 总线观察 ---------- */

.bus-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(780px, 100vw);
    padding: 14px 16px 16px;
    border-left: 1px solid rgba(56, 189, 248, 0.28);
    background: linear-gradient(180deg, #0b1422, #0a101c);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.55);
    /* 抽屉本身不滚动：接收区吸收剩余高度，发送区常驻底部 */
    overflow: hidden;
}

.bus-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bus-head strong {
    font-size: 14px;
    font-weight: 500;
}

.bus-status {
    flex: 1 1 auto;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
}

.bus-serial {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.bus-serial .field {
    flex: 0 1 116px;
    min-width: 96px;
}

.bus-serial .field select {
    height: 32px;
    border-radius: 5px;
    font-size: 12px;
}

.bus-state {
    padding-bottom: 6px;
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
}

.bus-state.ok { color: #4ade80; }
.bus-state.err { color: #f87171; }
.bus-state.idle { color: var(--faint); }

.bus-recv {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-height: 96px;
    overflow: hidden;
}

.bus-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.bus-count {
    font-family: var(--mono);
    font-size: 11.5px;
    color: #9adcff;
}

.bus-hint {
    font-size: 11px;
    color: var(--faint);
}

.bus-pair {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-height: 0;
}

.bus-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 0;
}

.bus-col-cap {
    font-size: 11px;
    color: var(--faint);
}

.bus-pair textarea {
    flex: 1 1 auto;
    min-height: 72px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: rgba(8, 14, 24, 0.75);
    color: #a9c4e4;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.55;
    white-space: pre;
    overflow: auto;
    resize: none;
}

.bus-send {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
}

.bus-send textarea {
    flex: 0 0 auto;
    height: 76px;
    min-height: 56px;
    max-height: 38vh;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: rgba(8, 14, 24, 0.75);
    color: #a9c4e4;
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: pre-wrap;
    word-break: break-all;
    outline: none;
    resize: vertical;
}

.bus-send textarea:focus {
    border-color: var(--accent);
}

.bus-sendbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.bus-gap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--muted);
}

.bus-gap input {
    width: 80px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: rgba(7, 14, 25, 0.64);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    outline: none;
}

@media (max-width: 1240px) {
    .loop-body {
        grid-template-columns: 1fr;
    }

    .loop-side {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (max-width: 900px) {
    .loop-side {
        grid-template-columns: minmax(0, 1fr);
    }

    .loop-tablewrap {
        max-height: 440px;
    }

    .loop-rx {
        height: 420px;
    }

    .bus-drawer {
        width: 100vw;
        /* 窄屏改为整体滚动，两个接收框各给固定高度 */
        overflow: auto;
    }

    .bus-recv {
        flex: 0 0 auto;
        overflow: visible;
    }

    .bus-pair {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
    }

    .bus-pair textarea {
        flex: 0 0 auto;
        height: 180px;
    }
}
