/* Lendr CSF Tracker styles
   Palette matches the executive deck work: navy 0F1C3F, cyan 06B6D4 */

:root {
  --navy: #0F1C3F;
  --navy-deep: #081229;
  --royal: #1E3A8A;
  --cyan: #06B6D4;
  --cyan-deep: #0891B2;
  --cyan-bright: #22D3EE;
  --ice: #CADCFC;
  --white: #FFFFFF;
  --bg: #F8FAFC;
  --bg-soft: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #1E293B;
  --text-soft: #475569;
  --muted: #64748B;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --green: #059669;
  --green-bg: #D1FAE5;
  --shadow-sm: 0 1px 2px rgba(15, 28, 63, 0.06);
  --shadow: 0 2px 6px rgba(15, 28, 63, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 28, 63, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 320px 1fr 180px;
  align-items: center;
  background: var(--navy);
  color: var(--white);
  padding: 14px 28px;
  border-bottom: 3px solid var(--cyan);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px;
  background: var(--cyan);
  border-radius: 4px;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: var(--navy);
  border-radius: 2px;
}
.brand-title { font-family: Georgia, serif; font-size: 17px; font-weight: 700; }
.brand-subtitle { font-size: 11px; color: var(--ice); letter-spacing: 1.5px; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; justify-content: center; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ice);
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.tab.active {
  background: var(--white);
  color: var(--navy);
}

.save-indicator {
  font-size: 12px;
  color: var(--ice);
  text-align: right;
  opacity: 0;
  transition: opacity 0.25s;
  min-height: 18px;
}
.save-indicator.visible { opacity: 1; }
.save-indicator.error { color: #FCA5A5; }

/* ---------- Main views ---------- */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px;
}
.view { display: none; }
.view.active { display: block; }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.view-head h1 {
  font-family: Georgia, serif;
  font-size: 26px;
  color: var(--navy);
  margin: 0 0 4px 0;
}
.subtitle {
  color: var(--muted);
  font-style: italic;
  margin: 0;
  font-size: 13px;
}

main h2 {
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--navy);
  margin-top: 28px;
  margin-bottom: 12px;
}

/* ---------- Week selector ---------- */
.week-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.week-selector label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.week-selector input[type=date] {
  border: 1px solid var(--border);
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 4px;
  font-family: inherit;
}

/* ---------- Theme banner ---------- */
.theme-banner {
  background: linear-gradient(90deg, var(--navy) 0%, var(--royal) 100%);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 6px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.theme-banner .label {
  font-size: 11px;
  color: var(--cyan-bright);
  letter-spacing: 2px;
  font-weight: 700;
}
.theme-banner .name {
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
}
.theme-banner .csfs {
  font-size: 12px;
  color: var(--ice);
  margin-left: auto;
}

/* ---------- Dashboard table ---------- */
.dashboard-table-wrap {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
}
.dashboard-table th {
  background: var(--navy);
  color: var(--white);
  padding: 12px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.dashboard-table th.col-num { width: 36px; text-align: center; }
.dashboard-table th.col-name { width: 220px; }
.dashboard-table th.col-owner { width: 140px; }
.dashboard-table th.col-theme { width: 70px; text-align: center; }
.dashboard-table th.col-status { width: 80px; text-align: center; }
.dashboard-table th.col-trend { width: 70px; text-align: center; }
.dashboard-table th.col-decision { width: 90px; text-align: center; }
.dashboard-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dashboard-table tr:last-child td { border-bottom: none; }
.dashboard-table tr:hover td { background: var(--bg-soft); }
.dashboard-table .num { font-weight: 700; color: var(--cyan-deep); text-align: center; }
.dashboard-table .csf-name { font-weight: 700; color: var(--navy); }
.dashboard-table .csf-link { cursor: pointer; }
.dashboard-table .csf-link:hover { color: var(--cyan-deep); text-decoration: underline; text-underline-offset: 3px; }
.dashboard-table .owner { color: var(--text-soft); }
.dashboard-table .theme {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
}

/* Inline editable input for comments */
.comment-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  border-radius: 4px;
}
.comment-input:hover { border-color: var(--border); background: var(--bg); }
.comment-input:focus {
  outline: none;
  border-color: var(--cyan);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

/* ---------- Status pills (G/Y/R) ---------- */
.pill {
  display: inline-block;
  width: 34px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.15s;
}
.pill:hover { transform: scale(1.05); box-shadow: var(--shadow); }
.pill-G { background: var(--green-bg); color: var(--green); }
.pill-Y { background: var(--amber-bg); color: var(--amber); }
.pill-R { background: var(--red-bg); color: var(--red); }

.trend-cell {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.trend-cell.up { color: var(--green); }
.trend-cell.right { color: var(--muted); }
.trend-cell.down { color: var(--red); }

.decision-flag {
  text-align: center;
}
.decision-flag input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
  cursor: pointer;
}

/* ---------- Legend ---------- */
.legend {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }

/* ---------- Milestones grid ---------- */
.milestones-grid { display: flex; flex-direction: column; gap: 8px; }
.milestone-row {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 200px 1fr 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  overflow: hidden;
}
.milestone-csf {
  background: var(--bg-soft);
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.milestone-csf .num {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-deep);
  letter-spacing: 1px;
}
.milestone-csf .name {
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.milestone-csf .owner {
  font-size: 11px;
  color: var(--muted);
}
.milestone-cell {
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  position: relative;
  min-height: 110px;
  cursor: pointer;
  transition: background 0.15s;
}
.milestone-cell:last-child { border-right: none; }
.milestone-cell:hover { background: var(--bg-soft); }
.milestone-cell .quarter {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.milestone-cell .desc { color: var(--text); }
.milestone-cell .mstatus {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 18px;
  line-height: 1;
}
.mstatus-planned { color: var(--muted); }
.mstatus-in_progress { color: var(--cyan-deep); }
.mstatus-at_risk { color: var(--amber); }
.mstatus-done { color: var(--green); }
.mstatus-missed { color: var(--red); }

/* ---------- CSF Reference ---------- */
.reference-controls {
  display: flex;
  gap: 8px;
}
#reference-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ref-card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--cyan);
  overflow: hidden;
}
.ref-card.open { box-shadow: var(--shadow); }

.ref-card-header {
  display: grid;
  grid-template-columns: 60px 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.ref-card-header:hover { background: var(--bg-soft); }
.ref-card-header .num {
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--cyan-deep);
  line-height: 1;
  text-align: center;
}
.ref-card-header .name {
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.ref-card-header .owner-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-deep);
  background: rgba(6, 182, 212, 0.08);
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.ref-card-header .theme-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.ref-card-header .chevron {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  transition: transform 0.2s;
}
.ref-card.open .ref-card-header .chevron { transform: rotate(90deg); color: var(--cyan-deep); }

.ref-card-body {
  display: none;
  padding: 0 22px 22px 22px;
  border-top: 1px solid var(--border);
  margin-top: -1px;
}
.ref-card.open .ref-card-body { display: block; }

.ref-card-body .outcome {
  font-family: Georgia, serif;
  font-size: 15px;
  font-style: italic;
  color: var(--navy);
  background: var(--bg-soft);
  padding: 14px 18px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 4px 4px 0;
  margin: 18px 0;
}

.ref-section {
  margin-top: 18px;
}
.ref-section h3 {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 6px 0;
}
.ref-section .content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.ref-section.warning .content { color: var(--red); }
.ref-section .content.muted-only { color: var(--muted); font-style: italic; }

.ref-card-body .meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .ref-card-body .meta-row { grid-template-columns: 1fr; gap: 0; }
  .ref-card-header { grid-template-columns: 50px 1fr auto; row-gap: 8px; }
  .ref-card-header .owner-pill,
  .ref-card-header .theme-pill { grid-column: 2; }
  .ref-card-header .chevron { grid-row: 1; grid-column: 3; }
}


.indicator-card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  margin-bottom: 12px;
  border-left: 4px solid var(--cyan);
}
.indicator-card .head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.indicator-card .num { font-size: 14px; font-weight: 700; color: var(--cyan-deep); }
.indicator-card .name { font-family: Georgia, serif; font-size: 16px; font-weight: 700; color: var(--navy); }
.indicator-card .owner { font-size: 12px; color: var(--muted); margin-left: auto; }
.indicator-card .row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.indicator-card .row label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding-top: 3px;
}
.indicator-card .warning { color: var(--red); }

