:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 30%),
    linear-gradient(180deg, #eef4ff 0%, #f6f8fc 36%, #f3f6fb 100%);
  color: #18212f;
  --bg-soft: #f8fbff;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --border: #dbe6f3;
  --border-strong: #bfd4f7;
  --text-main: #172033;
  --text-muted: #607089;
  --text-soft: #8a99b1;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #e8f0ff;
  --success: #16a34a;
  --success-soft: #e8f9ef;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --warning: #d97706;
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 26px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-soft);
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--text-main);
}

button,
input,
select,
textarea,
progress {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 14px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease, background 0.16s ease;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.18);
}

button:hover {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  box-shadow: 0 14px 22px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 3.5vw, 2.5rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
  line-height: 1.35;
}

.app-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy {
  padding: 10px 2px;
}

.eyebrow,
.section-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-copy p,
.sidebar-head p {
  margin-top: 10px;
  max-width: 72ch;
  color: var(--text-muted);
  line-height: 1.65;
}

.hero-status {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.hero-status-head,
.sidebar-head,
.mode-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.sidebar-head .eyebrow,
.section-tag {
  width: fit-content;
}

.status-stack {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status,
.mini-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #eef3fb;
  color: #38506f;
  padding: 8px 12px;
  white-space: nowrap;
}

.status::before,
.mini-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.mini-status {
  padding: 6px 10px;
  font-size: 12px;
}

.status.ok,
.mini-status.ok {
  background: var(--success-soft);
  border-color: #c7edd4;
  color: #116132;
}

.status.ok::before,
.mini-status.ok::before {
  background: var(--success);
}

.status.bad,
.mini-status.bad {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

.status.bad::before,
.mini-status.bad::before {
  background: #ef4444;
}

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

.panel,
.sub-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.sidebar {
  position: sticky;
  top: 14px;
  box-shadow: var(--shadow-lg);
}

.compact-connect {
  padding-top: 18px;
}

.mode-choice {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.mode-choice label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
  color: var(--text-main);
  font-weight: 600;
}

.mode-choice input,
.switch-line input,
.check-label input,
.inline-check input {
  width: auto;
  accent-color: var(--brand);
}

.mode-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.mode-panel + .mode-panel {
  margin-top: 14px;
}

.mode-panel.hidden,
.hidden {
  display: none;
}

.mode-panel-head strong,
.ble-status-line strong {
  font-size: 1rem;
}

.compact-connect .field-row {
  grid-template-columns: 92px minmax(0, 1fr);
}

.connect-open-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.connect-led {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #9ca3af;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.16);
}

.connect-led.on {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.18);
}

.two-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ble-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-main);
  margin: 0;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.selected-line {
  display: grid;
  gap: 4px;
  min-height: 22px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

.selected-label {
  font-size: 12px;
  color: var(--text-soft);
}

.main-panel {
  min-width: 0;
}

.card-title,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head > div:first-child {
  display: grid;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
}

.tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  box-shadow: none;
}

.tab:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  box-shadow: none;
}

.tab.active {
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.console-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.version-line {
  display: inline-grid;
  grid-template-columns: auto minmax(90px, auto);
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #cad6e5;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.version-line span {
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
}

.version-line strong {
  min-width: 88px;
  color: #0f172a;
  font-size: 15px;
  text-align: center;
}

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

.config-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid #cad6e5;
  border-radius: 8px;
  background: #f8fbff;
}

.config-actions button,
.preview-action-row button,
.console-head-actions button {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 6px;
  box-shadow: none;
}

.config-actions button:hover,
.preview-action-row button:hover,
.console-head-actions button:hover {
  transform: none;
  box-shadow: none;
}

.config-actions .ghost-button,
.preview-action-row .ghost-button {
  border: 1px solid #cad6e5;
  background: #fff;
  color: #334155;
  box-shadow: none;
}

.config-actions .ghost-button:hover,
.preview-action-row .ghost-button:hover {
  border-color: var(--brand);
  background: #eef5ff;
  color: var(--brand-dark);
  box-shadow: none;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #46576e;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--text-main);
  background: #fff;
  border: 1px solid #cad6e5;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c9e2;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.device-list {
  margin-top: 2px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.empty-row {
  padding: 16px;
  color: var(--text-muted);
}

.device-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #edf2f8;
  border-radius: 0;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  box-shadow: none;
}

.device-row:hover {
  background: #eff5ff;
  color: var(--brand-dark);
}

.device-row.selected {
  background: #e8f0ff;
  box-shadow: inset 4px 0 0 var(--brand);
}

.device-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.device-main small,
.device-rssi {
  color: var(--text-muted);
}

.metrics-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.qt-console-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  box-shadow: var(--shadow-sm);
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -20px -20px auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.06);
}

.metric span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.15;
  color: #0f172a;
}

.indicator-panel,
.fault-panel,
.config-summary,
.fold-panel,
details {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.indicator-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px 16px;
}

.fault-panel {
  margin-top: 14px;
  padding: 14px 16px;
}

