/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0c0d0f;
  --surface:  #131416;
  --surface2: #1a1b1e;
  --surface3: #222428;
  --border:   #2a2c30;
  --border2:  #333640;
  --text:     #f2f3f5;
  --text2:    #9ea3ad;
  --text3:    #5c6170;
  --accent:   #ffffff;
  --shopify:  #96bf48;
  --ebay:     #e53238;
  --tropship: #4a9eff;
  --green:    #34d399;
  --orange:   #f59e0b;
  --red:      #ef4444;
  --blue:     #4a9eff;
  --sidebar-w: 240px;
  --radius:   10px;
  --radius-sm: 6px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 0 0 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface3);
  color: var(--text);
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text3);
}

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

.platform-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-top: 4px;
}

.btn-logout svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

.badge.shopify  { background: rgba(150, 191, 72, 0.15);  color: var(--shopify); }
.badge.ebay     { background: rgba(229, 50, 56, 0.15);   color: #f07070; }
.badge.tropship { background: rgba(74, 158, 255, 0.15);  color: var(--tropship); }

/* ─── Main ─────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
}

.page {
  display: none;
  padding: 36px 40px 60px;
  max-width: 1200px;
  animation: fadeIn 0.2s ease;
}

.page.active { display: block; }

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

/* ─── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text3);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.last-sync {
  font-size: 12px;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn-refresh svg {
  width: 14px;
  height: 14px;
}

.btn-refresh:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

/* ─── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border2); }

.stat-card.highlight {
  background: var(--surface2);
  border-color: rgba(255,255,255,0.1);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.8px;
  line-height: 1;
}

.stat-meta {
  font-size: 11.5px;
  color: var(--text3);
}

.stat-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  align-self: flex-start;
  margin-top: 2px;
}

.stat-badge.shopify { background: rgba(150,191,72,.15); color: var(--shopify); }
.stat-badge.ebay    { background: rgba(229,50,56,.15);  color: #f07070; }

/* ─── Section Title ────────────────────────────────────────────────────────── */
.section-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* ─── Stock feed badges & sync button ───────────────────────────────────────── */
.feed-source-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.feed-source-badge.live {
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
}

.feed-source-badge.mock {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
}

.feed-sync-time {
  font-size: 12px;
  color: var(--text3);
}

.btn-refresh.syncing svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─── Stock status bar ───────────────────────────────────────────────────────── */
.feed-status-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 28px;
  margin-bottom: 24px;
}

.feed-status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 0 20px;
}

.feed-status-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.feed-status-num.red    { color: var(--red); }
.feed-status-num.orange { color: var(--orange); }
.feed-status-num.green  { color: var(--green); }

.feed-status-label {
  font-size: 11.5px;
  color: var(--text3);
  font-weight: 500;
  white-space: nowrap;
}

.feed-status-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

.feed-status-spacer { flex: 1; }

.feed-status-msg {
  font-size: 12px;
  color: var(--text3);
  text-align: right;
  max-width: 280px;
}

/* ─── Orders Row ───────────────────────────────────────────────────────────── */
.orders-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: 24px 32px;
  margin-bottom: 32px;
  gap: 0;
}

.order-stat {
  flex: 1;
  text-align: center;
}

.order-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.order-stat-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

.order-stat-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Two Column ───────────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ─── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.panel-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
}

.panel-badge.alert {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.25);
  color: var(--red);
}

.panel-list {
  padding: 8px 0;
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  transition: background 0.1s;
}

.panel-row:hover { background: var(--surface2); }

.panel-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.panel-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-row-sub {
  font-size: 11.5px;
  color: var(--text3);
}

.panel-row-right {
  flex-shrink: 0;
  text-align: right;
}

.units-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface3);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
}

.rank-num {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  width: 20px;
  flex-shrink: 0;
}

.stock-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}

.stock-pill.out   { background: rgba(239,68,68,.15);   color: var(--red); }
.stock-pill.low   { background: rgba(245,158,11,.15);  color: var(--orange); }
.stock-pill.ok    { background: rgba(52,211,153,.15);  color: var(--green); }

/* ─── Skeleton ─────────────────────────────────────────────────────────────── */
.skeleton-row {
  height: 44px;
  margin: 6px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Filters Bar ──────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 14px 9px 38px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--text3); }
.search-input:focus { border-color: var(--border2); }

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6170' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

.filter-select:focus { border-color: var(--border2); }

/* ─── Orders Table ─────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.orders-table thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}

.orders-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.orders-table tbody tr:last-child { border-bottom: none; }
.orders-table tbody tr:hover { background: var(--surface2); }

.orders-table tbody td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text2);
  vertical-align: middle;
}

.order-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.customer-name {
  color: var(--text);
  font-weight: 500;
}

.platform-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.platform-chip.shopify { background: rgba(150,191,72,.15); color: var(--shopify); }
.platform-chip.ebay    { background: rgba(229,50,56,.15);  color: #f07070; }

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

.product-item {
  font-size: 12.5px;
  color: var(--text2);
}

.product-qty {
  color: var(--text3);
}

.order-total {
  font-weight: 600;
  color: var(--text);
}

.status-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.status-chip.pending    { background: rgba(245,158,11,.12); color: var(--orange); }
.status-chip.processing { background: rgba(74,158,255,.12); color: var(--blue); }
.status-chip.shipped    { background: rgba(52,211,153,.12); color: var(--green); }
.status-chip.delivered  { background: rgba(255,255,255,.08); color: var(--text2); }

.tracking-num {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11.5px;
  color: var(--text3);
}

.tropship-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.tropship-chip.pending   { background: rgba(245,158,11,.12); color: var(--orange); }
.tropship-chip.awaiting  { background: rgba(74,158,255,.12); color: var(--blue); }
.tropship-chip.shipped   { background: rgba(52,211,153,.12); color: var(--green); }
.tropship-chip.delivered { background: rgba(255,255,255,.08); color: var(--text2); }

.table-loading {
  text-align: center;
  color: var(--text3);
  padding: 48px !important;
  font-size: 13px;
}

.table-empty {
  text-align: center;
  color: var(--text3);
  padding: 48px !important;
  font-size: 13px;
}

.table-footer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text3);
  text-align: right;
  padding: 0 4px;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  .sidebar { width: 64px; }
  .brand-text, .nav-item span, .sidebar-footer { display: none; }
  .sidebar-brand { padding: 20px 14px; justify-content: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .page { padding: 24px 20px 40px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
