:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1b2228;
  background: #f4f6f7;
  letter-spacing: 0;
  --ink: #1b2228;
  --muted: #68747d;
  --line: #d9e0e4;
  --panel: #ffffff;
  --sidebar: #20292f;
  --teal: #087f75;
  --teal-dark: #06675f;
  --amber: #b66a08;
  --red: #b33a32;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f6f7;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #f5f8f8;
  border-right: 1px solid #13191d;
  z-index: 10;
}

.brand-mark {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #344149;
}

.brand-symbol {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #f1b83b;
  color: #192126;
  font-weight: 800;
  border-radius: 4px;
}

.brand-mark strong, .brand-mark span { display: block; }
.brand-mark strong { font-size: 15px; }
.brand-mark span { margin-top: 3px; color: #aebbc2; font-size: 12px; }

nav { padding: 14px 10px; }

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: #c7d1d6;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  text-align: left;
}

.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { color: #ffffff; background: #28343b; }
.nav-item.active {
  color: #ffffff;
  background: #2d3a41;
  border-left-color: #34b5a8;
}

.sidebar-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px;
  color: #aebbc2;
  font-size: 12px;
  border-top: 1px solid #344149;
}

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

main {
  min-height: 100vh;
  margin-left: 236px;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin: 0; }
h1 { font-size: 21px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
.topbar p, .section-heading p { margin-top: 5px; color: var(--muted); font-size: 13px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.version {
  padding: 5px 8px;
  border: 1px solid #dec894;
  color: #78500c;
  background: #fff8e8;
  font-size: 12px;
  border-radius: 4px;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #344149;
  background: #ffffff;
}

.icon-button:hover { border-color: #9fadb4; background: #f6f8f9; }
.icon-button:disabled { opacity: 0.4; cursor: default; }
.icon-button svg { width: 17px; height: 17px; }

.view { display: none; padding: 24px 28px 36px; }
.view.active { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.metric {
  min-height: 114px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 12px; font-size: 28px; font-weight: 700; }
.metric-note { margin-top: 6px; color: #7c878e; font-size: 12px; }

.content-band {
  margin-top: 18px;
  padding: 20px;
  background: #ffffff;
  border-top: 3px solid #2b6269;
  border-bottom: 1px solid var(--line);
}

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

.review-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  border: 1px solid var(--line);
}

.breakdown-item {
  padding: 16px;
  border-right: 1px solid var(--line);
}

.breakdown-item:last-child { border-right: 0; }
.breakdown-item strong { display: block; margin-top: 7px; font-size: 23px; }
.breakdown-item span { color: var(--muted); font-size: 12px; }
.breakdown-item.high { border-top: 3px solid var(--red); }
.breakdown-item.medium { border-top: 3px solid var(--amber); }

.split-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  border-top-color: #b66a08;
}

.large-value { margin-top: 12px; font-size: 26px; font-weight: 700; }
.muted { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.relationship {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.relationship code {
  padding: 6px 8px;
  color: #15555b;
  background: #edf5f4;
  border: 1px solid #c7dcda;
  border-radius: 4px;
}

.relationship svg { width: 18px; color: var(--muted); }

.filter-bar {
  display: grid;
  grid-template-columns: 180px minmax(200px, 1fr) 130px minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.filter-bar label { display: block; }
.filter-bar label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

input, select, textarea {
  width: 100%;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #bfcbd1;
  border-radius: 4px;
  outline: none;
}

input, select { height: 38px; }
textarea { padding: 9px 10px; resize: vertical; line-height: 1.45; }

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 127, 117, 0.12);
}

.primary-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 4px;
  font-weight: 600;
}

.primary-button:hover { background: var(--teal-dark); }
.primary-button svg { width: 17px; height: 17px; }

.secondary-button,
.danger-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.secondary-button {
  color: #33444c;
  background: #ffffff;
  border: 1px solid #b8c5cb;
}

.secondary-button:hover { background: #f1f5f6; border-color: #8799a2; }
.danger-button { color: #8e2924; background: #fff4f3; border: 1px solid #dca7a2; }
.danger-button:hover { background: #ffe9e7; }
.secondary-button svg, .danger-button svg { width: 16px; height: 16px; }

.table-toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.table-toolbar strong { font-size: 13px; }
.pagination { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.pagination .icon-button { width: 30px; height: 30px; }

.table-wrap {
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  color: #435058;
  background: #eef2f4;
  border-bottom: 1px solid #cbd5da;
  text-align: left;
  white-space: nowrap;
}

td {
  max-width: 280px;
  padding: 9px 10px;
  border-bottom: 1px solid #e6ebee;
  vertical-align: top;
  overflow-wrap: anywhere;
}

tbody tr:hover { background: #f7faf9; }
td code { color: #24565c; font-size: 12px; }

#vehicles-view table { min-width: 1280px; }
#vehicles-view td { white-space: nowrap; overflow-wrap: normal; }

.badge {
  display: inline-block;
  padding: 3px 6px;
  border: 1px solid #c8d2d7;
  border-radius: 3px;
  color: #53616a;
  background: #f4f7f8;
  white-space: nowrap;
}

.badge.warning { color: #80520b; background: #fff7e5; border-color: #e1c88e; }
.badge.danger { color: #8e2924; background: #fff0ef; border-color: #e5b2ae; }
.badge.ok { color: #0d665d; background: #eaf7f4; border-color: #a8d9d2; }

.compact-search { width: 280px; }
.master-filter { grid-template-columns: minmax(260px, 1fr) 220px auto auto; }
.model-filter { grid-template-columns: 200px minmax(240px, 1fr) 220px auto auto; }
.vehicle-filter {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.review-filter { grid-template-columns: 160px 220px minmax(260px, 1fr) auto auto; }
.audit-filter { grid-template-columns: minmax(300px, 1fr) auto auto; }

.checkbox-label {
  min-height: 38px;
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid #cbd5da;
  border-radius: 4px;
  background: #f9fbfb;
  white-space: nowrap;
}

.checkbox-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.checkbox-label span { margin: 0 !important; color: #445159 !important; }

.export-toolbar { gap: 16px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.toolbar-actions > select { width: 220px; }

.review-list {
  background: #ffffff;
  border: 1px solid var(--line);
}

.review-row {
  display: grid;
  grid-template-columns: 82px 200px minmax(240px, 1fr) auto;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid #e3e9ec;
}

.review-row:last-child { border-bottom: 0; }
.review-id { color: var(--muted); font-size: 12px; }
.review-entity { font-weight: 600; overflow-wrap: anywhere; }
.review-detail { color: #46535b; font-size: 13px; line-height: 1.5; }
.review-action { margin-top: 6px; color: var(--muted); font-size: 12px; }
.review-controls { display: flex; align-items: center; }

.cell-edit {
  max-width: 100%;
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 4px;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  text-align: left;
  overflow-wrap: anywhere;
}

.cell-edit span { min-width: 0; overflow-wrap: anywhere; }
.cell-edit svg {
  width: 12px;
  min-width: 12px;
  height: 12px;
  margin-top: 2px;
  color: #7a8a92;
  opacity: 0;
}
.cell-edit:hover { border-color: #b8cbc9; background: #f1f8f7; }
.cell-edit:hover svg, .cell-edit:focus svg { opacity: 1; }
.strong-edit span { font-weight: 650; }

.dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #aab8bf;
  border-radius: 6px;
  box-shadow: 0 18px 60px rgba(20, 32, 38, 0.24);
}

.dialog::backdrop { background: rgba(22, 31, 36, 0.48); }
.dialog form { padding: 20px; }
.dialog form > label { display: block; margin-top: 14px; }
.dialog form > label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.dialog-header h2 { font-size: 18px; }
.dialog-header p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.form-note { margin-top: 10px; color: #7b5917; font-size: 12px; }

.comparison {
  margin-top: 16px;
  padding: 14px;
  background: #f5f8f9;
  border: 1px solid #d9e2e5;
}
.comparison-title { margin-bottom: 10px; font-weight: 650; }
.comparison-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-top: 8px;
  font-size: 13px;
}
.comparison-row svg { width: 15px; color: var(--muted); }
.comparison-row del { color: #8e3934; text-decoration: none; }
.comparison-row ins { color: #0d665d; text-decoration: none; font-weight: 600; }
.comparison > p { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.annual-attribute-cell {
  display: grid;
  gap: 5px;
  min-width: 96px;
}

.annual-attribute-cell .badge {
  justify-self: start;
  font-size: 10px;
}

.status-action {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 104px;
}

.status-action .icon-button {
  width: 28px;
  height: 28px;
}

.evidence-dialog {
  width: min(780px, calc(100vw - 32px));
  overflow: hidden;
}

.evidence-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 50px);
  padding: 20px;
}

.evidence-list {
  display: grid;
  flex: 1 1 auto;
  gap: 10px;
  margin-top: 14px;
  overflow: auto;
}

.evidence-item {
  padding: 12px;
  border: 1px solid #d7e0e4;
  background: #f8fafb;
}

.evidence-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.evidence-item dl {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.evidence-item dt { color: var(--muted); }
.evidence-item dd { margin: 0; overflow-wrap: anywhere; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: 360px;
  padding: 11px 14px;
  color: #ffffff;
  background: #17665f;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(20, 32, 38, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #a43a34; }

.current-user {
  max-width: 180px;
  overflow: hidden;
  color: #43515a;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #edf1f3;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
  margin: 0;
}

.login-panel {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d4dce0;
  border-radius: 6px;
  box-shadow: 0 18px 44px rgba(28, 40, 47, 0.14);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 16px 22px;
  color: #f5f8f8;
  background: var(--sidebar);
  border-bottom: 1px solid #13191d;
}

.login-brand strong,
.login-brand span { display: block; }
.login-brand strong { font-size: 15px; }
.login-brand div span { margin-top: 3px; color: #aebbc2; font-size: 12px; }

.login-form {
  display: grid;
  gap: 18px;
  padding: 28px 24px 24px;
}

.login-form h1 {
  margin: 0;
  font-size: 22px;
}

.login-form p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #43515a;
  font-size: 13px;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #bdc9cf;
  border-radius: 4px;
}

.login-form input:focus {
  border-color: var(--teal);
  outline: 2px solid rgba(8, 127, 117, 0.16);
}

.login-form .login-error {
  min-height: 18px;
  margin: -6px 0;
  color: var(--red);
  font-weight: 600;
}

.login-submit {
  width: 100%;
  min-height: 42px;
  justify-content: center;
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .filter-bar { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .filter-bar .primary-button, .filter-bar .secondary-button { width: 100%; }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }
  .brand-mark { min-height: 60px; }
  nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    padding: 6px;
  }
  .nav-item {
    min-height: 48px;
    justify-content: center;
    padding: 0 6px;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }
  .nav-item.active { border-left-color: transparent; border-bottom-color: #34b5a8; }
  .nav-item span { display: none; }
  .sidebar-meta { display: none; }
  main { margin-left: 0; }
  .topbar { height: auto; min-height: 70px; padding: 12px 16px; }
  .version { display: none; }
  .view { padding: 16px; }
  .metric-grid, .review-breakdown, .split-band, .filter-bar, .review-filter {
    grid-template-columns: 1fr;
  }
  .breakdown-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .review-row { grid-template-columns: 72px minmax(0, 1fr); }
  .review-content, .review-controls { grid-column: 1 / -1; }
  .review-controls .secondary-button { width: 100%; }
  .compact-search { width: 100%; }
  .section-heading { display: block; }
  .section-heading .compact-search { margin-top: 12px; }
  .section-heading .secondary-button { width: 100%; margin-top: 12px; }
  .export-toolbar { align-items: flex-start; }
  .toolbar-actions { width: 100%; flex-wrap: wrap; justify-content: flex-end; }
  .toolbar-actions > select { width: 100%; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions button { flex: 1 1 auto; }
  .comparison-row { grid-template-columns: 1fr; }
  .comparison-row svg { transform: rotate(90deg); }
  .evidence-item dl { grid-template-columns: 1fr; }
}
