:root {
  --yellow: #ffc400;
  --yellow-deep: #f5aa00;
  --ink: #171717;
  --muted: #6f737b;
  --line: #edf0f4;
  --panel: rgba(255, 255, 255, 0.94);
  --green: #1dbf73;
  --red: #ee3f45;
  --blue: #3269d6;
  --aqua: #45c9aa;
  font-family: "Microsoft YaHei", "PingFang SC", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: #f5f6f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 168px minmax(620px, 1fr) 300px;
  gap: 14px;
  padding: 14px;
  background:
    radial-gradient(circle at 65% 6%, rgba(255, 196, 0, 0.15), transparent 32%),
    linear-gradient(135deg, #f7f8fb 0%, #f2f4f7 100%);
}

.sidebar {
  background: linear-gradient(180deg, #232629 0%, #111314 100%);
  color: white;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 28px);
  box-shadow: 0 20px 50px rgba(24, 27, 31, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--yellow);
  color: #171717;
  padding: 15px 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #151515;
  color: var(--yellow);
  font-weight: 900;
  font-size: 22px;
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1;
}

.brand span {
  font-size: 11px;
  font-weight: 700;
}

.sidebar nav {
  padding: 15px 10px;
  display: grid;
  gap: 7px;
}

.sidebar nav button,
.settle-btn {
  display: grid;
  grid-template-columns: 20px 1fr 14px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #f7f7f7;
  background: transparent;
  text-align: left;
}

.sidebar nav button.active {
  background: var(--yellow);
  color: #171717;
  font-weight: 800;
}

.settle-btn {
  margin: auto 15px 18px;
  grid-template-columns: 20px 1fr;
  color: var(--yellow);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.crumb,
.search,
.topbar select,
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(31, 34, 38, 0.06);
}

.crumb {
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.crumb svg {
  color: var(--yellow-deep);
}

.search {
  margin-left: auto;
  height: 40px;
  width: 230px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 8px;
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: white;
}

.icon-btn b {
  position: absolute;
  top: -5px;
  right: -4px;
  background: #e9272e;
  color: white;
  border-radius: 10px;
  font-size: 10px;
  min-width: 18px;
  line-height: 18px;
}

.topbar select {
  height: 40px;
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
}

.api-status {
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: white;
}

.api-status.online {
  color: #087a43;
  background: #eafff4;
  border-color: #b7efd2;
}

.api-status.offline {
  color: #8a5b00;
  background: #fff6d8;
  border-color: #ffe29a;
}

.auth-mini {
  height: 40px;
  min-width: 72px;
  padding: 0 14px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(31, 34, 38, 0.06);
  font-weight: 800;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 196, 0, 0.2), transparent 28%),
    linear-gradient(135deg, #f7f8fb 0%, #eef1f5 100%);
}

.auth-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 20px 56px rgba(30, 34, 39, 0.14);
}

.auth-brand {
  border-radius: 8px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.auth-tabs button {
  height: 42px;
  border-radius: 8px;
  background: #f5f7fa;
  font-weight: 900;
}

.auth-tabs button.active {
  background: var(--yellow);
}

.notice {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #fff8dc;
  color: #6a5200;
  border: 1px solid #ffe79b;
  font-weight: 700;
}

.page-grid,
.weighing,
.split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(33, 37, 41, 0.08);
}

.metric {
  min-height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px;
}

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

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(20px, 1.5vw, 30px);
  letter-spacing: 0;
}

.metric-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff1bd;
  color: var(--yellow-deep);
}

.panel {
  padding: 18px;
  min-height: 205px;
  overflow: hidden;
}

.panel.wide {
  grid-column: span 2;
}

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

.panel h2 {
  margin: 0;
  font-size: 16px;
}

.panel-head button {
  color: #8b8f98;
  background: transparent;
  font-size: 13px;
}

.chart {
  height: 170px;
  display: flex;
  align-items: end;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px 0;
}

.chart i,
.chart b {
  width: 12px;
  border-radius: 999px 999px 0 0;
}

.chart i {
  background: var(--yellow);
}

.chart b {
  background: #222;
  margin-left: -10px;
  opacity: 0.82;
}

.donut {
  display: grid;
  grid-template-columns: 155px 1fr;
  align-items: center;
  gap: 14px;
}

