:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #64736e;
  --line: #d8dfdc;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --green: #2f7f67;
  --green-dark: #17362e;
  --green-bright: #6bbf45;
  --mint: #dff2eb;
  --gold: #c78b2e;
  --red: #c84e3f;
  --blue: #406fb3;
  --shadow: 0 18px 55px rgba(31, 48, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(140deg, rgba(47, 127, 103, 0.14), rgba(64, 111, 179, 0.08) 38%, transparent 68%),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  fill: currentColor;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  color: #f6fffb;
  background: #10251f;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid rgba(107, 191, 69, 0.6);
  border-radius: 8px;
  background: #020403;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.side-note small {
  color: rgba(246, 255, 251, 0.72);
  line-height: 1.3;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-count {
  margin-left: auto;
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #10251f;
  background: var(--green-bright);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.nav-list a,
.nav-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: rgba(246, 255, 251, 0.78);
  text-decoration: none;
  background: transparent;
  text-align: left;
}

.nav-list a.active,
.nav-list a:hover,
.nav-list button.active,
.nav-list button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-list svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.side-note {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green-bright);
  box-shadow: 0 0 0 5px rgba(107, 191, 69, 0.14);
}

.main-panel {
  display: grid;
  gap: 24px;
  padding: 32px;
}

#dashboardPanel {
  display: grid;
  gap: 24px;
}

.page-section {
  display: none;
}

.page-section.active-page {
  display: grid;
  gap: 24px;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  gap: 14px;
  color: #f6fffb;
  background: rgba(16, 37, 31, 0.92);
}

.loading-screen img {
  width: 110px;
  height: 110px;
  border-radius: 8px;
  object-fit: cover;
}

.topbar,
.section-heading,
.dialog-heading,
menu,
.topbar-actions,
.button-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.topbar {
  min-height: 176px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.76)),
    repeating-linear-gradient(135deg, rgba(47, 127, 103, 0.2) 0 2px, transparent 2px 16px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.35rem, 6vw, 4.7rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 12px;
}

.lede {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.auth-panel {
  display: grid;
  gap: 24px;
  align-content: start;
}

.about-panel {
  display: grid;
  gap: 24px;
  align-content: start;
}

.about-grid,
.dashboard-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.about-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.about-join {
  justify-self: start;
}

.dashboard-fact {
  display: block;
  margin-top: 14px;
  color: var(--green-dark);
  font-size: 1rem;
}

.auth-identity {
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-identity img {
  width: 164px;
  height: 164px;
  object-fit: cover;
  border-radius: 8px;
  background: #020403;
}

.auth-identity p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.auth-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.auth-card,
.stat-card,
.project-section,
.funds-panel,
.timeline-section,
.admin-section,
.admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(31, 48, 42, 0.08);
}

.auth-card,
.admin-card {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.auth-card h2,
.admin-card h3 {
  margin-bottom: 2px;
}

.form-message {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--green-dark);
  font-weight: 700;
}

.primary-action,
.secondary-action,
.danger-action,
.stacked-form button,
menu button,
.button-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
}

.primary-action {
  color: #fff;
  background: var(--green);
}

