:root {
  --bg-0: #f4f5fa;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --panel-2: rgba(17, 24, 39, 0.035);
  --border: rgba(17, 24, 39, 0.09);
  --border-soft: rgba(17, 24, 39, 0.06);
  --text: #1a1d29;
  --text-dim: #6b7280;
  --text-dimmer: #9aa0b4;
  --accent: #6366f1;
  --accent-2: #10b981;
  --accent-pink: #ec4899;
  --accent-grad: linear-gradient(135deg, #818cf8 0%, #6366f1 45%, #a855f7 100%);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 1px rgba(17, 24, 39, 0.03);
  --shadow-md: 0 4px 14px rgba(17, 24, 39, 0.07), 0 1px 2px rgba(17, 24, 39, 0.04);
  --glow: 0 0 0 1px rgba(99, 102, 241, 0.15), 0 8px 24px rgba(99, 102, 241, 0.1);
  --radius: 11px;
  --sidebar-w: 200px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(900px 500px at -5% -10%, rgba(99, 102, 241, 0.06), transparent 55%),
    radial-gradient(700px 450px at 105% 0%, rgba(236, 72, 153, 0.05), transparent 50%), var(--bg-0);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  font-size: 12.5px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

svg.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ---------- App shell (sidebar layout) ---------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.75);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 16px 11px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 18px;
}

.brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: white;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.brand .mark svg {
  width: 13px;
  height: 13px;
}

.brand .word {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1px;
  line-height: 1.15;
  color: var(--text);
}

.brand .word small {
  display: block;
  font-weight: 500;
  font-size: 9px;
  color: var(--text-dimmer);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

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

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 12.5px;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar nav a.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar nav a.active svg {
  color: var(--accent);
}

.sidebar .logout {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dimmer);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 12.5px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar .logout:hover {
  background: var(--panel-2);
  color: #dc2626;
}

main {
  flex: 1;
  padding: 24px 30px 50px;
  max-width: 1100px;
  min-width: 0;
}

h1 {
  font-size: 17px;
  margin: 0 0 3px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.page-header {
  margin-bottom: 18px;
}

.page-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

/* ---------- Cards / panels ---------- */

.card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  box-shadow: var(--shadow-sm);
}

.stat-tile .icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  flex-shrink: 0;
}

.stat-tile .icon-wrap.green {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.stat-tile .icon-wrap.pink {
  background: rgba(236, 72, 153, 0.1);
  color: #db2777;
}

.stat-tile .value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-tile .label {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 1px;
}

/* ---------- Platform rows ---------- */

.platform-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.platform-row .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.platform-row .icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dimmer);
  flex-shrink: 0;
}

.dot.on {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.06);
  }
}

.platform-row .name {
  font-weight: 600;
  font-size: 12.5px;
}

.platform-row .sub {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 1px;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: filter 0.12s, transform 0.06s, background 0.12s;
  box-shadow: var(--shadow-sm);
}

button:hover {
  background: #fafafe;
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

button.primary:hover {
  filter: brightness(1.06);
}

button.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
}

button.danger {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.2);
  color: #dc2626;
}

button.stop {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.2);
  color: #dc2626;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.tabs button {
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.tabs button.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: white;
}

/* ---------- Log panel (kept dark - console convention) ---------- */

.log-panel {
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  height: 380px;
  overflow-y: auto;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  color: #d4d7e6;
}

.log-time {
  color: #565b78;
}

.log-tag {
  color: #a5b4fc;
  font-weight: 600;
}

.log-level-WARN {
  color: #fbbf24;
}

.log-level-ERROR {
  color: #f87171;
}

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

input,
select {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

label {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 3px;
}

.field {
  margin-bottom: 11px;
}

.field .hint {
  font-size: 10.5px;
  color: var(--text-dimmer);
  margin-top: 3px;
  line-height: 1.5;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- Product cards ---------- */

.product-card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.product-card .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 6px;
}

.product-card .head .title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}

.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
}

.badge.on {
  color: #059669;
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}

.product-card .fields {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
}

.product-card .fields.skip {
  grid-template-columns: 1fr;
  margin-top: 9px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
}

.chip button {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-dim);
  font-size: 12px;
  box-shadow: none;
}

/* ---------- Toggle ---------- */

.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
}

.toggle.on {
  background: var(--accent-grad);
  border-color: transparent;
}

.toggle .knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: left 0.15s;
}

.toggle.on .knob {
  left: 15px;
}

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-row .right {
  display: flex;
  gap: 6px;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 300px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 26px 24px;
  box-shadow: var(--glow), 0 16px 40px rgba(17, 24, 39, 0.08);
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.login-card .mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: white;
  box-shadow: 0 5px 16px rgba(99, 102, 241, 0.4);
}

.login-card .mark svg {
  width: 18px;
  height: 18px;
}

.login-card h1 {
  text-align: center;
  font-size: 15px;
  margin: 0;
}

.login-card .sub {
  text-align: center;
  color: var(--text-dimmer);
  font-size: 11px;
  margin-top: 1px;
}

.error-text {
  color: #dc2626;
  font-size: 12px;
  margin-top: 8px;
  min-height: 15px;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 32px 0;
  font-size: 12px;
}

/* ---------- Bulk import panel ---------- */

.bulk-panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.bulk-panel .row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.bulk-table-wrap {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-top: 12px;
}

table.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.bulk-table th {
  position: sticky;
  top: 0;
  background: #fafafe;
  text-align: left;
  padding: 7px 10px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}

table.bulk-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-soft);
}

table.bulk-table tr:last-child td {
  border-bottom: none;
}

table.bulk-table tr.unmatched {
  opacity: 0.45;
}

svg.icon.ok {
  color: #059669;
}

svg.icon.bad {
  color: #dc2626;
}

.chevron {
  transition: transform 0.15s;
}

.chevron.open {
  transform: rotate(180deg);
}
