/* First-run and small-screen polish. Tokens and on-scale sizes only. */

.psb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.psb-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.psb-track {
  width: 100%;
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
#pilot-sync-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--text-primary);
  transition: width 0.4s ease;
}
.psb-eta { margin: 4px 0 0; font-size: 12px; line-height: 1.4; color: var(--text-muted); }
.psb-retry {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
#pilot-sync-banner { flex-wrap: wrap; }
#pilot-sync-banner .psb-close { min-width: 44px; min-height: 44px; }
.kpi-card .metric { min-height: 28px; }
.metric.fos-skel {
  color: transparent;
  border-radius: 8px;
  background: var(--border);
}
#chart-revenue-profit,
#chart-cost-breakdown,
#chart-ad-spend {
  display: block !important;
  width: 100%;
  height: 240px;
  min-height: 240px;
}

body.fos-loading .kpi-card .metric,
body.fos-syncing .kpi-card .metric {
  color: transparent;
  border-radius: 8px;
  background: var(--border);
  min-height: 28px;
}

.kpi-card,
.card,
.sidebar {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.section:not(.active) { content-visibility: auto; contain-intrinsic-size: 800px 480px; }

#fos-onboarding-extra:empty { display: none; }
#fos-onboarding-extra { margin-top: 12px; }

.fos-tabbar { display: none; }

@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .mobile-menu-btn,
  .header-icon-btn,
  .nav-item,
  .login-btn,
  .btn,
  .btn-primary {
    min-height: 44px;
    min-width: 44px;
  }
  .content { padding-bottom: 64px; }
  .table-container,
  .fa-attr-table-wrap,
  .fa-table-frame {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .products-table th:first-child,
  .products-table td:first-child,
  .fa-costs-table th:first-child,
  .fa-costs-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-card);
  }
  .fos-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    gap: 4px;
    padding: 8px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
  }
  .fos-tabbar button {
    flex: 1;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
  }
  .fos-tabbar button[aria-current="page"] {
    background: var(--bg-secondary, var(--border));
    color: var(--text-primary);
  }
}

@media (max-width: 600px) {
  #products .table-container {
    overflow-x: hidden;
  }
  #products .fa-search {
    min-width: 0;
    width: 100%;
  }
  #products .products-table,
  #products .products-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }
  #products .products-table thead {
    display: none;
  }
  #products .products-table tr {
    display: block;
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  #products .products-table td {
    display: block;
    width: auto;
    padding: 4px;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #products .products-table td:nth-child(1),
  #products .products-table td:nth-child(4),
  #products .products-table td:nth-child(5),
  #products .products-table td:nth-child(6),
  #products .products-table td:nth-child(9),
  #products .products-table td:nth-child(11) {
    display: none;
  }
  #products .products-table td:nth-child(7)::before {
    content: "Profit per sale ";
    color: var(--text-muted);
    font-weight: 500;
  }
  #products .products-table td:nth-child(8)::before {
    content: "Margin ";
    color: var(--text-muted);
    font-weight: 500;
  }
  #products .products-table td:nth-child(10)::before {
    content: "Trend ";
    color: var(--text-muted);
    font-weight: 500;
  }
}

@media (max-width: 390px) {
  .fa-ask-box { max-width: 100%; }
  .fa-tb, .fa-tb-left, .fa-views, .fa-views-trend { flex-wrap: wrap; max-width: 100%; }
  .fa-view-pill { min-height: 44px; }
}
