:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d9e1e5;
  --muted: #687782;
  --text: #18242c;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --warn: #b7791f;
  --ok: #15803d;
  --ink-soft: #eef3f4;
  --shadow: 0 12px 28px rgba(24, 36, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

body.locked .app-shell {
  display: none;
}

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

button {
  cursor: pointer;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #f5f7f8 0%, #dfe9e7 100%);
}

body.locked .login-screen {
  display: grid;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 24px;
}

.login-card p {
  color: var(--muted);
}

.login-brand {
  color: var(--text);
}

.login-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.login-hint {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
  color: var(--muted);
  font-size: 13px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px;
  background: #18242c;
  color: #eef7f5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #b8c8cc;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: #dce8eb;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav .badge {
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #dce8eb;
  font-size: 12px;
  text-align: center;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  color: #b8c8cc;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.main {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
}

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

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 320px;
}

.user-chip {
  display: grid;
  min-width: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--panel);
  font-size: 12px;
}

.user-chip strong {
  font-size: 13px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 280px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
}

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

.icon-button,
.primary-button,
.ghost-button,
.small-button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.icon-button {
  width: 42px;
  font-size: 20px;
}

.primary-button {
  border-color: var(--accent);
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost-button,
.small-button {
  padding: 0 12px;
}

.small-button {
  min-height: 30px;
  font-size: 13px;
}

.mobile-nav-wrap {
  display: none;
  margin-bottom: 14px;
}

.mobile-nav-wrap select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
}

.view-root {
  display: grid;
  gap: 16px;
}

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

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

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

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.toolbar input,
.toolbar select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.table-wrap {
  overflow: auto;
}

