/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fc;
  --color-border: #e2e8f0;
  --color-border-2: #cbd5e1;
  --color-primary: #005bff;
  --color-primary-hover: #0047d4;
  --color-primary-light: #e8efff;
  --color-text: #1e293b;
  --color-text-2: #475569;
  --color-text-muted: #94a3b8;
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-error: #dc2626;
  --color-error-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --color-pending: #7c3aed;
  --color-pending-bg: #ede9fe;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.05);
  --nav-height: 60px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'Fira Code', 'Courier New', monospace; font-size: 0.85em; background: var(--color-surface-2); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--color-border); }

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
  cursor: pointer;
}
.nav-brand:hover { text-decoration: none; opacity: 0.85; }

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-2);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-link:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
.nav-link.active { background: var(--color-primary-light); color: var(--color-primary); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.nav-username { font-size: 14px; font-weight: 500; color: var(--color-text-2); }

.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: 4px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.nav-burger:hover { background: var(--color-surface-2); }
.nav-burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
  transform-origin: center;
}
.nav-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Main Layout ─────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* ── Auth Page ───────────────────────────────────────────────────────────────── */
.auth-body {
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { color: var(--color-text-2); text-align: center; font-size: 14px; margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }

/* ── Card ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

/* ── Page Header ─────────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--color-text-2); font-size: 14px; }
.back-link { margin-bottom: 12px; display: inline-flex; }

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.status-badge-lg {
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Form ────────────────────────────────────────────────────────────────────── */
.form-section { margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--color-border); }
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-2);
}

.form-label-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
}

.form-input, .form-select {
  padding: 9px 12px;
  border: 1px solid var(--color-border-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 91, 255, 0.1);
}

.form-input-sm { padding: 6px 10px; font-size: 13px; }

.form-hint { font-size: 12px; color: var(--color-text-muted); }

.form-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-2);
  border: 1px solid var(--color-border-2);
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

.btn-download { margin-left: auto; flex-shrink: 0; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--color-error-bg); color: var(--color-error); border: 1px solid rgba(220,38,38,0.2); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-user { background: var(--color-surface-2); color: var(--color-text-2); border: 1px solid var(--color-border); }
.badge-you { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Status Badges ───────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-done { background: var(--color-success-bg); color: var(--color-success); }
.badge-error { background: var(--color-error-bg); color: var(--color-error); }
.badge-running { background: var(--color-primary-light); color: var(--color-primary); }
.badge-pending { background: var(--color-pending-bg); color: var(--color-pending); }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-text-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
.spinner-blue { border-top-color: var(--color-primary); }
.spinner-inline { width: 12px; height: 12px; border-width: 2px; border-top-color: var(--color-primary); }

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

/* ── Progress Card ───────────────────────────────────────────────────────────── */
.progress-card { margin-bottom: 20px; }

.progress-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}

.progress-label { font-weight: 600; font-size: 16px; }
.progress-step { font-size: 14px; color: var(--color-text-2); margin-top: 2px; }

.status-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-done { background: var(--color-success-bg); color: var(--color-success); }
.icon-error { background: var(--color-error-bg); color: var(--color-error); }

.error-message {
  margin-top: 10px;
  padding: 12px;
  background: var(--color-error-bg);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--color-error);
  max-height: 200px;
  overflow-y: auto;
}

/* ── Log Output ──────────────────────────────────────────────────────────────── */
#log-container {
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.log-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.log-output {
  background: #0f1117;
  color: #c8d3e0;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid #2a2f3a;
  scrollbar-width: thin;
  scrollbar-color: #3a404d transparent;
}

