/* ==========================================================================
   TIPS — Full Visual Redesign v3
   Wider admin layout, clearer table rows, status pills, fixed imbalance.
   ========================================================================== */

:root {
  --navy: #14213d;
  --navy-deep: #0b1526;
  --navy-soft: #29425e;
  --gold: #c9973b;
  --gold-deep: #a67c2a;
  --gold-soft: #f5edde;
  --cream: #fdfcfa;
  --bg: #f0ede8;
  --card: #ffffff;
  --text: #1e1b16;
  --muted: #8a7f71;
  --border: #e2dbce;
  --border-light: #f0ece4;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --success: #1e6b3f;
  --success-bg: #e6f4ea;
  --info: #2c5a7d;
  --info-bg: #e6eff7;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 4px 16px rgba(20, 33, 61, 0.10), 0 1px 4px rgba(20, 33, 61, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 33, 61, 0.16), 0 4px 12px rgba(20, 33, 61, 0.10);
  --shadow-sm: 0 1px 3px rgba(20, 33, 61, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout - wider for admin, narrower for public ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}
.narrow { max-width: 460px; }

/* Admin uses the full width so stat cards + tables breathe */
.admin.container { max-width: 1140px; }

/* ---------- Headings ---------- */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--navy-deep);
}
h1 { font-size: 1.75rem; margin: 0 0 .15rem 0; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .75rem 0; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; border: 0; padding: 0; }
h3 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 .5rem 0; }
.lead { font-size: 1rem; color: var(--muted); }

/* ---------- Hero (public landing) ---------- */
.hero {
  text-align: center;
  padding: 4rem 2rem 3rem;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--navy), var(--gold));
}
.hero h1 { font-size: 2rem; }
.start-form { margin: 2rem auto 0; max-width: 340px; text-align: left; }

/* ---------- Form elements ---------- */
input, select, textarea, .form-control {
  width: 100%;
  padding: .7rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  background: var(--cream);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus, .form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 151, 59, 0.15);
  background: #fff;
}
label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--navy-soft);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 600; font-size: .8rem; margin-bottom: .35rem; color: var(--navy-soft); text-transform: uppercase; letter-spacing: .04em; }
.help-text { font-size: .85rem; color: var(--muted); margin: .35rem 0 .75rem 0; line-height: 1.5; }
code {
  background: var(--border-light);
  padding: .12rem .4rem;
  border-radius: 4px;
  font-size: .82rem;
  color: var(--navy-soft);
  border: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--navy);
  text-decoration: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all .12s ease;
}
.btn:hover {
  border-color: var(--navy-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:hover {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
  color: #fff;
  box-shadow: 0 4px 12px rgba(20, 33, 61, 0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-secondary:hover {
  background: var(--cream);
  border-color: var(--navy-soft);
  color: var(--navy);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #8e1f19;
  border-color: #8e1f19;
}

.btn-outline {
  background: transparent;
  border-color: var(--navy);
  color: var(--navy);
}
.btn-outline:hover {
  background: var(--navy);
  color: #fff;
}

.btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.btn-gold:hover {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: #fff;
}

.btn-sm { padding: .32rem .65rem; font-size: .76rem; border-radius: 7px; }
.btn-lg { padding: .75rem 1.35rem; font-size: .95rem; border-radius: var(--radius); }
.muted { color: var(--muted); }
.inline { display: inline; }

/* ---------- Status alerts ---------- */
.error, .notice, .success {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  font-size: .9rem;
  line-height: 1.4;
}
.error { background: var(--danger-bg); color: var(--danger); border-left: 4px solid var(--danger); }
.notice { background: var(--info-bg); color: var(--info); border-left: 4px solid var(--info); }
.success { background: var(--success-bg); color: var(--success); border-left: 4px solid var(--success); }

/* ---------- Admin header bar ---------- */
.admin .admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.admin .admin-header h1 { font-size: 1.35rem; }

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat {
  background: var(--card);
  padding: 1.25rem 1rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: box-shadow .15s ease, transform .12s ease;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat strong { display: block; font-size: 2.2rem; font-weight: 800; color: var(--navy-deep); letter-spacing: -0.03em; line-height: 1.1; margin-bottom: .1rem; }
.stat span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* ---------- Admin nav ---------- */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}
.admin-nav .btn {
  background: var(--card);
  border: 1.5px solid var(--border-light);
  color: var(--navy);
  font-weight: 600;
  font-size: .82rem;
  padding: .5rem .95rem;
}
.admin-nav .btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  border: 1px solid var(--border-light);
  position: relative;
}
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.card-accent { border-left: 4px solid var(--gold); }
.card-danger { border-left: 4px solid var(--danger); }

/* ---------- Tables – the main visual fix ---------- */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  border: 1px solid var(--border-light);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td { padding: .75rem .85rem; text-align: left; border-bottom: 1px solid var(--border-light); }
th {
  background: var(--card);
  color: var(--navy-soft);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  padding-top: .85rem;
  padding-bottom: .85rem;
  border-bottom: 2px solid var(--border);
}
/* Zebra striping — every row gets a distinct base */
tbody tr {
  transition: background-color .1s ease;
}
tbody tr:nth-child(even) {
  background: var(--cream);
}
tbody tr:hover {
  background: var(--gold-soft);
}
tbody tr:last-child td { border-bottom: none; }

/* ---------- Status pills ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.4;
}
.status-active {
  background: var(--success-bg);
  color: var(--success);
}
.status-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- Progress (survey) ---------- */
.progress-wrap { display: flex; align-items: center; gap: 1rem; margin: 1.75rem 0; }
.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--navy-soft), var(--navy)); transition: width .3s; }
#progress-text { font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ---------- Survey questions ---------- */
.question-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.question-block legend { font-weight: 600; margin-bottom: .85rem; padding: 0; font-size: .95rem; }
.qnum { color: var(--gold-deep); font-weight: 700; margin-right: .35rem; }
.likert { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; }
.choice {
  display: block;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .4rem;
  text-align: center;
  cursor: pointer;
  transition: all .12s ease;
  font-size: .78rem;
}
.choice input { display: block; margin: 0 auto .25rem; accent-color: var(--navy); }
.choice:hover { border-color: var(--navy-soft); background: var(--cream); }
.choice:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); font-weight: 700; }
.check { display: block; margin: .5rem 0; }
.check input { width: auto; display: inline; margin-right: .4rem; accent-color: var(--navy); vertical-align: middle; }
.check input[type="checkbox"] { min-width: 18px; min-height: 18px; }

