:root {
  --ink: #17211d;
  --muted: #69736f;
  --line: #dbe3dd;
  --surface: #f8faf8;
  --panel: #ffffff;
  --accent: #d63d2e;
  --accent-ink: #ffffff;
  --good: #1d7a55;
  --warn: #b76b00;
  --bad: #b42318;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  color: var(--ink);
  background: linear-gradient(135deg, #fbfcf8 0%, #eef5f2 48%, #f8eeee 100%);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(214, 61, 46, 0.18), transparent 28%),
    linear-gradient(135deg, rgba(248, 250, 248, 0.96), rgba(238, 245, 242, 0.96));
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 22px 80px rgba(23, 33, 29, 0.16);
}

.login-card h2 {
  margin: 8px 0 8px;
  font-size: 26px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--ink);
  font-weight: 700;
}

.login-card button {
  width: 100%;
  margin-top: 22px;
}

.login-eyebrow {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff2eb;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.login-message {
  min-height: 20px;
  margin-top: 12px;
  color: var(--bad);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 13px;
}

.sidebar {
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
  border-radius: 8px;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.nav {
  width: 100%;
  display: block;
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}

.nav.active,
.nav:hover {
  border-color: var(--line);
  background: var(--panel);
}

main {
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

button:hover {
  filter: brightness(0.98);
}

.actions,
.row-actions,
.formula-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.module-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.module-tab,
.profit-tab {
  border-color: transparent;
  background: transparent;
}

.module-tab.active,
.profit-tab.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent);
}

.risk-tab {
  border-color: transparent;
  background: transparent;
}

.risk-tab.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent);
}

.goods-panel,
.profit-panel {
  display: none;
}

.goods-panel.active,
.risk-panel.active,
.profit-panel.active {
  display: block;
}

.risk-panel {
  display: none;
}

.risk-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.risk-metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.risk-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.analysis-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.72);
  color: var(--muted);
  line-height: 1.6;
}

.status-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.compact-tabs {
  margin-bottom: 0;
}

.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  background: rgba(255, 255, 255, 0.72);
}

.time-profit-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.status-tab span {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  padding: 0 7px;
  border-radius: 8px;
  background: #edf3f0;
  color: var(--muted);
  font-size: 12px;
}

.status-tab.active {
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent);
}

.toolbar,
.bulk-toolbar,
.rule-card {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rule-card {
  display: block;
}

.bulk-toolbar {
  justify-content: space-between;
  gap: 10px;
  margin-top: -6px;
  padding: 12px 16px;
  background: rgba(255, 248, 246, 0.86);
}

.bulk-toolbar button {
  min-height: 38px;
}

.bulk-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.settings-status {
  margin: 8px 0 14px;
  line-height: 1.8;
}

.title-config-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.title-config-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.title-config-item strong,
.title-config-item .config-value {
  display: block;
}

.title-config-item .config-value {
  margin-top: 6px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.title-config-prompt .config-value {
  max-height: 110px;
  overflow: auto;
  white-space: pre-wrap;
}

.prompt-preview {
  max-height: 320px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  white-space: pre-wrap;
  line-height: 1.7;
  font: 13px/1.7 "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.copy-box {
  margin-top: 12px;
  word-break: break-all;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.rule-card label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
}

#searchInput,
#profitFormula {
  min-width: min(480px, 100%);
  flex: 1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #f7faf8;
}

.select-cell {
  width: 44px;
  min-width: 44px;
  text-align: center;
  vertical-align: middle;
}

.select-cell input {
  min-height: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

.goods-cell {
  display: flex;
  gap: 12px;
  min-width: 320px;
}

.goods-cell.compact {
  min-width: 260px;
}

.goods-cell img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f4;
}

.image-placeholder {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--muted);
  font-size: 12px;
}

.goods-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent);
  filter: none;
}

.detail-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-header h2 {
  margin: 0 0 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.detail-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.detail-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f4;
}

.detail-image.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.image-gallery a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f4f6f4;
}

.image-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

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

