/* ==========================================================================
   库存管理系统 · 样式表
   设计原则：浅色、克制、信息密度高；无外部依赖，全部手写。
   ========================================================================== */

:root {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-soft:   #eff4ff;
  --brand-border: #c7d7fe;

  --bg:      #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border:  #e3e8ef;
  --border-strong: #d0d7e2;

  --text:       #101828;
  --text-mid:   #475467;
  --text-muted: #7c8799;

  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger:  #dc2626;
  --danger-soft: #fef2f2;
  --info:    #0369a1;
  --info-soft: #f0f9ff;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow:    0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --sidebar-w: 232px;
  --topbar-h:  60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

svg { display: block; flex: none; }

button { font: inherit; color: inherit; }

input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ==========================================================================
   布局：侧边栏 + 主区
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  flex: none;
}
.sidebar-brand:hover { color: var(--text); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  flex: none;
}

.brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
}

.nav-group {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}

.sidebar-foot {
  flex: none;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.env-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- 主区 ---------- */
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-mid);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }

/* ---------- 用户菜单 ---------- */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }

.user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 5px;
  border-radius: 99px;
  transition: background .12s;
}
.user-trigger:hover { background: var(--surface-alt); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: none;
  letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }

.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.dropdown-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.dropdown-name { font-weight: 600; font-size: 13.5px; }
.dropdown-email { font-size: 12px; color: var(--text-muted); word-break: break-all; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-mid);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-alt); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-form { margin: 0; }

/* ---------- 内容区 ---------- */
.app-content {
  flex: 1;
  padding: 22px 24px 32px;
  max-width: 1560px;
  width: 100%;
}

.app-footer {
  padding: 16px 24px 24px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.app-footer .dot { color: var(--border-strong); }

/* ==========================================================================
   登录 / 注册布局
   ========================================================================== */

.layout-auth {
  background:
    radial-gradient(900px 500px at 15% -10%, #e0ecff 0%, transparent 60%),
    radial-gradient(700px 400px at 100% 0%, #eef2ff 0%, transparent 55%),
    var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-panel { width: 100%; max-width: 420px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}
.auth-brand:hover { color: var(--text); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
}

.auth-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}
.auth-title.center { text-align: center; }

.auth-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 20px;
  line-height: 1.6;
}
.auth-subtitle.center { text-align: center; }

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}
.auth-success-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* ==========================================================================
   页面容器
   ========================================================================== */

.page { display: flex; flex-direction: column; gap: 18px; }
.page-narrow { max-width: 860px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.page-desc {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
}

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
}

.stack { display: flex; flex-direction: column; gap: 18px; }

/* ==========================================================================
   卡片
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-size: 14.5px;
  font-weight: 620;
}

.card-link { font-size: 12.5px; font-weight: 500; }

.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }
.card-body.no-pad-bottom { padding-bottom: 0; }
.card-body.border-top { border-top: 1px solid var(--border); }

.card-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.card-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 13px;
  font-weight: 620;
  color: var(--text-mid);
  margin-bottom: 14px;
}

/* ==========================================================================
   统计卡片
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
}
.stat-grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.stat-card.alert-card {
  border-color: #fcd9a8;
  background: linear-gradient(180deg, #fffdf7, #ffffff);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.stat-icon.blue   { background: var(--brand-soft);   color: var(--brand); }
.stat-icon.teal   { background: #ecfeff;             color: #0e7490; }
.stat-icon.green  { background: var(--success-soft); color: var(--success); }
.stat-icon.amber  { background: var(--warning-soft); color: var(--warning); }
.stat-icon.purple { background: #f5f3ff;             color: #7c3aed; }

.stat-value {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 660;
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-value.sm { font-size: 16px; font-weight: 600; }
.stat-unit { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.stat-foot {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   快捷操作
   ========================================================================== */

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-mid);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, color .12s, transform .12s;
}
.quick-btn:hover {
  border-color: var(--brand-border);
  color: var(--brand-dark);
  transform: translateY(-1px);
}

/* ==========================================================================
   图表
   ========================================================================== */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 190px;
  padding-top: 10px;
}
.chart-wide { height: 170px; gap: 4px; }

