:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #303133;
  background: #f0f2f5;
  font-synthesis: none;
  line-height: 1.5;
  --primary: #409eff;
  --primary-dark: #337ecc;
  --primary-soft: #ecf5ff;
  --border: #e4e7ed;
  --border-light: #ebeef5;
  --muted: #909399;
  --sidebar: #304156;
  --sidebar-deep: #263445;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: #f0f2f5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.boot-screen,
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.boot-screen { background: #f5f7fa; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dcdfe6;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-page {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(48, 65, 86, .96), rgba(28, 45, 64, .94)),
    #304156;
}
.login-page::before,
.login-page::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
}
.login-page::before { width: 520px; height: 520px; top: -260px; right: -90px; }
.login-page::after { width: 360px; height: 360px; bottom: -220px; left: -110px; }
.login-card {
  position: relative;
  z-index: 1;
  width: min(410px, calc(100% - 36px));
  padding: 38px 40px 34px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(9, 20, 34, .24);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 30px;
}
.login-brand h1 { margin: 0; color: #303133; font-size: 22px; font-weight: 600; }
.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 7px;
}
.brand-mark svg { width: 23px; height: 23px; fill: currentColor; }
.login-card label,
.form-grid label {
  display: grid;
  gap: 7px;
  margin: 15px 0;
  color: #606266;
  font-size: 14px;
}
.login-card input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.toolbar input,
.toolbar select,
.upload input,
.upload select {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  color: #303133;
  background: #fff;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, .12);
}
.login-submit,
.panel button,
.dialog-actions button {
  min-height: 34px;
  padding: 7px 15px;
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 4px;
  transition: background .18s, border-color .18s;
}
.login-submit:hover,
.panel button:hover,
.dialog-actions button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.login-submit { width: 100%; height: 40px; margin-top: 8px; }
.error { min-height: 20px; margin-top: 11px; color: #f56c6c; font-size: 13px; text-align: center; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  transition: grid-template-columns .2s ease;
}
.layout.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.layout aside {
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 0;
  height: 100vh;
  overflow: hidden auto;
  color: #bfcbd9;
  background: var(--sidebar);
  box-shadow: 1px 0 4px rgba(0, 21, 41, .18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 16px;
  color: #fff;
  background: var(--sidebar-deep);
  white-space: nowrap;
}
.brand .brand-mark { width: 30px; height: 30px; border-radius: 5px; }
.brand .brand-mark svg { width: 20px; height: 20px; }
.brand strong { overflow: hidden; font-size: 16px; letter-spacing: .02em; }
.layout nav { padding: 10px 0 18px; }
.layout nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 48px;
  padding: 0 20px;
  overflow: hidden;
  color: #bfcbd9;
  text-align: left;
  white-space: nowrap;
  background: transparent;
  border: 0;
  transition: color .16s, background .16s;
}
.layout nav button:hover { color: #fff; background: #263445; }
.layout nav button.active { color: #409eff; background: #263445; }
.layout nav button.active::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: #409eff;
}
.nav-icon { display: inline-grid; flex: 0 0 20px; width: 20px; place-items: center; }
.nav-icon svg,
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.layout.collapsed .brand { justify-content: center; padding: 0; }
.layout.collapsed .brand strong,
.layout.collapsed .nav-label { display: none; }
.layout.collapsed nav button { justify-content: center; padding: 0; }

.layout main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px 0 14px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
}
.topbar-left,
.topbar-actions { display: flex; align-items: center; min-width: 0; }
.topbar-left { gap: 9px; }
.topbar-actions { gap: 10px; color: #606266; font-size: 13px; }
.topbar h1 { margin: 0; color: #303133; font-size: 14px; font-weight: 500; white-space: nowrap; }
.breadcrumb,
.breadcrumb-separator { color: #a8abb2; font-size: 13px; }
.icon-button,
.text-button {
  display: inline-grid;
  place-items: center;
  color: #606266;
  background: transparent;
  border: 0;
}
.icon-button { width: 36px; height: 36px; padding: 0; border-radius: 4px; }
.icon-button:hover { color: var(--primary); background: #f5f7fa; }
.text-button { display: inline-block; padding: 7px 2px; font-size: 13px; }
.text-button:hover { color: var(--primary); }
.identity-avatar {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: #5f7187;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
}
.page-tab {
  position: sticky;
  top: 58px;
  z-index: 7;
  height: 34px;
  padding: 4px 16px;
  background: #fff;
  border-bottom: 1px solid #d8dce5;
  box-shadow: 0 1px 3px rgba(0, 21, 41, .08);
}
.page-tab span {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  color: #fff;
  background: var(--primary);
  border-radius: 2px;
  font-size: 12px;
}
.page-tab span::before { width: 5px; height: 5px; margin-right: 6px; content: ""; background: #fff; border-radius: 50%; }
#content { min-width: 0; padding: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; }
.metric,
.panel {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0, 21, 41, .04);
}
.metric { position: relative; min-height: 108px; padding: 19px 20px; color: #909399; font-size: 13px; }
.metric::after {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  content: "";
  background: #d9ecff;
  border: 3px solid #ecf5ff;
  border-radius: 50%;
}
.metric b { display: block; margin-top: 10px; color: #303133; font-size: 28px; font-weight: 500; line-height: 1.1; }
.panel { margin-top: 16px; padding: 18px; }
.metrics + .panel { margin-top: 16px; }
.panel:first-child { margin-top: 0; }
.panel-head,
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 { margin: 0; color: #303133; font-size: 15px; font-weight: 600; }
.toolbar { justify-content: flex-start; flex-wrap: wrap; }
.toolbar input,
.toolbar select { width: auto; min-width: 140px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border-light); }
table { width: 100%; border-collapse: collapse; color: #606266; font-size: 13px; }
th, td { height: 45px; padding: 9px 12px; border-bottom: 1px solid var(--border-light); text-align: left; white-space: nowrap; }
th { color: #606266; background: #f8f8f9; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5f7fa; }
td.wrap { max-width: 360px; white-space: normal; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  color: #337ecc;
  background: #ecf5ff;
  border: 1px solid #d9ecff;
  border-radius: 3px;
  font-size: 12px;
}
.badge.warn { color: #b88230; background: #fdf6ec; border-color: #faecd8; }
.badge.risk { color: #c45656; background: #fef0f0; border-color: #fde2e2; }
.actions { display: flex; gap: 8px; }
.actions button { min-height: 28px; padding: 4px 10px; font-size: 12px; }
.panel button.ghost,
.dialog-actions button.ghost { color: #606266; background: #fff; border-color: #dcdfe6; }
.panel button.ghost:hover,
.dialog-actions button.ghost:hover { color: var(--primary); background: #ecf5ff; border-color: #b3d8ff; }
.panel button.danger { color: #fff; background: #f56c6c; border-color: #f56c6c; }
.panel button.danger:hover { background: #dd6161; border-color: #dd6161; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid textarea { min-height: 130px; resize: vertical; }
.empty { padding: 54px 20px; color: #909399; text-align: center; }
.loading-state { display: grid; min-height: 160px; place-items: center; }
.upload { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.upload label { display: grid; gap: 6px; margin: 0; color: #606266; font-size: 13px; }
.upload label:has(input[type="checkbox"]) { display: flex; align-items: center; min-height: 38px; }
.upload input[type="checkbox"],
.form-grid input[type="checkbox"] { width: auto; min-height: auto; box-shadow: none; }
.company-cell { display: flex; align-items: center; gap: 9px; }
.company-logo {
  position: relative;
  display: inline-grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  overflow: hidden;
  place-items: center;
  color: #337ecc;
  background: #ecf5ff;
  border: 1px solid #d9ecff;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.company-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }

dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: auto;
  background: #fff;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .22);
}
dialog::backdrop { background: rgba(0, 0, 0, .46); }
#dialog-form { padding: 22px 24px 20px; }
#dialog-body h2 { margin: 0 0 18px; font-size: 17px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-light); }
#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: none;
  padding: 10px 15px;
  color: #fff;
  background: rgba(48, 49, 51, .92);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  font-size: 13px;
}
.code { max-width: 480px; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

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

@media (max-width: 780px) {
  .layout,
  .layout.collapsed { display: block; }
  .layout aside {
    position: fixed;
    inset: 0 auto 0 0;
    width: 210px;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .layout:not(.collapsed) aside { transform: translateX(0); }
  .layout.collapsed .brand { justify-content: flex-start; padding: 0 16px; }
  .layout.collapsed .brand strong,
  .layout.collapsed .nav-label { display: inline; }
  .layout.collapsed nav button { justify-content: flex-start; padding: 0 20px; }
  .topbar { padding-right: 12px; }
  .breadcrumb,
  .breadcrumb-separator,
  #identity { display: none; }
  #content { padding: 12px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 95px; padding: 16px; }
  .panel { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px 28px; }
  .metrics { grid-template-columns: 1fr; }
  .text-button { display: none; }
}
