:root {
  --sidebar-bg: #07090f;
  --canvas: #0a0c14;
  --surface-1: #0d1019;
  --surface-2: #10182a;
  --surface-3: #151b2d;
  --hairline: #1d2333;
  --hairline-strong: #30384d;
  --ink: #f7f8f8;
  --ink-muted: #cdc8db;
  --ink-subtle: #918aa6;
  --ink-tertiary: #645d7a;
  --profit-purple: #7022BB;
  --profit-purple-soft: #a66cff;
  --profit-cognac: #8B5A2B;
  --success: #27ae60;
  --danger: #ff5656;
  --warn: #e0a44a;
  --plan-accent-pale: #a66cff;
  --plan-accent-rgb: 112,34,187;
  --semantic-success: #27ae60;
  --red: #ff5656;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.boot-screen, .auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(112,34,187,0.22), transparent 34%),
    radial-gradient(circle at 86% 76%, rgba(139,90,43,0.18), transparent 30%),
    var(--canvas);
}
.boot-screen {
  gap: 14px;
  text-align: center;
  color: var(--ink-subtle);
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--profit-purple), #8a3fe0);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: 0 16px 45px rgba(112,34,187,0.28);
  flex-shrink: 0;
}
.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: rgba(13,16,25,0.94);
  box-shadow: 0 28px 90px rgba(0,0,0,0.36);
  padding: 28px;
}
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.auth-brand h1 { margin: 0; font-size: 24px; letter-spacing: -0.04em; }
.auth-brand p { margin: 4px 0 0; color: var(--ink-subtle); font-size: 13px; line-height: 1.45; }
.auth-form, .stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 750;
}
.field input, .profit-control select, .profit-store-switch select, .cogs-filter-select {
  min-height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,0.035);
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}
.field input:focus, select:focus {
  border-color: rgba(112,34,187,0.65);
  box-shadow: 0 0 0 3px rgba(112,34,187,0.16);
}
.secret-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }

.btn-primary, .btn-secondary, .icon-btn {
  min-height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
  color: #fff;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--profit-purple), #8a3fe0);
  box-shadow: 0 12px 28px rgba(112,34,187,0.22);
}
.btn-primary:hover:not(:disabled), .btn-secondary:hover:not(:disabled), .icon-btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-secondary, .icon-btn {
  background: rgba(255,255,255,0.035);
  border-color: var(--hairline-strong);
  color: var(--ink-muted);
}
.btn-secondary:hover:not(:disabled), .icon-btn:hover:not(:disabled) { color: var(--ink); background: rgba(255,255,255,0.07); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.form-msg { min-height: 18px; color: var(--ink-tertiary); font-size: 12px; line-height: 1.45; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  background: var(--canvas);
}
.sidebar {
  min-height: 100vh;
  padding: 18px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
}
.side-brand { display: flex; gap: 12px; align-items: center; }
.side-brand strong { display: block; font-size: 15px; }
.side-brand span { display: block; margin-top: 3px; color: var(--ink-tertiary); font-size: 11px; word-break: break-word; }
.side-nav { display: flex; flex-direction: column; gap: 8px; }
.side-nav button:not(.tool-nav-item) {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-subtle);
  font-weight: 750;
  text-align: left;
}
.side-nav button:not(.tool-nav-item).active, .side-nav button:not(.tool-nav-item):hover {
  background: rgba(112,34,187,0.20);
  color: var(--ink);
}
.tool-nav-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--ink-tertiary); padding: 12px 10px 4px;
}
.tool-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; color: var(--ink-subtle); cursor: pointer;
  transition: background .15s, color .15s;
}
.tool-nav-item:hover { background: var(--surface-2); color: var(--ink); }
.tool-nav-item.active { background: rgba(var(--plan-accent-rgb),0.14); color: var(--ink); font-weight: 600; }
.tool-placeholder {
  border: 1px dashed var(--hairline-strong); border-radius: var(--r-lg);
  padding: 48px 24px; text-align: center; color: var(--ink-subtle); font-size: 13px;
  background: var(--surface-1); line-height: 1.6;
}
.tool-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tool-actions .btn-primary { width: auto; padding-left: 18px; padding-right: 18px; }
.logout-btn { margin-top: auto; width: 100%; }
.content {
  padding: 28px;
  min-width: 0;
}
.content-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.content-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.04em; }
.content-head p { margin: 6px 0 0; color: var(--ink-subtle); font-size: 13px; }