.log-output::-webkit-scrollbar { width: 6px; }
.log-output::-webkit-scrollbar-track { background: transparent; }
.log-output::-webkit-scrollbar-thumb { background: #3a404d; border-radius: 3px; }

/* ── Params Grid ─────────────────────────────────────────────────────────────── */
.params-card { margin-bottom: 20px; }
.params-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.param-item { display: flex; flex-direction: column; gap: 2px; background: var(--color-surface-2); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
.param-key { font-size: 11px; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.param-val { font-size: 14px; font-weight: 500; color: var(--color-text); }

/* ── Table ───────────────────────────────────────────────────────────────────── */
.summary-period-title { margin-bottom: 14px; }

/* ── Summary breakdown waterfall ──────────────────────────────────────────── */
.summary-breakdown {
  margin-top: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.bdr-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 16px;
  border-bottom: 1px solid var(--color-border);
}
.bdr-row:last-child { border-bottom: none; }
.bdr-label { color: var(--color-text-2); }
.bdr-rub   { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--color-text); min-width: 140px; text-align: right; }
.bdr-pct   { font-variant-numeric: tabular-nums; color: var(--color-text-muted); min-width: 52px; text-align: right; }
.bdr-revenue  { background: var(--color-surface-2); font-weight: 600; }
.bdr-revenue .bdr-label { color: var(--color-text); font-weight: 600; }
.bdr-cost     { background: var(--color-surface); }
.bdr-cost .bdr-rub { color: var(--color-error); }
.bdr-total    { background: var(--color-surface-2); }
.bdr-neutral  { background: var(--color-surface-2); font-weight: 600; }
.bdr-profit   { background: var(--color-surface-2); font-weight: 700; font-size: 14px; }
.bdr-sep      { border-top: 2px solid var(--color-border); }
.bdr-profit-pos .bdr-rub, .bdr-profit-pos .bdr-pct { color: var(--color-success); }
.bdr-profit-neg .bdr-rub, .bdr-profit-neg .bdr-pct { color: var(--color-error); }
.btn-xs { font-size: 11px; padding: 2px 8px; margin-top: 6px; }
.breakdown-toggle-btn { display: block; }

.table-card { padding: 0; overflow: hidden; }
.table-card .section-title { padding: 20px 24px 0; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-surface-2); }

.row-inactive td { opacity: 0.5; }
.task-link { font-family: monospace; font-size: 13px; }
.actions-cell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--color-text-2);
}
.empty-icon { color: var(--color-border-2); }

/* ── Admin Layout ────────────────────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.create-user-form { display: flex; flex-direction: column; gap: 14px; }

.reset-form { margin-top: 10px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 13px; }

/* ── Generate Form ───────────────────────────────────────────────────────────── */
.generate-form .form-section:first-child { border-top: none; }

/* ── Wide content ────────────────────────────────────────────────────────────── */
.main-content-wide { max-width: 1280px; }

/* ── Report Data Table ───────────────────────────────────────────────────────── */
.report-table-section { margin-top: 20px; }

.report-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  flex-wrap: wrap;
}

.report-table-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.report-table-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.report-table-search {
  padding: 7px 12px;
  border: 1px solid var(--color-border-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  width: 220px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.report-table-search:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,91,255,0.1);
}

.report-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 68vh;
  border-top: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
}

.report-table-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.report-table-scroll::-webkit-scrollbar-track { background: var(--color-surface-2); }
.report-table-scroll::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: 3px; }
.report-table-scroll { scrollbar-width: thin; scrollbar-color: var(--color-border-2) var(--color-surface-2); }

.report-dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.report-dtable th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.report-dtable th:last-child { border-right: none; }

.report-dtable td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  vertical-align: middle;
}
.report-dtable td:last-child { border-right: none; }
.report-dtable tr:last-child td { border-bottom: none; }
.report-dtable tr:hover td { background: rgba(0,91,255,0.03); }

.report-dtable .col-name {
  min-width: 200px;
  max-width: 280px;
  white-space: normal;
  word-break: break-word;
  font-weight: 500;
}
.report-dtable .col-offer-id { font-family: 'Fira Code', monospace; font-size: 12px; }
.report-dtable .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.report-dtable .col-actions { text-align: center; padding: 6px 10px; }

