:root {
  --teal: #0f9b9b;
  --teal-dark: #0b7a7a;
  --ink: #10293b;
  --paper: #fdf8ec;
  --panel: #ffffff;
  --border: #d9e2e8;
  --accent: #2f7fb8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

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

.page-header { margin-bottom: 24px; position: relative; }
.header-top { display: flex; align-items: center; gap: 20px; margin-bottom: 10px; }
.site-logo { height: 80px; width: auto; flex-shrink: 0; }
.header-titles { display: flex; flex-direction: column; }
.eyebrow {
  color: var(--teal-dark);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
  margin: 0 0 4px;
}
h1 { margin: 0 0 8px; font-size: 32px; }
.subtitle { color: #4a5b68; margin: 0; }

.header-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logout-link {
  color: var(--accent);
  font-size: 14px;
}
.download-btn {
  font-size: 13px;
  padding: 8px 16px;
  text-decoration: none;
}

.content {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.chart-wrap {
  flex: 1 1 480px;
  min-width: 320px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px;
}

.chart-wrap svg { width: 100%; height: auto; display: block; }

.controls {
  flex: 1 1 320px;
  min-width: 280px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 24px;
}

.name-row {
  display: flex;
  gap: 12px;
  margin-bottom: 0;
}
.name-row > div {
  flex: 1 1 0;
  min-width: 0;
}
.name-row input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  margin-bottom: 16px;
}

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

.controls input[type="email"],
.controls input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  margin-bottom: 16px;
}

.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--teal); color: white; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.secondary { background: #eef4f7; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e2ebef; }
.btn.full-width { width: 100%; margin-top: 4px; }

.status-msg {
  min-height: 20px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--teal-dark);
  font-weight: 600;
}

.legend { margin-top: 20px; }
.legend h2 { font-size: 16px; margin-bottom: 10px; }
.legend ul { list-style: none; padding: 0; margin: 0; }
.legend li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.legend li span.val {
  font-weight: 700;
  color: var(--teal-dark);
}

/* Radar chart elements */
.grid-ring { fill: none; stroke: #cfe3e3; stroke-width: 1; }
.spoke-line { stroke: #b9cdd0; stroke-width: 1; }
.category-label {
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
}
.value-marker {
  fill: white;
  stroke: #9db3b8;
  stroke-width: 1.5;
  cursor: pointer;
}
.value-marker:hover { stroke: var(--teal); }
.value-marker.selected { fill: var(--teal); stroke: var(--teal-dark); }
.value-marker-label {
  font-size: 10px;
  fill: #4a5b68;
  text-anchor: middle;
  pointer-events: none;
}
.value-marker-label.selected { fill: white; }
.selection-polygon {
  fill: rgba(15, 155, 155, 0.18);
  stroke: var(--teal);
  stroke-width: 2;
}
.center-hub { fill: #e8f4f4; stroke: #cfe3e3; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 41, 59, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: 14px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal p { margin: 0 0 18px; font-size: 15px; line-height: 1.4; }
.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 340px;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.error-msg { color: #b3261e; font-size: 14px; margin-bottom: 12px; }

/* Report wheels */
.report-wheels {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}
.wheel-panel {
  flex: 1 1 380px;
  min-width: 300px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px 16px 16px;
  text-align: center;
}
.wheel-panel-title {
  font-size: 17px;
  margin: 0 0 4px;
}
.wheel-panel-subtitle {
  font-size: 13px;
  color: #4a5b68;
  margin: 0 0 12px;
  min-height: 18px;
}
.wheel-empty-msg {
  font-size: 14px;
  fill: #9db3b8;
  text-anchor: middle;
  font-style: italic;
}

/* Read-only reflection textareas on reports page */
#reportReflections textarea[readonly] {
  background: #f7fafa;
  color: #4a5b68;
  cursor: default;
}
#reportReflections textarea[readonly]:focus {
  outline: none;
  border-color: var(--border);
  box-shadow: none;
}

/* Reports table */
.section-title { font-size: 18px; margin: 28px 0 4px; }
.section-hint { font-size: 13px; color: #6b7c86; margin: 0 0 10px; }
.table-wrap { overflow-x: auto; background: var(--panel); border-radius: 16px; border: 1px solid var(--border); margin-bottom: 8px; }
.reports-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.reports-table th, .reports-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.reports-table th { background: #f3f8f8; font-weight: 700; }
.empty-row { text-align: center; color: #6b7c86; padding: 24px; }
.select-prompt { font-size: 14px; }
td.reflection-cell { white-space: pre-wrap; min-width: 200px; max-width: 320px; font-size: 13px; line-height: 1.5; vertical-align: top; }
.clickable-row { cursor: pointer; transition: background 0.1s ease; }
.clickable-row:hover { background: #f0f9f9; }
.row-selected { background: #e0f4f4 !important; outline: 2px solid var(--teal); outline-offset: -2px; }

/* Reflections section */
.reflections-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.reflections-title {
  font-size: 20px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.optional-tag {
  font-size: 12px;
  font-weight: 600;
  color: #6b7c86;
  background: #eef4f7;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.reflections-subtitle {
  color: #4a5b68;
  font-size: 14px;
  margin: 0 0 24px;
}
.reflection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.reflection-item label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--ink);
}
.reflection-item textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  background: var(--panel);
  color: var(--ink);
  transition: border-color 0.15s ease;
}
.reflection-item textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 155, 155, 0.12);
}

/* Report link in header */
.report-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.report-link:hover { text-decoration: underline; }

/* Save button footer below reflections */
.reflections-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding: 28px 20px;
  border-top: 2px solid var(--teal);
  background: linear-gradient(to bottom, #f3fbfb, var(--paper));
  border-radius: 12px;
}
.reflections-footer-hint {
  margin: 0;
  font-size: 14px;
  color: #4a5b68;
}
.btn-lg {
  padding: 14px 36px;
  font-size: 16px;
}

/* ── Mobile responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  .page { padding: 20px 14px 48px; }

  /* Header: stack logo + titles vertically, smaller logo */
  .header-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .site-logo { height: 52px; }
  h1 { font-size: 22px; }
  .eyebrow { font-size: 11px; }
  .subtitle { font-size: 13px; }

  /* Reports page: un-float the action links so they sit below the title */
  .header-actions {
    position: static;
    flex-wrap: wrap;
    margin-top: 10px;
    gap: 10px;
  }

  /* Name row: stack first/last name fields */
  .name-row { flex-direction: column; gap: 0; }

  /* Reflections grid: single column */
  .reflection-grid { grid-template-columns: 1fr; }

  /* Wheel + controls: explicit vertical stack, tighter spacing */
  .content { flex-direction: column; gap: 16px; }
  .wheel-panel { min-width: 0; }
  .chart-wrap { min-width: 0; padding: 8px; }
  .controls { min-width: 0; padding: 16px; }

  /* Buttons: full-width stacked for easy tapping */
  .button-row { flex-direction: column; }
  .button-row .btn { width: 100%; text-align: center; }

  /* SVG wheel labels: scale up in SVG coordinate space so they
     stay readable when the 640×640 viewBox renders at ~320–360px */
  .category-label { font-size: 22px; }
  .value-marker-label { font-size: 14px; }
}

@media (max-width: 400px) {
  h1 { font-size: 19px; }
  .site-logo { height: 44px; }
  .category-label { font-size: 26px; }
}
