:root {
  --page: #d9dee2;
  --app: #eef4f6;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --ink: #172028;
  --muted: #667480;
  --line: #dce5e7;
  --line-strong: #cbd7da;
  --blue: #16a9de;
  --blue-dark: #0a6d92;
  --blue-soft: #dff4fb;
  --lime: #c9f24a;
  --lime-soft: #eefbc8;
  --lavender: #d9d0ff;
  --mint: #96e2bd;
  --gold-soft: #ffe8a9;
  --red: #e55048;
  --amber: #b97819;
  --green: #198a64;
  --shadow: 0 26px 70px rgba(35, 48, 58, .16);
  --soft-shadow: 0 12px 30px rgba(31, 46, 54, .07);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 28px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

.loginScreen {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.loginCard {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.loginBrand,
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brandAvatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid rgba(11, 125, 174, .16);
  box-shadow: 0 8px 18px rgba(9, 113, 157, .14);
}

.loginBrand h1 { font-size: 25px; letter-spacing: 0; }
.loginBrand p,
.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.loginTabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: #eef4f5;
}

.loginTab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #53616b;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 900;
}

.loginTab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(31, 46, 54, .08);
}

.loginFields {
  display: grid;
  gap: 14px;
}

.codeRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.loginNote {
  color: var(--amber);
  font-size: 12px;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 6px;
  color: #53616b;
  font-size: 12px;
  font-weight: 700;
}

