:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: #17212b;
    background: #eef2f5;
    --ink: #17212b;
    --muted: #65717d;
    --line: #d9e0e5;
    --surface: #ffffff;
    --accent: #087f5b;
    --accent-strong: #066649;
    --warning: #d97706;
    --danger: #c2413b;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #eef2f5; }
button, input, select { font: inherit; }
button, .secondary-button { min-height: 38px; border: 1px solid var(--accent); border-radius: 6px; padding: 0 16px; background: var(--accent); color: white; cursor: pointer; }
button:hover { background: var(--accent-strong); }
label { display: grid; gap: 7px; color: #3c4853; font-size: 14px; }
input, select { width: 100%; min-height: 40px; border: 1px solid #bac5cd; border-radius: 5px; padding: 8px 10px; background: white; color: var(--ink); }
input:focus, select:focus { outline: 2px solid #84d7bc; border-color: var(--accent); }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef2f5; }
.login-panel { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 36px; box-shadow: 0 12px 30px rgba(23, 33, 43, .08); }
.brand-mark { color: var(--accent); font-size: 38px; font-weight: 800; letter-spacing: 0; }
h1 { margin: 4px 0 10px; font-size: 24px; }
h2 { margin: 0 0 4px; font-size: 20px; }
h3 { margin: 0 0 4px; font-size: 16px; }
p { margin: 0; color: var(--muted); }
.form-stack { display: grid; gap: 16px; margin-top: 26px; }
.text-button { margin-top: 18px; padding: 0; min-height: auto; border: 0; background: transparent; color: var(--accent); }
.text-button:hover { background: transparent; text-decoration: underline; }
.error-text { min-height: 20px; margin-top: 14px; color: var(--danger); font-size: 14px; }
.scan-login-hint { padding: 14px; border: 1px solid var(--line); color: var(--muted); text-align: center; }
.app-shell { min-height: 100vh; }
.topbar { height: 64px; padding: 0 max(20px, calc((100vw - 1280px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #17212b; color: white; }
.topbar > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.product-name { font-size: 24px; color: #5fd3aa; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar select { width: 220px; min-height: 36px; }
.role-label { font-size: 13px; color: #cbd5dc; }
.sync-status { font-size: 12px; color: #d6a34a; white-space: nowrap; }
.sync-status.connected { color: #5fd3aa; }
.icon-button { width: 38px; padding: 0; font-size: 21px; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; background: transparent; border-color: #8b9aa5; color: inherit; text-decoration: none; }
.tabs { display: flex; gap: 2px; padding: 0 max(20px, calc((100vw - 1280px) / 2)); overflow-x: auto; background: white; border-bottom: 1px solid var(--line); }
.tab { min-width: max-content; border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 14px 16px 11px; background: transparent; color: #4b5863; }
.tab:hover, .tab.active { background: #f2f7f5; color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 48px; }
.tab-panel.active { display: block; }
.section-heading { min-height: 52px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.query-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.query-controls input { width: 190px; min-height: 38px; }
.status-badge { border-radius: 999px; padding: 6px 12px; background: #e5e9ec; color: #53616c; font-size: 13px; font-weight: 700; }
.status-badge.online { background: #d9f4e9; color: #087f5b; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.metric-grid article { min-height: 130px; padding: 22px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span, .detail-band span { color: var(--muted); font-size: 13px; }
.metric-grid strong { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-grid small { color: var(--muted); }
.detail-band { margin-top: 16px; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.detail-band div { padding: 16px 18px; display: grid; gap: 6px; border-right: 1px solid var(--line); }
.detail-band div:last-child { border-right: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid #e7ebee; font-size: 14px; }
th { background: #f5f7f8; color: #4b5863; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
#protocol table { min-width: 1500px; }
#protocol th:nth-child(5), #protocol td:nth-child(5) { min-width: 520px; }
#protocol th:nth-child(6), #protocol td:nth-child(6) { min-width: 360px; }
#protocol td:nth-child(5), #protocol td:nth-child(6) { font-family: Consolas, "Courier New", monospace; line-height: 1.6; overflow-wrap: normal; word-break: normal; }
.empty-row { text-align: center; color: var(--muted); padding: 30px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 18px 24px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; padding-top: 8px; }
.danger-button { border-color: var(--danger); background: transparent; color: var(--danger); }
.danger-button:hover { background: #fff0ef; }
.management-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.management-table { margin-top: 18px; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.tool-panel { display: grid; align-content: start; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
output { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--muted); font-size: 13px; }
.access-qr { width: min(240px, 100%); height: auto; justify-self: center; border: 10px solid white; image-rendering: pixelated; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; padding: 13px 16px; border-radius: 6px; background: #17212b; color: white; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.simulator-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 50px; }
.simulator-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 24px; }
.simulator-header > div { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 14px; }
.simulator-header p { grid-column: 2; }
.brand-mark.small { font-size: 25px; }
.secondary-button.dark { border-color: #667681; color: var(--ink); }
.simulator-layout { display: grid; grid-template-columns: minmax(620px, 1.25fr) minmax(380px, .75fr); gap: 20px; align-items: start; }
.simulator-controls, .message-console { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 22px; }
.simulator-fields { padding: 0; border: 0; }
.toggle-label { display: flex; grid-auto-flow: column; align-items: center; gap: 8px; }
.toggle-label input, .fault-fieldset input { width: 17px; min-height: 17px; accent-color: var(--accent); }
.fault-fieldset { margin: 20px 0; padding: 16px; display: flex; flex-wrap: wrap; gap: 16px 24px; border: 1px solid var(--line); border-radius: 6px; }
.fault-fieldset legend { padding: 0 8px; color: var(--muted); font-size: 14px; }
.fault-fieldset label { display: flex; align-items: center; grid-auto-flow: column; gap: 7px; }
.simulator-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.message-list { min-height: 460px; max-height: 720px; overflow: auto; display: grid; align-content: start; gap: 10px; }
.message-item { border-left: 4px solid var(--accent); background: #f1f7f5; padding: 12px; }
.message-item.down { border-left-color: #2563a5; background: #f0f5fa; }
.message-item div { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.message-item code { display: block; overflow-wrap: anywhere; color: #293640; font-size: 12px; line-height: 1.6; }
@media (max-width: 900px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .metric-grid article:nth-child(3) { border-right: 0; }
    .metric-grid article { border-bottom: 1px solid var(--line); }
    .detail-band, .management-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar { height: auto; min-height: 64px; padding: 12px 20px; align-items: flex-start; }
    .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
    .simulator-layout { grid-template-columns: 1fr; }
    .section-heading { flex-wrap: wrap; }
    .query-controls { justify-content: flex-start; }
}
@media (max-width: 600px) {
    .login-panel { padding: 26px 22px; }
    .topbar { display: grid; }
    .topbar-actions { justify-content: flex-start; }
    .topbar select { width: min(100%, 230px); }
    .tab-panel { width: calc(100% - 24px); padding-top: 20px; }
    .tabs { padding: 0 8px; }
    .metric-grid, .detail-band, .management-grid, .settings-grid { grid-template-columns: 1fr 1fr; }
    .metric-grid article:nth-child(odd), .detail-band div:nth-child(odd) { border-right: 1px solid var(--line); }
    .metric-grid article:nth-child(even), .detail-band div:nth-child(even) { border-right: 0; }
    .settings-grid { padding: 18px; }
    .form-actions { flex-direction: column; }
    .simulator-shell { width: calc(100% - 24px); }
    .simulator-header { align-items: flex-start; }
    .simulator-header > div { display: block; }
    .simulator-header p { margin-top: 5px; }
    .simulator-fields { grid-template-columns: 1fr 1fr; }
}