.profit-dashboard {
  --profit-panel: #10182a;
  --profit-line: rgba(255,255,255,0.075);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.profit-dashboard-titlebar, .profit-dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.profit-store-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  background: rgba(112,34,187,0.10);
}
.profit-store-switch select {
  border: 0;
  background: transparent;
  min-width: 190px;
  min-height: 36px;
  padding: 0 4px;
  cursor: pointer;
}
.profit-dashboard-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profit-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,0.035);
  color: var(--ink-subtle);
  font-size: 12px;
  font-weight: 750;
}
.profit-icon-btn.icon-only { width: 36px; padding: 0; }
.profit-icon-btn svg { width: 15px; height: 15px; }
.profit-filter-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--profit-purple);
  color: #fff;
  font-size: 9px;
  box-shadow: 0 0 0 2px var(--surface-2);
}
.profit-filter-badge.show { display: inline-flex; }
.profit-dashboard-toolbar {
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(112,34,187,0.10), rgba(16,24,42,0.76));
}
.profit-controls-left { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.profit-control { display: flex; flex-direction: column; gap: 7px; min-width: 180px; }
.profit-control label, .profit-control > span {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-tertiary);
  text-transform: uppercase;
  letter-spacing: .55px;
}
.profit-datedrop { position: relative; align-self: end; }
.profit-datedrop-toggle {
  min-height: 42px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.035);
  color: var(--ink);
  padding: 0 14px;
  min-width: 170px;
  text-align: left;
  font-weight: 800;
}
.profit-datedrop-pop {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: 318px;
  max-width: calc(100vw - 36px);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  background: #0d1019;
  box-shadow: 0 20px 70px rgba(0,0,0,0.42);
  padding: 12px;
}
.profit-datedrop.open .profit-datedrop-pop { display: block; }
.profit-datedrop-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.profit-datedrop-presets button {
  min-height: 30px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.025);
  color: var(--ink-subtle);
  font-size: 11px;
  font-weight: 800;
  padding: 0 10px;
}
.profit-datedrop-presets button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--profit-purple), #8a3fe0);
  border-color: transparent;
}
.profit-cal { border-top: 1px solid var(--hairline); padding-top: 10px; }
.profit-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.profit-cal-title { color: var(--ink); font-size: 12px; font-weight: 800; text-transform: capitalize; }
.profit-cal-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.03);
  color: var(--ink-subtle);
}
.profit-cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.profit-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.profit-cal-wd { text-align: center; font-size: 10px; font-weight: 800; color: var(--ink-tertiary); padding: 4px 0; }
.profit-cal-day {
  min-height: 31px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-subtle);
  font-size: 11px;
  font-weight: 800;
}
.profit-cal-day:hover:not(:disabled):not(.empty) { background: rgba(255,255,255,0.07); color: var(--ink); }
.profit-cal-day.today { box-shadow: inset 0 0 0 1px rgba(112,34,187,0.55); }
.profit-cal-day.in-range { background: rgba(112,34,187,0.18); border-radius: 0; }
.profit-cal-day.edge { background: var(--profit-purple); color: #fff; }
.profit-cal-day.edge.start { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.profit-cal-day.edge.end { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.profit-cal-day.edge.single { border-radius: var(--r-sm); }
.profit-cal-day:disabled { color: var(--ink-tertiary); opacity: .3; cursor: not-allowed; }
.profit-cal-day.empty { cursor: default; }
.profit-datedrop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.profit-datedrop-hint { color: var(--ink-tertiary); font-size: 10px; }
.profit-date-row { display: flex; gap: 8px; flex-wrap: wrap; }
.profit-date-row button {
  min-height: 34px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.025);
  color: var(--ink-subtle);
  font-size: 11px;
  font-weight: 800;
  padding: 0 11px;
}
.profit-date-row button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--profit-purple), #8a3fe0);
  border-color: transparent;
}
.profit-custom-range {
  display: none;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}
.profit-custom-range.show { display: flex; }
.profit-custom-range input { min-height: 34px; max-width: 150px; }
.profit-date-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(112,34,187,0.34);
  border-radius: var(--r-sm);
  background: rgba(112,34,187,0.12);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}
