/* ============================================================================
 * One.Track — design system (Fang / Threk-Intranet token structure,
 * reskinned in a One Church blue palette). Vanilla CSS, no build.
 * ==========================================================================*/

:root {
  color-scheme: light;

  /* Surfaces / ink (cool, clean) */
  --paper: #f4f7fb;
  --surface: #ffffff;
  --ink: #14233a;
  --muted: #687894;
  --line: #dbe3ee;
  --line-strong: #c2cedd;

  /* One Church blue palette */
  --brand: #1f4e79;
  --brand-deep: #163a5c;
  --brand-soft: #e6eef6;
  --accent: #2f7fd1;

  /* Semantic */
  --green: #1f7a4d;
  --green-soft: #dff3e6;
  --blue: #235b82;
  --blue-soft: #e0eff8;
  --amber: #b06d1d;
  --amber-soft: #f8ead4;
  --red: #a73a37;
  --red-soft: #f5dfdd;
  --slate: #43505a;
  --slate-soft: #e9ecef;

  /* Source-type accents */
  --src-federal: #6d4ca8;
  --src-federal-soft: #ece7f7;
  --src-state: #1f7a8c;
  --src-state-soft: #ddf0f3;
  --src-foundation: #1f4e79;
  --src-foundation-soft: #e6eef6;
  --src-local: #9a6a1d;
  --src-local-soft: #f6ecd6;

  --shadow: 0 16px 36px rgba(20, 35, 58, 0.08);
  --shadow-sm: 0 6px 16px rgba(20, 35, 58, 0.06);
  --radius: 10px;
  --radius-sm: 7px;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; }
.muted { color: var(--muted); }
.boot { padding: 40px; color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .5px;
}
.brand-mark.big { width: 64px; height: 64px; font-size: 22px; border-radius: 16px; margin: 0 auto 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text small { color: var(--muted); font-size: 11.5px; }

.tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; flex-wrap: wrap; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600;
  color: var(--muted);
}
.tab:hover { background: var(--brand-soft); color: var(--brand); }
.tab.is-active { background: var(--brand); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  padding: 4px 9px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber);
}
.mode-badge.live { background: var(--green-soft); color: var(--green); }
.mode-badge.owner { background: #2b2150; color: #d9d2f5; }

/* ---------- Program switcher ---------- */
.program-switch { display: inline-flex; align-items: center; }
.program-switch select {
  font: inherit; font-weight: 650; color: var(--ink);
  padding: 7px 30px 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--brand-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%231f4e79' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; cursor: pointer; max-width: 220px;
}
.program-switch select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,127,209,.16); }

/* ---------- Programs overview ---------- */
.rollup { margin-bottom: 16px; }
.rollup-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.rollup-stats > div { display: flex; flex-direction: column; }
.rollup-stats strong { font-size: 22px; color: var(--brand); }
.rollup-stats span { font-size: 12px; color: var(--muted); }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.program-card { display: flex; flex-direction: column; gap: 8px; }
.program-card.is-locked { background: var(--paper); border-style: dashed; }
.program-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.program-card-head h3 { margin: 0; }
.program-card-stats { display: flex; gap: 18px; margin: 6px 0 10px; }
.program-card-stats > div { display: flex; flex-direction: column; }
.program-card-stats strong { font-size: 17px; }
.program-card-stats span { font-size: 11px; color: var(--muted); }
.program-card .small { font-size: 12.5px; }
.program-card button { align-self: flex-start; }

/* ---------- Locked program panel ---------- */
.locked-panel { text-align: center; padding: 40px 24px; max-width: 560px; margin: 0 auto; }
.locked-panel .lock-emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.locked-panel .fine { font-size: 12px; color: var(--muted); margin-top: 14px; }
.locked-panel .primary-button { margin-top: 6px; }

