:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --primary: #2f6df6;
  --primary-d: #2456c8;
  --accent: #16a34a;
  --accent-d: #128a3e;
  --danger: #e5484d;
  --warn: #d99e2b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { font-size: 17px; margin: 0; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }

.status-pills { display: flex; gap: 8px; }
.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-2);
}
.pill-green { color: #4ade80; border-color: #1f5135; }
.pill-red { color: #f87171; border-color: #5a2226; }
.pill-gray { color: var(--muted); }

.layout {
  display: grid; grid-template-columns: 360px 1fr; gap: 16px;
  padding: 16px 22px; align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.config-panel h2, .data-panel h2 { font-size: 14px; margin: 18px 0 10px; color: var(--text); }
.config-panel h2:first-child { margin-top: 0; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); }

.btn {
  display: inline-block; cursor: pointer; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: #3a4150; }
.btn-primary { background: var(--primary); border-color: var(--primary-d); }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent { background: var(--accent); border-color: var(--accent-d); }
.btn-accent:hover { background: var(--accent-d); }
.btn-ghost { background: transparent; }
.btn:active { transform: translateY(1px); }

.switch-row { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.switch { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.switch input { width: 16px; height: 16px; accent-color: var(--primary); }

.auto-box { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 14px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.data-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.data-head h2 { margin: 0; }
.actions { display: flex; align-items: center; gap: 10px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 12px; background: var(--panel-2);
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.stock-low { color: var(--danger); font-weight: 600; }
.stock-mid { color: var(--warn); }
.stock-ok { color: #4ade80; }

.toast {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; border: 1px solid var(--border);
}
.toast.ok { background: #10301d; border-color: #1f5135; color: #86efac; }
.toast.err { background: #321417; border-color: #5a2226; color: #fca5a5; }
.hidden { display: none; }
