:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --navy-950: #071827;
  --navy-900: #0b2034;
  --navy-800: #15364f;
  --teal-700: #0f6f6a;
  --teal-600: #0e8179;
  --teal-100: #d9f1ee;
  --ink: #172b3a;
  --muted: #5c6d78;
  --line: #cbd7dc;
  --surface: #ffffff;
  --canvas: #f2f5f6;
  --danger: #9b2525;
  --radius: .75rem;
  --shadow: 0 1px 2px rgb(7 24 39 / .08), 0 10px 28px rgb(7 24 39 / .06);
}

* { box-sizing: border-box; }
html { min-width: 20rem; overflow-x: hidden; scroll-behavior: smooth; }
body { min-width: 0; margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
a { color: var(--teal-700); text-decoration-thickness: .1em; text-underline-offset: .16em; }
a:hover { color: var(--navy-800); }
svg { width: 1.15rem; height: 1.15rem; fill: currentColor; flex: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.75rem, 4vw, 2.35rem); line-height: 1.15; letter-spacing: -.025em; color: var(--navy-950); }
h2 { margin-bottom: .5rem; font-size: 1.2rem; line-height: 1.25; color: var(--navy-900); }
h3 { margin-bottom: .45rem; color: var(--navy-900); }
button, input, select, textarea { font: inherit; }
button, input:not([type="checkbox"]):not([type="hidden"]), select { min-height: 44px; }
button { cursor: pointer; }

