:root {
  color-scheme: light;
  --bg: #eef3f5;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --text: #172126;
  --muted: #64737a;
  --line: #d8e2e4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f4ef;
  --warn: #b45309;
  --danger: #b42318;
  --blue: #2563eb;
  --green: #16803c;
  --gray: #64737a;
  --neutral: #475569;
  --shadow: 0 18px 50px rgba(24, 39, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.18), rgba(180, 83, 9, 0.08)),
    var(--bg);
}

.login-shell {
  width: min(100%, 440px);
}

.login-panel {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  flex: 0 0 auto;
  object-fit: contain;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

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

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #30434a;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.login-form button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.login-form button,
.primary-button {
  color: #fff;
  background: var(--accent);
}

.login-form button:hover,
.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 0 16px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.ghost-button {
  width: 100%;
  color: #33474e;
  background: #eef4f5;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #f9fbfb;
}

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row strong {
  line-height: 1.25;
}

.brand-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  padding: 10px 12px;
  border-radius: 6px;
  color: #30434a;
  background: transparent;
  text-decoration: none;
  font-weight: 650;
  text-align: left;
}

.nav-item.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.nav-item.disabled {
  color: #93a1a5;
  pointer-events: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(238, 243, 245, 0.56);
  backdrop-filter: blur(2px);
}

.loading-panel {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d9f4ef;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(23, 33, 38, 0.42);
}

