:root {
  --bg: #f4f7fb;
  --side: #10232e;
  --panel: #fff;
  --line: #d8e1ea;
  --text: #17202a;
  --muted: #627085;
  --brand: #0f766e;
  --warn: #b45309;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button, input, select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 40px;
}
button {
  background: white;
  padding: 0 14px;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover, .resource-open:hover { border-color: var(--brand); }
.resource-open {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}
.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}
.side {
  background: var(--side);
  color: white;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 10px;
}
.brand span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #0b5f79);
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: #bdd0dc; margin-top: 3px; }
.nav {
  color: #dce8ef;
  background: transparent;
  border-color: transparent;
  text-align: left;
}
.nav.active, .nav:hover {
  color: white;
  background: rgba(255,255,255,.11);
  border-color: transparent;
}
.side-note {
  margin-top: auto;
  color: #bdd0dc;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 12px;
  line-height: 1.7;
  font-size: 13px;
}
.main { padding: 24px; min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
h1 { margin: 0 0 5px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 20px 0 10px; font-size: 15px; }
p { margin-top: 0; }
.muted, #stats { color: var(--muted); }
.badge {
  border: 1px solid #f5c98e;
  background: #fff7ed;
  color: #9a3412;
  border-radius: var(--radius);
  padding: 10px 12px;
  white-space: nowrap;
}
.setup, .panel, .detail, .vehicle {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.setup, .panel { padding: 18px; margin-bottom: 18px; }
.view { display: none; }
.view.active { display: block; }
.filters {
  display: grid;
  grid-template-columns: 1fr 180px 140px 88px;
  gap: 10px;
  margin-bottom: 16px;
}
input, select {
  width: 100%;
  padding: 0 11px;
  background: white;
  outline: 0;
}
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,118,110,.14);
}
.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(520px, 1.35fr);
  gap: 16px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.section-title span { color: var(--muted); font-size: 13px; }
.vehicle-list { display: grid; gap: 10px; }
.vehicle {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.vehicle.selected {
  border-color: var(--brand);
  box-shadow: 0 16px 36px rgba(20,40,60,.10);
}
.vehicle h3 { margin: 0 0 7px; font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #d8e2ec;
  background: #edf2f7;
  color: #334155;
  border-radius: 999px;
}
.detail {
  padding: 16px;
  min-height: 260px;
  align-self: start;
}
.detail code {
  display: block;
  background: #f3f6fa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  overflow-wrap: anywhere;
}
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 16px 0; }
.form { display: grid; gap: 12px; max-width: 620px; }
.form.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.four { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); }
.row { display: flex; gap: 10px; margin: 12px 0; }
.resource-head {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 10px;
  align-items: center;
}
.resource-head h3 { margin: 20px 0 10px; }
.resource-summary {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}
#resourceGroups {
  max-height: calc(100vh - 310px);
  min-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.resource-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  margin-bottom: 8px;
  padding: 0 10px 10px;
}
.resource-group summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  font-weight: 700;
}
.resource-group summary span {
  color: var(--muted);
  font-weight: 400;
}
.manuals { display: grid; gap: 8px; margin-top: 10px; }
.manual {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.manual strong { display: block; margin-bottom: 4px; }
.manual small { color: var(--muted); }
pre {
  white-space: pre-wrap;
  background: #f3f6fa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.progress {
  margin: 12px 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfd;
  padding: 12px;
}
.progress div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.progress progress {
  width: 100%;
  height: 12px;
}
.check-result {
  margin: 10px 0 4px;
  border: 1px solid #b7ded8;
  border-radius: var(--radius);
  background: #f0fdfa;
  padding: 12px;
}
.check-result strong { display: block; margin-bottom: 8px; }
.check-result dl {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}
.check-result dt { color: var(--muted); }
.check-result dd { margin: 0; overflow-wrap: anywhere; }
.check-result code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
}
#resourcesTable, #usersTable, #accessLogsTable {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; min-width: 640px; border-collapse: collapse; background: white; }
th, td { border-bottom: 1px solid var(--line); padding: 9px; text-align: left; }
td { overflow-wrap: anywhere; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #10232e;
  color: white;
  border-radius: var(--radius);
  padding: 12px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
@media (max-width: 980px) {
  .layout { display: block; }
  .side {
    padding: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .brand {
    margin-bottom: 4px;
    padding-bottom: 10px;
  }
  .side-note { display: none; }
  .nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    margin-right: 6px;
    padding: 0 10px;
  }
  .main { padding: 16px; }
  .top {
    align-items: flex-start;
    flex-direction: column;
  }
  .badge { white-space: normal; }
  .filters, .content-grid, .form.two, .form.four, .resource-head { grid-template-columns: 1fr; }
  #resourceGroups {
    max-height: none;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
  }
  .vehicle, .manual {
    grid-template-columns: 1fr;
  }
  .vehicle button, .manual button, .resource-open {
    width: 100%;
  }
  .pager {
    flex-wrap: wrap;
  }
}

@media (max-width: 430px) {
  .main { padding: 12px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  button, input, select { min-height: 44px; }
  .setup, .panel, .detail { padding: 14px; }
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .resource-group {
    padding-left: 8px;
    padding-right: 8px;
  }
}