.skip-link { position: fixed; z-index: 20; top: .5rem; left: .5rem; padding: .7rem 1rem; background: white; color: var(--navy-950); border-radius: .35rem; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.app-header { background: var(--navy-950); color: white; border-bottom: 3px solid var(--teal-600); }
.header-inner { width: min(92rem, 100%); min-width: 0; min-height: 4rem; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); display: flex; align-items: center; gap: clamp(1rem, 4vw, 3rem); }
.brand { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; color: white; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand > span:first-child { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .45rem; background: var(--teal-600); font-size: .78rem; letter-spacing: .04em; }
.primary-navigation { min-width: 0; flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.primary-navigation ul { min-width: 0; display: flex; align-items: stretch; gap: .2rem; padding: 0; margin: 0; list-style: none; }
.primary-navigation a, .nav-logout { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem .75rem; border: 0; border-radius: .4rem; background: transparent; color: #d9e5eb; font-weight: 650; text-decoration: none; white-space: nowrap; }
.primary-navigation a:hover, .nav-logout:hover { background: rgb(255 255 255 / .1); color: white; }
.primary-navigation a[aria-current="page"] { background: var(--teal-600); color: white; }
.primary-navigation form { margin: 0; }
main { min-width: 0; }
.content-shell { width: min(78rem, 100%); min-width: 0; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.75rem) clamp(1rem, 3vw, 2rem) 4rem; }
.app-footer { color: var(--muted); text-align: center; font-size: .86rem; }
.app-footer p { padding: 1rem; margin: 0; }
.page-stack { min-width: 0; display: grid; gap: 1.5rem; }
.page-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.page-heading p:last-child { max-width: 46rem; margin-bottom: 0; color: var(--muted); }
.eyebrow { margin-bottom: .2rem; color: var(--teal-700); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; color: var(--muted); font-size: .88rem; }
.breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .62rem .9rem; border: 1px solid #aebdc4; border-radius: .45rem; background: var(--surface); color: var(--navy-900); font-weight: 700; line-height: 1.2; text-decoration: none; box-shadow: 0 1px 1px rgb(7 24 39 / .04); }
.button:hover { background: #edf3f4; color: var(--navy-950); }
.button-primary { border-color: var(--teal-700); background: var(--teal-700); color: white; }
.button-primary:hover { background: #0b5d59; color: white; }
.button-quiet { border-color: transparent; background: transparent; box-shadow: none; }
.button-danger { border-color: var(--danger); color: var(--danger); background: white; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin: 0; }
.summary-grid > div { min-width: 0; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.summary-grid dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
.summary-grid dd { margin: .2rem 0 0; font-size: clamp(1.2rem, 3vw, 1.55rem); font-weight: 800; color: var(--navy-900); }
.project-summary { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.project-summary dd { font-size: 1rem; }
.project-grid { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.project-card { min-width: 0; display: flex; flex-direction: column; gap: .8rem; padding: 1.1rem; border: 1px solid var(--line); border-top: 3px solid var(--teal-600); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.project-card h2, .project-card h3 { margin-top: .55rem; font-size: 1.12rem; }
.project-card h2 a, .project-card h3 a, .activity-list a, .date-list a, .section-heading > a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }
.project-card > p { flex: 1; margin: 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.project-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.project-card dt { color: var(--muted); font-size: .7rem; font-weight: 700; }
.project-card dd { margin: 0; font-size: .88rem; font-weight: 750; }
.project-card footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .75rem; border-top: 1px solid #e2e9ec; color: var(--muted); font-size: .78rem; }
.project-card footer a { display: inline-flex; align-items: center; min-height: 44px; }
.status-chip { display: inline-flex; align-items: center; min-height: 1.6rem; padding: .18rem .55rem; border-radius: 99rem; font-size: .73rem; font-weight: 800; }
.status-active { background: #d8f2e8; color: #115d43; }
.status-planned { background: #e6edf5; color: #314c68; }
.status-completed { background: var(--teal-100); color: #155d59; }
.status-archived { background: #ececef; color: #53545a; }
.surface, .form-surface, .table-surface { min-width: 0; padding: clamp(1rem, 3vw, 1.4rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.dashboard-columns { min-width: 0; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(16rem, .65fr); gap: 1rem; }
.activity-list, .date-list { padding: 0; margin: 0; list-style: none; }
.activity-list li { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid #e1e8eb; }
.activity-list li:first-child, .date-list li:first-child { border-top: 0; }
.activity-list a, .date-list a { font-weight: 750; }
.activity-list p, .date-list p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.activity-list time { white-space: nowrap; color: var(--muted); font-size: .82rem; }
.date-list li { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-top: 1px solid #e1e8eb; }
.date-list time { width: 3.1rem; flex: none; padding: .35rem; border-radius: .4rem; background: var(--teal-100); color: var(--teal-700); text-align: center; font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.date-list time span { display: block; font-size: 1.1rem; line-height: 1.05; }
.empty-state { min-width: 0; padding: clamp(1.5rem, 5vw, 3rem); border: 1px dashed #aebdc4; border-radius: var(--radius); background: rgb(255 255 255 / .55); text-align: center; }
.empty-state > svg { width: 2.5rem; height: 2.5rem; margin-bottom: .7rem; color: var(--teal-700); }
.empty-state p { color: var(--muted); }
.empty-state.compact { padding: 1.25rem; }

.field { min-width: 0; display: grid; align-content: start; gap: .32rem; }
.field label, fieldset legend { font-weight: 750; color: var(--navy-900); }
.field label span { color: var(--muted); font-size: .78rem; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; max-width: 100%; padding: .65rem .72rem; border: 1px solid #82949d; border-radius: .4rem; background: white; color: var(--ink); }
.field textarea { resize: vertical; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.field-help { margin: 0; color: var(--muted); font-size: .82rem; }
.field-error { margin: 0; color: var(--danger); font-size: .84rem; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field-wide { grid-column: 1 / -1; }
.form-actions, .journal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: 1.2rem; }
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(8rem, 1fr)) auto; align-items: end; gap: .7rem; padding: .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: #eaf0f2; }
.module-choices { min-width: 0; margin: 1.25rem 0 0; padding: 0; border: 0; }
.module-choices > p { color: var(--muted); font-size: .84rem; }
.module-choices > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.module-choices label { display: flex; align-items: start; gap: .6rem; min-height: 4.5rem; padding: .8rem; border: 1px solid var(--line); border-radius: .5rem; background: #f8fafb; }
.module-choices input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; accent-color: var(--teal-700); }
.module-choices strong, .module-choices small { display: block; }
.module-choices small { margin-top: .15rem; color: var(--muted); font-weight: 500; }
.error-summary { padding: 1rem; border: 1px solid #d89a9a; border-left: .35rem solid var(--danger); border-radius: .45rem; background: #fff5f4; }
.error-summary h2 { font-size: 1rem; }
.error-summary ul { margin-bottom: 0; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #e5cccc; }
.module-navigation { display: flex; gap: .25rem; overflow-x: auto; padding: .2rem; border-bottom: 1px solid var(--line); }
.module-navigation a { display: inline-flex; align-items: center; min-height: 44px; padding: .55rem .8rem; border-radius: .4rem .4rem 0 0; text-decoration: none; white-space: nowrap; }
.module-navigation a[aria-current="page"] { background: var(--navy-900); color: white; }
.table-surface { padding: 0; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: .75rem .85rem; border-bottom: 1px solid #e0e7ea; text-align: left; vertical-align: top; }
.data-table th { background: #e9eff1; color: var(--navy-900); font-size: .75rem; letter-spacing: .035em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .money { white-space: nowrap; font-weight: 750; }
.pagination { display: flex; justify-content: flex-end; gap: .6rem; }
.journal-list { display: grid; gap: .7rem; padding: 0; margin: 0; list-style: none; }
.journal-list li { min-width: 0; display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 1rem; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.journal-list h2 { margin: 0; }
.journal-list time { color: var(--muted); font-weight: 700; }
.editor-grid { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(20rem, .8fr); align-items: start; gap: 1rem; }
.preview-surface { max-height: 48rem; overflow: auto; }
#journal-editor, #journal-entry, #journal-preview, #journal-list, .markdown { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
#journal-editor textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }
.markdown { line-height: 1.65; }
.markdown :is(h1,h2,h3,h4,h5,h6) { line-height: 1.25; margin: 1.5em 0 .6em; }
.markdown h1 { font-size: 2rem; } .markdown h2 { font-size: 1.6rem; }
.markdown h3 { font-size: 1.35rem; } .markdown h4 { font-size: 1.15rem; }
.markdown h5, .markdown h6 { font-size: 1rem; }
.markdown :is(p,ul,ol,blockquote,pre) { margin: .8rem 0; }
.markdown :is(ul,ol) { padding-left: 1.8rem; }
.markdown li > :is(ul,ol) { margin: .2rem 0; }
.markdown input[type="checkbox"] { width: 1rem; height: 1rem; margin-right: .5rem; accent-color: var(--teal-700); }
.markdown blockquote { margin-left: 0; padding: .3rem 1rem; border-left: .25rem solid var(--teal-600); background: #edf7f6; }
.markdown strong { font-weight: 750; } .markdown em { font-style: italic; }
.markdown del { text-decoration: line-through; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; background: #eaf0f2; padding: .15em .3em; border-radius: .2rem; }
.markdown pre { box-sizing: border-box; min-width: 100%; width: max-content; padding: 1rem; background: #eaf0f2; }
.markdown pre code { padding: 0; white-space: pre; overflow-wrap: normal; }
.markdown-scroll { min-width: 0; max-width: 100%; overflow-x: auto; margin: 1rem 0; }
.markdown table { border-collapse: collapse; width: max-content; min-width: 100%; }
.markdown :is(th,td) { padding: .6rem .8rem; border: 1px solid var(--line); }
.markdown th { background: #e5edef; font-weight: 750; }
.markdown tbody tr:nth-child(even) { background: #f7f9fa; }

:focus-visible { outline: 3px solid #0e8179; outline-offset: 3px; }
.app-header :focus-visible { outline-color: #48e4d7; }

@media (max-width: 900px) {
  .header-inner { align-items: start; flex-direction: column; gap: .25rem; padding-top: .45rem; padding-bottom: .45rem; }
  .primary-navigation { width: 100%; }
  .primary-navigation ul { flex: 1; }
  .primary-navigation a, .nav-logout { padding-inline: .55rem; font-size: .86rem; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-columns, .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-surface { max-height: none; }
}

@media (max-width: 720px) {
  html { scroll-behavior: auto; }
  .header-inner { padding-inline: .75rem; }
  .brand { align-self: center; }
  .primary-navigation { align-items: stretch; flex-direction: column; gap: .25rem; }
  .primary-navigation ul { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .primary-navigation a { min-width: 0; flex-direction: column; gap: .15rem; padding: .35rem .15rem; font-size: .7rem; }
  .nav-logout { width: 100%; }
  .content-shell { padding-top: 1.25rem; }
  .page-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .page-heading > .button, .section-heading > a { align-self: stretch; }
  .summary-grid, .project-grid, .form-grid, .module-choices > div { grid-template-columns: minmax(0, 1fr); }
  .project-card dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-wide { grid-column: auto; }
  .filter-bar { grid-template-columns: minmax(0, 1fr); }
  .table-surface { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .data-table tbody { display: grid; gap: .75rem; }
  .data-table tr { padding: .35rem .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
  .data-table td { display: grid; grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr); gap: .65rem; padding: .55rem 0; border-bottom: 1px solid #e2e9ec; text-align: right; }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; font-weight: 800; text-align: left; text-transform: uppercase; }
  .data-table td a { justify-self: end; display: inline-flex; align-items: center; min-height: 44px; }
  .journal-list li { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
  .form-actions > *, .journal-actions > * { flex: 1 1 10rem; }
  .markdown h1 { font-size: 1.6rem; }
}

@media (max-width: 430px) {
  .primary-navigation a svg { display: none; }
  .project-card dl { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

[hidden] { display: none !important; }
.project-context { margin-bottom: 2rem; }
.request-status { margin-bottom: 1.5rem; border-left: 4px solid var(--teal-700, #0f766e); }