.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-pair {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.chart-bar {
  flex: 1;
  max-width: 14px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: opacity .12s;
}
.chart-bar.bar-in  { background: #3b82f6; }
.chart-bar.bar-out { background: #f59e0b; }
.chart-col:hover .chart-bar { opacity: .78; }

.chart-label {
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.legend { display: flex; gap: 14px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}
.legend-item .dot.in  { background: #3b82f6; }
.legend-item .dot.out { background: #f59e0b; }

/* ---------- 横向条形图 ---------- */
.hbar-list { display: flex; flex-direction: column; gap: 12px; }

.hbar-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 10px;
}

.hbar-name {
  font-size: 12.5px;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar-track {
  height: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.hbar-track.thin { height: 6px; }

.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 99px;
  min-width: 2px;
}

.hbar-value {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   表格
   ========================================================================== */

.table-wrap { overflow-x: auto; }

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

.table thead th {
  padding: 10px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfcfe; }

.table-compact thead th { padding: 8px 12px; }
.table-compact tbody td { padding: 9px 12px; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-col { width: 1%; white-space: nowrap; text-align: right; }

.cell-title { font-weight: 550; color: var(--text); }
.cell-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.cell-link  { font-weight: 550; }
.cell-link:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 620; }
.unit { font-size: 11.5px; color: var(--text-muted); margin-left: 2px; }

.text-in      { color: #1d4ed8; }
.text-out     { color: #b45309; }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-action:hover { background: var(--brand-soft); color: var(--brand); }
.icon-action.danger:hover { background: var(--danger-soft); color: var(--danger); }

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

/* ---------- 标签 / 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.7;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #047857; }
.badge-danger  { background: var(--danger-soft);  color: #b91c1c; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-muted   { background: #f1f3f7; color: var(--text-muted); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

.badge-in     { background: #eff6ff; color: #1d4ed8; }
.badge-out    { background: #fff7ed; color: #b45309; }
.badge-adjust { background: #f5f3ff; color: #6d28d9; }

.badge-role-admin   { background: #eef2ff; color: #4338ca; }
.badge-role-manager { background: #ecfdf5; color: #047857; }
.badge-role-viewer  { background: #f1f3f7; color: var(--text-muted); }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mid);
}

/* ==========================================================================
   按钮
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  color: var(--text-mid);
}
.btn-secondary:hover { background: #f1f3f7; color: var(--text); }

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-mid);
}
.btn-outline:hover { border-color: var(--brand-border); color: var(--brand-dark); background: var(--brand-soft); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 5px; }

.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* ==========================================================================
   表单
   ========================================================================== */

.form { display: block; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

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

.field > label {
  font-size: 12.5px;
  font-weight: 570;
  color: var(--text-mid);
}

.req { color: var(--danger); }

.hint-inline { font-weight: 400; color: var(--text-muted); font-size: 11.5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
}

.input::placeholder, .textarea::placeholder { color: #a8b1c1; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
  border-color: var(--danger);
}
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }

.input:disabled, .select:disabled {
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

.textarea { resize: vertical; min-height: 68px; line-height: 1.6; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  padding-right: 30px;
}

.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 56px; }

.input-suffix {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.input-suffix:hover { background: var(--surface-alt); color: var(--text); }

.field-error {
  font-size: 12px;
  color: var(--danger);
}

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

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
  user-select: none;
}
.checkbox input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

.link { font-weight: 500; font-size: 13px; }
.link-danger { color: var(--danger); font-weight: 500; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.inline-form { display: inline; margin: 0; }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
}
.filter-search svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding: 8px 11px 8px 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
}
.filter-search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.filter-bar .select { width: auto; min-width: 130px; }
.date-input { width: auto; }
.range-sep { color: var(--text-muted); font-size: 12.5px; }

.inline-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-search input[type="search"] {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  min-width: 190px;
}

/* ---------- 密码强度 ---------- */
.strength {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.strength-seg {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: #e8ecf3;
  transition: background .18s;
}
.strength-label {
  margin-left: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.strength[data-level="1"] .strength-seg:nth-child(1) { background: #ef4444; }
.strength[data-level="2"] .strength-seg:nth-child(-n+2) { background: #f59e0b; }
.strength[data-level="3"] .strength-seg:nth-child(-n+3) { background: #3b82f6; }
.strength[data-level="4"] .strength-seg { background: #059669; }

/* ==========================================================================
   提示条
   ========================================================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
}
.alert:last-child { margin-bottom: 0; }
.alert svg { margin-top: 1px; }

.alert-error   { background: var(--danger-soft);  border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-info    { background: var(--info-soft);    border-color: #bae6fd; color: #075985; }
.alert-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13.5px;
  animation: flash-in .22s ease-out;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}
.flash-text { flex: 1; }
.flash-icon { display: flex; }
.flash-close {
  display: flex;
  padding: 3px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  opacity: .6;
  cursor: pointer;
}
.flash-close:hover { opacity: 1; }

.flash-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }
.flash-error   { background: var(--danger-soft);  border-color: #fecaca; color: #991b1b; }
.flash-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.flash-info    { background: var(--info-soft);    border-color: #bae6fd; color: #075985; }

/* ==========================================================================
   分页
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

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

.page-links { display: flex; align-items: center; gap: 4px; }

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-mid);
  font-size: 12.5px;
  transition: background .12s, border-color .12s, color .12s;
}
.page-link:hover { border-color: var(--brand-border); color: var(--brand-dark); background: var(--brand-soft); }
.page-link.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.page-link.disabled { color: #c3cad6; background: var(--surface-alt); cursor: not-allowed; }
.page-ellipsis { padding: 0 3px; color: var(--text-muted); }

/* ==========================================================================
   空状态
   ========================================================================== */

.empty-state {
  padding: 48px 24px;
  text-align: center;
}
.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: #b6c0d0;
}
.empty-icon.success { background: var(--success-soft); color: var(--success); }

.empty-title { font-size: 14.5px; font-weight: 600; margin-bottom: 5px; }
.empty-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }

.empty-inline {
  padding: 34px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-inline.success { color: var(--success); }

/* ==========================================================================
   详情列表 / 仪表
   ========================================================================== */

.detail-list { display: flex; flex-direction: column; }

.detail-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--text-muted); font-size: 12.5px; }
.detail-row dd { color: var(--text); word-break: break-word; }

.gauge-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.gauge-track {
  height: 12px;
  border-radius: 99px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #34d399, #059669);
  min-width: 3px;
  transition: width .3s;
}
.gauge-fill.warning { background: linear-gradient(90deg, #fbbf24, #d97706); }
.gauge-fill.danger  { background: linear-gradient(90deg, #f87171, #dc2626); }

.gauge-marks {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.mini-label { display: block; font-size: 12px; color: var(--text-muted); }
.mini-value { display: block; margin-top: 3px; font-size: 15px; font-weight: 620; }

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 15.5px; font-weight: 620; }
.profile-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------- 计算预览 ---------- */
.calc-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
}
.calc-label { font-size: 13px; color: var(--brand-dark); font-weight: 500; }
.calc-value {
  font-size: 18px;
  font-weight: 660;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.diff-preview {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.diff-preview.positive { background: var(--success-soft); border-color: #a7f3d0; color: #047857; }
.diff-preview.negative { background: var(--danger-soft);  border-color: #fecaca; color: #b91c1c; }
.diff-preview.zero     { background: var(--info-soft);    border-color: #bae6fd; color: #0369a1; }

/* ---------- 错误页 ---------- */
.error-page {
  padding: 70px 24px;
  text-align: center;
}
.error-code {
  font-size: 68px;
  font-weight: 700;
  letter-spacing: -.04em;
  color: var(--brand);
  line-height: 1;
}
.error-code.danger { color: var(--danger); }
.error-title { margin-top: 14px; font-size: 19px; font-weight: 620; }
.error-desc {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.7;
}
.error-actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   安全问题 / 表单分区
   ========================================================================== */

/* 表单中的分节标题：一条带文字的横线 */
.form-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 16px;
  color: var(--text-mid);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.form-divider::before,
.form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.form-divider span { flex: none; }

/* 单条安全问题：问题输入框 + 答案输入框 */
.security-item { margin-bottom: 18px; }

.security-item .security-answer {
  margin-top: 8px;
  background: var(--surface-alt);
}

/* 找回密码第二步：展示问题原文 */
.security-question {
  margin: -2px 0 8px;
  padding: 9px 12px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.6;
  word-break: break-word;
}

/* ==========================================================================
   系统更新
   ========================================================================== */

/* 更新页的 Release 说明（来自 GitHub，已转义后按纯文本展示） */
.release-notes {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-mid);
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
}

/* 说明列表 */
.hint-list { display: flex; flex-direction: column; gap: 9px; }
.hint-list li {
  position: relative;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-mid);
}
.hint-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}

/* 行内代码片段 */
code {
  padding: 1px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

/* 统计卡片上的语义化取值 */
.stat-value.ok { color: var(--success); }
.stat-value.danger { color: var(--danger); }

/* 重启等待页 */
.update-restarting {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 52px 20px 40px;
}

.restart-spinner { color: var(--brand); }

.update-restarting-title {
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -.01em;
}

.update-restarting-desc {
  max-width: 460px;
  color: var(--text-mid);
  font-size: 13.5px;
  line-height: 1.75;
}

.update-restarting-hint {
  color: var(--text-muted);
  font-size: 13px;
}

.update-restarting .alert {
  width: 100%;
  max-width: 520px;
  text-align: left;
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1080px) {
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }

  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }

  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .38);
    z-index: 35;
  }

  .app-content { padding: 16px 14px 28px; }
  .topbar { padding: 0 14px; }
  .user-meta { display: none; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .select, .filter-bar .btn, .date-input { width: 100%; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
  .pagination { flex-direction: column; align-items: flex-start; }
}

@media print {
  .sidebar, .topbar, .page-actions, .filter-bar, .app-footer { display: none !important; }
  .app-main { margin-left: 0; }
  .card { box-shadow: none; border-color: #ccc; }
}
