:root {
  --bg: #0f1115;
  --card: #181c23;
  --card-2: #202632;
  --text: #f3f4f6;
  --muted: #b9c0cc;
  --accent: #d93025;
  --line: #2d3442;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 42px;
}

.subhead {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  font-size: 14px;
}

input, select, textarea, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 15px;
}

input, select, textarea {
  background: var(--card-2);
  color: var(--text);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 700;
  margin-top: 16px;
  cursor: pointer;
}

button.secondary {
  width: auto;
  background: transparent;
  border: 1px solid var(--line);
}

.hidden {
  display: none;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.tab {
  width: auto;
  background: transparent;
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--accent);
}

.auth-form {
  max-width: 420px;
}

.result-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  background: #141922;
}

.result-block h4 {
  margin: 0 0 8px;
}

.history-item {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

a.pdf-link {
  color: #ffffff;
  text-decoration: underline;
}

.chart-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 16px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 340px;
}

.chart-container-sm {
  height: 280px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}

.help-icon:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.help-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e2330;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  width: 300px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  pointer-events: none;
}

.help-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e2330;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
}

.status-bar.scanned {
  background: rgba(52, 168, 83, 0.08);
  border-color: rgba(52, 168, 83, 0.3);
}

.status-bar.overdue {
  background: rgba(217, 48, 37, 0.08);
  border-color: rgba(217, 48, 37, 0.3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green {
  background: #34a853;
  box-shadow: 0 0 6px rgba(52, 168, 83, 0.5);
}

.status-dot.red {
  background: #d93025;
  box-shadow: 0 0 6px rgba(217, 48, 37, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.streak-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.streak-flame {
  font-size: 18px;
}

.streak-divider {
  color: var(--line);
}

.reminder-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
  font-weight: 400;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.reminder-time-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reminder-time-row label {
  margin: 0;
  white-space: nowrap;
}

.reminder-time-row select {
  width: 140px;
}

.reminder-time-row button {
  margin-top: 0;
}

#reminderPreview {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

#reminderPreview iframe {
  width: 100%;
  height: 480px;
  border: none;
  background: #0f1115;
}

.fgd-card {
  background: var(--card);
}

.fgd-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 20px;
}

.fgd-score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--line);
  flex-shrink: 0;
}