/* ---------- Admin program rows ---------- */
.prog-admin-row { flex-direction: row !important; align-items: center; justify-content: space-between; }
.prog-admin-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Layout ---------- */
.workspace { max-width: 1180px; margin: 0 auto; padding: 22px; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
}
.view-head h2 { font-size: 22px; }
.back { font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-block; margin-bottom: 2px; }
.head-actions, .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.panel h3 { font-size: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.primary-button, .ghost-button {
  appearance: none; cursor: pointer; font: inherit; font-weight: 650;
  min-height: 38px; padding: 0 15px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.primary-button { border: 1px solid transparent; background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-deep); }
.ghost-button { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.ghost-button:hover { border-color: var(--brand); color: var(--brand); }
.ghost-button.danger:hover { border-color: var(--red); color: var(--red); }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Pills ---------- */
.status-pill, .src-pill, .tier-pill {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 23px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
button.status-pill { border: 0; cursor: pointer; font-family: inherit; }
.status-overdue { color: var(--red); background: var(--red-soft); }
.status-review { color: var(--amber); background: var(--amber-soft); }
.status-waiting { color: var(--blue); background: var(--blue-soft); }
.status-complete { color: var(--green); background: var(--green-soft); }
.tier-pill { background: var(--slate-soft); color: var(--slate); }
.src-pill.src-federal { background: var(--src-federal-soft); color: var(--src-federal); }
.src-pill.src-state { background: var(--src-state-soft); color: var(--src-state); }
.src-pill.src-foundation { background: var(--src-foundation-soft); color: var(--src-foundation); }
.src-pill.src-local { background: var(--src-local-soft); color: var(--src-local); }

/* ---------- Dashboard grid ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid .wide, .dash-grid .hero { grid-column: 1 / -1; }

.hero {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff; border: 0;
}
.hero-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-head h2 { font-size: 20px; color: #fff; }
.hero-head .muted { color: rgba(255,255,255,.75); }
.hero-bar { height: 12px; border-radius: 999px; background: rgba(255,255,255,.22); margin: 14px 0; overflow: hidden; }
.hero-bar-fill { height: 100%; border-radius: 999px; background: #7dd3a8; transition: width .4s ease; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.hero-stats > div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 19px; }
.hero-stats span { font-size: 11.5px; color: rgba(255,255,255,.78); }

.stage-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stage-count {
  appearance: none; cursor: pointer; border: 1px solid var(--line); background: var(--paper);
  border-radius: 9px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.stage-count:hover { border-color: var(--brand); }
.stage-count span { font-size: 20px; font-weight: 800; color: var(--brand); }
.stage-count small { color: var(--muted); font-size: 11px; }

.due-list, .risk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.due-list a, .risk-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.due-list a:hover, .risk-list a:hover { background: var(--brand-soft); text-decoration: none; }
.due-title { font-weight: 600; }
.due-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .total td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.req-table .row-actions { display: flex; gap: 4px; white-space: nowrap; }
.evidence { color: var(--green); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 120px; }
.kanban-col > header { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.kanban-col > header small { color: var(--muted); font-weight: 600; font-size: 11px; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }
.kanban-cards.drop-hot { background: var(--brand-soft); border-radius: 8px; }

.grant-card { border: 1px solid var(--line); border-radius: 9px; padding: 11px; background: var(--surface); cursor: grab; box-shadow: var(--shadow-sm); }
.grant-card:active { cursor: grabbing; }
.grant-card.dragging { opacity: .5; }
.grant-card-top { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 7px; }
.grant-card h4 { font-size: 13.5px; cursor: pointer; }
.grant-card h4:hover { color: var(--brand); }
.grant-card-prog { color: var(--muted); font-size: 11.5px; margin: 2px 0 9px; }
.grant-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.grant-card-foot strong { font-size: 14px; }
.mini-bar { height: 6px; border-radius: 999px; background: var(--slate-soft); overflow: hidden; margin-bottom: 4px; }
.mini-bar > div { height: 100%; border-radius: 999px; }

/* ---------- Grant workspace ---------- */
.grant-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grant-layout .full { grid-column: 1 / -1; }
.facts-row { display: flex; gap: 7px; margin-bottom: 12px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 0; }
.facts .full { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.facts dd { margin: 0; }
.grant-readiness { text-align: center; }
.ring { width: 130px; height: 130px; margin: 4px auto 6px; display: block; }

/* ---------- Task list ---------- */
.task-list, .plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-row { display: flex; align-items: center; gap: 9px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row .check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; color: var(--green); font-weight: 800; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { flex: 1; }
.task-meta { white-space: nowrap; }
.plain-list li { padding: 7px 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list .muted { font-size: 12px; }

/* ---------- Calendar / timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.tl-month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.tl-month h3 { font-size: 14px; color: var(--brand); }
.tl-month ul { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: 0; }
.tl-date { color: var(--muted); font-size: 12px; font-weight: 600; }
.tl-item.kind-deadline .tl-label { font-weight: 600; }
.tl-item.kind-done .tl-label { color: var(--muted); text-decoration: line-through; }
.tl-item.kind-deadline { border-left: 3px solid var(--red); padding-left: 8px; margin-left: -8px; }
.tl-item.kind-task { border-left: 3px solid var(--accent); padding-left: 8px; margin-left: -8px; }
.tl-item.kind-req { border-left: 3px solid var(--amber); padding-left: 8px; margin-left: -8px; }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty { text-align: center; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 9px; color: var(--muted); }
.empty code { background: var(--slate-soft); padding: 1px 5px; border-radius: 4px; }

/* ---------- Auth gate ---------- */
.auth-gate { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); padding: 20px; }
.auth-card { background: var(--surface); border-radius: 16px; padding: 36px 32px; text-align: center; max-width: 360px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; }
.auth-card p { color: var(--muted); margin-bottom: 18px; }

/* ---------- Editor dialog ---------- */
dialog#editor { border: 0; border-radius: 14px; box-shadow: var(--shadow); padding: 0; max-width: 540px; width: 92%; }
dialog#editor::backdrop { background: rgba(20, 35, 58, .42); }
.editor-form { padding: 22px; display: flex; flex-direction: column; gap: 11px; }
.editor-form h3 { font-size: 17px; margin-bottom: 4px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.fld input, .fld select, .fld textarea {
  font: inherit; color: var(--ink); font-weight: 400;
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 127, 209, .16); }
.editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.small { font-size: 12.5px; }

/* ---------- Outcomes ---------- */
.outcome-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.outcome-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.outcome-top { display: flex; justify-content: space-between; align-items: center; }
.outcome-val { font-size: 26px; font-weight: 800; color: var(--ink); }
.outcome-val small { font-size: 13px; font-weight: 600; color: var(--muted); }
.ghost-button.sm, .report-tile.sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; }
.outcome-card .ghost-button.sm { align-self: flex-start; }

/* ---------- Document vault ---------- */
.coverage { background: var(--brand-soft); border-radius: 9px; padding: 12px 14px; margin-bottom: 14px; }
.coverage-head { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 13px; }
.vault-group { margin-top: 12px; }
.vault-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 0 0 4px; }
.vault-group .plain-list li { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.doc-actions { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Reports ---------- */
.report-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.report-sub { margin: 22px 0 4px; font-size: 14px; }
.report-tile {
  appearance: none; cursor: pointer; text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm);
}
.report-tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.report-tile strong { font-size: 14px; }
.report-ico { font-size: 22px; }

.report-toolbar { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.report-doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 30px 34px; max-width: 880px; box-shadow: var(--shadow-sm); }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 18px; }
.report-head h1 { font-size: 22px; color: var(--brand-deep); }
.report-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.report-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.report-doc h3 { margin: 20px 0 8px; font-size: 14px; color: var(--brand-deep); }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.report-table th, .report-table td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.report-table thead th { background: var(--brand-soft); color: var(--brand-deep); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.report-foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

@media print {
  .topbar, .no-print, .program-switch { display: none !important; }
  body { background: #fff; }
  .workspace { padding: 0; max-width: none; }
  .report-doc { border: 0; box-shadow: none; max-width: none; padding: 0; }
  .report-table thead th { background: #eef2f7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- AI Copilot ---------- */
.ai-btn { border-color: var(--accent); color: var(--accent); }
.primary-button.ai-btn { background: linear-gradient(135deg, var(--accent), #6aa9e0); color: #fff; border-color: transparent; }
.ai-btn:hover { border-color: var(--accent); color: var(--accent); }
.primary-button.ai-btn:hover { filter: brightness(1.05); color: #fff; }
.copilot-draft { max-width: 100%; }
.draft-block { margin-bottom: 12px; }
.draft-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.draft-block textarea { width: 100%; font: inherit; color: var(--ink); padding: 10px; border: 1px solid var(--line-strong); border-radius: 8px; line-height: 1.5; resize: vertical; }
.application-doc .app-section { margin-bottom: 16px; }
.application-doc .app-section h3 { font-size: 14px; color: var(--brand-deep); margin-bottom: 6px; }
.application-doc .app-section p { line-height: 1.55; }
.application-doc .app-section .plain-list li { border: 0; padding: 3px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .dash-grid, .grant-layout, .admin-grid, .facts { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .stage-counts { grid-template-columns: repeat(2, 1fr); }
  .tabs { order: 3; width: 100%; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  body { overflow-x: hidden; }
  .workspace { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .hero-head h2 { font-size: 17px; }
  .hero-stats strong { font-size: 16px; }
  .tl-item { grid-template-columns: 1fr auto; }
  .tl-date { grid-column: 1 / -1; }
}
