:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-size: 1.2rem; font-weight: 700; }
.server-info { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.label, .muted { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; gap: 8px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: #334155; color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.server-select {
  background: #0f1419;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.9rem;
  max-width: 220px;
}

main { padding: 20px 24px; }
main h2 { margin: 0 0 16px; font-size: 1rem; color: var(--muted); font-weight: 600; }

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.column-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.column-card .item-name {
  font-weight: 700;
  font-size: 1rem;
  word-break: break-all;
}

.stock-badge {
  display: inline-block;
  background: #1e3a2f;
  color: var(--ok);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.column-card.out-of-stock {
  border-color: #7f1d1d;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.25);
}
.stock-badge.empty {
  background: #3f1d1d;
  color: #fca5a5;
}

.need-badge {
  display: inline-block;
  margin-left: 8px;
  background: #7c2d12;
  color: #fed7aa;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.multi-badge {
  display: inline-block;
  margin-left: 8px;
  background: #4c1d95;
  color: #e9d5ff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-badge.stock { background: #1e3a2f; color: var(--ok); }
.status-badge.extracted { background: #3f3f46; color: #d4d4d8; }
.status-badge.deleted { background: #450a0a; color: #fecaca; }
.stock-table tr.row-extracted td { opacity: 0.72; }
.stock-table tr.row-deleted td { opacity: 0.55; }

.field { font-size: 0.9rem; }
.field .k { color: var(--muted); margin-right: 6px; }
.field .v {
  font-family: Consolas, monospace;
  word-break: break-all;
}

.empty-tip { color: var(--muted); font-size: 0.9rem; }

.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.min-stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.85rem;
}
.min-stock-row label { color: var(--muted); white-space: nowrap; }
.min-stock-row input {
  width: 64px;
  background: #0f1419;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
}

.logs-panel {
  margin: 0 24px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.logs-panel h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); }
#logs {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #14532d;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: opacity .2s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-body {
  padding: 12px 16px 16px;
  overflow: auto;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.stock-table th,
.stock-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
.stock-table th { color: var(--muted); font-weight: 600; }
.stock-table .mono {
  font-family: Consolas, monospace;
  word-break: break-all;
}
.stock-table tr:hover td { background: rgba(59, 130, 246, 0.08); }
.stock-empty { color: var(--muted); padding: 24px 0; text-align: center; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .actions { justify-content: stretch; }
  .actions .btn { flex: 1; }
}
