/* InstaStat — application styles (Bootstrap 5 extension). */
:root,
[data-bs-theme="light"] {
  --is-primary: #0ea5b7;
  --is-primary-rgb: 14, 165, 183;
  --is-primary-dark: #0b8494;
  --is-accent: #f2844b;
  --is-danger: #e5482d;
  --is-success: #2f9e44;
  --is-warning: #f59e0b;
  --is-surface: #ffffff;
  --is-bg: #f4f7f9;
  --is-sidebar: #ffffff;
  --is-border: #e3e9ee;
  --is-muted: #6b7a88;
  --is-soft: #f7fbfc;
  --bs-primary: var(--is-primary);
  --bs-primary-rgb: var(--is-primary-rgb);
  --bs-link-color: var(--is-primary-dark);
  --bs-link-color-rgb: 11, 132, 148;
  --bs-link-hover-color: #086b78;
  --bs-body-bg: var(--is-bg);
  --bs-border-color: var(--is-border);
}
[data-bs-theme="dark"] {
  --is-surface: #161d24;
  --is-bg: #0e1418;
  --is-sidebar: #121920;
  --is-border: #26313b;
  --is-muted: #93a3b1;
  --is-soft: #1a232b;
  --bs-body-bg: var(--is-bg);
  --bs-border-color: var(--is-border);
  --bs-link-color: #4fd1e0;
  --bs-link-color-rgb: 79, 209, 224;
  --bs-link-hover-color: #7fe0eb;
}

body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; }
.btn-primary { --bs-btn-bg: var(--is-primary); --bs-btn-border-color: var(--is-primary); --bs-btn-hover-bg: var(--is-primary-dark); --bs-btn-hover-border-color: var(--is-primary-dark); --bs-btn-active-bg: var(--is-primary-dark); --bs-btn-disabled-bg: var(--is-primary); --bs-btn-disabled-border-color: var(--is-primary); }
.btn-outline-primary { --bs-btn-color: var(--is-primary-dark); --bs-btn-border-color: var(--is-primary); --bs-btn-hover-bg: var(--is-primary); --bs-btn-hover-border-color: var(--is-primary); --bs-btn-active-bg: var(--is-primary-dark); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #4fd1e0; }
.text-primary { color: var(--is-primary) !important; }
.bg-primary { background-color: var(--is-primary) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--is-primary); box-shadow: 0 0 0 .2rem rgba(var(--is-primary-rgb), .2); }
.form-check-input:checked { background-color: var(--is-primary); border-color: var(--is-primary); }
.card { --bs-card-bg: var(--is-surface); --bs-card-border-color: var(--is-border); border-radius: 14px; }
.table { --bs-table-bg: transparent; }
.skip-link { position: absolute; z-index: 2000; top: .5rem; left: .5rem; background: var(--is-surface); padding: .5rem 1rem; border-radius: 8px; }

/* Brand */
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--is-primary), #22c3d6); color: #fff; font-size: 1.1rem; flex: none; }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 256px; flex: none; background: var(--is-sidebar); border-right: 1px solid var(--is-border); display: flex; flex-direction: column; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
.sidebar-brand { display: flex; align-items: center; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid var(--is-border); }
.sidebar-brand a { color: var(--bs-body-color); }
.sidebar-brand small { color: var(--is-muted); font-size: .72rem; }
.sidebar-nav { padding: .75rem .6rem; flex: 1; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--bs-body-color); padding: .55rem .75rem; border-radius: 9px; font-size: .92rem; }
.sidebar-nav .nav-link i { font-size: 1.05rem; color: var(--is-muted); width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--is-soft); }
.sidebar-nav .nav-link.active { background: rgba(var(--is-primary-rgb), .12); color: var(--is-primary-dark); font-weight: 600; }
[data-bs-theme="dark"] .sidebar-nav .nav-link.active { color: #4fd1e0; }
.sidebar-nav .nav-link.active i { color: inherit; }
.sidebar-heading { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--is-muted); padding: 1rem .75rem .4rem; }
.sidebar-foot { padding: .75rem 1.1rem; color: var(--is-muted); border-top: 1px solid var(--is-border); }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: color-mix(in srgb, var(--is-bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--is-border); }
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.5rem; max-width: 1400px; width: 100%; }
@media (max-width: 575.98px) { .app-content { padding: 1rem; } .topbar { padding: .6rem 1rem; } }
.btn-icon { width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--is-border); background: var(--is-surface); color: var(--bs-body-color); }
.btn-user { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--is-border); background: var(--is-surface); border-radius: 10px; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: var(--is-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; }

