:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #eef2f4;
  --ink: #182026;
  --ink-soft: #5d6973;
  --line: #d8e0e5;
  --brand: #145c63;
  --brand-strong: #0d4248;
  --green: #217a52;
  --amber: #a76513;
  --red: #b33131;
  --blue: #2c618f;
  --violet: #6950a1;
  --shadow: 0 18px 42px rgba(30, 42, 50, 0.12);
  font-family:
    "Microsoft YaHei UI",
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  color: #ffffff;
  background: #253039;
  border-bottom: 3px solid #18a07d;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  background: #137161;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.72;
}

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

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.3;
}

.handoff-status {
  display: inline-flex;
  align-items: center;
  min-width: 168px;
  gap: 8px;
  padding: 8px 10px;
  color: #dfe9eb;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #929ca3;
}

.status-ok {
  background: #4fce8a;
}

.status-warning {
  background: #f0ac45;
}

.status-bad {
  background: #e16363;
}

.status-pending {
  background: #9aa6ad;
}

main {
  padding: 18px 24px 28px;
}

.connection-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.connection-strip > div {
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
}

.label,
.muted,
.card-kicker {
  color: var(--ink-soft);
}

.label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.connection-strip strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
}

.device-panel,
.detail-panel,
.audit-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.device-panel {
  min-height: 660px;
  padding: 14px;
}

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

.compact-heading {
  margin-bottom: 8px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--brand-strong);
  background: #e4f2ef;
  border: 1px solid #b6d8d1;
  border-radius: 6px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  margin-bottom: 12px;
  padding: 0 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-icon {
  color: var(--ink-soft);
  font-size: 18px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.segmented-control button {
  min-height: 30px;
  color: var(--ink-soft);
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.segmented-control button.active {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.device-list {
  display: grid;
  gap: 8px;
}

.device-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
  color: inherit;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid #91a1aa;
  border-radius: 8px;
}

.device-card.active {
  border-color: #86b9ac;
  border-left-color: var(--brand);
  background: #f2faf8;
}

.device-card[data-state="online"] {
  border-left-color: var(--green);
}

.device-card[data-state="warning"] {
  border-left-color: var(--amber);
}

.device-card[data-state="offline"] {
  border-left-color: var(--red);
}

.device-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-card strong,
.device-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-card small {
  color: var(--ink-soft);
}

.state-badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  background: #edf1f3;
  border-radius: 999px;
}

.state-online,
.pill.success {
  color: var(--green);
  background: #e0f3e9;
}

.state-warning {
  color: var(--amber);
  background: #fff0da;
}

.state-offline,
.pill.danger {
  color: var(--red);
  background: #f9e2e2;
}

.detail-panel {
  padding: 16px;
}

.device-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.summary-actions,
.audit-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
}

.primary-button {
  color: #ffffff;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.secondary-button {
  color: var(--ink);
  background: #f7fafb;
  border: 1px solid var(--line);
}

.text-button {
  color: var(--brand-strong);
  background: transparent;
  border: 0;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-card,
.panel-block {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.status-card strong {
  font-size: 18px;
}

.status-card.ok {
  border-top: 3px solid var(--green);
}

.status-card.warning {
  border-top: 3px solid var(--amber);
}

.status-card.bad {
  border-top: 3px solid var(--red);
}

.status-card.neutral {
  border-top: 3px solid var(--blue);
}

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

.panel-block {
  min-height: 260px;
  padding: 14px;
}

.diagnostics-block {
  border-top: 3px solid var(--blue);
}

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

.metric-item {
  padding: 12px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
}

.metric-item strong {
  display: block;
  font-size: 18px;
}

.event-list,
.sync-list,
.session-stack {
  display: grid;
  gap: 9px;
}

.event-row,
.sync-row,
.session-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.event-row {
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

.severity {
  width: 8px;
  height: 38px;
  border-radius: 8px;
  background: #9aa6ad;
}

.severity.info {
  background: var(--blue);
}

.severity.warning {
  background: var(--amber);
}

.severity.critical {
  background: var(--red);
}

.event-row strong,
.sync-row strong,
.session-row strong {
  display: block;
  font-size: 14px;
}

.event-time,
.sync-row span,
.session-row span {
  color: var(--ink-soft);
  font-size: 12px;
}

.sync-progress {
  height: 8px;
  overflow: hidden;
  background: #dfe7eb;
  border-radius: 999px;
}

.sync-progress > span {
  display: block;
  height: 100%;
  background: var(--green);
}

.audit-section {
  margin-top: 16px;
  padding: 16px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  background: #f0f4f6;
}

td {
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 28px 12px;
  color: var(--ink-soft);
  text-align: center;
  background: #f8fafb;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

@media (max-width: 1180px) {
  .connection-strip,
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .device-panel {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .topbar,
  .device-summary {
    align-items: stretch;
    flex-direction: column;
  }

  main {
    padding: 12px;
  }

  .connection-strip,
  .status-grid,
  .ops-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .summary-actions,
  .audit-tools {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }
}