/* ---------- Snapshot / thank-you ---------- */
.snapshot { background: var(--card); padding: 1.75rem; border-radius: var(--radius-xl); box-shadow: var(--shadow); margin: 1.75rem 0; position: relative; }
.snapshot::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--gold), var(--navy), var(--gold)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.score-circle { text-align: center; margin-bottom: 1.25rem; }
.score-big { font-size: 3.5rem; font-weight: 800; color: var(--navy-deep); letter-spacing: -0.03em; }
.score-table th, .score-table td { padding: .6rem; border-bottom: 1px solid var(--border-light); text-align: left; }
.score-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; background: transparent; border-bottom: 2px solid var(--border); }

/* ---------- Section badge ---------- */
.section-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .75rem;
}
.section-badge::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: .5rem;
}

/* ---------- Reports page ---------- */
@media print { .no-print { display: none; } body { background: #fff; color: #000; } .report { box-shadow: none; } }
.report { background: var(--card); padding: 2rem; border-radius: var(--radius-xl); box-shadow: var(--shadow); margin-top: 1rem; position: relative; }
.report::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--gold), var(--navy), var(--gold)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.report h2 { font-size: 1.3rem; text-transform: none; letter-spacing: -0.02em; color: var(--navy-deep); padding-bottom: .5rem; border-bottom: 2px solid var(--gold); }
.chart-row { display:flex; justify-content:space-between; align-items:center; padding:.6rem 0; border-bottom:1px solid var(--border-light); }
.chart-label { width:38%; font-weight: 500; font-size: .9rem; }
.chart-score { width:10%; text-align:center; font-weight: 700; color: var(--navy-deep); font-size: .9rem; }
.chart-bar-bg { width:47%; background: var(--border-light); border-radius:5px; height: 18px; position: relative; }
.bar { height:100%; background: linear-gradient(90deg, var(--navy-soft), var(--navy)); border-radius:5px; transition: width .5s ease; }
.priority { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin:1rem 0; }
.box { border:1px solid var(--border); padding:1.1rem 1.25rem; border-radius: var(--radius); background: var(--cream); }
.box strong { color: var(--navy-deep); }

/* Shade Shift Map */
.shift-map-wrap { position: relative; width: 100%; max-width: 600px; margin: 1.75rem auto; }
.shift-grid { position: relative; width: 100%; aspect-ratio: 1; background: linear-gradient(to top right, #b3261e 0%, #c9973b 50%, #1e6b3f 100%); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.shift-dot { position: absolute; width: 22px; height: 22px; background: #fff; border: 2.5px solid var(--navy-deep); border-radius: 50%; transform: translate(-50%, -50%); cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: var(--navy-deep); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.shift-dot:hover { transform: translate(-50%, -50%) scale(1.3); z-index: 3; }
.shift-label { position: absolute; transform: translate(-50%, 10px); font-size: 10px; font-weight: 600; white-space: nowrap; color: var(--navy-deep); text-shadow: 0 0 3px #fff, 0 0 3px #fff; z-index: 3; pointer-events: none; }
.shift-axis-x { position: absolute; bottom: -28px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.shift-axis-y { position: absolute; top: 0; bottom: 0; left: -28px; display: flex; align-items: center; font-size: 11px; color: var(--muted); writing-mode: vertical-lr; transform: rotate(180deg); }

/* Distribution bar chart modal */
.dist-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(20,33,61,0.4); z-index: 100; justify-content: center; align-items: center; backdrop-filter: blur(2px); }
.dist-modal { background: var(--card); padding: 2rem; border-radius: var(--radius-xl); max-width: 480px; width: 90%; position: relative; box-shadow: var(--shadow-lg); }
.dist-close { position: absolute; top: 14px; right: 16px; font-size: 1.4rem; cursor: pointer; color: var(--muted); background: none; border: none; transition: color .12s ease; }
.dist-close:hover { color: var(--navy-deep); }
.dist-chart { display: flex; align-items: flex-end; gap: 8px; height: 200px; margin: 1rem 0; padding-bottom: 24px; position: relative; }
.dist-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; position: relative; }
.dist-bar { width: 100%; max-width: 50px; border-radius: 5px 5px 0 0; min-height: 2px; transition: height .3s; background: var(--navy-soft); }
.dist-bar-label { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); font-weight: 500; }
.dist-bar-count { position: absolute; top: -18px; font-size: 11px; color: var(--text); font-weight: 700; }
.dist-stats { font-size: .82rem; color: var(--muted); margin-top: .5rem; text-align: center; }
.dim-link { cursor: pointer; color: var(--navy-soft); font-weight: 600; }
.dim-link:hover { color: var(--gold-deep); text-decoration: underline; }

/* Group management */
.group-manage { background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin: 1rem 0; }
.group-manage h4 { margin: 0 0 .5rem 0; color: var(--navy-deep); }
.group-badges { margin-bottom:.5rem; }
.response-check-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: .5rem; margin: .5rem 0; background: var(--card); }
.response-check-item { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid var(--border-light); }
.response-check-item input[type="checkbox"] { margin: 0; width: 18px; height: 18px; min-width: 44px; min-height: 44px; cursor: pointer; accent-color: var(--navy); }
.group-badge { display: inline-block; background: var(--gold-soft); color: var(--gold-deep); padding: .2rem .6rem; border-radius: 20px; font-size: .72rem; margin: .1rem; font-weight: 600; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .admin.container { max-width: 100%; }
  .shift-map-wrap { max-width: 100%; }
  .shift-grid { max-width: calc(100vw - 60px); margin: 0 auto; }
  .shift-label { font-size: 9px; }
  .shift-dot { width: 16px; height: 16px; font-size: 6px; }
  .chart-row { flex-wrap: wrap; }
  .chart-label { width: 100%; order: 1; margin-bottom: 4px; font-size: .85rem; }
  .chart-score { width: auto; order: 2; }
  .chart-bar-bg { width: 65%; order: 3; }
  .priority { grid-template-columns: 1fr; }
  .dist-modal { padding: 1rem; }
  .group-name-input { max-width: 100%; }
  .admin-nav { flex-direction: column; }
  .admin-nav .btn { width: 100%; text-align: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .admin .admin-header { flex-direction: column; align-items: flex-start; gap: .75rem; padding: 1rem; }
}