.front-fault-panel {
  margin-top: 0;
  margin-bottom: 14px;
}

.fault-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.fault-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.fault-lamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--text-muted);
  border: 1px solid #dbe5f1;
  border-radius: 999px;
  background: #fff;
}

.fault-lamp::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #94a3b8;
}

.fault-lamp.on {
  background: var(--danger-soft);
  border-color: #fecdd3;
  color: #be123c;
}

.fault-lamp.on::before {
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12);
}

.indicator-row {
  display: flex;
  gap: 12px;
}

.lamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-weight: 700;
}

.lamp.on {
  background: var(--success);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.16);
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.qt-checkbox-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.config-summary {
  margin-top: 14px;
  padding: 14px 16px;
  color: #334155;
}

.filter-input {
  margin: 14px 0 10px;
}

.fold-panel,
details {
  margin-bottom: 12px;
  padding: 14px 16px;
}

.fold-panel summary,
summary {
  cursor: pointer;
  font-weight: 700;
  color: #334155;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 13px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #edf1f7;
}

th {
  position: sticky;
  top: 0;
  background: #f8fbff;
  color: #475569;
  z-index: 1;
}

tbody tr:hover td {
  background: #f9fbff;
}

tr.pending-changed td {
  background: #fef9ec;
}

tr.pending-changed td code {
  color: #b45309;
}

tr.pending-changed:hover td {
  background: #fdf3d8;
}

td code {
  color: #0f4eb8;
}

.split-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
}

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

