/* =========================================================
   RD 管理平台壳层样式：深色中性主题 + 橙色强调
   无外部字体 / 图片 / CDN
   ========================================================= */

:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-soft: #11161d;
  --panel: #151a21;
  --panel-2: #1b2230;
  --border: #253041;
  --border-soft: #1f2734;
  --text: #e7ebf2;
  --muted: #93a0b4;
  --accent: #f97316;
  --accent-strong: #fb923c;
  --accent-dim: rgba(249, 115, 22, 0.14);
  --accent-line: rgba(249, 115, 22, 0.38);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-dim: rgba(52, 211, 153, 0.12);
  --radius: 10px;
  --sidebar-w: 232px;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app-root {
  min-height: 100vh;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

a {
  color: var(--accent-strong);
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

/* ---------------- 登录 ---------------- */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 18px;
  background:
    radial-gradient(900px 480px at 50% -12%, rgba(249, 115, 22, 0.13), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 26px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.login-title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.3px;
}

.login-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.brand-mark {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #c2410c);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-foot {
  display: flex;
  justify-content: flex-start;
}

.form-error {
  min-height: 0;
  color: var(--danger);
  font-size: 12.5px;
  word-break: break-word;
}

.form-error:empty {
  display: none;
}

/* ---------------- 表单控件 ---------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  color: var(--muted);
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.input {
  width: 100%;
  min-width: 0;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #66738a;
}

.input:hover {
  border-color: #33425a;
}

.input:focus-visible,
.btn:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.input-sm {
  padding: 6px 9px;
  font-size: 12.5px;
}

textarea.input {
  resize: vertical;
  min-height: 58px;
  line-height: 1.45;
}

.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 1px;
}

select.input {
  cursor: pointer;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.switch-text {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------------- 按钮 ---------------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--panel-2);
  border-color: #33425a;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1b0d02;
  font-weight: 650;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.38);
}

.btn-danger:hover {
  background: var(--danger-dim);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px 16px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  appearance: none;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--panel-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  color: var(--accent-strong);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0 6px;
  font-size: 11.5px;
  color: #5f6b7d;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(14, 17, 22, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.page-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.identity {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.35;
}

.identity-name {
  font-size: 13px;
  font-weight: 600;
}

.identity-meta {
  font-size: 11.5px;
  color: var(--muted);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 26px 56px;
  width: 100%;
  max-width: 1280px;
}

/* ---------------- 卡片 ---------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  min-width: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0.4px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------------- 面板与表格 ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.panel-body {
  padding: 4px 0 0;
}

.panel-foot {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.012);
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.018);
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cell-strong {
  font-weight: 550;
}

.cell-hint {
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.detail-cell {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------- 徽章 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-ok {
  color: var(--ok);
  background: var(--ok-dim);
  border-color: rgba(52, 211, 153, 0.32);
}

.badge-off {
  color: #9aa6b8;
  background: rgba(154, 166, 184, 0.08);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-dim);
  border-color: rgba(248, 113, 113, 0.32);
}

/* ---------------- 工具条 ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar .input {
  width: auto;
  min-width: 200px;
  flex: 0 1 280px;
}

/* ---------------- 状态占位 ---------------- */

.state-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.state-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 12px 16px;
  background: rgba(255, 255, 255, 0.012);
}

.state-error {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: var(--radius);
  background: var(--danger-dim);
}

.state-error .state-title {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.state-error .muted {
  margin: 0;
  max-width: 520px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- 弹窗 ---------------- */

dialog.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: calc(100% - 36px);
  max-width: 460px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modal-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 650;
}

.modal-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.secret-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.secret-box .mono-input {
  flex: 1;
  font-size: 13px;
}

/* ---------------- Toast ---------------- */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  word-break: break-word;
  animation: toast-in 0.16s ease-out;
}

.toast-ok {
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--ok);
}

.toast-error {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--danger);
}

.toast-out {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .nav {
    flex-direction: row;
    gap: 4px;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 7px 12px;
  }

  .sidebar-foot {
    display: none;
  }

  .brand-text {
    display: none;
  }

  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .content {
    padding: 16px 16px 48px;
    gap: 14px;
  }

  .identity {
    align-items: flex-start;
  }

  .toolbar .input {
    flex: 1 1 180px;
    min-width: 0;
  }
}

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