.row-profit-pos td { background: rgba(22,163,74,0.05); }
.row-profit-neg td { background: rgba(220,38,38,0.04); }
.row-profit-pos:hover td { background: rgba(22,163,74,0.1) !important; }
.row-profit-neg:hover td { background: rgba(220,38,38,0.08) !important; }

.profit-pos { color: var(--color-success); font-weight: 600; }
.profit-neg { color: var(--color-error); font-weight: 600; }

.col-sizes {
  max-width: 180px;
  white-space: normal;
  word-break: break-word;
  font-size: 12px;
  color: var(--color-text-2);
}

.report-table-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.report-table-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  color: var(--color-text-2);
  font-size: 14px;
}

/* ── Product Detail Page ─────────────────────────────────────────────────────── */
.product-header { margin-bottom: 24px; }

.product-summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.product-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.product-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.product-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}
.product-stat-value.stat-pos { color: var(--color-success); }
.product-stat-value.stat-neg { color: var(--color-error); }
.product-stat-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.detail-table-card { padding: 0; overflow: hidden; }

.detail-section-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  border-bottom: 2px solid rgba(0,0,0,0.08);
  /* White right-border creates clean gap between adjacent colored headers */
  border-right: 2px solid rgba(255,255,255,0.8);
}
.detail-section-header:last-child { border-right: none; }