.ring {
  width: 142px;
  height: 142px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: conic-gradient(var(--blue) 0 45%, var(--aqua) 45% 75%, var(--yellow) 75% 92%, #ffd84d 92%);
  position: relative;
}

.ring::before {
  content: "";
  width: 88px;
  height: 88px;
  position: absolute;
  border-radius: 50%;
  background: white;
}

.ring strong,
.ring span {
  position: relative;
}

.ring strong {
  font-size: 18px;
}

.ring span {
  font-size: 12px;
  color: var(--muted);
}

.donut ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.donut li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.donut em {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
}

.donut li:nth-child(2) em { background: var(--aqua); }
.donut li:nth-child(3) em { background: var(--yellow); }
.donut li:nth-child(4) em { background: #ffd84d; }

.status-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-row span {
  display: grid;
  gap: 2px;
}

.status-row small {
  color: var(--muted);
}

.ok {
  color: var(--green);
}

.bad {
  color: var(--red);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

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

th {
  color: #66707a;
  background: #fbfcfd;
  font-weight: 700;
}

td {
  color: #22262b;
}

td input {
  width: 112px;
  min-width: 96px;
  padding: 8px 10px;
}

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

.quick-grid button,
.mobile-actions button {
  min-height: 72px;
  border-radius: 8px;
  background: #fff5cf;
  color: #1c1c1c;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  font-weight: 800;
}

.quick-grid svg,
.mobile-actions svg {
  color: var(--yellow-deep);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #555b64;
  font-weight: 700;
  font-size: 13px;
}

input,
select,
textarea {
  height: 42px;
  border: 1px solid #e3e7ed;
  border-radius: 8px;
  padding: 0 12px;
  outline-color: var(--yellow);
  background: white;
}

textarea {
  min-height: 220px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.data-box {
  width: 100%;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
}

.fatal-error {
  max-width: 860px;
  margin: 48px auto;
  padding: 24px;
  background: white;
  border: 1px solid #ffd2d2;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(40, 43, 47, 0.14);
}

.fatal-error h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.fatal-error p {
  color: var(--muted);
}

.fatal-error pre {
  max-height: 280px;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #fff5f5;
  color: #9b1c1c;
  white-space: pre-wrap;
}

.fatal-error div {
  display: flex;
  gap: 10px;
}

.fatal-error button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  background: #f5f7fa;
}

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

.trace-preview strong {
  font-size: 20px;
}

.trace-preview span,
.trace-preview small {
  color: var(--muted);
  line-height: 1.6;
}

code {
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  background: #f3f5f8;
  border-radius: 6px;
  padding: 3px 6px;
}

.primary,
.scale-actions .primary,
.mobile-bottom button:last-child {
  background: var(--yellow);
  color: #161616;
  font-weight: 900;
}

.primary {
  height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.link {
  color: var(--yellow-deep);
  background: transparent;
  font-weight: 800;
}

.weighing .panel:first-child {
  grid-column: span 1;
}

.scale-card {
  min-height: 250px;
  display: grid;
  gap: 12px;
}

.scale-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.scale-head span {
  margin-left: auto;
}

.scale-card > strong {
  align-self: end;
  text-align: center;
  font-size: 58px;
}

.scale-card > span {
  text-align: center;
  color: var(--muted);
}

.scale-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.scale-actions button,
.mobile-bottom button {
  min-height: 42px;
  border-radius: 8px;
  background: #f5f7fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.calc-grid div {
  padding: 18px;
  border-radius: 8px;
  background: #f9fafc;
}

.calc-grid span,
.stock-bars span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.calc-grid strong {
  font-size: 28px;
}

.stock-bars {
  display: grid;
  gap: 16px;
}

.stock-bars b {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: #eff2f5;
  overflow: hidden;
}

.stock-bars i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--green));
  border-radius: inherit;
}

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

.role-card {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfcfe;
}

.role-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

.role-card svg {
  color: var(--yellow-deep);
}

.role-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 18px;
}

.role-card p {
  min-height: 58px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.role-card span {
  display: inline-flex;
  margin-top: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff0b6;
  font-size: 12px;
  font-weight: 800;
}

.phone-lab {
  display: grid;
  align-content: start;
  gap: 12px;
}

.phone-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.phone-tabs button {
  height: 34px;
  border-radius: 8px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.phone-tabs button.active {
  background: var(--yellow);
  font-weight: 900;
}

.phone {
  width: 280px;
  min-height: 610px;
  margin: 0 auto;
  border-radius: 28px;
  background: #f7f8fa;
  border: 10px solid #111;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(30, 34, 39, 0.22);
}

.phone-head {
  height: 64px;
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-weight: 900;
}

.connect {
  height: 42px;
  margin: 12px;
  border-radius: 8px;
  background: white;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  font-size: 12px;
}

.connect span {
  margin-left: auto;
  color: var(--green);
}

.mobile-metrics,
.mobile-calc {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px;
}

.mobile-metrics div,
.mobile-calc div,
.mobile-weight,
.mobile-form label {
  background: white;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--line);
}

.mobile-metrics span,
.mobile-calc span,
.mobile-weight span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mobile-metrics strong,
.mobile-calc strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.mobile-actions {
  margin: 14px 12px;
  grid-template-columns: repeat(3, 1fr);
}

.mobile-actions button {
  min-height: 68px;
  font-size: 12px;
}

.mobile-actions svg {
  width: 20px;
  height: 20px;
}

.mobile-form {
  display: grid;
  gap: 8px;
  margin: 12px;
}

.mobile-form label {
  padding: 10px;
}

.mobile-form select {
  height: 34px;
  border: 0;
  padding: 0;
}

.mobile-weight {
  margin: 12px;
  position: relative;
}

.mobile-weight strong {
  display: block;
  text-align: center;
  font-size: 48px;
  margin: 14px 0;
}

.mobile-weight em {
  position: absolute;
  right: 14px;
  top: 50%;
  color: var(--green);
  font-style: normal;
  font-weight: 900;
}

.mobile-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 8px;
  padding: 12px;
  margin-top: 14px;
  background: white;
  border-top: 1px solid var(--line);
}

.settlement-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.settlement-actions button {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
  background: var(--yellow);
  color: #111;
}

.settlement-actions strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 1160px) {
  .app {
    grid-template-columns: 168px minmax(760px, 1fr);
  }

  .phone-lab {
    grid-column: 2;
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 760px) {
  .app {
    display: block;
    min-height: 100vh;
    padding: 0;
    background: #f7f8fa;
  }

  .sidebar,
  .workspace {
    display: none;
  }

  .phone-lab {
    display: block;
    padding: 0;
  }

  .phone-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px;
    background: #f7f8fa;
  }

  .phone-tabs button {
    height: 40px;
  }

  .phone {
    width: 100%;
    min-height: calc(100vh - 60px);
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .phone-head {
    border-radius: 0;
  }

  .mobile-actions button {
    min-height: 64px;
  }

  .mobile-weight strong {
    font-size: 42px;
  }

  .auth-shell {
    min-height: 100vh;
    padding: 16px;
  }

  .auth-panel {
    padding: 16px;
  }
}
