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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange:       #FF9D00;
  --orange-dark:  #E68D00;
  --orange-light: #FFF7EB;
  --orange-50:    #FFF7EB;
  --green:        #17B26A;
  --green-bg:     #E6F7EE;
  --green-text:   #0F7A45;
  --amber-bg:     #FFF3E0;
  --amber-text:   #B36E00;
  --red:          #E63946;
  --red-bg:       #FCE6E8;
  --red-text:     #8C1A1A;
  --border:       #ECECEC;
  --gray-50:      #F9F9F9;
  --gray-100:     #F3F3F3;
  --gray-200:     #ECECEC;
  --gray-400:     #AAAAAA;
  --gray-500:     #858585;
  --gray-700:     #404040;
  --gray-900:     #2A2A2A;
  --radius:       6px;
  --radius-lg:    10px;
  --shadow:       none;
  --sidebar-w:    208px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-box {
  width: 30px; height: 30px;
  background: var(--orange);
  border-radius: 6px;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 16px;
}
.logo-text { font-size: 13px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.logo-sub  { font-size: 10px; color: var(--gray-500); }

.nav-section { padding: 10px 10px 4px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .6px; padding: 0 8px; margin-bottom: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 5px;
  color: var(--gray-700);
  font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
  user-select: none;
  text-decoration: none;
}
.nav-item:hover { background: var(--gray-100); }
.nav-item.active { background: var(--orange-light); color: var(--orange-dark); font-weight: 600; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .65; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 99px; padding: 1px 6px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
}
.footer-controls { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.lang-toggle {
  display: flex; border: 1px solid var(--border); border-radius: 4px;
  overflow: hidden; font-size: 11px; font-weight: 600;
}
.lang-toggle span { padding: 3px 7px; cursor: pointer; color: var(--gray-500); }
.lang-toggle span.active { background: var(--gray-900); color: #fff; }
.icon-btn {
  width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 4px;
  display: grid; place-items: center; cursor: pointer;
  font-size: 13px; color: var(--gray-500); background: #fff; border: none;
}
.icon-btn:hover { background: var(--gray-100); }
.user-row { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 24px; height: 24px; background: var(--orange); border-radius: 50%;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-email { font-size: 11px; color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { margin-top: 8px; font-size: 11.5px; color: var(--gray-400); cursor: pointer; display: flex; align-items: center; gap: 4px; text-decoration: none; }
.logout-btn:hover { color: var(--gray-700); }

/* ── Main ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0;
}

/* ── Store switcher ── */
.store-picker-wrap { position: relative; flex: 1; max-width: 320px; }
.store-switcher {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; background: #fff; transition: background 120ms;
  font-size: 13px; color: var(--gray-700); width: 100%;
}
.store-switcher:hover { background: var(--gray-50); }
.store-switcher-badge {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.store-switcher-info { flex: 1; min-width: 0; }
.store-switcher-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-switcher-url { font-size: 11.5px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-switcher-alert {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red-text);
  flex-shrink: 0; margin-right: -2px;
}
.store-picker {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 300px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 6px; z-index: 200; display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.store-picker.open { display: block; }
.store-picker-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; transition: background 120ms;
  text-decoration: none; color: inherit;
}
.store-picker-item:hover { background: var(--gray-50); }
.store-picker-item.current { background: var(--orange-50); }
.store-picker-item-info { flex: 1; min-width: 0; }
.store-picker-item-name { font-size: 13px; font-weight: 600; }
.store-picker-item-url { font-size: 11.5px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-picker-divider { height: 1px; background: var(--border); margin: 4px 0; }
.store-picker-add {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--orange);
  font-weight: 500; transition: background 120ms; text-decoration: none;
}
.store-picker-add:hover { background: var(--orange-50); }

/* ── Toggle button ── */
.toggle-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 12px; font-size: 12.5px; font-weight: 500;
  color: var(--gray-700); cursor: pointer; background: #fff;
}
.toggle-btn:hover { background: var(--gray-100); }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.page-title { font-size: 19px; font-weight: 700; }
.page-sub { font-size: 12.5px; color: var(--gray-500); margin-top: 3px; }
.page-sub-store { font-weight: 500; color: var(--gray-700); }

/* ── Cards ── */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-body { padding: 18px 20px; }
.card-header {
  padding: 13px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }

/* ── Pills ── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.pill-green  { background: var(--green-bg);  color: var(--green-text); }
.pill-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.pill-red    { background: var(--red-bg);    color: var(--red-text); }
.pill-orange { background: var(--orange-light); color: var(--orange-dark); }
.pill-gray   { background: var(--gray-100);  color: var(--gray-500); }
.pill-blue   { background: #DBEAFE; color: #1E40AF; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: opacity .15s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-danger { background: var(--red-bg); border: 1px solid #FCA5A5; color: var(--red-text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-link { background: none; border: none; padding: 0; color: var(--orange-dark); font-size: 12px; cursor: pointer; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }

/* ── Stat cards ── */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}
.stat-cell { background: #fff; padding: 12px 16px; }
.stat-label { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-value-sm { font-size: 13px; font-weight: 600; }
.stat-sub { font-size: 11px; color: var(--gray-500); margin-top: 3px; }
.trend-up   { color: var(--green); font-size: 12px; font-weight: 600; margin-top: 3px; }
.trend-down { color: var(--red);   font-size: 12px; font-weight: 600; margin-top: 3px; }

/* ── Sync bar ── */
.sync-bar { height: 6px; background: var(--gray-200); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.sync-fill { height: 100%; border-radius: 99px; }
.sync-fill.green { background: var(--green); }
.sync-fill.amber { background: var(--orange); }
.sync-fill.red   { background: var(--red); }

/* ── Alert strip ── */
.alert-strip {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius); border: 1px solid;
  margin-bottom: 14px; font-size: 13px;
}
.alert-strip.red    { background: var(--red-bg);    border-color: #FCA5A5; }
.alert-strip.amber  { background: var(--amber-bg);  border-color: #FCD34D; }
.alert-strip.green  { background: var(--green-bg);  border-color: #86EFAC; }
.alert-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-desc  { color: var(--gray-700); font-size: 12.5px; line-height: 1.5; }
.alert-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Row list ── */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s; text-decoration: none; color: inherit;
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--gray-50); }
.platform-icon {
  width: 34px; height: 34px; border-radius: 7px;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: #fff; flex-shrink: 0; color: var(--gray-700);
}

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px;
  padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--gray-50);
}
.data-table td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; transition: background .1s; }
.data-table tr.clickable:hover { background: var(--gray-50); }
.data-table tr.row-amber td { background: rgba(255, 157, 0, 0.04); }
.data-table tr.row-amber:hover td { background: rgba(255, 157, 0, 0.08); }
.table-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

/* ── Form ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.form-input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; font-family: inherit;
  color: var(--gray-900); background: #fff; outline: none; width: 100%;
}
.form-input:focus { border-color: var(--orange); outline: none; }
.form-input.mono { font-family: 'Roboto Mono', monospace; font-size: 12px; }
.form-hint { font-size: 12px; color: var(--gray-500); line-height: 1.6; margin-bottom: 14px; }
.form-hint a { color: var(--orange-dark); text-decoration: none; }
.form-hint code { background: var(--gray-100); border-radius: 3px; padding: 1px 5px; font-size: 11px; font-family: monospace; }

/* ── Side panel (overlay) ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 100; display: none; justify-content: flex-end;
}
.overlay.open { display: flex; }
.panel {
  background: #fff; width: 460px; height: 100vh;
  box-shadow: -4px 0 24px rgba(0,0,0,.1); overflow-y: auto;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.panel-close {
  margin-left: auto; background: var(--gray-100); border: none;
  border-radius: 5px; width: 26px; height: 26px; font-size: 15px;
  cursor: pointer; display: grid; place-items: center; color: var(--gray-500);
}
.panel-close:hover { background: var(--gray-200); }
.panel-body { padding: 20px; }
.panel-section { margin-bottom: 20px; }
.panel-section-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--gray-500); margin-bottom: 8px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.38);
  z-index: 200; display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.14);
  animation: fadeUp .18s ease;
}
@keyframes fadeUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 20px 22px 0; display: flex; align-items: center; gap: 10px; }
.modal-title  { font-size: 15px; font-weight: 700; }
.modal-close  { margin-left: auto; cursor: pointer; font-size: 18px; color: var(--gray-400); background: none; border: none; line-height: 1; }
.modal-body   { padding: 16px 22px 22px; }

/* ── Product thumbnail ── */
.product-thumb {
  width: 30px; height: 30px;
  background: var(--gray-100); border-radius: 4px;
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--gray-500);
}

/* ── Bar chart sparkline ── */
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 36px; margin: 8px 0 4px; }
.chart-bar { flex: 1; background: var(--orange-light); border-radius: 2px 2px 0 0; min-height: 4px; }
.chart-bar.current { background: var(--orange); }

/* ── Misc ── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12.5px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mono { font-family: 'Roboto Mono', monospace; font-size: 12px; }
.ts { font-family: monospace; font-size: 11px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse 2s infinite; margin-right: 3px; }

/* ── Empty state ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center; color: var(--gray-400);
}
.empty-state-icon { margin-bottom: 16px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; line-height: 1.6; max-width: 340px; }

/* ── Settings rows ── */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row-label { font-size: 13px; font-weight: 500; }
.settings-row-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ── Store item in settings ── */
.store-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0;
}
.store-item + .store-item { border-top: 1px solid var(--border); }
.store-item:last-child { padding-bottom: 14px; }
.store-item-info { flex: 1; }
.store-item-name { font-size: 13px; font-weight: 600; }
.store-item-url { font-size: 12px; color: var(--gray-400); }

/* ── Flash messages ── */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.flash-success { background: var(--green-bg); color: var(--green-text); border: 1px solid #86EFAC; }
.flash-error   { background: var(--red-bg);   color: var(--red-text);   border: 1px solid #FCA5A5; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
