:root {
  --paper: #f4f0e7;
  --paper-deep: #e8e1d5;
  --ink: #17231f;
  --ink-soft: #53615a;
  --moss: #3f654f;
  --moss-dark: #284b39;
  --ochre: #b27d3e;
  --berry: #9b554d;
  --rule: #cfc8ba;
  --white: #fffdf8;
  --shadow: 0 12px 28px rgba(23, 35, 31, .07);
  color: var(--ink);
  background: var(--paper);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; background: var(--paper); }
a { color: var(--moss-dark); text-decoration-thickness: .08em; text-underline-offset: .16em; }
a:hover { color: var(--berry); }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 44px; }
button, .button, select, input, textarea { border-radius: 3px; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }

.site-header { width: min(1200px, calc(100% - 48px)); margin: 0 auto; min-height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rule); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-family: Georgia, "Times New Roman", serif; font-size: 1.3rem; font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--paper); background: var(--ink); border-radius: 50%; font-size: 1rem; }
.site-nav { display: flex; align-items: center; gap: 23px; }
.site-nav a, .text-button { color: var(--ink-soft); font-size: .9rem; text-decoration: none; }
.site-nav a:hover, .text-button:hover { color: var(--ink); }
.inline-form { display: inline; }
.text-button { border: 0; background: transparent; padding: 10px 0; cursor: pointer; }
.link-button { min-height: 44px; padding: 9px 0; border: 0; background: transparent; color: var(--moss-dark); cursor: pointer; font-size: .8rem; font-weight: 700; }
.link-button:hover { color: var(--berry); }
.page-shell { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 58px 0 90px; }
.site-footer { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 40px; color: var(--ink-soft); border-top: 1px solid var(--rule); font-size: .8rem; }
.eyebrow { margin: 0 0 12px; color: var(--moss-dark); font-size: .76rem; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.025em; }
h1 { max-width: 720px; margin-bottom: 14px; font-size: clamp(2.2rem, 5vw, 4.2rem); line-height: 1.04; }
h2 { font-size: 1.45rem; line-height: 1.15; }
h3 { font-size: 1.06rem; line-height: 1.25; }
.lede { max-width: 650px; color: var(--ink-soft); font-size: 1.08rem; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 42px; }
.page-heading h1 { margin-bottom: 10px; }
.form-heading { margin-bottom: 30px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.2; }
.button:hover { color: var(--ink); text-decoration: none; }
.button-primary { color: var(--paper); background: var(--ink); }
.button-primary:hover { color: var(--paper); background: var(--moss-dark); }
.button-secondary { background: transparent; border-color: var(--rule); }
.button-secondary:hover { border-color: var(--ink); background: var(--paper-deep); }
.button-small { min-height: 40px; padding: 7px 13px; font-size: .88rem; }
.text-link, .back-link { color: var(--ink-soft); }
.muted, .quiet-note { color: var(--ink-soft); }
.quiet-note { font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.form-error { max-width: 760px; margin: 0 0 24px; padding: 12px 15px; border-left: 4px solid var(--berry); background: #f2dfd8; color: #5d2b27; }

/* Login: a spare two-column opening page with one memorable ink circle. */
.login-page .site-header { border-bottom: 0; }
.login-layout { min-height: 60vh; display: grid; grid-template-columns: 1fr minmax(300px, 420px); gap: clamp(40px, 10vw, 150px); align-items: center; }
.login-copy { position: relative; max-width: 590px; padding: 50px 0 45px 56px; }
.login-copy::before { content: ""; position: absolute; z-index: -1; top: 0; left: 0; width: 170px; height: 170px; border-radius: 50%; background: var(--paper-deep); }
.login-copy h1 { font-size: clamp(3rem, 7vw, 6.2rem); }
.login-copy p:not(.eyebrow) { max-width: 410px; color: var(--ink-soft); font-size: 1.15rem; }
.form-panel { padding: 27px; border: 1px solid var(--rule); background: rgba(255, 253, 248, .52); box-shadow: var(--shadow); }
.login-panel h2 { margin-bottom: 25px; }
.login-panel .button { width: 100%; margin-top: 12px; }

/* Forms */
.record-form { max-width: 920px; }
.form-layout { display: grid; gap: 28px; }
fieldset { min-width: 0; padding: 0 0 27px; border: 0; border-bottom: 1px solid var(--rule); }
legend { margin-bottom: 18px; padding: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 700; }
.field-grid { display: grid; gap: 18px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--ink-soft); font-size: .88rem; font-weight: 600; }
label small { color: var(--ink-soft); font-size: .77rem; font-weight: 400; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #bcb4a5; background: var(--white); color: var(--ink); }
textarea { min-height: 100px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
.full-field { grid-column: 1 / -1; }
.checkbox-label { display: flex; grid-template-columns: none; align-items: center; gap: 10px; margin: 20px 0; color: var(--ink); font-size: .9rem; font-weight: 500; }
.checkbox-label input { width: 20px; height: 20px; }
.form-actions { display: flex; gap: 10px; padding-top: 9px; }
.stack-form { display: grid; gap: 14px; }
.stack-form .button { justify-self: start; }

/* Dashboard */
.dashboard-heading { align-items: end; }
.dashboard-heading h1 { font-size: clamp(2rem, 4vw, 3.35rem); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(270px, .75fr); gap: clamp(38px, 7vw, 90px); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.section-heading h2 { margin-bottom: 0; }
.action-group { margin-top: 26px; }
.group-title { margin: 0; color: var(--ink-soft); font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif; font-size: .78rem; font-weight: 700; }
.section-count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; color: var(--moss-dark); background: var(--paper-deep); border-radius: 50%; font-size: .78rem; font-weight: 700; }
.action-list, .compact-list, .recent-list, .record-list, .timeline { margin: 0; padding: 0; list-style: none; }
.action-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 15px; align-items: start; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.action-marker { width: 11px; height: 11px; margin-top: 6px; border: 2px solid var(--moss); border-radius: 50%; }
.priority-high .action-marker { border-color: var(--berry); background: var(--berry); }
.action-reason { margin-bottom: 3px; color: var(--ink-soft); font-size: .75rem; font-weight: 700; }
.action-main h3 { margin-bottom: 2px; }
.action-main h3 a { text-decoration: none; }
.action-main .muted { margin-bottom: 0; font-size: .87rem; }
.action-date { color: var(--ink-soft); font-size: .82rem; text-align: right; white-space: nowrap; }
.side-column { display: grid; align-content: start; gap: 33px; }
.ruled-section { padding-bottom: 4px; }
.compact-list li { border-bottom: 1px solid var(--rule); }
.task-row { display: flex; align-items: center; gap: 11px; min-height: 55px; }
.task-row span { display: grid; gap: 1px; }
.task-row strong { font-size: .9rem; font-weight: 600; }
.task-row small { color: var(--ink-soft); font-size: .76rem; }
.task-actions { display: grid; gap: 5px; }
.task-actions .task-row { flex-wrap: wrap; }
.check-button { position: relative; display: grid; flex: 0 0 auto; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.check-button::before { content: ""; width: 19px; height: 19px; border: 1px solid var(--moss); border-radius: 50%; background: transparent; }
.check-button:hover::before { background: var(--paper-deep); }
.check-button.checked::before { background: var(--moss); }
.quick-task-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 14px; }
.count-list { margin: 0; }
.count-list div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.count-list dt, .count-list dd { margin: 0; }
.count-list dd { color: var(--ink-soft); font-size: .86rem; }
.count-list dd span { margin-left: 5px; color: var(--ink); }
.recent-list li { display: grid; gap: 1px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.recent-list li a { font-weight: 600; text-decoration: none; }
.recent-list li span, .recent-list li small { color: var(--ink-soft); font-size: .81rem; }
.empty-state { padding: 50px 25px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-align: center; }
.empty-state.wide { max-width: 760px; margin: 0 auto; }
.empty-glyph { display: block; margin-bottom: 10px; color: var(--ochre); font-size: 2rem; }
.empty-state h2, .empty-state h3 { margin-bottom: 8px; }
.empty-state p { max-width: 430px; margin: 0 auto 22px; color: var(--ink-soft); }

/* Applications index */
.filter-bar { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)); gap: 9px; margin-bottom: 30px; }
.filter-disclosure > summary { display: none; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; margin-top: 24px; color: var(--ink-soft); font-size: .86rem; text-align: center; }
.pagination > :last-child { justify-self: end; }
.table-wrap { overflow-x: auto; border-top: 2px solid var(--ink); }
.application-table { width: 100%; border-collapse: collapse; }
.application-table th { padding: 12px 13px; color: var(--ink-soft); font-size: .76rem; font-weight: 700; text-align: left; }
.application-table td { padding: 17px 13px; border-top: 1px solid var(--rule); vertical-align: top; }
.application-table tbody tr:hover { background: rgba(232, 225, 213, .45); }
.table-title, .table-subtitle, .tag-line { display: block; }
.table-title { font-family: Georgia, "Times New Roman", serif; font-size: 1.06rem; font-weight: 700; text-decoration: none; }
.table-subtitle, .tag-line { color: var(--ink-soft); font-size: .82rem; }
.tag-line { margin-top: 4px; color: var(--moss-dark); font-size: .73rem; text-transform: capitalize; }
.stage-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--moss); }
.stage-lead, .stage-researching { background: var(--ochre); }
.stage-preparing { background: #6b7895; }
.stage-applied { background: var(--moss); }
.stage-interviewing, .stage-offer { background: var(--berry); }
.stage-closed { background: var(--ink-soft); }

/* Detail */
.detail-heading { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 35px; }
.back-link { display: inline-block; margin-bottom: 24px; font-size: .87rem; text-decoration: none; }
.detail-heading h1 { margin-bottom: 7px; }
.detail-role { margin-bottom: 0; color: var(--ink-soft); font-size: 1.08rem; }
.detail-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { padding: 7px 10px; border: 1px solid var(--rule); font-size: .77rem; font-weight: 700; }
.status-active { color: var(--moss-dark); border-color: #91ae99; background: #e0ebdf; }
.status-on_hold { color: #765621; border-color: #c9aa70; background: #f0e7d3; }
.status-closed { color: var(--ink-soft); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .72fr); gap: clamp(38px, 7vw, 90px); }
.detail-main, .detail-side { display: grid; align-content: start; gap: 32px; }
.detail-section { padding-bottom: 27px; border-bottom: 1px solid var(--rule); }
.overview-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 17px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.overview-strip > div { display: grid; gap: 6px; align-content: start; }
.meta-label, .detail-facts dt, .timeline-meta, .mini-label { color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.overview-strip strong { font-size: .89rem; font-weight: 600; }
.detail-facts { display: grid; gap: 10px; margin: 22px 0 0; }
.detail-facts div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 15px; }
.detail-facts dt, .detail-facts dd { margin: 0; }
.detail-facts dd { white-space: pre-wrap; }
.prose { white-space: pre-wrap; }
.timeline { margin-top: 6px; }
.timeline li { position: relative; display: grid; grid-template-columns: 17px minmax(0, 1fr); gap: 14px; padding: 15px 0 15px 4px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; top: 29px; bottom: -16px; left: 9px; border-left: 1px solid var(--rule); }
.timeline-dot { z-index: 1; width: 11px; height: 11px; margin-top: 5px; border: 2px solid var(--moss); border-radius: 50%; background: var(--paper); }
.kind-status_change { border-color: var(--ochre); }
.kind-note { border-color: var(--ink-soft); }
.timeline-meta { margin-bottom: 4px; }
.timeline h3 { margin-bottom: 3px; }
.timeline p { margin-bottom: 4px; font-size: .9rem; }
.timeline-follow-up { color: var(--berry); font-size: .81rem !important; font-weight: 600; }
.record-list li { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.record-list li span, .record-list li small, .record-list li a { color: var(--ink-soft); font-size: .82rem; }
.record-list li a { width: fit-content; }
.mini-label { margin-left: 4px; color: var(--moss-dark); }
.inline-editor { margin-top: 19px; }
.inline-editor summary { width: fit-content; min-height: 44px; padding: 10px 0; color: var(--moss-dark); cursor: pointer; font-size: .88rem; font-weight: 700; }
.inline-editor[open] summary { margin-bottom: 10px; }
.compact-editor { margin-top: 8px; }
.compact-editor summary { min-height: 36px; padding: 6px 0; font-size: .8rem; font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .7fr); align-items: start; gap: clamp(35px, 7vw, 85px); max-width: 980px; }
.settings-grid fieldset { display: grid; gap: 16px; }
.settings-side { display: grid; gap: 24px; }
.settings-side h2 { margin-bottom: 10px; }
.config-status { display: flex; align-items: center; gap: 8px; margin: 5px 0 0; color: var(--berry); font-size: .82rem; }
.config-status.ready { color: var(--moss-dark); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }
@media (max-width: 820px) {
  .dashboard-grid, .detail-grid, .settings-grid { grid-template-columns: 1fr; }
  .side-column, .detail-side { grid-template-columns: repeat(2, minmax(0, 1fr)); display: grid; }
  .detail-side { align-items: start; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .site-header, .page-shell, .site-footer { width: min(100% - 30px, 1200px); }
  .site-header { min-height: 72px; align-items: start; padding: 16px 0; }
  .site-nav { flex-wrap: wrap; justify-content: end; gap: 4px 13px; }
  .site-nav a, .text-button { padding: 7px 0; font-size: .82rem; }
  .page-shell { padding-top: 38px; }
  .page-heading, .detail-heading { display: grid; align-items: start; gap: 17px; margin-bottom: 30px; }
  h1 { font-size: clamp(2.1rem, 12vw, 3.35rem); }
  .dashboard-heading h1 { font-size: clamp(2rem, 11vw, 3rem); }
  .page-heading .button, .detail-actions .button { justify-self: start; }
  .login-layout { display: block; min-height: 0; }
  .login-copy { padding: 35px 0 45px 24px; }
  .login-copy::before { width: 120px; height: 120px; }
  .login-copy h1 { font-size: clamp(3rem, 15vw, 5rem); }
  .login-panel { padding: 21px; }
  .two-col, .overview-strip, .side-column, .detail-side { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .filter-bar .button { width: 100%; }
  .filter-disclosure { margin-bottom: 26px; }
  .filter-disclosure > summary { display: block; min-height: 44px; padding: 10px 0; color: var(--moss-dark); cursor: pointer; font-size: .9rem; font-weight: 700; }
  .filter-disclosure[open] > summary { margin-bottom: 10px; }
  .table-wrap { overflow: visible; }
  .application-table, .application-table tbody, .application-table tr, .application-table td { display: block; width: 100%; }
  .application-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .application-table tr { padding: 14px 0; border-bottom: 1px solid var(--rule); }
  .application-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 7px 0; border: 0; }
  .application-table td::before { content: attr(data-label); color: var(--ink-soft); font-size: .76rem; font-weight: 700; }
  .application-table td:first-child { display: block; }
  .application-table td:first-child::before { display: none; }
  .application-table td:not(:first-child) .table-value { grid-column: 2; min-width: 0; }
  .action-row { grid-template-columns: 13px minmax(0, 1fr); gap: 10px; }
  .action-date { grid-column: 2; text-align: left; }
  .detail-actions { flex-wrap: wrap; }
  .detail-facts div { grid-template-columns: 1fr; gap: 2px; }
  .form-actions { flex-wrap: wrap; }
}