/* ---------- Reference tables ---------- */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.ref-table th {
  background: var(--navy);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
}
.ref-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:nth-child(even) td { background: var(--bg-soft); }
.ref-table .time { color: var(--cyan-deep); font-weight: 700; font-size: 12px; }

.protocol {
  background: var(--white);
  padding: 16px 22px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  list-style: none;
  margin: 0;
}
.protocol li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.protocol li:last-child { border-bottom: none; }

/* ---------- Decisions ---------- */
.decisions-list {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.decision-item {
  display: grid;
  grid-template-columns: 110px 1fr 160px 100px;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.decision-item:hover { background: var(--bg-soft); }
.decision-item:last-child { border-bottom: none; }
.decision-item .date {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.decision-item .body { font-size: 13px; }
.decision-item .body .text { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.decision-item .body .meta { font-size: 11px; color: var(--muted); }
.decision-item .csf-tag {
  font-size: 11px;
  color: var(--cyan-deep);
  font-weight: 700;
  padding: 4px 8px;
  background: rgba(6, 182, 212, 0.08);
  border-radius: 4px;
  width: fit-content;
  height: fit-content;
}
.decision-item .status-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: fit-content;
  height: fit-content;
  text-align: center;
}
.status-committed { background: var(--bg-soft); color: var(--navy); }
.status-in_motion { background: rgba(6, 182, 212, 0.12); color: var(--cyan-deep); }
.status-completed { background: var(--green-bg); color: var(--green); }
.status-superseded { background: var(--bg); color: var(--muted); text-decoration: line-through; }

.decisions-empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  border: none;
  padding: 8px 14px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--cyan);
  color: var(--white);
}
.btn-primary:hover { background: var(--cyan-deep); }
.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-soft); border-color: var(--border-strong); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 63, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--white);
  border-radius: 10px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 19px;
  color: var(--navy);
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
}
.modal-close:hover { color: var(--navy); }

#decision-form { padding: 20px 24px 24px 24px; }
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-2 .form-row { margin-bottom: 0; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.form-actions #decision-delete { margin-right: auto; color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; padding: 12px 18px; }
  .tabs { flex-wrap: wrap; justify-content: flex-start; }
  .save-indicator { text-align: left; }
  .milestone-row { grid-template-columns: 1fr; }
  .milestone-csf { border-right: none; border-bottom: 1px solid var(--border); }
  .milestone-cell { border-right: none; border-bottom: 1px solid var(--border); min-height: auto; }
  .decision-item { grid-template-columns: 1fr; gap: 6px; }
}