.secondary-action,
menu button,
.button-row button,
.stacked-form button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.danger-action {
  color: #fff;
  background: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 18px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 2rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.project-section,
.funds-panel,
.timeline-section,
.admin-section {
  padding: 22px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 10px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  color: #fff;
  background: var(--green);
}

.project-list,
.admin-list,
.fund-breakdown {
  display: grid;
  gap: 12px;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.project-card h3 {
  margin: 0 0 7px;
  font-size: 1.05rem;
}

.project-meta,
.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-milestone {
  margin: 10px 0 0;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.on-track {
  color: #17644f;
  background: var(--mint);
}

.badge.at-risk {
  color: #85520a;
  background: #f7e4bd;
}

.badge.blocked {
  color: #922f26;
  background: #f9d8d3;
}

.badge.complete {
  color: #174d87;
  background: #dbeafe;
}

.progress-track {
  height: 9px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeeb;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.project-budget {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 6px;
  min-width: 118px;
}

.project-budget strong {
  font-size: 1.15rem;
}

.project-budget small {
  color: var(--muted);
}

.fund-ring {
  position: relative;
  display: grid;
  width: min(230px, 100%);
  margin: 6px auto 22px;
  place-items: center;
}

.fund-ring svg {
  width: 100%;
  transform: rotate(-90deg);
}

.fund-ring circle {
  fill: none;
  stroke: #e7eeeb;
  stroke-width: 12;
}

.fund-ring .fund-progress {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 289;
  stroke-dashoffset: 289;
  transition: stroke-dashoffset 240ms ease;
}

.fund-ring div {
  position: absolute;
  display: grid;
  place-items: center;
}

.fund-ring strong {
  font-size: 2.2rem;
}

.fund-ring span {
  color: var(--muted);
  font-weight: 700;
}

.fund-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.fund-row .bar {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeeb;
}

.fund-row .bar span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.funding-page-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.funding-project-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.funding-parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.mini-fund-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.mini-ring {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, #fff 0 52%, transparent 53%),
    conic-gradient(var(--green) calc(var(--percent) * 1%), #e7eeeb 0);
}

.mini-ring strong {
  font-size: 0.92rem;
}

.mini-fund-card small {
  display: block;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 92px;
  padding: 10px 11px;
  resize: vertical;
}

.checkbox-label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
}

.project-card {
  transition: border-color 160ms ease, transform 160ms ease;
}

.project-card:hover,
.project-card.selected {
  border-color: rgba(47, 127, 103, 0.65);
  transform: translateY(-1px);
}

.project-detail-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(31, 48, 42, 0.08);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.detail-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-card-wide {
  grid-column: 1 / -1;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.detail-facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.detail-facts dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-facts dd {
  margin: 4px 0 0;
  font-weight: 850;
}

.detail-about {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-strip {
  margin-top: 12px;
}

.status-flag.more-funding-needed {
  color: #85520a;
  background: #f7e4bd;
}

.status-flag.funding-goal-reached {
  color: #17644f;
  background: var(--mint);
}

.status-flag.funding-goal-critically-low,
.status-flag.deadline-running-behind {
  color: #922f26;
  background: #f9d8d3;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px auto;
  gap: 10px;
  align-items: end;
}

.project-rail-wrap,
.timeline-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.project-rail,
.global-rail {
  position: relative;
  min-width: 900px;
  min-height: 170px;
  padding: 58px 70px 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.rail-line {
  position: absolute;
  left: 70px;
  right: 70px;
  top: 74px;
  height: 4px;
  border-radius: 999px;
  background: #dce5e1;
}

.rail-edge {
  position: absolute;
  top: 90px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.rail-start {
  left: 22px;
}

.rail-end {
  right: 22px;
}

.today-marker {
  position: absolute;
  top: 36px;
  bottom: 18px;
  width: 2px;
  background: var(--blue);
}

.today-marker span {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
}

.stage-dot {
  position: absolute;
  top: 62px;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green);
}

.stage-dot span,
.stage-dot small {
  position: absolute;
  left: 50%;
  width: 150px;
  transform: translateX(-50%);
  text-align: center;
}

.stage-dot span {
  top: 30px;
  font-size: 0.78rem;
  font-weight: 850;
}

.stage-dot small {
  top: 54px;
  color: var(--muted);
  font-size: 0.72rem;
}

.stage-dot.complete {
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green);
}

.stage-dot.upcoming {
  background: #fff;
  box-shadow: 0 0 0 2px var(--green);
}

.stage-dot.late {
  background: var(--red);
  box-shadow: 0 0 0 2px var(--red);
}

.stage-dot.skipped {
  background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue);
}

.timeline-content.late::before {
  background: var(--red);
  box-shadow: 0 0 0 2px var(--red);
}

.timeline-content.complete::before {
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green);
}

.timeline-content.skipped::before {
  background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue);
}

.scroll-list {
  max-height: 380px;
  overflow: auto;
  padding-right: 4px;
}

.chat-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chat-message.own-message {
  justify-self: end;
  border-color: rgba(47, 127, 103, 0.45);
  background: var(--mint);
}

.chat-message strong,
.chat-message small {
  display: block;
}

.chat-message p {
  margin: 4px 0;
}

.chat-message small {
  color: var(--muted);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 18px;
  padding: 0 0 22px;
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 130px;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-date {
  color: var(--green);
  font-weight: 900;
}

.timeline-content {
  position: relative;
  padding: 0 0 0 28px;
}

.timeline-content::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 13px;
  height: 13px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green);
  z-index: 1;
}

.timeline-content h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.empty-state,
.muted-note {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.admin-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.admin-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.request-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.request-panel[hidden] {
  display: none !important;
}

#accountList,
#approvalList {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.expanded-log-list {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.notification-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.notification-open {
  display: grid;
  gap: 4px;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.admin-item strong,
.admin-item small {
  display: block;
}

.admin-item small {
  color: var(--muted);
}

.button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.button-row button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.9rem;
}

.stacked-form {
  display: grid;
  gap: 10px;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

#adminDialog,
#projectEditorDialog {
  width: min(1120px, calc(100vw - 28px));
}

.admin-dialog-card {
  max-height: min(82vh, 860px);
  overflow: auto;
}

.dialog-subsection {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

dialog::backdrop {
  background: rgba(12, 26, 22, 0.5);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: #fff;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

menu {
  margin: 8px 0 0;
  padding: 0;
}

@media (max-width: 1120px) {
  .admin-grid,
  .workspace-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-list a,
  .nav-list button {
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .project-card,
  .auth-identity,
  .auth-grid,
  .topbar-actions,
  .inline-form,
  .chat-form,
  .detail-facts {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-heading,
  .topbar-actions {
    align-items: stretch;
  }

  .auth-grid,
  .stats-grid,
  .nav-list,
  .funding-page-grid,
  .about-grid,
  .dashboard-overview-grid {
    grid-template-columns: 1fr;
  }

  .auth-identity img {
    width: 130px;
    height: 130px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .timeline-item:not(:last-child)::after {
    left: 6px;
    top: 44px;
  }

  .timeline-content {
    padding-left: 28px;
  }

  .project-budget {
    justify-items: start;
  }

  .detail-header {
    display: grid;
  }

  .project-rail {
    overflow-x: auto;
    min-width: 100%;
  }
}
