:root {
  --bg: #f7f7f8;
  --panel: #fff;
  --line: #e8e8ed;
  --text: #1d1d22;
  --muted: #737782;
  --dark: #17171c;
  --soft: #f1f1f4;
  --accent: #6f56f6;
  --danger: #e5484d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 18px;
  border-bottom: 1px solid var(--line);
}

.admin-brand img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  object-fit: contain;
}

.admin-brand strong {
  display: block;
  font-size: 1rem;
}

.admin-brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.nav-links {
  display: grid;
  gap: 5px;
  padding-top: 14px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #3f4148;
  font-size: 0.88rem;
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active {
  background: #f4f2ff;
  color: #2f236f;
}

.nav-section-title {
  padding: 14px 10px 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.admin-main {
  min-width: 0;
  padding: 30px;
}

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

h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.actions,
.filters,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill,
.dark {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.dark {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.pill.danger {
  border-color: #ffd4d6;
  color: var(--danger);
  background: #fff8f8;
}

.sales-auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sales-auth-card {
  width: min(460px, 100%);
  padding: 24px;
}

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

.panel + .panel,
.stack > .panel + .panel {
  margin-top: 16px;
}

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

.panel-title {
  font-weight: 900;
}

.note,
.muted {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

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

.platform-stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.resource-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid #f0a4a8;
  border-left: 5px solid var(--danger);
  background: #fff2f3;
  color: #7f1d24;
}

.resource-alert > div {
  display: grid;
  gap: 4px;
}

.resource-alert strong {
  font-size: 1rem;
}

.resource-alert span {
  font-size: .78rem;
  color: #9f3037;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
}

.stat-value {
  margin-top: 4px;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 900;
}

.small-value {
  font-size: 1rem;
  line-height: 1.3;
}

.table-wrap {
  overflow: auto;
}

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

.data-table th,
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.86rem;
}

.data-table th {
  background: #fbfbfd;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.data-table tr:hover td {
  background: #fafafe;
}

.cell-title {
  font-weight: 900;
}

.cell-muted {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.role,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: #4f525b;
  font-size: 0.74rem;
}

.badge.danger,
.role.disabled {
  background: #fff0f0;
  color: #b42318;
}

.notify-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 900;
}

.notify-badge[hidden] {
  display: none;
}

.title-with-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 12px;
  outline: 0;
}

.filter-input,
.filter-select {
  width: auto;
  min-width: 130px;
  height: 34px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.filter-input {
  min-width: 190px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.side {
  padding: 18px;
}

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

.sales-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row {
  min-width: 0;
}

.button-row {
  margin-top: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.check-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
}

.check-row input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  background: #fafafe;
}

.pager {
  min-height: 52px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
}

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

.record-line {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.record-line.medium,
.record-line.warning,
.record-line.notice {
  border-color: #ffe0a3;
  background: #fffaf0;
}

.record-line.high,
.record-line.critical {
  border-color: #ffd4d6;
  background: #fff8f8;
}

.compact-kv {
  display: grid;
  gap: 10px;
}

.compact-kv > div {
  min-height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.compact-kv > div:last-child {
  border-bottom: 0;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.video-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.video-admin-card {
  min-width: 0;
}

.video-admin-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  margin-bottom: 12px;
  border-radius: 11px;
  background: #10131a;
  object-fit: cover;
}

.video-admin-fields {
  margin-top: 14px;
}

.video-admin-description {
  grid-column: 1 / -1;
}

.video-admin-description textarea {
  width: 100%;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  resize: vertical;
  color: var(--text);
}

.entry-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  text-decoration: none;
}

.entry-card:hover {
  background: #fafafe;
}

.record-list,
.tx-list,
.order-list {
  display: grid;
  gap: 10px;
}

.tx,
.order-card,
.record {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.tx-main,
.order-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
}

.record {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
}

.record-thumb {
  width: 100px;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f2f2f5 center / cover no-repeat;
}

.feedback-table td {
  vertical-align: top;
}

.feedback-thumb {
  width: 92px;
  height: 68px;
}

.feedback-prompt {
  min-width: 300px;
  max-width: 520px;
  white-space: normal;
}

.feedback-final-title {
  margin-top: 8px;
}

.feedback-admin-cell {
  min-width: 220px;
}

.feedback-admin-cell textarea {
  width: 100%;
  min-height: 64px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  resize: vertical;
  color: var(--text);
}

.feedback-status-select {
  min-width: 104px;
}

.feedback-row-actions {
  margin-top: 8px;
}

.rule-list {
  display: grid;
  gap: 12px;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.rule-card textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  resize: vertical;
  color: var(--text);
}

.copy-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.copy-line input {
  height: 34px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
}

.sales-rate-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.sales-rate-editor input {
  width: 66px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.sales-rate-editor .pill {
  min-height: 34px;
  padding: 0 10px;
}

button.record-thumb {
  padding: 0;
  cursor: zoom-in;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 17, 22, 0.62);
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-card {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.image-preview-head {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.image-preview-card img {
  width: 100%;
  max-height: min(680px, calc(100vh - 116px));
  object-fit: contain;
  background: #f4f4f6;
}

@media (max-width: 900px) {
  .admin-layout {
    display: block;
  }

  .admin-nav {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-brand {
    padding: 0 4px 10px;
  }

  .nav-links {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0 2px;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .admin-main {
    padding: 18px;
  }

  .top {
    display: grid;
  }

  .stats-grid,
  .form-grid,
  .sales-form,
  .two-col {
    grid-template-columns: 1fr;
  }

  .video-admin-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    min-width: 860px;
  }
}

/* ZMD Industrial Intelligence UI */
:root {
  --bg: #f3f6f9;
  --panel: #ffffff;
  --line: #dce2e8;
  --text: #151a23;
  --muted: #5e6877;
  --dark: #111318;
  --soft: #f7f9fb;
  --accent: #1463ff;
  --info: #008fa8;
  --success: #168653;
  --warning: #b9680c;
  --danger: #c9363e;
  --focus-ring: 0 0 0 3px rgba(20, 99, 255, 0.16);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input,
select,
textarea {
  border-color: #c9d1d9;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover { border-color: #8c98a6; }
input:focus,
select:focus,
textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); outline: 0; }

.admin-layout { grid-template-columns: 216px minmax(0, 1fr); }
.admin-nav {
  padding: 18px 12px;
  border-right: 1px solid #252a32;
  background: #111318;
  color: #f7f9fc;
}
.admin-brand { min-height: 58px; padding: 0 8px 16px; border-bottom-color: #292e37; }
.admin-brand img { width: 32px; height: 32px; }
.admin-brand strong { color: #fff; font-size: .92rem; }
.admin-brand span { color: #8f99a8; font-size: .7rem; }
.nav-links { gap: 3px; padding-top: 12px; }
.nav-link {
  min-height: 40px;
  padding: 0 11px;
  border-radius: 6px;
  color: #aeb7c4;
  font-size: .8rem;
  font-weight: 650;
  transition: background-color 120ms ease, color 120ms ease;
}
.nav-link:hover { background: #1c2129; color: #fff; }
.nav-link.active {
  background: #183462;
  color: #fff;
  box-shadow: inset 3px 0 0 #3b82ff;
}
.nav-section-title { padding: 17px 11px 6px; color: #707b8c; font-size: .65rem; }
.notify-badge { background: #1463ff; color: #fff; }

.admin-main { padding: 24px 28px 40px; }
.top { min-height: 58px; align-items: center; margin-bottom: 18px; }
h1 { font-size: 1.5rem; font-weight: 750; }
.sub { margin-top: 5px; color: var(--muted); font-size: .78rem; }

.pill,
.dark {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 650;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.pill { border-color: #cfd6de; background: #fff; }
.pill:hover { border-color: #9da9b7; background: #f7f9fb; }
.dark { border-color: #1463ff; background: #1463ff; }
.dark:hover { border-color: #0d51d4; background: #0d51d4; }

.panel { border-color: var(--line); border-radius: 8px; box-shadow: none; }
.panel-head { min-height: 58px; padding: 13px 16px; }
.panel-title { font-size: .88rem; font-weight: 750; }
.note, .muted { color: var(--muted); font-size: .72rem; }
.stats-grid { gap: 8px; }
.stat {
  min-height: 100px;
  padding: 13px 14px;
  border-color: var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 2px 0 #eef2f6;
}
.stat-value {
  color: #101722;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1.34rem;
  font-weight: 750;
  letter-spacing: 0;
}
.cell-muted { color: #6d7785; font-size: .7rem; }
.data-table thead th { height: 40px; background: #f7f9fb; color: #5f6977; font-size: .7rem; }
.data-table tbody tr { transition: background-color 120ms ease; }
.data-table tbody tr:hover { background: #f3f7ff; }
.data-table td { min-height: 48px; }
.record-line.warning { border-left-color: var(--warning); background: #fffaf2; }
.error-monitor-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}
.error-monitor-kpis .metric-card {
  min-height: 78px;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 7px;
}
.error-monitor-kpis .metric-card:last-child { border-right: 0; }
.error-monitor-kpis .metric-card span { color: var(--muted); font-size: .72rem; }
.error-monitor-kpis .metric-card strong { color: #101722; font: 750 1.32rem/1 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }

@media (max-width: 900px) {
  .admin-nav { background: #111318; }
  .admin-main { padding: 18px 14px 32px; }
  .nav-links { padding-top: 10px; }
  .error-monitor-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .error-monitor-kpis .metric-card:nth-child(2n) { border-right: 0; }
  .error-monitor-kpis .metric-card { border-bottom: 1px solid var(--line); }
  .error-monitor-kpis .metric-card:last-child { border-bottom: 0; }
}
