/* AI stats review: light theme on top of Bootstrap 5.3 */
:root {
  --app-bg: #f5f6f8;
  --app-surface: #ffffff;
  --app-border: #e6e8ec;
  --app-text: #1f2430;
  --app-muted: #6b7280;
  --app-primary: #2456c5;
  --app-primary-soft: #e8eefb;
  --app-good: #1c7c4a;
  --app-bad: #b42323;
  --app-amber: #b46a00;
  --app-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-link-color: var(--app-primary);
  --bs-link-hover-color: #183d8f;
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: 36, 86, 197;
}
html { font-size: 15px; }
body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
h1, .h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }
h2, .h2 { font-size: 1.2rem; font-weight: 600; }
h3, .h3 { font-size: 1.05rem; font-weight: 600; }
.text-muted, .muted { color: var(--app-muted) !important; }
.num, .tabular, table.metrics td, table.metrics th, .stat .value { font-variant-numeric: tabular-nums; }

/* nav */
.app-nav { background: var(--app-surface); border-bottom: 1px solid var(--app-border); }
.app-nav .navbar-brand { font-weight: 700; color: var(--app-text); letter-spacing: -.01em; }
.app-nav .nav-link { color: #3b4250; padding: .5rem .75rem; border-radius: .5rem; }
.app-nav .nav-link:hover { background: var(--app-primary-soft); color: var(--app-primary); }
.app-nav .nav-link.active { color: var(--app-primary); background: var(--app-primary-soft); font-weight: 600; }
.app-nav .btn-logout { color: var(--app-muted); text-decoration: none; }
.app-nav .btn-logout:hover { color: var(--app-text); }

/* buttons */
.btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: #1d47a4; --bs-btn-hover-border-color: #1d47a4; --bs-btn-active-bg: #183d8f; --bs-btn-active-border-color: #183d8f; }
.btn-outline-primary { --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary); --bs-btn-active-bg: var(--app-primary); --bs-btn-active-border-color: var(--app-primary); }
.btn-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.btn-fb:hover, .btn-fb:focus { background: #1462cc; border-color: #1462cc; color: #fff; }

/* cards */
.card { border: 1px solid var(--app-border); border-radius: .75rem; box-shadow: var(--app-shadow); background: var(--app-surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); font-weight: 600; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .75rem; padding: .85rem 1rem; box-shadow: var(--app-shadow); min-width: 0; }
.stat .label { font-size: .78rem; color: var(--app-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; margin: .15rem 0; overflow-wrap: anywhere; }
.stat .sub { font-size: .78rem; color: var(--app-muted); }
.stat .sub .delta { margin-right: .5rem; white-space: nowrap; }
.delta-good { color: var(--app-good); }
.delta-bad { color: var(--app-bad); }
.delta-flat { color: var(--app-muted); }

/* link state badges */
.badge-link { font-weight: 600; font-size: .72rem; padding: .3em .6em; border-radius: .5rem; letter-spacing: .01em; }
.badge-link-ok { background: #dcf3e5; color: #12633a; }
.badge-link-collecting { background: #dde9fb; color: #1f4fb0; }
.badge-link-lost, .badge-link-fb_action, .badge-link-no_access { background: #fbdcdc; color: #8f1d1d; }
.badge-link-paused, .badge-link-disabled { background: #e9ebef; color: #4b5563; }
.badge-link-disabled_platform { background: #fbe9cf; color: #7d4a00; }
.badge-status { font-weight: 500; font-size: .72rem; background: #eef0f3; color: #4b5563; }
.badge-status-ACTIVE { background: #dcf3e5; color: #12633a; }
.badge-status-PAUSED, .badge-status-CAMPAIGN_PAUSED, .badge-status-ADSET_PAUSED { background: #e9ebef; color: #4b5563; }
.badge-status-DELETED, .badge-status-ARCHIVED, .badge-status-DISAPPROVED, .badge-status-WITH_ISSUES { background: #fbe9cf; color: #7d4a00; }

/* tables */
.table { --bs-table-bg: var(--app-surface); }
.table > :not(caption) > * > * { padding: .5rem .6rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--app-muted); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--app-border); }
.table-responsive { border: 1px solid var(--app-border); border-radius: .75rem; background: var(--app-surface); box-shadow: var(--app-shadow); }
.table-responsive > .table { margin-bottom: 0; }
table.metrics td.text-end, table.metrics th.text-end { text-align: right; white-space: nowrap; }
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--app-primary); }
.th-sort.active { color: var(--app-primary); }
.table-dense { font-size: .85rem; }
.table-dense > :not(caption) > * > * { padding: .35rem .5rem; }
.cell-wrap { max-width: 320px; overflow-wrap: anywhere; white-space: normal; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

/* account cards */
.account-card .name { font-weight: 600; font-size: 1.02rem; }
.account-card .id { color: var(--app-muted); font-size: .8rem; }
.account-card .metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .75rem; margin-top: .75rem; }
.account-card .metrics .k { font-size: .74rem; color: var(--app-muted); text-transform: uppercase; letter-spacing: .04em; }
.account-card .metrics .v { font-weight: 600; }
.state-note { font-size: .85rem; }

/* findings */
.finding { border-left: 4px solid var(--app-amber); }
.finding.finding-rising_star { border-left-color: var(--app-good); }
.finding.finding-delivery_stopped, .finding.finding-conversions_drop, .finding.finding-spend_no_result { border-left-color: var(--app-bad); }
.finding .rule { font-weight: 600; }
.finding .summary { font-size: .95rem; }
.finding dl.values { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .75rem; font-size: .82rem; margin: .5rem 0 0; }
.finding dl.values dt { color: var(--app-muted); font-weight: 500; }
.finding dl.values dd { margin: 0; }
.explanation { background: var(--app-primary-soft); border-radius: .5rem; padding: .75rem 1rem; font-size: .93rem; }

/* chart */
.chart-box { position: relative; height: 280px; }
@media (max-width: 767px) { .chart-box { height: 220px; } }

/* period picker */
.period-form .form-control { max-width: 160px; }
.period-form .btn-group .btn { font-size: .85rem; }

/* prose pages */
.prose { max-width: 800px; }
.prose h2 { margin-top: 1.75rem; }
.prose p, .prose li { line-height: 1.6; }
.legal-note { background: #fff7e6; border: 1px solid #f3dcae; border-radius: .5rem; padding: .25rem .5rem; font-size: .85rem; }

/* landing */
.hero { padding: 3rem 0 2rem; }
.hero h1 { font-size: 2.2rem; font-weight: 700; }
.hero .lead { font-size: 1.15rem; color: #3b4250; max-width: 640px; }
.feature .icon { width: 42px; height: 42px; border-radius: .6rem; background: var(--app-primary-soft); color: var(--app-primary); display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; }

/* consent screen */
.consent { max-width: 640px; margin: 3rem auto; }

/* admin */
.admin-nav .nav-link { padding: .35rem .7rem; font-size: .9rem; border-radius: .5rem; color: #3b4250; }
.admin-nav .nav-link.active { background: var(--app-primary-soft); color: var(--app-primary); font-weight: 600; }
.key-once { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; word-break: break-all; }

/* misc */
.empty { text-align: center; color: var(--app-muted); padding: 2.5rem 1rem; }
.empty .bi { font-size: 2rem; display: block; margin-bottom: .5rem; }
footer.app-footer { border-top: 1px solid var(--app-border); color: var(--app-muted); font-size: .85rem; padding: 1.25rem 0; margin-top: 2rem; background: var(--app-surface); }
footer.app-footer a { color: var(--app-muted); text-decoration: none; margin-right: 1rem; }
footer.app-footer a:hover { color: var(--app-text); }
pre.spec { background: #f0f2f5; border-radius: .5rem; padding: .75rem; font-size: .8rem; margin: 0; white-space: pre-wrap; }
.usage .progress { height: .5rem; }