.profit-date-chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--profit-purple);
  box-shadow: 0 0 0 3px rgba(112,34,187,0.18);
}
.profit-last-updated {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-subtle);
  font-size: 11px;
  white-space: nowrap;
}
.profit-last-updated::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(39,166,68,0.12);
}
.profit-alert {
  display: none;
  border: 1px solid rgba(224,164,74,0.28);
  background: rgba(224,164,74,0.08);
  color: #e0b96e;
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
}
.profit-alert.show { display: block; }
.profit-dashboard-body { display: flex; flex-direction: column; gap: 14px; transition: opacity .18s ease; }
.profit-dashboard-body.refreshing { opacity: .72; }
.profit-empty, .profit-dashboard-empty {
  color: var(--ink-subtle);
  font-size: 13px;
  line-height: 1.5;
}
.profit-dashboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 38px 22px;
}
.profit-dashboard-empty strong { color: var(--ink); }
.profit-skeleton { display: grid; gap: 16px; }
.profit-skeleton-card {
  height: 210px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, var(--surface-1), var(--surface-3), var(--surface-1));
  background-size: 240% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.profit-kpi-panel, .profit-panel, .profit-consolidated, .profit-store-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03), 0 18px 50px rgba(0,0,0,0.18);
}
.profit-kpi-panel { overflow: hidden; }
.profit-kpi-grid {
  display: grid;
  grid-template-columns: minmax(250px, 1.25fr) repeat(3, minmax(132px, 1fr));
  gap: 0;
}
.profit-kpi {
  min-height: 92px;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  border-bottom: 1px solid rgba(255,255,255,0.035);
}
.profit-kpi:not(.hero) { border-left: 1px solid rgba(255,255,255,0.035); }
.profit-kpi.hero {
  grid-row: span 2;
  justify-content: flex-start;
  padding: 22px 24px 18px;
}
.profit-kpi-label, .profit-consolidated-kpi-label {
  width: fit-content;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 750;
  border-bottom: 1px dashed rgba(255,255,255,0.20);
  padding-bottom: 2px;
}
.profit-kpi-value {
  color: var(--ink);
  font-size: clamp(18px, 1.65vw, 25px);
  font-weight: 850;
  letter-spacing: -.6px;
}
.profit-kpi.hero .profit-kpi-value {
  color: var(--profit-purple-soft);
  font-size: clamp(38px, 3.8vw, 56px);
}
.profit-kpi-value.neg { color: #ff7a7a; }
.profit-kpi-note { min-height: 18px; color: var(--ink-tertiary); font-size: 11px; }
.profit-kpi-foot {
  padding: 11px 24px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-subtle);
  font-size: 12px;
  background: rgba(255,255,255,0.025);
}
.profit-panel { padding: 16px 18px; min-width: 0; }
.profit-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.profit-panel-title { color: var(--ink); font-size: 13px; font-weight: 800; }
.profit-panel-sub { color: var(--ink-tertiary); font-size: 11px; margin-top: 3px; line-height: 1.45; }
.profit-section-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.profit-chart-placeholder {
  height: 190px;
  position: relative;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px) 0 34px/100% 56px,
    linear-gradient(180deg, rgba(112,34,187,0.06), transparent);
}
.profit-chart-placeholder svg { position: absolute; inset: 18px 0 0; width: 100%; height: 150px; opacity: .72; }
.profit-chart-placeholder .empty-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-subtle);
  font-size: 12px;
  text-align: center;
  padding: 0 18px;
}
.profit-breakdown {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(360px, 1fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
}
.profit-donut {
  width: min(250px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0 auto;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.profit-donut.empty { background: conic-gradient(rgba(255,255,255,0.08) 0deg, rgba(255,255,255,0.08) 360deg); }
.profit-donut::after {
  content: '';
  position: absolute;
  inset: 23%;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.profit-donut-center {
  position: absolute;
  inset: 27%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}
.profit-donut-center span { color: var(--ink-subtle); font-size: 11px; font-weight: 750; }
.profit-donut-center strong { color: var(--ink); font-size: 18px; letter-spacing: -.4px; }
.profit-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 18px 34px;
}
.profit-legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 48px;
}
.profit-legend-swatch { width: 12px; height: 12px; border-radius: 4px; margin-top: 2px; }
.profit-legend-label { color: var(--ink-muted); font-size: 12px; font-weight: 700; line-height: 1.25; }
.profit-legend-value { color: var(--ink); font-size: 12px; margin-top: 4px; line-height: 1.25; }
.profit-legend-percent { color: var(--ink-tertiary); font-size: 10px; margin-top: 3px; line-height: 1.25; }

.profit-ad-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.profit-channel-placeholder { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.profit-channel-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  opacity: .86;
}
.profit-channel-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.profit-channel-icon img { width: 18px; height: 18px; object-fit: contain; display: block; }
.profit-channel-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.profit-channel-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--profit-purple), var(--profit-cognac));
  transition: width .18s ease;
}
.profit-channel-value { color: var(--ink); font-size: 12px; font-weight: 800; white-space: nowrap; text-align: right; }
.profit-channel-value.empty { color: var(--ink-tertiary); }
.profit-summary-list, .profit-detail-list { display: flex; flex-direction: column; gap: 10px; }
.profit-summary-row, .profit-detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  color: var(--ink-subtle);
  font-size: 12px;
}
.profit-summary-row strong, .profit-detail-value { color: var(--ink); font-weight: 850; text-align: right; white-space: nowrap; }
.profit-detail-value.neg { color: #ff7a7a; }
.profit-detail-value.unavailable { color: var(--ink-tertiary); }
.profit-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.profit-detail-card { min-height: 220px; }
.profit-detail-label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.profit-detail-label > span:first-child { border-bottom: 1px dashed rgba(255,255,255,0.18); line-height: 1.35; }
.profit-info-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(112,34,187,0.18);
  color: var(--profit-purple-soft);
  border: 1px solid rgba(112,34,187,0.32);
  font-size: 10px;
  font-weight: 900;
  cursor: help;
  flex-shrink: 0;
}
.profit-detail-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--profit-line);
  color: var(--ink-tertiary);
  font-size: 11px;
  line-height: 1.45;
}

