:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-2: #eaf0f7;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --ink: #0d1826;
  --text: #243246;
  --muted: #6d7b8f;
  --faint: #9aa8ba;
  --line: #dce5ef;
  --line-strong: #c6d3e2;
  --nav: #0b1020;
  --nav-2: #121a2d;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --teal: #0f766e;
  --success: #128047;
  --success-bg: #e7f8ee;
  --danger: #c2413f;
  --danger-bg: #fdeceb;
  --warning: #9a6a1c;
  --warning-bg: #fff5da;
  --shadow: 0 18px 46px rgba(35, 48, 75, 0.1);
  --shadow-soft: 0 10px 30px rgba(35, 48, 75, 0.07);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 0 0, rgba(79, 70, 229, 0.08), transparent 26rem),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  background: linear-gradient(135deg, var(--nav), var(--nav-2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 40px rgba(10, 16, 32, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #f8fafc;
  min-width: 0;
}

.brand:hover {
  color: #ffffff;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 700;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  color: #ffffff;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  color: #91a0b6;
  font-size: 12px;
}

nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

nav a,
.link-button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: #cbd5e1;
  background: transparent;
  padding: 8px 10px;
  min-height: 34px;
}

nav a:hover,
.link-button:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.container {
  width: min(1240px, calc(100% - 40px));
  margin: 28px auto 48px;
}

.page-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-head {
  margin-bottom: 20px;
}

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

h1,
h2 {
  color: var(--ink);
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  font-weight: 720;
}

h2 {
  font-size: 19px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.page-subtitle,
.muted {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.panel,
.metric-card,
.table-section {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 22px;
}

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

.metric-card {
  padding: 18px;
  min-height: 118px;
  display: grid;
  align-content: space-between;
}

.metric-card span {
  color: var(--muted);
  font-weight: 600;
}

.metric-card strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}

.instrument-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  margin-bottom: 16px;
}

.instrument-panel {
  display: grid;
  grid-template-columns: minmax(230px, 290px) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 250px;
}

.dial-wrap {
  min-width: 0;
}

.dial-svg {
  width: 100%;
  max-width: 290px;
  display: block;
}

.dial-track,
.dial-value {
  fill: none;
  stroke-linecap: round;
  stroke-width: 17;
}

.dial-track {
  stroke: #dfe8f3;
}

.dial-value {
  stroke: url("#dial-gradient");
}

.dial-needle {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 3px 5px rgba(13, 24, 38, 0.18));
}

.dial-pin {
  fill: var(--ink);
  stroke: #ffffff;
  stroke-width: 4;
}

.dial-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
}

.dial-label-mid {
  fill: var(--teal);
}

.dial-label-end {
  fill: var(--success);
}

.instrument-readout {
  min-width: 0;
}

.instrument-readout h2 {
  font-size: 25px;
}

.readout-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 4px;
  flex-wrap: wrap;
}

.readout-line strong {
  color: var(--ink);
  font-size: 42px;
  line-height: 1;
}

.operation-panel {
  display: grid;
  align-content: start;
}