.fact {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.fact span,
.reference-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.fact strong,
.reference-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

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

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.reference-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.reference-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.tag-wrap {
  margin-top: 10px;
}

.description-block,
.raw-json {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}

.raw-json {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #17211d;
  color: #eaf2ec;
  font-size: 12px;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #edf3f0;
  color: var(--muted);
  margin: 2px 4px 2px 0;
  font-size: 12px;
}

.tag.bad {
  background: #fff1ef;
  color: var(--bad);
}

.tag.warn {
  background: #fff8e8;
  color: var(--warn);
}

.tag.good {
  background: #e9f7ef;
  color: var(--good);
}

.tag.high {
  background: #fff1ef;
  color: var(--bad);
}

.tag.medium {
  background: #fff8e8;
  color: var(--warn);
}

.tag.low {
  background: #e9f7ef;
  color: var(--good);
}

.count-button {
  min-width: 72px;
  justify-content: center;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.progress-bar {
  width: 160px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf3f0;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #e58b32);
}

.task-feedback {
  min-width: 260px;
}

.task-feedback button {
  margin-top: 8px;
  padding: 7px 10px;
}

.task-detail-progress {
  width: 100%;
  margin-top: 14px;
}

.task-detail-table {
  max-height: 300px;
}

.retry-button {
  margin-top: 12px;
}

.inline-json {
  max-width: 420px;
  max-height: 160px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #17211d;
  color: #eaf2ec;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.expand-row td {
  background: #fbfdfb;
  padding: 0;
}

.expanded-goods {
  padding: 14px;
}

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

.nested-table table {
  min-width: 900px;
}

dialog {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 520px;
  padding: 24px;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--accent);
  filter: none;
}

.analysis-dialog {
  width: min(1080px, calc(100vw - 48px));
  max-width: 1080px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dialog-header h2 {
  margin: 0 0 6px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.analysis-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.analysis-card h3 {
  margin: 0 0 12px;
}

.chart-card {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.pie-chart {
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.08);
}

.pie-chart > div {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}

.pie-chart strong {
  font-size: 28px;
}

.pie-chart span {
  color: var(--muted);
  font-size: 13px;
}

.pie-legend {
  width: 100%;
}

.legend-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.order-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-breakdown {
  margin-top: 14px;
}

.order-table-wrap {
  max-height: 320px;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    gap: 8px;
    align-items: center;
    overflow: auto;
  }

  .brand {
    min-width: 220px;
    margin-bottom: 0;
  }

  .nav {
    width: auto;
    white-space: nowrap;
  }

  .topbar,
  .toolbar,
  .bulk-toolbar {
    display: block;
  }

  .settings-grid,
  .form-grid,
  .risk-summary,
  .detail-grid,
  .fact-grid,
  .metric-grid,
  .reference-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .analysis-dialog {
    width: calc(100vw - 24px);
  }

  .actions,
  .toolbar > *,
  .bulk-toolbar > * {
    margin-top: 10px;
  }
}


/* in-progress button feedback */
button[data-loading="true"] {
  position: relative;
  cursor: progress;
  opacity: 0.85;
}
button[data-loading="true"]::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: codex-spin 0.8s linear infinite;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
@keyframes codex-spin {
  to { transform: rotate(360deg); }
}
.toast-inline {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  background: rgba(20, 24, 28, 0.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.toast-inline .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  vertical-align: middle;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: codex-spin 0.8s linear infinite;
}


/* sku image preview + collapsible raw json */
.sku-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f4f6f4;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}
.sku-thumb:hover {
  transform: scale(1.04);
}
.sku-raw-pre {
  margin-top: 8px;
}
.raw-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.raw-toggle:hover {
  background: rgba(0,0,0,0.04);
}


/* table bottom pagination */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 4px 4px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pagination-bar button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}


/* paged pagination */
.pagination-info {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.pagination-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.pagination-page-size select {
  padding: 2px 8px;
}
.pagination-page-list,
.page-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  flex: 1;
}
.pagination-page-list button,
.page-list button {
  min-width: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pagination-page-list button:hover:not(:disabled),
.page-list button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pagination-page-list button.is-active,
.page-list button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: default;
}
.pagination-page-list .ellipsis,
.page-list .ellipsis {
  padding: 4px 6px;
  color: var(--muted);
  user-select: none;
}
.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.pagination-jump input {
  width: 56px;
  padding: 4px 6px;
  text-align: center;
}

.has-detection-issue {
  background: #fff7f7;
}
.detection-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* auto-dismiss flash toast */
.toast-flash-stack {
  position: fixed;
  right: 16px;
  bottom: 64px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-flash {
  pointer-events: auto;
  background: rgba(20, 24, 28, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toast-flash-in 0.18s ease-out;
  cursor: pointer;
}
.toast-flash--error {
  background: rgba(190, 36, 36, 0.95);
}
.toast-flash.is-leaving {
  animation: toast-flash-out 0.22s ease-in forwards;
}
@keyframes toast-flash-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-flash-out {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(8px); opacity: 0; }
}

/* 妙手 cookie 配置卡 */
.miaoshou-config-card textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf8;
  resize: vertical;
  margin-bottom: 8px;
}
.miaoshou-config-card .form-grid-tight {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.miaoshou-config-card code {
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 12px;
}


/* ---- User Management ---- */
.management-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.management-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
}
.management-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.user-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.user-stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}
.user-stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}
.user-stat strong {
  font-size: 24px;
}

.users-table td {
  vertical-align: middle;
}
.user-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.user-cell strong {
  font-size: 15px;
}
.user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.user-actions .small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}
.user-actions .small.danger {
  border-color: var(--bad);
  color: var(--bad);
}
.user-actions .small.danger:hover {
  background: #fff1ef;
}
.empty-row td {
  text-align: center;
  padding: 32px 12px;
  color: var(--muted);
}

/* div-based dialog overlay (user management) */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 29, 0.42);
}
.dialog.hidden {
  display: none;
}
.dialog-card {
  width: min(680px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 80px rgba(23, 33, 29, 0.18);
}

.dialog-card textarea,
.dialog-card input {
  width: 100%;
  margin-top: 12px;
}
.dialog-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.dialog-title h3 {
  margin: 0;
  font-size: 18px;
}
.dialog-card .form-grid {
  margin-bottom: 16px;
}
.dialog-card .row-actions {
  justify-content: flex-end;
}

.image-risk-details {
  margin-top: 8px;
}

.image-risk-details summary {
  list-style: none;
  cursor: pointer;
}

.image-risk-details summary::-webkit-details-marker {
  display: none;
}

.image-risk-details .raw-json {
  max-height: 320px;
  margin-top: 8px;
  overflow: auto;
}
.icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 860px) {
  .user-summary,
  .management-head {
    grid-template-columns: 1fr;
  }
  .management-head {
    flex-direction: column;
  }
}