label small {
  color: #7b8a96;
  font-size: 11px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c9ce;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

input:disabled {
  background: #eef4f5;
  color: #6d7b85;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}

.useNote {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.beianLink {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-decoration: none;
}

.beianLink:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.appShell {
  width: min(1560px, 100%);
  min-height: calc(100vh - 56px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  background: var(--app);
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar {
  background: #fbfcfb;
  color: var(--ink);
  padding: 28px 18px 22px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.brand {
  padding: 0 6px 28px;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.sideNav {
  display: grid;
  gap: 8px;
}

.navItem {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #2a343b;
  text-align: left;
  padding: 12px 14px 12px 38px;
  font-size: 14px;
  font-weight: 800;
}

.navItem::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  transform: translateY(-50%);
  background: #d8e2e5;
}

.navItem:hover {
  background: #eff5f6;
}

.navItem.active {
  background: var(--lime);
  color: #101820;
}

.navItem.active::before {
  background: #11191f;
}

.sideFoot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 18px 6px 0;
}

.mainArea {
  min-width: 0;
  background: var(--app);
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 38px 18px;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

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

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

.topActions input {
  width: min(36vw, 430px);
  min-width: 280px;
  background: rgba(255, 255, 255, .94);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(39, 52, 60, .05);
}

.content {
  padding: 10px 38px 40px;
}

.primaryBtn,
.ghostBtn,
.dangerBtn,
.smallBtn,
.textBtn {
  border-radius: 6px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primaryBtn:hover,
.ghostBtn:hover,
.dangerBtn:hover,
.smallBtn:hover {
  transform: translateY(-1px);
}

.primaryBtn {
  border: 0;
  background: #111a20;
  color: white;
  box-shadow: 0 10px 22px rgba(18, 32, 42, .12);
}

.ghostBtn {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.dangerBtn {
  background: #fff0ef;
  color: var(--red);
  border: 1px solid #f2c9c6;
}

.smallBtn {
  border: 0;
  background: var(--lime);
  color: #101820;
}

.textBtn {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.metricGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.metric {
  min-height: 112px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric:nth-child(1) { background: #c8edff; }
.metric:nth-child(2) { background: #e6f8be; }
.metric:nth-child(3) { background: #ded6ff; }
.metric:nth-child(4) { background: #fff0b8; }

.metric span {
  color: rgba(23, 32, 40, .72);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  font-size: 31px;
  line-height: 1;
  margin-top: 10px;
}

.metric p {
  color: rgba(23, 32, 40, .65);
  font-size: 12px;
}

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

.panelHead h2 {
  font-size: 18px;
  line-height: 1.2;
}

.panelHead p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.tableWrap {
  overflow: auto;
  padding: 0 18px 18px;
}

.filterBar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px 18px 6px;
}

.filterItem {
  font-size: 11px;
}

.importPanel {
  overflow: hidden;
}

.importGrid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 280px) minmax(280px, 1fr);
  gap: 14px;
  padding: 18px;
  align-items: end;
}

.importGrid .wide {
  min-width: 0;
}

.importNote {
  display: grid;
  gap: 8px;
  margin: 0 18px 18px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbfb;
}

.importNote b {
  font-size: 12px;
}

.importNote code {
  display: block;
  overflow: auto;
  color: #33424c;
  font-size: 12px;
  white-space: nowrap;
}

.importErrors {
  margin: 0 18px 18px;
  padding: 12px 14px;
  border: 1px solid #f2c9c6;
  border-radius: var(--radius);
  background: #fff0ef;
  color: var(--red);
  font-size: 13px;
  line-height: 1.55;
}

.importPreviewHead {
  border-top: 1px solid var(--line);
}

.emptyState {
  padding: 34px 18px;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

th {
  color: #6a7781;
  background: #f3f7f6;
  font-weight: 900;
}

td b {
  font-weight: 900;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 11px;
}

.routeCell {
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.routeThumb {
  width: 76px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef4f6;
}

tbody tr:hover {
  background: #f9fcfc;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef3f4;
  color: #5c6c78;
  font-size: 11px;
  font-weight: 900;
}

.pill.ok {
  background: #dff5e7;
  color: #14744d;
}

.pill.warn {
  background: #fff0bf;
  color: #866019;
}

.pill.danger {
  background: #ffe2df;
  color: #ae3c35;
}

.workspace {
  display: grid;
  grid-template-columns: 326px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.listPanel {
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.recordList {
  display: grid;
  gap: 8px;
  padding: 12px;
  max-height: calc(100vh - 214px);
  overflow: auto;
}

.recordBtn {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
  padding: 12px;
  color: var(--ink);
}

.recordBtn:hover {
  border-color: #bfd0d5;
  background: #ffffff;
}

.recordBtn.active {
  border-color: var(--lime);
  box-shadow: inset 4px 0 0 var(--lime);
  background: #ffffff;
}

.recordBtn b {
  font-size: 13px;
  line-height: 1.25;
}

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

.editorPanel {
  overflow: hidden;
}

.recordHead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  background: linear-gradient(90deg, #fafdff, #ffffff);
  border-bottom: 1px solid var(--line);
}

.recordHead img {
  width: 154px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius);
}

.recordHead small {
  color: var(--blue-dark);
  font-weight: 900;
  font-size: 12px;
}

.recordHead h2 {
  font-size: 22px;
  line-height: 1.22;
  margin-top: 5px;
}

.recordHead p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
}

.recordActions {
  display: grid;
  gap: 10px;
  justify-items: end;
  align-self: start;
}

.recordActions .primaryBtn {
  background: var(--blue-dark);
}

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

.formGrid .wide { grid-column: span 4; }
.formGrid .tall textarea { min-height: 190px; }

.adminHead {
  grid-template-columns: minmax(0, 1fr) auto;
}

.adminForm label {
  align-self: start;
}

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

.permissionCard {
  display: grid;
  gap: 7px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
  padding: 12px;
}

.permissionCard.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.permissionCard b {
  font-size: 13px;
}

.permissionCard span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.emptyState.compact {
  padding: 14px 12px;
}

.inlineGrid {
  padding: 0;
  margin-top: 12px;
}

.subSection {
  border-top: 1px solid var(--line);
  padding: 16px 18px;
}

.subSection > h3,
.subHead h3 {
  font-size: 16px;
}

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

.subHead span {
  font-size: 11px;
  color: #52616a;
  border-radius: 999px;
  background: #edf4f5;
  padding: 4px 8px;
}

.tierList {
  display: grid;
  gap: 10px;
}

.tierRow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  background: #f8fbfa;
  border-radius: var(--radius);
  padding: 12px;
}

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

.computedBox {
  min-height: 66px;
  border: 1px solid #cde6ee;
  border-radius: var(--radius);
  background: var(--blue-soft);
  padding: 11px 12px;
}

.computedBox span {
  color: #53616b;
  font-size: 12px;
  font-weight: 800;
}

.computedBox strong {
  display: block;
  font-size: 20px;
  line-height: 1.15;
  margin-top: 8px;
}

.computedBox.wide { grid-column: span 4; }

.sourceSection.system {
  background: linear-gradient(90deg, rgba(22, 169, 222, .09), transparent);
}

.sourceSection.user {
  background: linear-gradient(90deg, rgba(201, 242, 74, .14), transparent);
}

.sourceSection.staff {
  background: linear-gradient(90deg, rgba(255, 232, 169, .22), transparent);
}

.sourceSection.sensitive {
  background: linear-gradient(90deg, rgba(229, 80, 72, .08), transparent);
}

.checkField {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  padding: 0 10px;
  color: var(--ink);
}

.checkField input { width: auto; }

.actionRow {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

pre {
  margin: 18px;
  max-height: 70vh;
  overflow: auto;
  border-radius: var(--radius);
  background: #0f1b22;
  color: #effbff;
  padding: 18px;
  line-height: 1.55;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  border-radius: 6px;
  background: #121d24;
  color: white;
  padding: 11px 13px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 1180px) {
  body { padding: 0; }
  .appShell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sideNav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sideFoot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .listPanel { position: static; }
  .recordList { max-height: none; }
}

@media (max-width: 760px) {
  .loginScreen { min-height: 100vh; padding: 18px; }
  .topbar {
    min-height: auto;
    align-items: start;
    flex-direction: column;
    padding: 22px 18px 12px;
  }
  .topbar h1 { font-size: 24px; }
  .topActions {
    width: 100%;
    flex-wrap: wrap;
  }
  .topActions input {
    width: 100%;
    min-width: 0;
  }
  .content { padding: 8px 18px 28px; }
  .metricGrid,
  .filterBar,
  .importGrid,
  .formGrid,
  .inventoryGrid,
  .tierRow,
  .permissionGrid {
    grid-template-columns: 1fr;
  }
  .formGrid .wide,
  .computedBox.wide {
    grid-column: auto;
  }
  .recordHead {
    grid-template-columns: 1fr;
  }
  .recordHead img {
    width: 100%;
    height: 180px;
  }
  .recordActions {
    justify-items: start;
  }
  .sideNav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