/* Auth */
.auth-body { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, rgba(var(--is-primary-rgb), .14), transparent), var(--is-bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 440px; }

/* Install wizard */
.install-steps { display: flex; list-style: none; padding: 0; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.install-steps li { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--is-muted); }
.install-steps li span { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--is-border); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; }
.install-steps li.active { color: var(--bs-body-color); font-weight: 600; }
.install-steps li.active span { background: var(--is-primary); color: #fff; border-color: var(--is-primary); }
.install-steps li.done span { background: var(--is-success); color: #fff; border-color: var(--is-success); }

/* Stat cards */
.stat-card { padding: 1.1rem 1.2rem; height: 100%; }
.stat-card .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--is-muted); }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; }
.stat-card .stat-sub { font-size: .8rem; color: var(--is-muted); }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--is-primary-rgb), .12); color: var(--is-primary); font-size: 1.2rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: .9rem; }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 220px; }

/* Category badges */
.cat-badge { background: color-mix(in srgb, var(--cat) 14%, transparent); color: color-mix(in srgb, var(--cat) 80%, var(--bs-body-color)); border: 1px solid color-mix(in srgb, var(--cat) 35%, transparent); font-weight: 600; }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cat); margin-right: .4rem; }

/* Fitness score blocks (mirrors the report design) */
.score-block { border-left: 4px solid var(--band, var(--is-primary)); padding: 1.25rem 1.25rem 1.25rem 1.5rem; }
.score-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.score-head h3 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.score-num { font-size: 1.5rem; font-weight: 700; color: var(--band); }
.band-pill { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; background: color-mix(in srgb, var(--band) 14%, transparent); color: var(--band); }
.band-excellent { --band: #2f9e44; }
.band-good { --band: #0ea5b7; }
.band-average { --band: #f2844b; }
.band-needs_improvement { --band: #e5482d; }
.band-na { --band: #94a3b8; }
.score-ring { --val: 0; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--band) calc(var(--val) * 1%), color-mix(in srgb, var(--band) 14%, transparent) 0); flex: none; }
.score-ring::after { content: attr(data-label); width: 88px; height: 88px; border-radius: 50%; background: var(--is-surface); display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; color: var(--band); }
.callout { border: 1px solid color-mix(in srgb, var(--band, var(--is-primary)) 25%, transparent); background: color-mix(in srgb, var(--band, var(--is-primary)) 6%, transparent); border-radius: 10px; padding: .8rem 1rem; font-size: .92rem; }
.guidance-label { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--is-muted); }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: var(--is-soft); border: 1px dashed var(--is-border); border-radius: 8px; padding: .5rem .75rem; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 70px; gap: .75rem; align-items: center; padding: .45rem .5rem; border-radius: 8px; }
.bar-row.best { background: rgba(124, 92, 246, .08); }
.bar-track { height: 10px; border-radius: 999px; background: var(--is-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--is-accent); }
.bar-row.best .bar-fill { background: #7c5cf6; }

/* Tables */
.table-responsive { border-radius: 12px; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--is-muted); font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.profile-cell { display: flex; align-items: center; gap: .6rem; min-width: 180px; }
.profile-pic { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--is-soft); flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--is-muted); font-weight: 600; font-size: .8rem; }
.sortable { cursor: pointer; user-select: none; }
.sortable .bi { opacity: .45; }
.sortable.sorted .bi { opacity: 1; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--is-muted); }
.empty-state .bi { font-size: 2.5rem; display: block; margin-bottom: .5rem; color: color-mix(in srgb, var(--is-primary) 60%, var(--is-muted)); }
.loading-overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--is-surface) 70%, transparent); display: flex; align-items: center; justify-content: center; z-index: 5; border-radius: inherit; }
.source-note { font-size: .78rem; color: var(--is-muted); }
.kv dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--is-muted); font-weight: 600; }
.kv dd { margin-bottom: .75rem; }
.reason-list li { margin-bottom: .3rem; }
.help-content h2 { font-size: 1.25rem; margin-top: 1.5rem; }
.help-content h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.help-content code { word-break: break-word; }
.pair-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 2rem; letter-spacing: .3em; font-weight: 700; }
.progress { height: 12px; border-radius: 999px; }
.progress-bar { background-color: var(--is-primary); }
.ai-output { white-space: pre-wrap; line-height: 1.6; }
.nav-tabs .nav-link.active { font-weight: 600; }

@media print {
  .sidebar, .topbar, .no-print, #flash-area { display: none !important; }
  .app-content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none !important; }
}
