/* main.css — Kinetix design system */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0a0a0a;
  --surface: #141414;
  --border:  #1f1f1f;
  --accent:  #e8ff47;
  --text:    #f5f2ec;
  --muted:   #888888;
  --green:   #47ff8a;
  --amber:   #ffb347;
  --red:     #ff4747;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif;
       min-height: 100vh; }

/* Nav */
.nav { display: flex; align-items: center; justify-content: space-between;
       padding: 1rem 2rem; border-bottom: 1px solid var(--border); }
.nav-logo { font-family: 'Bebas Neue', sans-serif; font-size: 1.6rem;
             color: var(--accent); text-decoration: none; letter-spacing: 1px; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem;
               transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-coach { color: var(--text); font-weight: 500; font-size: 0.9rem; }
.nav-logout { color: var(--red) !important; }

/* Main content */
.main-content { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* Flash messages */
.flash-container { padding: 0 2rem; }
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash-error { background: rgba(255,71,71,0.15); border: 1px solid var(--red); color: var(--red); }
.flash-success { background: rgba(71,255,138,0.15); border: 1px solid var(--green); color: var(--green); }

/* Page header */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.page-header h1 { font-family: 'Bebas Neue', sans-serif; font-size: 2.5rem; letter-spacing: 1px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

/* Stats bar */
.stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
             padding: 1.25rem 1.5rem; }
.stat-alert { border-color: var(--red); background: rgba(255,71,71,0.08); }
.stat-value { display: block; font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem;
               color: var(--accent); }
.stat-alert .stat-value { color: var(--red); }
.stat-label { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

/* Client grid */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.client-card { background: var(--surface); border: 1px solid var(--border);
               border-radius: 10px; padding: 1.25rem; transition: border-color 0.2s; }
.client-card:hover { border-color: #333; }
.client-card.dot-red  { border-left: 3px solid var(--red); }
.client-card.dot-amber { border-left: 3px solid var(--amber); }
.client-card.dot-green { border-left: 3px solid var(--green); }
.client-card-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.dot-green  { background: var(--green); }
.dot-amber  { background: var(--amber); }
.dot-red    { background: var(--red); }
.dot-sm { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.client-name { font-weight: 600; font-size: 1rem; }
.client-prog { color: var(--muted); font-size: 0.8rem; }
.client-meta { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 0.75rem; }
.mini-bar-wrap { margin-bottom: 1rem; }
.mini-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 0.25rem; }
.mini-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.mini-bar-label { font-size: 0.75rem; color: var(--muted); }
.client-actions { display: flex; gap: 0.5rem; }

/* Buttons */
.btn-primary { display: block; width: 100%; padding: 0.875rem 1.5rem; background: var(--accent);
               color: #0a0a0a; border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif;
               font-size: 1rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn-primary:hover { opacity: 0.9; }
.btn-sm { display: inline-block; padding: 0.4rem 0.875rem; border: 1px solid var(--border);
           border-radius: 6px; color: var(--text); background: transparent; cursor: pointer;
           font-family: 'DM Sans', sans-serif; font-size: 0.82rem; text-decoration: none;
           transition: border-color 0.2s; white-space: nowrap; }
.btn-sm:hover { border-color: #444; }
.btn-accent { background: var(--accent); color: #0a0a0a; border-color: var(--accent); font-weight: 600; }
.btn-accent:hover { opacity: 0.9; border-color: var(--accent); }

/* Auth page */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.auth-box { width: 100%; max-width: 400px; }
.auth-logo { font-family: 'Bebas Neue', sans-serif; font-size: 3rem; color: var(--accent);
              text-align: center; letter-spacing: 2px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 2.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { font-size: 0.85rem; color: var(--muted); }
.auth-form input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
                    color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 1rem;
                    padding: 0.875rem 1rem; outline: none; transition: border-color 0.2s; }
.auth-form input:focus { border-color: var(--accent); }
.auth-message { text-align: center; padding: 1.5rem; background: var(--surface);
                 border: 1px solid var(--border); border-radius: 10px; }
.auth-message p:last-child { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }

/* Profile meta */
.profile-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted);
                 font-size: 0.9rem; margin-bottom: 2rem; }

/* Charts grid */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
              padding: 1.5rem; }
.chart-box h3 { font-family: 'Bebas Neue', sans-serif; font-size: 1.1rem; color: var(--muted);
                 letter-spacing: 1px; margin-bottom: 1rem; }

/* Sections */
.section { margin-bottom: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between;
                   margin-bottom: 1rem; }
.section-header h2 { font-family: 'Bebas Neue', sans-serif; font-size: 1.6rem; }

/* Narrative */
.narrative-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
                  padding: 1.5rem; line-height: 1.8; }

/* Table */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; padding: 0.75rem 1rem; color: var(--muted); font-weight: 500;
                  border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr.expandable { cursor: pointer; }
.data-table tr.expandable:hover td { background: var(--surface); }
.data-table tr.detail-row.hidden { display: none; }
.detail-content { padding: 1rem; background: var(--surface); border-radius: 8px;
                   display: flex; flex-direction: column; gap: 0.5rem; }
.ai-message { margin-top: 0.75rem; padding: 0.75rem; background: rgba(232,255,71,0.05);
               border: 1px solid rgba(232,255,71,0.2); border-radius: 6px; }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Alerts */
.filter-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab { padding: 0.4rem 1rem; border: 1px solid var(--border); border-radius: 100px;
        background: transparent; color: var(--muted); cursor: pointer; font-family: 'DM Sans', sans-serif;
        font-size: 0.85rem; transition: all 0.2s; }
.tab.active { background: var(--accent); color: #0a0a0a; border-color: var(--accent); font-weight: 600; }
.alerts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.alert-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
              padding: 1.25rem; display: flex; justify-content: space-between; align-items: flex-start;
              gap: 1rem; flex-wrap: wrap; }
.alert-at_risk { border-left: 3px solid var(--red); }
.alert-no_checkin { border-left: 3px solid var(--amber); }
.alert-client { font-weight: 600; color: var(--text); text-decoration: none; display: block;
                 margin-bottom: 0.25rem; }
.alert-client:hover { color: var(--accent); }
.alert-message { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.alert-meta { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.75rem;
          font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-active { background: rgba(71,255,138,0.15); color: var(--green); }
.badge-at_risk { background: rgba(255,71,71,0.15); color: var(--red); }
.badge-no_checkin { background: rgba(255,179,71,0.15); color: var(--amber); }
.badge-inactive { background: rgba(136,136,136,0.15); color: var(--muted); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex;
          align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal.hidden { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
              max-width: 640px; width: 100%; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center;
                 padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-family: 'Bebas Neue', sans-serif; font-size: 1.5rem; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.5rem;
               cursor: pointer; line-height: 1; }
.brief-content { padding: 1.5rem; line-height: 1.7; white-space: pre-wrap; font-size: 0.9rem; }

/* Empty state */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.empty-state h2 { font-family: 'Bebas Neue', sans-serif; font-size: 2rem; color: var(--text);
                   margin-bottom: 1rem; }
.empty-state code { display: inline-block; margin-top: 0.75rem; padding: 0.5rem 1rem;
                     background: var(--surface); border-radius: 6px; font-size: 0.85rem; color: var(--accent); }

/* Utility */
.text-red { color: var(--red); }
.text-muted { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 900px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .nav { padding: 1rem; }
  .main-content { padding: 1rem; }
}
