:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #1d252d;
  --muted: #697482;
  --line: #e0e5eb;
  --line-strong: #c9d2dc;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --focus: #3159c9;
  --warn: #a36a00;
  --bad: #c24136;
  --good: #15803d;
  --shadow: 0 10px 28px rgba(26, 38, 52, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #1f2937;
  color: white;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); margin-top: 3px; font-size: 12px; }

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
  background: #eef6f5;
  color: var(--accent-strong);
  border-left-color: var(--accent);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin: 0; }
h1 { font-size: 25px; line-height: 1.2; }
h2 { font-size: 16px; line-height: 1.25; }
#viewSub { color: var(--muted); margin-top: 5px; font-size: 13px; }

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.global-country-control,
.export-country-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.global-country-control select,
.export-country-control select {
  min-width: 128px;
  font-weight: 700;
  color: var(--ink);
}

.country-scope-badge {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  background: #eef6f5;
  border: 1px solid #b7dcd8;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.export-hint {
  margin-top: 12px;
}

.icon-button, .small-button, .primary-button, .link-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
}

.icon-button { width: 38px; padding: 0; font-size: 18px; }
.primary-button { background: var(--accent); color: #fff; border-color: var(--accent); }
.primary-button:hover { background: var(--accent-strong); }
.small-button { min-height: 32px; font-size: 13px; background: #f8fafc; }
.small-button:hover, .link-button:hover, .icon-button:hover { border-color: var(--line-strong); background: #f4f7fa; }
.small-button.danger { border-color: #f0c7c2; color: var(--bad); background: #fffafa; }
.link-button.compact {
  min-height: 24px;
  border-color: transparent;
  color: var(--accent-strong);
  justify-content: flex-start;
  padding: 0;
  font-size: 13px;
}
.actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.clear-actions { margin: 10px 0 12px; justify-content: flex-end; width: 100%; }

.schedule-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-form label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.schedule-form input {
  width: 76px;
  min-height: 36px;
}

.message {
  border: 1px solid #b7dcd8;
  background: #eefbf8;
  color: var(--accent-strong);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.view { display: none; }
.view.active { display: grid; gap: 16px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.metric:nth-child(2)::before { background: var(--focus); }
.metric:nth-child(3)::before { background: #7c3aed; }
.metric:nth-child(4)::before { background: #d97706; }
.metric:nth-child(5)::before { background: #64748b; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 6px; font-size: 28px; line-height: 1; }

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-weight: 700;
}

.muted { color: var(--muted); font-size: 13px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 700; background: #f8fafc; }
tbody tr:hover { background: #fbfdff; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.wide { grid-column: 1 / -1; }

input, select, textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(13, 148, 136, 0.18);
  border-color: var(--accent);
}

textarea {
  min-height: 120px;
  padding: 10px;
  resize: vertical;
}

.upload-window {
  min-height: 220px;
  border: 1px dashed #9eb4c7;
  border-radius: 8px;
  background: #f8fbfc;
  color: var(--ink);
  padding: 32px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 12px;
  cursor: pointer;
}

.upload-window:hover,
.upload-window.dragging {
  border-color: var(--accent);
  background: #edf9f7;
}

.upload-window input[type="file"] {
  display: none !important;
}

.upload-title {
  font-size: 21px;
  font-weight: 700;
}

.upload-hint {
  color: var(--muted);
  font-size: 14px;
}

.upload-filename {
  color: var(--accent-strong);
  font-size: 14px;
  word-break: break-all;
}

.folder-rules {
  display: grid;
  gap: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
}

.asset-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.6fr) minmax(260px, 2fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.asset-jump-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.asset-filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.asset-filter-button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.asset-filter-button:hover {
  border-color: var(--line-strong);
  background: #eef6f5;
}

.asset-filter-button strong {
  color: var(--accent-strong);
  font-size: 12px;
}

.asset-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  box-shadow: 0 3px 14px rgba(31, 41, 55, 0.04);
}

.asset-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.asset-card-head h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.asset-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.asset-count {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef2f6;
  color: var(--muted);
}

.asset-count.good { background: #e7f7ee; color: var(--good); }
.asset-count.warn { background: #fff8e1; color: var(--warn); }
.asset-count.bad { background: #fff0ed; color: var(--bad); }

.asset-items {
  display: grid;
  gap: 8px;
}

.asset-item {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfd;
}

.asset-item.blacklisted { border-color: #f1b4ad; background: #fff8f6; }
.asset-item.suspended { border-color: #edd68a; background: #fffdf3; }
.asset-item.used { border-color: #cbd5e1; background: #f8fafc; }

.asset-thumb,
.asset-text-mark {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef2f6;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.asset-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.asset-line strong,
.asset-value,
.asset-meta span {
  overflow-wrap: anywhere;
}

.asset-value {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.42;
}

.asset-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.asset-pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.asset-pill.normal { background: #e7f7ee; color: var(--good); }
.asset-pill.used { background: #eef2f6; color: var(--muted); }
.asset-pill.suspended { background: #fff8e1; color: var(--warn); }
.asset-pill.blacklisted { background: #fff0ed; color: var(--bad); }

.asset-actions {
  display: flex;
  justify-content: flex-end;
}

.asset-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.preview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.preview-count {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.preview-count span,
.preview-count strong {
  display: block;
}

.preview-list {
  display: grid;
  gap: 12px;
}

.preview-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.preview-group h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.preview-item {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1fr) 140px 100px minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge.good { background: #e7f7ee; color: var(--good); }
.badge.bad { background: #fff0ed; color: var(--bad); }
.badge.warn { background: #fff8e1; color: var(--warn); }

.status-list, .scan-list {
  display: grid;
  gap: 8px;
}

.progress-line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.check-list-field {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 240px;
}

.check-list-field > span {
  color: var(--muted);
  font-size: 13px;
}

.check-list-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-list-field input {
  min-height: auto;
}

.task-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin-top: 12px;
}

.task-panel.compact {
  margin-bottom: 12px;
}

.task-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.task-row {
  display: grid;
  grid-template-columns: 70px minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(160px, 1.2fr) 70px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 11px;
}

.task-row.good { border-color: #b8dfca; background: #f2fbf6; }
.task-row.bad { border-color: #f1b4ad; background: #fff8f6; }
.task-row.warn { border-color: #edd68a; background: #fffdf3; }
.task-row span,
.task-row em,
.task-row small {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.task-row strong,
.task-row code {
  overflow-wrap: anywhere;
}

.compact-failures {
  margin-top: 8px;
}

.failure-note {
  display: grid;
  gap: 8px;
  border: 1px solid #f1b4ad;
  border-radius: 8px;
  background: #fff8f6;
  padding: 10px 11px;
}

.failure-note > strong {
  color: var(--bad);
}

.inventory-sections {
  display: grid;
  gap: 14px;
}

.inventory-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 3px 14px rgba(31, 41, 55, 0.04);
}

.inventory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.inventory-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inventory-head h3 {
  margin: 0;
  font-size: 16px;
}

.inventory-head strong {
  min-width: 30px;
  min-height: 30px;
  border-radius: 999px;
  background: #eef6f5;
  color: var(--accent-strong);
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inventory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.inventory-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inventory-title strong,
.inventory-title a,
.inventory-meta span {
  overflow-wrap: anywhere;
}

.inventory-title a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.inventory-title a:hover {
  text-decoration: underline;
}

.inventory-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  min-width: 0;
}

.inventory-select input {
  min-height: auto;
}

.inventory-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.inventory-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.inventory-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.material-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.material-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #d6e0ea;
  border-radius: 999px;
  background: #f3f7fb;
  color: #304050;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.inventory-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.status-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
  gap: 12px;
}

.status-row code {
  overflow-wrap: anywhere;
  text-align: right;
}

/* Failure rows carry an inline verdict plus 检测/删除账号 buttons, so they need to wrap
   instead of squeezing Telegram's long error text against the actions. */
.inventory-token {
  display: block;
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted, #64748b);
  overflow-wrap: anywhere;
}

.failure-row {
  flex-wrap: wrap;
  align-items: center;
}

.failure-row code {
  flex: 1 1 240px;
}

.failure-row .actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.failure-row [data-account-verdict] {
  color: var(--accent, #0f766e);
  font-style: normal;
  white-space: nowrap;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.stock-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.stock-tile span {
  color: var(--muted);
  font-size: 13px;
}

.stock-tile strong {
  font-size: 22px;
  line-height: 1;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  min-height: 36px;
}

.toggle-line input {
  min-height: auto;
}

.result {
  min-height: 140px;
  background: #17202a;
  color: #d9f7ef;
  border-radius: 6px;
  padding: 12px;
  white-space: pre-wrap;
  overflow: auto;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .metrics, .split, .asset-toolbar, .asset-card-grid, .inventory-grid, /* Failure rows carry an inline verdict plus 检测/删除账号 buttons, so they need to wrap
   instead of squeezing Telegram's long error text against the actions. */
.inventory-token {
  display: block;
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted, #64748b);
  overflow-wrap: anywhere;
}

.failure-row {
  flex-wrap: wrap;
  align-items: center;
}

.failure-row code {
  flex: 1 1 240px;
}

.failure-row .actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.failure-row [data-account-verdict] {
  color: var(--accent, #0f766e);
  font-style: normal;
  white-space: nowrap;
}

.stock-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .task-row { grid-template-columns: 1fr; }
  .asset-item { grid-template-columns: 48px minmax(0, 1fr); }
  .asset-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .asset-thumb, .asset-text-mark { width: 48px; height: 48px; }
  .workspace { padding: 16px; }
  .status-row { align-items: flex-start; flex-direction: column; }
  .status-row code { text-align: left; }
}
