:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #0b1220;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #ee4d2d;
  --primary-hover: #d73d1e;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

.small {
  font-size: 0.875rem;
}

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.85em;
  color: #fde68a;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: rgba(238, 77, 45, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-header-row h2,
.card-header-row h3 {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.grid-2-wide {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
}

@media (max-width: 960px) {
  .grid-2-wide {
    grid-template-columns: 1fr;
  }
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

/* Forms */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #cbd5e1;
}

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.92rem;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(238, 77, 45, 0.45);
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
  color: var(--text);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #64748b;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.full-width {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-sandbox {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.badge-live {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.badge-sent, .badge-available {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.badge-simulated_ok, .badge-assigned {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.badge-failed, .badge-out_of_stock, .badge-revoked {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.badge-processing {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* Misc blocks */
.kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.86rem;
  align-items: center;
  flex-wrap: wrap;
}

.info-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.85rem;
}

.info-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.error-text {
  color: #fca5a5;
  font-size: 0.86rem;
  margin-top: 10px;
}

.error-box {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.hint {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.mt-sm { margin-top: 10px; }
.mt-md { margin-top: 16px; }
.mb-sm { margin-bottom: 10px; }

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.chip {
  background: var(--surface-2);
  color: #93c5fd;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.76rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--info);
}

.preview-box {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
}

.preview-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.preview-box pre,
.modal-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  color: #e2e8f0;
}

.product-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.product-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.shop-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.88rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

/* Banner & Toast */
.banner {
  margin: 14px 24px 0;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.banner.success {
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
}

.banner.error {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 200;
  max-width: 380px;
  font-size: 0.88rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 150;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.modal-pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