.operation-list {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.operation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.operation-row span {
  color: var(--muted);
  font-weight: 700;
}

.operation-row strong {
  color: var(--ink);
  font-size: 25px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.gauge-panel {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.gauge {
  width: 142px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 57%, transparent 58%),
    conic-gradient(var(--primary) calc(var(--value) * 1%), #e4ebf4 0);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-soft);
}

.gauge span {
  color: var(--ink);
  font-size: 28px;
  font-weight: 760;
}

.distribution {
  height: 10px;
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
  margin-top: 18px;
}

.distribution-on {
  background: linear-gradient(90deg, var(--success), #20a66b);
}

.distribution-off {
  background: #d7e1ec;
}

.activity-panel {
  min-height: 232px;
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.activity-item strong {
  color: var(--ink);
}

.activity-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.table-section {
  overflow: hidden;
}

.table-section > .section-head {
  padding: 18px 20px 0;
}

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

th,
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f5f8fc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f8fbff;
}

td strong {
  color: var(--ink);
}

.product-cell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.product-cell p {
  margin: 6px 0 0;
  color: var(--muted);
  display: -webkit-box;
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-thumb {
  width: 76px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef3f9;
  object-fit: cover;
}

code,
pre,
.mono-cell {
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
}

code {
  color: #37506d;
  font-size: 12px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #1f2a44;
  color: #dbeafe;
  line-height: 1.7;
}

.mono-cell {
  color: var(--muted);
  font-size: 12px;
}

.status,
.event-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.on {
  color: var(--success);
  background: var(--success-bg);
}

.status.off {
  color: var(--danger);
  background: var(--danger-bg);
}

.status.neutral {
  color: #64748b;
  background: #eef3f9;
}

.event-pill {
  color: #41516a;
  background: #eef3f9;
}

button,
.button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: #eef3f9;
  color: #243246;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 100%;
}

button:hover,
.button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.primary-action {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.24);
}

.primary-action:hover {
  background: var(--primary-hover);
  color: #ffffff;
}

.secondary {
  background: #edf2f7;
  color: #334155;
}

.danger {
  background: var(--danger);
  color: #ffffff;
}

.danger:hover {
  background: #a93431;
  color: #ffffff;
}

.link-button {
  min-height: 34px;
}

.inline {
  display: inline;
}

.table-action {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #eef3f9;
  color: var(--primary);
  font-weight: 700;
}

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

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

.form-panel {
  max-width: 720px;
}

.software-preview {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.software-preview img {
  width: 100%;
  max-height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef3f9;
  object-fit: contain;
}

.software-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: grid;
  gap: 7px;
  color: #314157;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  font: inherit;
  background: #ffffff;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(79, 70, 229, 0.22);
  border-color: var(--primary);
}

.login-shell {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 30px;
  align-items: center;
}

.login-copy {
  padding: 28px 0;
}

.login-copy h1 {
  font-size: 42px;
  max-width: 620px;
}

.login-copy p {
  max-width: 600px;
  color: var(--muted);
  line-height: 1.7;
}

.login-status-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.login-status-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 12px;
  color: var(--muted);
  min-width: 0;
}

.login-status-grid strong {
  display: block;
  color: var(--ink);
}

.login-panel {
  box-shadow: var(--shadow);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.state-panel {
  min-height: 220px;
  display: grid;
  align-content: space-between;
}

.state-panel h2 {
  font-size: 27px;
}

.state-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.state-on {
  border-color: rgba(18, 128, 71, 0.24);
  background: linear-gradient(180deg, #ffffff, #f1fbf5);
}

.state-off {
  border-color: rgba(194, 65, 63, 0.24);
  background: linear-gradient(180deg, #ffffff, #fff4f4);
}

.config-panel,
.danger-zone {
  grid-column: 2;
}

.edit-panel {
  grid-column: 1;
  grid-row: span 2;
}

.danger-zone {
  border-color: rgba(194, 65, 63, 0.22);
}

.empty,
.error {
  color: var(--muted);
}

.error {
  border: 1px solid rgba(194, 65, 63, 0.24);
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
}

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

  .instrument-grid,
  .overview-grid,
  .detail-layout,
  .login-shell {
    grid-template-columns: 1fr;
  }

  .instrument-panel {
    grid-template-columns: 1fr;
  }

  .dial-svg {
    margin: 0 auto;
  }

  .config-panel,
  .danger-zone,
  .edit-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .login-status-grid {
    grid-template-columns: 1fr;
  }

  .product-thumb {
    width: 64px;
    height: 40px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .page-head,
  .section-head {
    display: grid;
  }

  .topbar {
    padding: 14px 18px;
  }

  .container {
    width: min(100% - 24px, 1240px);
    margin-top: 18px;
  }

  h1,
  .login-copy h1 {
    font-size: 26px;
  }

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

  .gauge-panel {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  th,
  td {
    padding: 12px 14px;
  }
}