/* Per-block header colors */
.dsh-prices   { background: #dff0fb; color: #0c5483; border-bottom-color: #7dbce8; }
.dsh-result   { background: #e0f5e8; color: #0f5c30; border-bottom-color: #5ec885; }
.dsh-cost-pct { background: #fdf4d8; color: #7a4810; border-bottom-color: #e8bc50; }
.dsh-cost-rub { background: #fde8d0; color: #7a3810; border-bottom-color: #e89050; }
.dsh-analytics{ background: #ede8ff; color: #4a18a0; border-bottom-color: #a07ae0; }

/* Section-start column separators — slightly thicker neutral line
   Column positions: Цены=3, Итог=5, Расходы%=8, Расходы₽=13, Аналитика=18 */
#product-sku-table #sort-header-row th:nth-child(3),
#product-sku-table tbody tr td:nth-child(3),
#product-sku-table #sort-header-row th:nth-child(5),
#product-sku-table tbody tr td:nth-child(5),
#product-sku-table #sort-header-row th:nth-child(8),
#product-sku-table tbody tr td:nth-child(8),
#product-sku-table #sort-header-row th:nth-child(13),
#product-sku-table tbody tr td:nth-child(13),
#product-sku-table #sort-header-row th:nth-child(18),
#product-sku-table tbody tr td:nth-child(18) {
  border-left: 2px solid var(--color-border-2);
}

/* Source cell highlight (buyout & tax base) — background only, normal text */
.src-cell {
  font-size: 12px;
  white-space: normal;
  padding: 8px 12px;
}
/* !important to override .row-profit-pos/neg td background */
.src-real      { background: rgba(22, 163, 74, 0.15) !important; }
.src-analytics { background: rgba(0,  91, 255, 0.10) !important; }
.src-default   { background: rgba(217,119,   6, 0.13) !important; }

/* Hover must also preserve src-cell colors — higher specificity + !important */
.report-dtable tr:hover td.src-real,
.row-profit-pos:hover td.src-real,
.row-profit-neg:hover td.src-real   { background: rgba(22, 163, 74, 0.24) !important; }

.report-dtable tr:hover td.src-analytics,
.row-profit-pos:hover td.src-analytics,
.row-profit-neg:hover td.src-analytics { background: rgba(0, 91, 255, 0.17) !important; }

.report-dtable tr:hover td.src-default,
.row-profit-pos:hover td.src-default,
.row-profit-neg:hover td.src-default  { background: rgba(217, 119, 6, 0.22) !important; }

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #ffffff;
  box-shadow: 2px 0 5px rgba(0,0,0,0.07);
}
.report-dtable tr:hover .sticky-col { background: #eef3ff; }
.report-dtable th.sticky-col { background: var(--color-surface-2); z-index: 4; }
/* Solid colors so sticky column is opaque when scrolling horizontally */
.row-profit-pos .sticky-col { background: #f2fbf5; }
.row-profit-neg .sticky-col { background: #fef5f5; }
.row-profit-pos:hover .sticky-col { background: #e3f7ea !important; }
.row-profit-neg:hover .sticky-col { background: #fdeaea !important; }

/* ── Sortable headers ─────────────────────────────────────────────────────────── */
.sort-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sort-th:hover { color: var(--color-text); background: #e8ecf3 !important; }
.sort-th::after { content: " ⇅"; opacity: 0.2; font-size: 9px; vertical-align: middle; }
.sort-th[data-dir="asc"]::after  { content: " ▲"; opacity: 1; color: var(--color-primary); }
.sort-th[data-dir="desc"]::after { content: " ▼"; opacity: 1; color: var(--color-primary); }

/* ── Clickable rows ───────────────────────────────────────────────────────────── */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #eef3ff !important; }
.clickable-row:hover .sticky-col { background: #dce8ff !important; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px 40px; }
  .navbar { padding: 0 16px; gap: 12px; }
  .nav-burger { display: flex; }
  .nav-username { display: none; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 8px 16px 16px;
    gap: 2px;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 10px 14px; font-size: 15px; }
  .admin-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .progress-status { flex-wrap: wrap; }
}

/* ── Debug panel ─────────────────────────────────────────────────────────────── */
.debug-panel {
  border: 1px solid var(--color-border-2);
  background: var(--color-surface-2);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.debug-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.debug-panel-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--color-text-2);
}
.debug-panel-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.dbg-section { }
.dbg-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.dbg-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dbg-table tr + tr td { border-top: 1px solid var(--color-border); }
.dbg-table td { padding: 4px 6px; vertical-align: middle; }
.dbg-key { color: var(--color-text-2); white-space: nowrap; padding-right: 12px; }
.ds-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.ds-fresh   { background: var(--color-success-bg); color: var(--color-success); }
.ds-cache   { background: var(--color-primary-light); color: var(--color-primary); }
.ds-skipped { background: var(--color-surface); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.ds-failed  { background: var(--color-error-bg); color: var(--color-error); }
.ds-partial { background: var(--color-warning-bg); color: var(--color-warning); }
.dbg-section-wide { grid-column: 1 / -1; }
.dbg-hint { font-size: 11px; color: var(--color-text-muted); margin-left: 6px; }
.dbg-qty-best td { color: var(--color-success); }
.dbg-qty-warn td { color: var(--color-warning, #b45309); }
.rl-table { font-family: 'Fira Code', 'Courier New', monospace; }
.rl-method { color: var(--color-text-muted); font-size: 11px; white-space: nowrap; padding-right: 8px; }
.rl-path   { font-size: 12px; }
.rl-note   { font-family: var(--font); font-size: 11px; color: var(--color-text-muted); margin-left: 6px; }
.rl-status { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.rl-ok  { color: var(--color-success); }
.rl-err { color: var(--color-error); }

/* ── Data warnings banner ─────────────────────────────────────────────────────── */
.data-warnings-banner {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid;
}
.data-warnings-warn {
  background: var(--color-warning-bg);
  border-color: #f6d860;
  color: #7c5a00;
}
.data-warnings-info {
  background: var(--color-surface-2);
  border-color: var(--color-border-2);
  color: var(--color-text-2);
}
.dw-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 8px;
}
.dw-header svg { flex-shrink: 0; }
.dw-list {
  margin: 0;
  padding: 0 0 0 26px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dw-item {
  font-size: 13px;
  line-height: 1.5;
}
.dw-item-warning { color: #7c5a00; }
.dw-item-info    { color: var(--color-text-2); }