.profit-consolidated { padding: 16px 18px; }
.profit-consolidated-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.profit-consolidated-title { font-size: 14px; font-weight: 800; color: var(--ink); }
.profit-consolidated-count {
  font-size: 11px;
  font-weight: 800;
  color: var(--profit-purple-soft);
  background: rgba(112,34,187,0.16);
  border: 1px solid rgba(112,34,187,0.3);
  border-radius: 999px;
  padding: 2px 9px;
}
.profit-consolidated-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 16px; }
.profit-consolidated-col { min-width: 0; }
.profit-consolidated-kpi-value {
  color: var(--ink);
  font-size: clamp(15px, 1.3vw, 19px);
  font-weight: 850;
  letter-spacing: -.4px;
  margin-top: 3px;
}
.profit-consolidated-kpi-value.neg, .profit-cstore-value.neg { color: #ff7a7a; }
.profit-consolidated-rows { margin-top: 12px; border-top: 1px solid var(--profit-line); padding-top: 8px; }
.profit-cstore-row { padding: 7px 0; }
.profit-cstore-row.is-hidden { display: none; }
.profit-cstore-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.profit-cstore-name { color: var(--ink-subtle); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profit-cstore-value { color: var(--ink); font-size: 11px; font-weight: 750; white-space: nowrap; }
.profit-cstore-bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; margin-top: 5px; }
.profit-cstore-bar span { display: block; height: 100%; width: var(--w,0%); border-radius: inherit; background: linear-gradient(90deg, var(--profit-purple), var(--profit-purple-soft)); }
.profit-cstore-bar.neg span { background: linear-gradient(90deg, #b3402f, #ff7a7a); }
.profit-store-toggle-wrap { display: flex; justify-content: center; margin-top: 14px; }
.profit-store-toggle {
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
  color: var(--ink-subtle);
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 750;
}

.profit-stores { display: flex; flex-direction: column; gap: 10px; }
.profit-store-card { padding: 14px; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.profit-store-name { font-size: 14px; font-weight: 800; color: var(--ink); }
.profit-store-meta { margin-top: 4px; font-size: 11px; color: var(--ink-subtle); line-height: 1.5; }
.profit-sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  color: var(--ink-subtle);
  background: rgba(255,255,255,0.035);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.profit-sync-pill.ok { color: var(--success); border-color: rgba(39,174,96,0.35); background: rgba(39,174,96,0.08); }
.profit-sync-pill.err { color: var(--danger); border-color: rgba(255,86,86,0.35); background: rgba(255,86,86,0.08); }

.profit-cogs { display: flex; flex-direction: column; gap: 14px; position: relative; }
.cogs-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid rgba(112,34,187,0.35); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(112,34,187,0.14), rgba(112,34,187,0.05));
}
.cogs-banner svg { width: 20px; height: 20px; color: var(--plan-accent-pale); flex-shrink: 0; }
.cogs-banner-text { font-size: 12px; color: var(--ink-subtle); line-height: 1.5; flex: 1; min-width: 0; }
.cogs-banner-text strong { color: var(--ink); font-weight: 700; }
.cogs-banner .btn-secondary { white-space: nowrap; }
.cogs-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cogs-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cogs-search { position: relative; flex: 1; min-width: 200px; }
.cogs-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-tertiary); }
.cogs-search input {
  width: 100%; min-height: 38px; padding: 0 12px 0 34px; border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong); background: rgba(255,255,255,0.035);
  color: var(--ink); font-family: var(--font); font-size: 13px; outline: none;
}
.cogs-toolbar-right { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cogs-nocost-chip {
  display: none; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px; cursor: pointer;
  border-radius: 999px; border: 1px solid rgba(224,164,74,0.4); background: rgba(224,164,74,0.10);
  color: #e0b96e; font-family: var(--font); font-size: 12px; font-weight: 750;
}
.cogs-nocost-chip.show { display: inline-flex; }
.cogs-nocost-chip.active { background: rgba(224,164,74,0.24); border-color: rgba(224,164,74,0.6); }
.cogs-filter-select {
  min-height: 36px; border-radius: var(--r-sm); border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,0.035); color: var(--ink); font-family: var(--font);
  font-size: 12px; font-weight: 650; padding: 0 26px 0 12px; cursor: pointer;
}
.cogs-bulk-btn { display: none; width: auto; padding: 9px 16px; margin: 0; }
.cogs-bulk-btn.show { display: inline-flex; }
.cogs-zone-row { display: flex; align-items: center; gap: 8px; }
.cogs-zone { font-size: 11px; font-weight: 750; padding: 5px 13px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #7022BB, #8a3fe0); }
.cogs-addzone { font-size: 11px; font-weight: 700; color: var(--ink-tertiary); background: transparent; border: 1px dashed var(--hairline-strong); border-radius: 999px; padding: 5px 12px; cursor: not-allowed; opacity: 0.6; font-family: var(--font); }
.cogs-table-scroll { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--surface-1); }
.cogs-table { min-width: 840px; }
.cogs-thead, .cogs-row {
  display: grid; grid-template-columns: 32px minmax(190px, 2.2fr) 88px 1fr 1.05fr 0.95fr 0.95fr;
  align-items: center; gap: 10px; padding: 8px 16px;
}
.cogs-thead { background: var(--surface-2); border-bottom: 1px solid var(--hairline); font-size: 11px; font-weight: 800; color: var(--ink-tertiary); text-transform: uppercase; letter-spacing: 0.4px; padding-top: 10px; padding-bottom: 10px; }
.cogs-thead .cogs-num { text-align: right; }
.cogs-info { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--ink-tertiary); color: var(--ink-tertiary); font-size: 9px; font-weight: 800; font-style: italic; cursor: help; vertical-align: middle; margin-left: 4px; text-transform: none; }
.cogs-bundle { font-size: 12px; }
.cogs-row { border-bottom: 1px solid var(--hairline); }
.cogs-row:last-child { border-bottom: 0; }
.cogs-row.variant { background: rgba(255,255,255,0.018); }
.cogs-prod { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cogs-prod-img { width: 30px; height: 30px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-3); flex-shrink: 0; border: 1px solid var(--hairline); }
.cogs-prod-info { min-width: 0; }
.cogs-prod-name { font-size: 13px; font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cogs-variants-toggle { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 11px; color: var(--ink-subtle); background: none; border: 0; cursor: pointer; padding: 0; font-family: var(--font); }
.cogs-variants-toggle:hover { color: var(--ink); }
.cogs-variants-toggle svg { width: 11px; height: 11px; transition: transform .15s; }
.cogs-variants-toggle.open svg { transform: rotate(180deg); }
.cogs-variant-name { font-size: 12px; color: var(--ink-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 48px; }
.cogs-status { font-size: 10px; font-weight: 750; padding: 3px 9px; border-radius: 999px; text-transform: capitalize; width: fit-content; }
.cogs-status.active { color: var(--semantic-success); background: rgba(39,166,68,0.10); border: 1px solid rgba(39,166,68,0.30); }
.cogs-status.other { color: var(--ink-subtle); background: var(--surface-3); border: 1px solid var(--hairline); }
.cogs-price { font-size: 13px; color: var(--ink); }
.cogs-num { text-align: right; }
.cogs-muted { color: var(--ink-tertiary); }
.cogs-cost-cell {
  display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; justify-self: end; cursor: text;
  border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 10px; font-size: 13px; color: var(--ink);
  transition: border-color .15s, background .15s; min-width: 84px;
}
.cogs-cost-cell:hover { border-color: var(--hairline-strong); background: rgba(255,255,255,0.04); }
.cogs-cost-cell.inherited { color: var(--ink-subtle); }
.cogs-cost-cell.saving { opacity: 0.6; }
.cogs-cost-cell.saved { border-color: rgba(39,166,68,0.55); background: rgba(39,166,68,0.06); }
.cogs-cost-cell.error { border-color: var(--red); background: rgba(255,86,86,0.06); }
.cogs-inherited-badge { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; color: var(--plan-accent-pale); background: rgba(112,34,187,0.16); border: 1px solid rgba(112,34,187,0.3); border-radius: 999px; padding: 1px 6px; }
.cogs-cost-input { width: 92px; text-align: right; min-height: 32px; border: 1px solid #7022BB; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font-family: var(--font); font-size: 13px; padding: 0 8px; outline: none; box-shadow: 0 0 0 2px rgba(112,34,187,0.18); }
.cogs-margin { font-size: 13px; color: var(--ink); }
.cogs-margin.neg { color: #ff7a7a; }
.cogs-check { width: 16px; height: 16px; accent-color: #7022BB; cursor: pointer; }
.cogs-recalc-back { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--ink-subtle); font-family: var(--font); font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 0; margin-bottom: 8px; }
.cogs-recalc-back:hover { color: var(--ink); }
.cogs-recalc-card { border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--surface-1); padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.cogs-recalc-card h3 { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0; }
.cogs-recalc-note { font-size: 12px; color: var(--ink-subtle); line-height: 1.6; }
.cogs-recalc-note strong { color: var(--ink); }
.cogs-recalc-scope { display: flex; flex-direction: column; gap: 10px; }
.cogs-recalc-scope label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.cogs-recalc-scope input { accent-color: #7022BB; }
.cogs-recalc-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.cogs-recalc-dates .field { flex: 1; min-width: 150px; margin: 0; }
.cogs-recalc-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--hairline); color: var(--ink-subtle); }
.cogs-recalc-status.running { color: var(--plan-accent-pale); border-color: rgba(112,34,187,0.4); background: rgba(112,34,187,0.10); }
.cogs-recalc-status.ok { color: var(--semantic-success); border-color: rgba(39,166,68,0.35); background: rgba(39,166,68,0.08); }
.cogs-recalc-status.err { color: var(--red); border-color: rgba(255,86,86,0.35); }
.cogs-toast {
  position: sticky; bottom: 10px; align-self: center; margin-top: 4px;
  background: var(--surface-3); border: 1px solid var(--hairline-strong); color: var(--ink);
  font-size: 12px; font-weight: 650; padding: 9px 16px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); opacity: 0; transform: translateY(6px);
  transition: opacity .18s, transform .18s; pointer-events: none; z-index: 5;
}
.cogs-toast.show { opacity: 1; transform: translateY(0); }
.cogs-toast.error { border-color: rgba(255,86,86,0.5); color: #ffb3b3; }
@media (max-width: 760px) {
  .cogs-search { min-width: 140px; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.62);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: var(--surface-1);
  box-shadow: 0 28px 90px rgba(0,0,0,0.48);
  padding: 18px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head p { margin: 4px 0 0; color: var(--ink-subtle); font-size: 12px; line-height: 1.45; }
.profit-filter-section-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.profit-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
.profit-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink);
}
.profit-checkbox input { width: 15px; height: 15px; accent-color: var(--profit-purple); cursor: pointer; flex-shrink: 0; }

@media (max-width: 1100px) {
  .profit-kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .profit-kpi.hero { grid-row: auto; grid-column: span 2; }
  .profit-consolidated-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .profit-detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .logout-btn { width: auto; margin-top: 0; }
  .content { padding: 18px; }
  .profit-breakdown, .profit-ad-grid, .profit-detail-grid, .profit-section-grid { grid-template-columns: 1fr; }
  .profit-legend { grid-template-columns: 1fr; }
  .profit-kpi-grid { grid-template-columns: 1fr; }
  .profit-kpi.hero { grid-column: auto; }
  .profit-kpi:not(.hero) { border-left: 0; }
}
@media (max-width: 560px) {
  .auth-card { padding: 22px; }
  .profit-consolidated-grid { grid-template-columns: 1fr; }
  .profit-dashboard-actions, .profit-store-switch, .profit-store-switch select { width: 100%; }
  .profit-icon-btn { flex: 1; }
  .profit-filter-grid { grid-template-columns: 1fr; }
}
