:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef0fe;

  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-soft: #fef2f2;

  --success: #10b981;
  --success-soft: #ecfdf5;

  --warn: #f59e0b;
  --warn-soft: #fffbeb;

  --sidebar-bg: #111319;
  --sidebar-text: #9aa0ac;
  --sidebar-text-active: #ffffff;
  --sidebar-border: #1f2129;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px 10px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  flex-shrink: 0;
}

.brand-name {
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.nav-section-label {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 10px 6px 10px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--sidebar-text);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
}

.nav-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-btn.active {
  background: rgba(99, 102, 241, 0.16);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  min-width: 0;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user span {
  color: #d1d5db;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.logout-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }

.main-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.content-inner {
  padding: 28px 36px 60px 36px;
  max-width: 1180px;
}

/* ---------- Panels ---------- */

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein 0.15s ease; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.panel-header h2 {
  margin: 0 0 2px 0;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.actions { display: flex; gap: 8px; flex-shrink: 0; }

.subtabs { display: flex; gap: 4px; margin-top: 14px; }

.subtab-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: inherit;
}
.subtab-btn:hover { border-color: var(--primary); color: var(--primary); }
.subtab-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- Buttons ---------- */

.btn {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  font-weight: 500;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.btn:hover { border-color: var(--text-faint); background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }

.btn-small { padding: 5px 11px; font-size: 12px; }

/* ---------- Status / cards ---------- */

.status {
  min-height: 20px;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.status.error { color: var(--danger); }

.card-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.order-card .order-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 14.5px;
}

.order-card .order-head .amounts { font-weight: 500; font-size: 13px; color: var(--text-muted); }
.order-card .order-head .amounts b { color: var(--success); font-weight: 700; }

.order-card .order-address {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.55;
}

.order-card .order-items { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

.order-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.order-actions input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.data-table th, .data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  white-space: nowrap;
}
.data-table td:nth-child(2) { white-space: normal; min-width: 220px; }

.data-table th { background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-published { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Forms ---------- */

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.form-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
}
.form-row input:focus, .form-grid input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.form-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 8px;
  margin-bottom: 18px;
}
.form-grid input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.form-grid .btn { white-space: nowrap; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: -8px 0 18px 0;
  cursor: pointer;
}
.checkbox-row input { margin-top: 2px; flex-shrink: 0; }

/* ---------- Product preview ---------- */

.preview-card {
  display: flex;
  gap: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}

.preview-images { display: flex; flex-wrap: wrap; gap: 6px; width: 220px; flex-shrink: 0; align-content: flex-start; }
.preview-images img {
  width: 100px; height: 100px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

.preview-body { flex: 1; min-width: 0; }
.preview-body h3 { margin: 0 0 8px 0; font-size: 17px; }
.preview-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.preview-meta b { color: var(--text); }

.specifics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 16px;
  font-size: 12.5px;
  margin-bottom: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.specifics-grid div span:first-child { color: var(--text-muted); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }

.preview-description {
  font-size: 13px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  margin-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text-muted);
}
.preview-description p, .preview-description ul { margin: 6px 0; }

.asin-queue {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asin-queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 13px;
}

/* ---------- Research ---------- */

.research-group { margin-bottom: 24px; }
.research-group h3 { font-size: 13px; margin-bottom: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }

.research-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.research-item .r-listing { flex: 1; font-size: 13px; }
.research-item .r-rec { font-size: 13px; color: var(--success); }
.research-item .r-none { font-size: 13px; color: var(--text-faint); }

/* ---------- Logs ---------- */

.log-view {
  background: #0d1117;
  color: #c9d1d9;
  padding: 18px;
  border-radius: var(--radius);
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 70vh;
  overflow-y: auto;
  white-space: pre-wrap;
  box-shadow: var(--shadow-md);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1a1c25, #0b0c10 60%);
}

.login-card {
  width: 340px;
  background: var(--panel);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-card .brand { justify-content: center; padding-bottom: 20px; }
.login-card .brand-name { color: var(--text); font-size: 16px; }

.login-card h1 {
  font-size: 16px;
  text-align: center;
  margin: 0 0 22px 0;
  color: var(--text-muted);
  font-weight: 500;
}

.login-field { margin-bottom: 14px; }
.login-field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}
.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
}
.login-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.login-error {
  background: var(--danger-soft);
  color: var(--danger-dark);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  font-size: 14px;
}