.fgd-score-circle.low { border-color: #34a853; }
.fgd-score-circle.moderate { border-color: #fbbc04; }
.fgd-score-circle.high { border-color: #ff6d01; }
.fgd-score-circle.severe { border-color: #d93025; }

.fgd-number {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.fgd-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.fgd-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.fgd-meta h3 {
  margin: 0;
  font-size: 20px;
}

.momentum-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.momentum-improving {
  background: rgba(52,168,83,0.15);
  color: #34a853;
  border: 1px solid rgba(52,168,83,0.3);
}

.momentum-declining {
  background: rgba(217,48,37,0.15);
  color: #d93025;
  border: 1px solid rgba(217,48,37,0.3);
}

.momentum-stable {
  background: rgba(251,188,4,0.12);
  color: #fbbc04;
  border: 1px solid rgba(251,188,4,0.25);
}

.fgd-context-line {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 8px;
  line-height: 1.5;
}

.fgd-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.fgd-top-cats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.fgd-top-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(217, 48, 37, 0.12);
  color: #ff6d01;
  border: 1px solid rgba(217, 48, 37, 0.25);
}

.fgd-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fgd-cat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fgd-cat-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.fgd-cat-bar {
  height: 8px;
  background: var(--card-2);
  border-radius: 4px;
  overflow: hidden;
}

.fgd-cat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.fgd-cat-fill.low { background: #34a853; }
.fgd-cat-fill.moderate { background: #fbbc04; }
.fgd-cat-fill.high { background: #ff6d01; }
.fgd-cat-fill.severe { background: #d93025; }

/* ─── STATS BAR ─────────────────────────────────────────────────────────────── */

.stats-bar {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 24px;
  margin-bottom: 20px;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

/* ─── PRIOR COMMITMENT CHECK ─────────────────────────────────────────────────── */

.commitment-check-box {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 3px solid #fbbc04;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.commitment-check-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.commitment-check-label strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-top: 4px;
}

/* ─── CONSTRAINT RESOLUTION TRACKER ──────────────────────────────────────────── */

.constraint-tracker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.tracker-col {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.tracker-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.tracker-value {
  font-size: 15px;
  font-weight: 700;
  color: #d93025;
  line-height: 1.4;
}

.tracker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tracker-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(66,133,244,0.12);
  color: #4285f4;
  border: 1px solid rgba(66,133,244,0.2);
}

.resolved-tag {
  background: rgba(52,168,83,0.12);
  color: #34a853;
  border: 1px solid rgba(52,168,83,0.25);
}

.tracker-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ─── TREND STORYTELLING ─────────────────────────────────────────────────────── */

.trend-story {
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
  margin-bottom: 14px;
  background: rgba(217,48,37,0.06);
  border-radius: 0 8px 8px 0;
}

.trend-story p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.trend-story:empty {
  display: none;
}

/* ─── OPERATING HISTORY ──────────────────────────────────────────────────────── */

.history-entry {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--card-2);
  transition: border-color 0.2s;
}

.history-entry:hover {
  border-color: #3d4558;
}

.history-entry-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.history-week {
  font-size: 14px;
  font-weight: 700;
}

.history-date {
  font-size: 12px;
  color: var(--muted);
}

.history-fgd-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.history-fgd-badge.low { background: rgba(52,168,83,0.15); color: #34a853; }
.history-fgd-badge.moderate { background: rgba(251,188,4,0.12); color: #fbbc04; }
.history-fgd-badge.high { background: rgba(255,109,1,0.12); color: #ff6d01; }
.history-fgd-badge.severe { background: rgba(217,48,37,0.12); color: #d93025; }

.history-constraints {
  font-size: 13px;
  margin-bottom: 6px;
}

.history-primary {
  font-weight: 600;
  color: var(--text);
}

.history-secondary {
  color: var(--muted);
}

.history-top-cats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.history-cat-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: rgba(161,66,244,0.1);
  color: #a142f4;
  border: 1px solid rgba(161,66,244,0.2);
}

.history-commitment {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.commitment-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.commitment-status-tag {
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.commitment-status-tag.yes { background: rgba(52,168,83,0.15); color: #34a853; }
.commitment-status-tag.partial { background: rgba(251,188,4,0.12); color: #fbbc04; }
.commitment-status-tag.no { background: rgba(217,48,37,0.12); color: #d93025; }

.history-shifts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.shift-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ─── PREVIOUS WEEKS (ENHANCED) ──────────────────────────────────────────────── */

.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--card-2);
}

.history-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.prev-commitment {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pdf-link.small {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
}

/* ─── RESULT COMMITMENT BLOCK ────────────────────────────────────────────────── */

.commitment-block {
  border-left: 3px solid #fbbc04;
  background: rgba(251,188,4,0.06);
  border-radius: 0 8px 8px 0;
  padding-left: 12px;
}

.commitment-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── BASIC HUMAN NEEDS ──────────────────────────────────────────────────────── */

.needs-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--warning, #b45309);
  border-left: 4px solid var(--warning, #b45309);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.needs-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.needs-banner-icon {
  color: var(--warning, #b45309);
  flex-shrink: 0;
  margin-top: 2px;
}

.needs-banner-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.needs-banner-text strong {
  font-size: 0.9rem;
  color: var(--text);
}

.needs-banner-text span {
  font-size: 0.82rem;
  color: var(--muted);
}

.needs-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-primary-sm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary-sm:hover { opacity: 0.88; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost-sm {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost-sm:hover { color: var(--text); border-color: var(--text); }

/* Assessment Card */
.needs-assessment {
  padding: 24px;
  margin-bottom: 16px;
}

.needs-assessment-header {
  margin-bottom: 24px;
}

.needs-assessment-header h3 {
  margin: 0 0 6px 0;
  font-size: 1.05rem;
}

.needs-assessment-subtitle {
  font-size: 0.83rem;
  color: var(--muted);
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.needs-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.needs-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.needs-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.needs-question-area {
  margin-bottom: 20px;
}

.needs-question-text {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin: 0 0 18px 0;
}

/* Likert Scale */
.needs-likert {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.needs-likert-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--background);
  text-align: center;
  user-select: none;
}

.needs-likert-option input[type=radio] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.needs-likert-label {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.3;
}

.needs-likert-option:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.needs-likert-option.selected {
  border-color: var(--accent);
  background: var(--surface);
}

.needs-likert-option.selected .needs-likert-label {
  color: var(--accent);
  font-weight: 600;
}

.needs-assessment-nav {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
}

.needs-error {
  color: #c0392b;
  font-size: 0.82rem;
  margin-top: 10px;
  text-align: right;
}

/* Profile Card */
.needs-profile-card {
  padding: 20px 24px;
  margin-bottom: 16px;
}

.needs-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.needs-profile-header h3 {
  margin: 0;
  font-size: 1rem;
}

.needs-profile-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.needs-profile-drivers {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.needs-driver-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
}

.needs-driver-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.needs-driver-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.needs-driver-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.needs-profile-summary {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.needs-score-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.needs-score-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.needs-score-bar-label {
  width: 100px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.needs-score-bar-label.primary {
  color: var(--accent);
  font-weight: 700;
}

.needs-score-bar-label.secondary {
  color: var(--text);
  font-weight: 600;
}

.needs-score-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.needs-score-bar-fill {
  height: 100%;
  background: var(--border);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.needs-score-bar-fill.primary {
  background: var(--accent);
}

.needs-score-bar-fill.secondary {
  background: var(--muted);
}

.needs-score-bar-val {
  width: 24px;
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .fgd-categories {
    grid-template-columns: 1fr;
  }

  .constraint-tracker-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    justify-content: flex-start;
    gap: 20px;
  }

  .needs-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .needs-banner-actions {
    width: 100%;
  }

  .needs-profile-drivers {
    flex-direction: column;
  }

  .needs-driver-divider {
    width: 100%;
    height: 1px;
  }

  .needs-score-bar-label {
    width: 80px;
  }

  .needs-likert {
    grid-template-columns: repeat(2, 1fr);
  }
}
