/* ============================================================
   视图组件样式：指标卡 / 图表 / 抽屉 / 弹窗 / 提示 / 登录
   ============================================================ */

/* ---------- 指标卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-3);
  font-size: 12.5px;
}

.stat-head .icon-box {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-weak);
  color: var(--brand-text);
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat-value small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 4px;
}

.stat-foot {
  font-size: 12px;
  color: var(--text-3);
}

.stat-foot .up {
  color: var(--ok);
}

.stat-foot .down {
  color: var(--danger);
}

/* ---------- 趋势图 ---------- */
.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  height: 190px;
  padding: 8px 4px 0;
}

.chart-col {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 8px;
  height: 100%;
}

.chart-bar-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: min(38px, 70%);
  min-height: 3px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 55%, transparent));
  transition: height 0.35s ease;
}

.chart-bar.zero {
  background: var(--surface-3);
}

.chart-val {
  font-size: 11.5px;
  color: var(--text-2);
}

.chart-label {
  font-size: 11px;
  color: var(--text-3);
}

/* ---------- 用量进度 ---------- */
.quota-row {
  display: grid;
  gap: 6px;
}

.quota-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-2);
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.3s ease;
}

.meter.warn > span {
  background: var(--warn);
}

.meter.danger > span {
  background: var(--danger);
}

/* ---------- 弹窗 ---------- */
.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 14, 24, 0.44);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.14s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: pop-in 0.16s ease;
}

@keyframes pop-in {
  from {
    transform: translateY(6px) scale(0.985);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 0;
}

.modal-head h3 {
  font-size: 15px;
}

.modal-head p {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 3px;
}

.modal-body {
  padding: 16px 20px;
  display: grid;
  gap: 14px;
}

.modal-body .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

/* ---------- 抽屉 ---------- */
.drawer-backdrop {
  place-items: stretch end;
  padding: 0;
}

.drawer {
  width: min(720px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.2s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h3 {
  font-size: 15px;
}

.drawer-head .sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  font-family: var(--font-mono);
}

.drawer-body {
  padding: 18px 22px 32px;
  overflow: auto;
  display: grid;
  gap: 18px;
}

.drawer-section > h4 {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: none;
  margin-bottom: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 8px 14px;
  font-size: 13px;
}

.kv dt {
  color: var(--text-3);
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

/* ---------- 隐患条目 ---------- */
.hazard-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  background: var(--surface);
}

.hazard-item.sev-major {
  border-left: 3px solid var(--danger);
}

.hazard-item.sev-minor {
  border-left: 3px solid var(--warn);
}

.hazard-item.sev-pending {
  border-left: 3px dashed var(--warn);
}

.hazard-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hazard-title {
  font-weight: 600;
  font-size: 13.5px;
}

.hazard-conf {
  font-size: 12px;
  color: var(--text-3);
  margin-left: auto;
}

.hazard-fields {
  display: grid;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}

.hazard-fields b {
  color: var(--text-3);
  font-weight: 500;
  margin-right: 6px;
}

.conf-bar {
  display: inline-block;
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  vertical-align: middle;
  overflow: hidden;
  margin-left: 6px;
}

.conf-bar span {
  display: block;
  height: 100%;
  background: var(--text-3);
}

.callout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.65;
}

.callout.warn {
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
  background: var(--warn-weak);
  color: var(--warn);
}

/* ---------- 提示 ---------- */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: pop-in 0.16s ease;
}

.toast svg {
  flex: none;
  margin-top: 1px;
}

.toast-success svg {
  color: var(--ok);
}

.toast-error svg {
  color: var(--danger);
}

.toast-info svg {
  color: var(--info);
}

.toast-close {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* ---------- 密钥展示 ---------- */
.secret-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
}

.secret-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.secret-row code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--brand-weak), transparent 70%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 26px;
  display: grid;
  gap: 16px;
}

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

.login-brand .brand-mark {
  width: 34px;
  height: 34px;
}

.login-brand strong {
  display: block;
  font-size: 14px;
}

.login-brand span {
  display: block;
  font-size: 12px;
  color: var(--text-3);
}

.login-err {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-weak);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
  }

  .brand {
    padding: 0 8px 0 0;
    flex: none;
  }

  .brand-text span {
    display: none;
  }

  .nav {
    flex-direction: row;
    margin: 0;
  }

  .nav-item {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .nav-item span {
    display: none;
  }

  .sidebar-foot {
    display: none;
  }

  .topbar,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content {
    padding-bottom: 40px;
  }

  .modal-body .grid-2 {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100%;
  }

  .chart {
    gap: 6px;
    height: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