.modal-panel {
  width: min(100%, 1180px);
  max-height: calc(100vh - 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.order-lifecycle-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-close-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #42565e;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.modal-chart {
  max-height: calc(100vh - 160px);
  border-bottom: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar .ghost-button {
  margin-top: auto;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.filter-band,
.table-region,
.timeline-region,
.chart-region {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filter-band {
  position: relative;
  margin-bottom: 32px;
  padding: 18px;
  padding-bottom: 24px;
}

.filter-form {
  display: grid;
  gap: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}

.advanced-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.check-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check-label input {
  width: 16px;
  min-height: 16px;
}

.filter-actions {
  display: flex;
  min-height: 40px;
  align-items: end;
  justify-content: flex-end;
}

.search-button {
  min-width: 96px;
  padding: 0 28px;
}

.filter-control-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

.order-filter-field {
  min-width: 0;
}

.advanced-toggle-tab {
  position: absolute;
  right: 16px;
  top: 100%;
  display: grid;
  width: 36px;
  min-height: 24px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  color: var(--accent-dark);
  background: #fff;
  box-shadow: 0 8px 18px rgba(24, 39, 44, 0.12);
}

.advanced-toggle-tab:hover,
.advanced-toggle-tab:focus {
  color: #fff;
  background: var(--accent);
}

.advanced-toggle-icon {
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease, margin 0.16s ease;
}

.advanced-toggle-tab[aria-expanded="true"] .advanced-toggle-icon {
  margin-top: 4px;
  transform: rotate(225deg);
}

.status-line {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.result-status {
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--panel);
}

.status-line[data-type="error"] {
  color: var(--danger);
}

.status-line[data-type="ok"] {
  color: var(--accent-dark);
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 390px);
}

.hidden {
  display: none !important;
}

.view-switch {
  display: inline-flex;
  gap: 2px;
  margin: 0 0 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.view-tab {
  min-width: 72px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: #52666d;
  background: transparent;
  font-weight: 750;
}

.view-tab.active {
  color: #fff;
  background: var(--accent);
}

.workspace-panel {
  display: block;
}

.profile-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.profile-current-grid,
.profile-metric-grid,
.profile-grid-two {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

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

.profile-metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.profile-current-card,
.profile-metric-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.profile-current-card span,
.profile-metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.profile-current-card strong,
.profile-metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.profile-current-card small,
.profile-metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.profile-section {
  margin-bottom: 14px;
}

.compact-chart {
  min-height: 220px;
}

.compact-table-scroll {
  max-height: 340px;
}

.compact-table-scroll table {
  min-width: 720px;
}

.inline-action-button {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 750;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
  font: inherit;
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: var(--accent);
}

.transaction-link {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.timeline-region,
.chart-region {
  border-radius: 0 0 8px 8px;
  border-top: 0;
}

.timeline-toolbar,
.chart-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.timeline-toolbar h2,
.chart-toolbar h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.timeline-toolbar p,
.chart-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.timeline-legend,
.chart-status-legend,
.chart-legend,
.event-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.timeline-legend span,
.chart-status-legend span,
.chart-legend span,
.event-chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  gap: 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.timeline-legend span,
.chart-status-legend span,
.chart-legend span,
.event-chip {
  padding: 2px 8px;
  color: #43565d;
  background: #eef4f5;
}

.status-badge {
  padding: 2px 8px;
}

.legend-swatch,
.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.status-offline {
  --status-color: var(--gray);
  --status-soft: #eef1f3;
  --status-text: #47555b;
}

.status-fault {
  --status-color: var(--danger);
  --status-soft: #fee4df;
  --status-text: #8f1f16;
}

.status-idle {
  --status-color: var(--green);
  --status-soft: #dff5e6;
  --status-text: #126b34;
}

.status-charging {
  --status-color: var(--blue);
  --status-soft: #dbeafe;
  --status-text: #1d4ed8;
}

.status-normal {
  --status-color: var(--accent);
  --status-soft: var(--accent-soft);
  --status-text: var(--accent-dark);
}

.status-unknown {
  --status-color: var(--neutral);
  --status-soft: #edf1f5;
  --status-text: #405060;
}

.power-swatch {
  background: var(--warn);
}

.voltage-swatch {
  background: var(--blue);
}

.current-swatch {
  background: #059669;
}

.temperature-swatch {
  background: var(--danger);
}

.duration-swatch {
  background: var(--neutral);
}

.legend-swatch.status-offline,
.legend-swatch.status-fault,
.legend-swatch.status-idle,
.legend-swatch.status-charging,
.duration-bar,
.chart-legend i {
  background: var(--status-color);
}

.event-chip.status-offline,
.event-chip.status-fault,
.event-chip.status-idle,
.event-chip.status-charging,
.event-chip.status-normal,
.event-chip.status-unknown,
.status-badge.status-offline,
.status-badge.status-fault,
.status-badge.status-idle,
.status-badge.status-charging,
.status-badge.status-normal,
.status-badge.status-unknown {
  color: var(--status-text);
  background: var(--status-soft);
}

.metric-chart,
.svg-chart {
  min-height: 260px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  overflow: auto;
}

.metric-chart svg,
.svg-chart svg {
  display: block;
  min-width: 100%;
  max-width: none;
  height: auto;
}

.chart-empty,
.timeline-empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.chart-legend {
  margin-top: 8px;
}

.timeline-list {
  display: grid;
  max-height: calc(100vh - 470px);
  overflow: auto;
}

.timeline-event {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;
  border-left: 4px solid var(--status-color);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.timeline-event:last-child {
  border-bottom: 0;
}

.event-time {
  color: #53676f;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  line-height: 28px;
  white-space: nowrap;
}

.event-body {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.event-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.event-header strong {
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.duration-shell {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.event-marker-row {
  grid-column: 1 / -1;
  display: flex;
  min-height: 24px;
  align-items: flex-end;
  gap: 8px;
}

.duration-track {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f4;
}

.duration-bar {
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: var(--status-color);
}

.duration-value {
  color: #42565e;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fault-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #8f1f16;
  background: #fee4df;
  font-size: 12px;
  font-weight: 800;
}

.heat-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff1d6;
  font-size: 15px;
}

.event-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1240px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-soft);
  color: #42565e;
  font-weight: 750;
}

td {
  color: #26383f;
}

.expand-cell {
  width: 52px;
}

.row-expand-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-dark);
  background: #f7fbfa;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.row-expand-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.message-detail-row td {
  padding: 0;
  white-space: normal;
  background: #f7faf9;
}

.message-detail-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--line);
}

.message-detail-title {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.message-detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-detail-summary span {
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #26383f;
  background: #fff;
  overflow-wrap: anywhere;
}

.message-detail-summary strong {
  color: var(--muted);
}

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

.message-detail-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-detail-block h3 {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: #42565e;
  font-size: 13px;
}

.message-detail-block pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  color: #172126;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-cell {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    padding: 16px;
  }

  .nav-list {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar .ghost-button {
    width: auto;
    margin-top: 0;
    padding: 0 14px;
  }

  .filter-grid,
  .advanced-filter-grid,
  .profile-filter-grid,
  .profile-current-grid,
  .profile-metric-grid,
  .profile-grid-two,
  .message-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-toolbar,
  .chart-toolbar,
  .event-header {
    display: grid;
  }

  .timeline-list {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .main-panel {
    padding: 16px;
  }

  .page-header,
  .sidebar {
    display: grid;
  }

  .filter-grid,
  .advanced-filter-grid,
  .profile-filter-grid,
  .profile-current-grid,
  .profile-metric-grid,
  .profile-grid-two,
  .message-detail-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .filter-control-row,
  .filter-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .table-scroll {
    max-height: none;
  }

  .timeline-event {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .duration-shell {
    grid-template-columns: 1fr;
  }
}