.table-wrap.compact-scroll {
  max-height: calc(98px + var(--visible-rows, 5) * 56px);
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbfcfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.filter-row th {
  top: 42px;
  padding-top: 6px;
  padding-bottom: 8px;
}

.filter-row input {
  width: 100%;
  min-width: 90px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.table-sort {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.selectable-row {
  cursor: pointer;
}

.selectable-row:hover td,
.selectable-row.selected td {
  background: #eef6ff;
}

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

.small-button.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.muted {
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--ink-soft);
  color: #36515a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.ok {
  background: #dcfce7;
  color: var(--ok);
}

.tag.warn {
  background: #fef3c7;
  color: var(--warn);
}

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

.tag.blue {
  background: #dbeafe;
  color: var(--accent-2);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  padding: 16px;
  overflow-x: auto;
}

.stage {
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.stage h3 {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.stage-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.mini-card strong {
  display: block;
  margin-bottom: 4px;
}

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

.trace-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.trace-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  text-align: left;
}

.trace-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.trace-detail {
  padding: 16px;
}

.trace-path {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.trace-step {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
}

.trace-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: -10px;
  width: 2px;
  background: var(--line);
}

.trace-dot {
  z-index: 1;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
}

.trace-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

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

.detail-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.detail-cell span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.security-grid .detail-cell {
  background: #fbfcfc;
}

.security-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.security-card strong {
  display: block;
  margin-bottom: 8px;
}

.security-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.report-select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

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

.chart-card,
.decision-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.bar-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 172px;
  overflow-x: auto;
  padding-top: 12px;
}

.bar-group {
  display: grid;
  gap: 8px;
  min-width: 56px;
  justify-items: center;
}

.bar-group > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bar-stack {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 128px;
}

.bar {
  display: block;
  width: 10px;
  border-radius: 4px 4px 0 0;
}

.bar-0 {
  background: var(--accent);
}

.bar-1 {
  background: var(--accent-2);
}

.bar-2 {
  background: var(--warn);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

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

.trend-list {
  display: grid;
  gap: 9px;
}

.trend-list div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 8px;
}

.trend-list span,
.trend-list strong {
  color: var(--muted);
  font-size: 12px;
}

.trend-list b {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}

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

.decision-card {
  display: grid;
  gap: 8px;
}

.decision-card h3 {
  margin: 0;
  font-size: 17px;
}

.decision-card p {
  margin: 0;
  color: var(--muted);
}

.decision-card small {
  color: var(--accent);
  font-weight: 700;
}

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

.field-task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field-task-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.field-task-card h3 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.field-task-card p {
  margin: 0;
  color: var(--muted);
}

.field-log,
.field-exception {
  margin-top: 12px !important;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.field-exception {
  border: 1px solid #f5c2c2;
  background: #fff5f5;
  color: var(--danger) !important;
}

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

.portal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.portal-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.portal-card h3 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.portal-card p {
  margin: 0;
  color: var(--muted);
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.field input[type="file"] {
  padding: 10px;
  background: #f8fafc;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field textarea {
  resize: vertical;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  align-items: center;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 14px;
}

.checkbox-group input {
  width: auto;
  min-height: auto;
}

.export-summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.export-fields {
  max-height: 220px;
  overflow: auto;
  align-content: flex-start;
}

.row-check {
  width: 18px;
  height: 18px;
}

.scene-browser {
  display: grid;
  gap: 14px;
}

.mobile-panel {
  margin-bottom: 12px;
}

.scene-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

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

.scene-card h3 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.scene-card p {
  margin: 0;
  color: var(--muted);
}

.scene-demo {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.scene-demo p {
  margin-top: 6px;
}

.scene-view-button {
  width: 100%;
  margin-top: 12px;
}

.scene-detail {
  display: grid;
  gap: 12px;
}

.scene-video-player {
  margin-top: 14px;
}

.scene-video-player h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.scene-video {
  width: 100%;
  max-height: 52vh;
  border-radius: 8px;
  background: #0f172a;
}

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

.scene-photo {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.scene-photo img,
.photo-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  background: #eef2f7;
  color: var(--muted);
}

.scene-photo figcaption {
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
}

.media-strip {
  display: flex;
  gap: 6px;
  min-width: 260px;
}

.media-thumb {
  width: 72px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fff;
  display: grid;
  gap: 3px;
  align-content: start;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
}

.media-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f7;
}

.media-thumb span {
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
}

.media-thumb small {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  color: var(--muted);
}

.media-thumb.empty {
  cursor: not-allowed;
  opacity: 0.58;
}

.media-thumb.video,
.media-thumb.file {
  place-items: center;
  text-align: center;
  background: #f8fafc;
}

.video-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff !important;
}

.field-preview {
  margin-top: 6px;
}

.media-large {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  background: #0f172a;
}

.media-file-preview {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  word-break: break-all;
}

dialog {
  width: min(860px, calc(100vw - 26px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(24, 36, 44, 0.24);
}

dialog::backdrop {
  background: rgba(24, 36, 44, 0.4);
}

.dialog-panel header,
.dialog-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-panel footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

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

.business-factory-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(24, 36, 44, 0.06);
}

.business-factory-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.business-factory-card h3 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.business-factory-card p {
  margin: 0;
  color: var(--muted);
}

.business-factory-card strong {
  white-space: nowrap;
  font-size: 18px;
}

.business-scene-line {
  margin: 10px 0;
  color: var(--text);
  line-height: 1.6;
}

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

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

  .content-grid,
  .trace-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    display: none;
  }

  .main {
    height: auto;
    overflow: visible;
    padding: 14px;
  }

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

  h1 {
    font-size: 22px;
  }

  .top-actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  .search-box {
    min-width: 0;
    flex-basis: 100%;
  }

  .mobile-nav-wrap {
    display: block;
  }

  .metrics-grid,
  .detail-grid,
  .detail-grid.compact,
  .form-grid,
  .security-grid,
  .chart-grid,
  .decision-grid,
  .field-task-grid,
  .customer-portal-grid,
  .scene-photo-grid {
    grid-template-columns: 1fr;
  }

  .kanban {
    grid-template-columns: repeat(5, 220px);
  }

  table {
    min-width: 680px;
  }
}