.qt-config-grid {
  align-items: end;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.config-form-panel {
  display: grid;
  gap: 16px;
}

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

.form-section-copy {
  display: grid;
  gap: 6px;
}

.form-section-copy p,
.config-group-head p {
  color: var(--text-muted);
  line-height: 1.5;
}

.config-group {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.config-group-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.config-group-head h4 {
  margin: 0;
  font-size: 15px;
  color: #0f172a;
}

.config-group-grid,
.config-info-grid,
.config-switch-grid {
  display: grid;
  gap: 12px;
}

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

.config-info-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.config-switch-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stack-field {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stack-field > span {
  color: #334155;
  font-weight: 600;
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.input-with-unit em {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 600;
}

.info-card {
  justify-content: space-between;
  min-height: 88px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fbfdff;
}

.info-card span {
  color: var(--text-muted);
}

.info-card strong {
  font-size: 22px;
  color: #0f172a;
}

.switch-card {
  min-height: 52px;
  margin: 0;
  justify-content: flex-start;
}

.text-button {
  min-width: 96px;
  width: auto;
  padding: 10px 14px;
}

.field-row {
  display: grid;
  align-items: center;
  gap: 8px;
  grid-template-columns: 96px minmax(0, 1fr);
}

.field-row > span {
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
}

.unit-field {
  grid-template-columns: 96px minmax(0, 1fr) 24px;
}

.unit-field em {
  color: var(--text-muted);
  font-style: normal;
}

.send-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.send-row button {
  min-height: 44px;
  align-self: end;
}

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

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

.cal-buttons {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.cal-direct {
  display: grid;
  gap: 10px;
}

.qt-config-import {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 280px) minmax(260px, max-content);
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.qt-config-import .template-source {
  width: auto;
}

.qt-config-import .switch-card {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
}

.cal-direct {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.cal-readout {
  display: grid;
  gap: 6px 10px;
  grid-template-columns: auto 1fr;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
}

.cal-readout span {
  color: var(--text-muted);
}

.cal-readout strong {
  text-align: right;
}

.cal-step {
  display: grid;
  gap: 8px;
  align-items: center;
  grid-template-columns: 1fr auto auto;
}

.cal-step-head,
.cal-step-row {
  display: grid;
  gap: 6px;
  align-items: center;
  grid-template-columns: 36px repeat(4, minmax(42px, 1fr));
}

.cal-step-head {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.cal-step-row > span {
  color: #334155;
  font-weight: 700;
}

.cal-step-row button {
  min-height: 34px;
  padding: 7px 8px;
}

.check-label,
.file-line,
.qt-info-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-label {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdff;
}

.file-line input {
  background: #f8fbff;
}

.inline-check {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
}

.mini-button {
  width: 40px;
  height: 40px;
  padding: 0;
  align-self: end;
}

.compact-table {
  margin-top: 12px;
  max-height: 260px;
}

.preview-panel {
  align-content: start;
}

.preview-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

.preview-action-row {
  width: fit-content;
  max-width: 100%;
}

.preview-metrics {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.preview-item {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fbff;
}

.preview-item span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.preview-item strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.voltage-chart {
  display: grid;
  place-items: center;
  min-height: 290px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.voltage-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-empty {
  color: var(--text-muted);
  font-size: 14px;
}

.chart-axis {
  stroke: #94a3b8;
  stroke-width: 1;
}

.chart-grid {
  stroke: #e2e8f0;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart-voltage-line,
.chart-current-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-voltage-line {
  stroke: #2563eb;
}

.chart-current-line {
  stroke: #f59e0b;
}

.chart-axis-title {
  font-size: 15px;
  font-weight: 700;
}

.chart-voltage-label,
.chart-voltage-points text {
  fill: #1d4ed8;
}

.chart-current-label,
.chart-current-points text {
  fill: #b45309;
}

.chart-voltage-points text,
.chart-current-points text,
.chart-legend text {
  font-size: 13px;
  font-weight: 600;
}

.chart-voltage-points circle {
  fill: #2563eb;
  stroke: #fff;
  stroke-width: 2;
}

.chart-current-points circle {
  fill: #f59e0b;
  stroke: #fff;
  stroke-width: 2;
}

.chart-line {
  fill: none;
  stroke: #2563eb;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-target,
.chart-threshold {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 2;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-label,
.chart-points text {
  fill: #475569;
  font-size: 13px;
}

.chart-points circle {
  fill: #2563eb;
  stroke: #fff;
  stroke-width: 2;
}

.chart-target-label,
.chart-threshold-label {
  fill: #b45309;
}

progress {
  width: 100%;
  height: 18px;
  margin-top: 14px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e2e8f0;
}

progress::-webkit-progress-bar {
  background: #e2e8f0;
  border-radius: 999px;
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #60a5fa);
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #60a5fa);
}

pre {
  max-height: 420px;
  margin: 14px 0 0;
  overflow: auto;
  padding: 14px;
  border-radius: 16px;
  background: #0f172a;
  color: #d8e4ff;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

@media (max-width: 1240px) {
  .topbar,
  .layout,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .qt-checkbox-row,
  .cal-grid,
  .preview-metrics {
    grid-template-columns: 1fr;
  }

  .config-info-grid,
  .config-switch-grid,
  .preview-action-row,
  .qt-config-import {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  .app-shell {
    padding: 18px 14px 24px;
  }

  .topbar,
  .panel-head,
  .card-title {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-grid,
  .form-grid,
  .send-row,
  .ota-grid,
  .fault-grid,
  .qt-checkbox-row,
  .preview-metrics,
  .preview-action-row,
  .qt-config-import,
  .two-buttons {
    grid-template-columns: 1fr;
  }

  .field-row,
  .unit-field,
  .cal-direct {
    grid-template-columns: 1fr;
  }

  .form-section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .config-group-grid {
    grid-template-columns: 1fr;
  }

  .indicator-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--text-main);
  box-shadow: none;
  max-height: 90vh;
  overflow: visible;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

.spec-dialog {
  width: min(780px, 92vw);
}

.spec-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 14px;
  background: var(--bg-panel);
  border-radius: 24px 24px 0 0;
  border-bottom: 1px solid var(--border);
}

.spec-dialog-head h3 {
  margin: 0;
  font-size: 16px;
}

.spec-image-wrap {
  padding: 16px 24px 20px;
  background: var(--bg-panel);
  border-radius: 0 0 24px 24px;
  overflow: auto;
  max-height: calc(90vh - 80px);
}

.spec-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.message-dialog {
  width: min(520px, 90vw);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}

.message-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.message-dialog-head h3 {
  margin: 0;
  font-size: 16px;
}

.message-dialog pre {
  margin: 0;
  max-height: 50vh;
  padding: 20px 24px;
  font-size: 13px;
  line-height: 1.65;
}

.message-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
}

.config-dialog {
  width: min(640px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}

.config-dialog.wide-dialog {
  width: min(820px, 94vw);
}

.config-dialog-body {
  padding: 16px 24px 20px;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
  display: grid;
  gap: 16px;
}

.dialog-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.dialog-card h4 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #0f172a;
}

.dialog-button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

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

.dialog-check-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.dialog-actions-inline {
  padding: 0;
  justify-content: flex-start;
}

.record-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.record-list:empty {
  display: none;
}

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1f7;
  font-size: 14px;
}

.record-row:last-child {
  border-bottom: 0;
}

.record-row .record-name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.record-row .record-name strong {
  font-size: 14px;
  color: var(--text-main);
}

.record-row .record-name small {
  font-size: 12px;
  color: var(--text-muted);
}

.record-row .record-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.combo-table {
  width: 100%;
  border-collapse: collapse;
}

.combo-table th,
.combo-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #edf1f7;
  font-size: 14px;
}

.combo-table th {
  background: #f8fbff;
  color: var(--text-muted);
  font-weight: 600;
}

.combo-table td .mini-status {
  font-size: 11px;
  padding: 4px 8px;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: none;
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ghost-button:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
  box-shadow: none;
  transform: none;
}

.ghost-button:active {
  transform: none;
}

@media (max-width: 700px) {
  dialog {
    width: 96vw;
    max-width: 96vw;
  }

  .config-dialog,
  .config-dialog.wide-dialog {
    width: 96vw;
  }

  .dialog-form-grid {
    grid-template-columns: 1fr;
  }

  .dialog-check-grid {
    grid-template-columns: 1fr;
  }

  .message-dialog-actions {
    flex-direction: column;
  }
}
