:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #17211f;
  --muted: #65736f;
  --line: #d8e1dd;
  --green: #17745f;
  --green-strong: #0d5a49;
  --blue: #245f9c;
  --amber: #b86b00;
  --red: #b73535;
  --shadow: 0 16px 40px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(23, 116, 95, 0.08), rgba(36, 95, 156, 0.04) 36%, transparent 72%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    sans-serif;
}

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

button,
.file-button {
  min-height: 38px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.logout-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
  color: var(--green-strong);
  border-color: var(--line);
}

.ghost-button {
  background: #fff;
  color: var(--green-strong);
  border-color: var(--line);
}

.optional-hidden {
  display: none !important;
}

.topbar {
  min-height: 84px;
  padding: 16px clamp(16px, 3vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-logo {
  width: clamp(132px, 16vw, 220px);
  height: 58px;
  object-fit: contain;
  object-position: left center;
  border-radius: 6px;
  background: #fff;
  flex: 0 0 auto;
}

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

h1 {
  font-size: clamp(20px, 2.6vw, 30px);
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.developer-unit {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.developer-unit span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-strong);
  background: var(--surface-soft);
  padding: 2px 8px;
  font-size: 12px;
}

.status-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(23, 33, 31, 0.05);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.workspace {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 2.6vw, 32px) 32px;
  display: grid;
  grid-template-columns: minmax(310px, 0.95fr) minmax(420px, 1.25fr) minmax(380px, 1.1fr);
  gap: 18px;
  align-items: start;
}

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

.route-panel,
.media-panel,
.sensor-panel,
.defects-panel,
.alert-panel,
.patrol-panel,
.assessment-panel,
.qa-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qa-panel {
  grid-row: span 3;
  min-height: calc(100vh - 130px);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
}

.panel-heading h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.road-search {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.road-search label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.road-search input {
  width: 100%;
}

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

label,
.wide-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

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

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 116, 95, 0.68);
  box-shadow: 0 0 0 3px rgba(23, 116, 95, 0.12);
}

.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(23, 116, 95, 0.2), rgba(36, 95, 156, 0.12)),
    repeating-linear-gradient(105deg, #32403c 0 18px, #273530 18px 30px);
}

.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: #111;
}

.video-stage.has-video video {
  display: block;
}

.video-stage.has-video .empty-state {
  display: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
  letter-spacing: 0;
}

.file-row,
.button-row,
.chat-input-row,
.report-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-row {
  justify-content: space-between;
}

.file-button input {
  display: none;
}

.file-button.compact {
  padding-inline: 12px;
}

.meta-line {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--muted);
  padding: 10px 11px;
  font-size: 13px;
  line-height: 1.5;
}

.notice-line.ok {
  border-color: rgba(23, 116, 95, 0.28);
  color: var(--green-strong);
  background: rgba(23, 116, 95, 0.08);
}

.notice-line.warn {
  border-color: rgba(184, 107, 0, 0.3);
  color: #7a4d08;
  background: rgba(184, 107, 0, 0.08);
}

.notice-line.error {
  border-color: rgba(183, 53, 53, 0.3);
  color: var(--red);
  background: rgba(183, 53, 53, 0.07);
}

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(23, 116, 95, 0.12);
  color: var(--green-strong);
  white-space: nowrap;
}

.badge.muted {
  color: var(--muted);
  background: var(--surface-soft);
}

#vibrationChart {
  width: 100%;
  height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

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

.alert-summary {
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
}

.metric-grid div,
.alert-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
  min-width: 0;
}

.metric-grid span,
.alert-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid strong,
.alert-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.defect-list {
  display: grid;
  gap: 10px;
}

.defect-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 86px 128px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.defect-row .defect-name {
  font-weight: 700;
}

.defect-row small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.alert-list,
.suggestion-list,
.patrol-route-list {
  display: grid;
  gap: 10px;
}

.alert-item,
.suggestion-item,
.patrol-route-item {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
}

.alert-item strong,
.suggestion-item strong,
.patrol-route-item strong {
  display: block;
  margin-bottom: 4px;
}

.alert-item p,
.suggestion-item p,
.patrol-route-item p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.patrol-route-item .route-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.route-chip {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--green-strong);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.level-正常 {
  border-left-color: var(--green);
}

.level-关注 {
  border-left-color: var(--blue);
}

.level-预警 {
  border-left-color: var(--amber);
}

.level-严重 {
  border-left-color: var(--red);
}

.score-layout {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}

.score-ring {
  width: 138px;
  height: 138px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  align-content: center;
  background: conic-gradient(var(--green) 0deg, var(--line) 0deg);
  color: var(--ink);
  position: relative;
  isolation: isolate;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: inherit;
  background: var(--surface);
  z-index: -1;
}

.score-ring strong {
  font-size: 38px;
  line-height: 1;
}

.score-ring span,
.decision-copy span {
  color: var(--muted);
  font-size: 13px;
}

.decision-copy h3 {
  margin-top: 7px;
  font-size: 24px;
}

.decision-copy p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.chat-messages {
  height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  width: fit-content;
  max-width: 88%;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.assistant {
  background: #eef4f1;
  border: 1px solid var(--line);
}

.message.user {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
}

.chat-input-row {
  align-items: stretch;
}

.chat-input-row textarea {
  min-height: 78px;
}

.chat-input-row button {
  width: 78px;
}

.report-toolbar {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.download-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-shell {
  width: min(980px, 100%);
  min-height: min(680px, calc(100vh - 44px));
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.login-logo {
  width: min(420px, 100%);
  height: auto;
  object-fit: contain;
  object-position: left center;
  background: #fff;
  border-radius: 8px;
}

.login-brand h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
}

.login-brand > p {
  color: var(--muted);
  font-size: 16px;
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-panel h2 {
  font-size: 24px;
}

.login-panel p {
  margin-top: 6px;
  color: var(--muted);
}

.login-panel button {
  width: 100%;
}

@media (max-width: 1320px) {
  .workspace {
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1fr);
  }

  .qa-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo {
    width: min(260px, 100%);
    height: 58px;
  }

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

  .form-grid,
  .road-search,
  .metric-grid,
  .alert-summary,
  .score-layout {
    grid-template-columns: 1fr;
  }

  .score-ring {
    margin: 0 auto;
  }

  .defect-row {
    grid-template-columns: 1fr;
  }

  .file-row,
  .button-row,
  .chat-input-row {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-input-row button {
    width: 100%;
  }

  .login-shell {
    min-height: auto;
    grid-template-columns: 1fr;
  }
}
