@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'DM Sans', system-ui, sans-serif; font-size: 14px; line-height: 1.5; }
body { background: #f8fafc; color: #1e293b; }
html.dark body { background: #0f172a; color: #e2e8f0; }
a { text-decoration: none; color: inherit; }

/* ═══════════════════════════════════════════════
   CORE LAYOUT — this is the critical part
   ═══════════════════════════════════════════════ */
.app-shell {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  width: 210px;
  min-width: 210px;
  max-width: 210px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
}
html.dark .sidebar { background: #1e293b; border-color: #334155; }

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 40;
}
html.dark .topbar { background: #1e293b; border-color: #334155; }

.page-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 70px;
}

/* ═══════════════════════════════════════════════
   SIDEBAR PARTS
   ═══════════════════════════════════════════════ */
.sidebar-logo {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
html.dark .sidebar-logo { border-color: #334155; }
.sidebar-logo img { height: 30px; width: auto; object-fit: contain; flex-shrink: 0; max-width: 36px; }
.sidebar-logo-text { min-width: 0; }
.sidebar-logo-text strong { display: block; font-size: 11px; font-weight: 700; color: #0f172a; line-height: 1.3; }
html.dark .sidebar-logo-text strong { color: #f1f5f9; }
.sidebar-logo-text small { display: block; font-size: 10px; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 10px 10px; overflow-y: auto; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  transition: all 0.12s;
  margin-bottom: 1px;
  white-space: nowrap;
}
.nav-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-link:hover { background: #f1f5f9; color: #1e293b; }
html.dark .nav-link { color: #94a3b8; }
html.dark .nav-link:hover { background: #0f172a; color: #f1f5f9; }
.nav-link.active { background: #eff6ff; color: #2563eb; font-weight: 600; }
html.dark .nav-link.active { background: rgba(37,99,235,0.15); color: #60a5fa; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
html.dark .sidebar-user { border-color: #334155; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-placeholder { width: 28px; height: 28px; border-radius: 50%; background: #dbeafe; color: #2563eb; font-weight: 700; font-size: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.dark .sidebar-user-name { color: #f1f5f9; }
.sidebar-user-role { font-size: 10px; color: #94a3b8; text-transform: capitalize; }

/* ═══════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════ */
.topbar-title { flex: 1; font-size: 14px; font-weight: 600; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.dark .topbar-title { color: #f1f5f9; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: none; background: none; cursor: pointer; color: #64748b; display: flex; align-items: center; justify-content: center; transition: background 0.12s; }
.icon-btn:hover { background: #f1f5f9; }
html.dark .icon-btn { color: #94a3b8; }
html.dark .icon-btn:hover { background: #0f172a; }
.icon-btn svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════
   ANNOUNCEMENT BAR
   ═══════════════════════════════════════════════ */
@keyframes marquee { 0% { transform: translateX(100vw); } 100% { transform: translateX(-100%); } }
.announce-bar { overflow: hidden; padding: 5px 0; flex-shrink: 0; }
.marquee-text { display: inline-block; white-space: nowrap; animation: marquee 35s linear infinite; font-size: 12px; font-weight: 500; padding: 0 16px; }

/* ═══════════════════════════════════════════════
   DROPDOWNS
   ═══════════════════════════════════════════════ */
.dd-wrap { position: relative; }
.dd-panel { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.12); border: 1px solid #e2e8f0; z-index: 999; min-width: 160px; display: none; }
html.dark .dd-panel { background: #1e293b; border-color: #334155; }
.dd-panel.open { display: block; }
.dd-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px; color: #374151; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-family: inherit; transition: background 0.1s; }
.dd-item:hover { background: #f9fafb; }
html.dark .dd-item { color: #d1d5db; }
html.dark .dd-item:hover { background: #334155; }
.dd-item svg { width: 14px; height: 14px; }
.dd-divider { border: none; border-top: 1px solid #f1f5f9; margin: 3px 0; }
html.dark .dd-divider { border-color: #334155; }

/* ═══════════════════════════════════════════════
   CARDS, BUTTONS, FORMS, TABLE, BADGES
   ═══════════════════════════════════════════════ */
.card { background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
html.dark .card { background: #1e293b; border-color: #334155; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.12s; font-family: inherit; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #f9fafb; }
html.dark .btn-secondary { background: #1e293b; color: #d1d5db; border-color: #334155; }
html.dark .btn-secondary:hover { background: #334155; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #22c55e; color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }

.form-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin-bottom: 4px; }
html.dark .form-label { color: #94a3b8; }
.form-input { width: 100%; border: 1px solid #e2e8f0; border-radius: 8px; padding: 7px 11px; font-size: 13px; background: #fff; color: #1e293b; outline: none; font-family: inherit; transition: border-color .12s; }
.form-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
html.dark .form-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #64748b; background: #f8fafc; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
html.dark thead th { background: #0f172a; border-color: #334155; color: #94a3b8; }
tbody td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: middle; }
html.dark tbody td { border-color: #0f172a; }
tbody tr:hover td { background: #f8fafc; }
html.dark tbody tr:hover td { background: #0f172a; }
tbody tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
html.dark .badge-gray { background: #334155; color: #94a3b8; }

/* ═══════════════════════════════════════════════
   PAGE HEADER, TOOLBAR
   ═══════════════════════════════════════════════ */
.page-wrap { padding: 20px 24px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 18px; font-weight: 700; color: #0f172a; }
html.dark .page-title { color: #f1f5f9; }
.page-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* stat card */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
.stat-card { padding: 16px; }
.stat-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat-icon svg { width: 16px; height: 16px; color: #fff; }
.stat-val { font-size: 22px; font-weight: 700; color: #0f172a; }
html.dark .stat-val { color: #f1f5f9; }
.stat-lbl { font-size: 12px; color: #64748b; margin-top: 2px; }

/* sections grid */
.two-col { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 800; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px rgba(0,0,0,.25); }
html.dark .modal-box { background: #1e293b; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #f1f5f9; position: sticky; top: 0; background: #fff; z-index: 1; }
html.dark .modal-head { background: #1e293b; border-color: #334155; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid #f1f5f9; }
html.dark .modal-foot { border-color: #334155; }

/* ═══════════════════════════════════════════════
   ALERTS, TABS, TOAST, PLATFORM TAGS
   ═══════════════════════════════════════════════ */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

.tabs { display: flex; border-bottom: 1px solid #e2e8f0; overflow-x: auto; }
html.dark .tabs { border-color: #334155; }
.tab-btn { padding: 9px 14px; font-size: 13px; font-weight: 500; color: #64748b; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; font-family: inherit; transition: all .12s; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 10px; color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: toastIn .2s ease; }
@keyframes toastIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-success { background: #22c55e; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }

.ptag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; margin: 1px; }
.pt-amazon { background: #ffedd5; color: #c2410c; }
.pt-flipkart { background: #fef9c3; color: #a16207; }
.pt-meesho { background: #fce7f3; color: #be185d; }
.pt-blinkit { background: #dcfce7; color: #15803d; }
.pt-myntra { background: #f3e8ff; color: #7e22ce; }
.pt-meta { background: #dbeafe; color: #1d4ed8; }
.pt-google { background: #fef9c3; color: #a16207; }
.pt-default { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════════
   IMPORT WIZARD
   ═══════════════════════════════════════════════ */
.step-bar { display: flex; align-items: center; margin-bottom: 20px; }
.step-item { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: #94a3b8; }
.step-item.active { color: #2563eb; }
.step-item.done { color: #22c55e; }
.step-num { width: 22px; height: 22px; border-radius: 50%; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; background: #f1f5f9; color: #64748b; flex-shrink: 0; }
.step-item.active .step-num { background: #dbeafe; color: #2563eb; border: 2px solid #2563eb; }
.step-item.done .step-num { background: #dcfce7; color: #15803d; }
.step-line { flex: 1; height: 1px; background: #e2e8f0; margin: 0 8px; }

.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #e2e8f0; border-radius: 12px; padding: 36px 20px; cursor: pointer; transition: all .15s; text-align: center; }
.file-drop:hover { border-color: #2563eb; background: #eff6ff; }
.file-drop svg { width: 36px; height: 36px; color: #cbd5e1; margin-bottom: 10px; }

/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 48; }
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #e2e8f0; padding: 5px 4px; z-index: 300; }
html.dark .mobile-nav { background: #1e293b; border-color: #334155; }
.mnav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; color: #94a3b8; border: none; background: none; cursor: pointer; font-family: inherit; }
.mnav-item svg { width: 20px; height: 20px; }
.mnav-item span { font-size: 10px; font-weight: 500; }
.mnav-item.active { color: #2563eb; }

#menu-btn { display: none; }

@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
  .mobile-nav { display: flex; align-items: center; justify-content: space-around; }
  #menu-btn { display: flex; }
}

/* ═══════════════════════════════════════════════
   UTILS
   ═══════════════════════════════════════════════ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.font-mono { font-family: monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-2 > * + * { margin-top: 8px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-gray-400 { color: #94a3b8; }
.text-gray-500 { color: #64748b; }
.text-red-600 { color: #dc2626; }
.text-green-600 { color: #16a34a; }
.text-blue-600 { color: #2563eb; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
html.dark ::-webkit-scrollbar-thumb { background: #475569; }

.hidden-mobile { }
@media (max-width: 768px) { .hidden-mobile { display: none; } }

