:root {
  color-scheme: light;
  --ink: #211e1c;
  --muted: #655e57;
  --paper: #fbf8f3;
  --panel: #fffdfa;
  --border: #ded8d0;
  --accent: #b83e24;
  --accent-deep: #953019;
  --rail: #22201e;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.055em; line-height: 1.08; overflow-wrap: anywhere; }
h2 { font-size: 1.125rem; letter-spacing: -.025em; line-height: 1.3; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #32699c; outline-offset: 3px; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; overflow-wrap: anywhere; font-size: .9em; }

.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 2;
  clip-path: inset(50%);
  padding: .6rem .85rem;
  background: var(--panel);
}
.skip-link:focus { clip-path: none; }
.layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--rail);
  color: #fff7ee;
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.1rem 1.4rem;
  gap: 2.4rem;
}
.sidebar :focus-visible { outline-color: #ffb69b; }
.brand { display: flex; gap: .7rem; align-items: center; text-decoration: none; min-width: 0; }
.brand strong { font-size: .9rem; letter-spacing: .07em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.65rem;
  height: 2.65rem;
  flex: none;
  background: #ec6949;
  border-radius: .6rem;
  color: #211b19;
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -.12em;
  padding-right: .15rem;
}
.sidebar nav { display: grid; gap: .4rem; }
.sidebar nav a {
  border-radius: .45rem;
  padding: .7rem .75rem;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 650;
  color: #e3d7cc;
}
.sidebar nav a:hover { background: #352e29; color: #fff7ee; }
.sidebar nav a[aria-current] { color: #ffd0bc; background: #46332c; }
.profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-top: .85rem;
  border-top: 1px solid #51453c;
}
.profile > span { color: #d5c8bb; font-size: .82rem; }
.profile form { margin-left: auto; flex: none; }
.logout { background: transparent; color: #f0ddce; border: 0; padding: .35rem .1rem; font-size: .78rem; text-decoration: underline; }

.main { padding: 2.3rem clamp(1.1rem, 4vw, 4.5rem) 4rem; width: 100%; max-width: 88rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.6rem; }
.page-head p { margin-top: .45rem; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.55; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .8rem;
  min-width: 0;
}
.panel-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .35rem .65rem; }
.body-panel, .form-panel { padding: clamp(1rem, 3vw, 1.5rem); }
.body-panel > :not(:first-child) { margin-top: .65rem; }
.button {
  border: 1px solid transparent;
  border-radius: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .62rem .9rem;
  min-height: 2.65rem;
  font-size: .9rem;
  font-weight: 690;
  text-decoration: none;
  text-align: center;
  line-height: 1.25;
}
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-deep); }
.secondary { color: var(--ink); background: var(--panel); border-color: var(--border); }
.secondary:hover { background: #f7eee3; border-color: #c8ac98; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.back, .text-link { color: var(--accent-deep); font-weight: 650; font-size: .9rem; text-underline-offset: .17em; }
.back { display: inline-flex; margin-bottom: .9rem; }
.text-link:hover, .back:hover { color: #652817; }
.record-ref { color: var(--muted); font-size: .9rem; font-weight: 650; margin: 0 0 .25rem; }
.flash {
  border: 1px solid #b2c7ac;
  color: #2c532c;
  background: #e9f2e6;
  padding: .55rem .85rem;
  border-radius: .45rem;
  margin-bottom: .8rem;
}
.flash.error { border-color: #e9b3a9; color: #8c2b1b; background: #fff0eb; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters .field:first-child { flex: 1 1 14rem; max-width: 23rem; }
.filters .field:nth-child(2) { flex: 0 1 11rem; }
.filters .text-link { align-self: center; }
.registry { overflow: hidden; }
.mobile-label { display: none; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
thead { background: #f7f1e9; color: #5d544b; font-size: .75rem; }
th, td { padding: .72rem 1rem; text-align: left; border-top: 1px solid var(--border); }
thead th { border-top: 0; }
td, thead th { white-space: nowrap; }
th[scope="row"] { min-width: 9rem; overflow-wrap: anywhere; }
.registry-id, .registry-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.lead-link { font-weight: 700; text-underline-offset: .18em; }
.lead-link:hover { color: var(--accent); }
.empty { padding: 2.2rem 1.15rem; }
.tag {
  display: inline-flex;
  border-radius: 99px;
  background: #efe8df;
  color: #504337;
  padding: .18rem .55rem;
  font-size: .74rem;
  line-height: 1.35;
  font-weight: 690;
  max-width: 100%;
  white-space: normal;
}
.tag.booked, .tag.working { color: #315672; background: #e8eff6; }
.tag.completed, .tag.sent { color: #28522e; background: #e7f0e4; }
.tag.declined, .tag.failed, .tag.uncertain { color: #8c2b1b; background: #fbe8e2; }

.detail-grid { display: grid; gap: .95rem; align-items: start; grid-template-columns: minmax(0, 1.55fr) minmax(16rem, 1fr); }
.stack { display: grid; gap: .95rem; }
.fields-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.25rem; border-top: 1px solid var(--border); padding-top: .85rem; }
.fields-list dt, .note h3 { color: var(--muted); font-size: .82rem; }
.fields-list dd { margin: .12rem 0 0; overflow-wrap: anywhere; }
.note { border-top: 1px solid var(--border); padding-top: .75rem; }
.note p { margin-top: .25rem; }
.preserve-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.connection-panel { max-width: 39rem; }
.large-value { font-size: 1.35rem; font-weight: 720; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.3; }

.form-panel { max-width: 47rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.form-grid > .errorlist, .full-width { grid-column: 1 / -1; }
.field-stack { display: grid; gap: 1rem; }
.field-stack > .button { justify-self: start; }
.field { display: grid; gap: .35rem; min-width: 0; }
label { font-weight: 680; font-size: .88rem; }
input:not([type="hidden"]), textarea, select {
  display: block;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfb5aa;
  border-radius: .45rem;
  padding: .53rem .65rem;
}
textarea { resize: vertical; }
.errorlist { color: #8c2b1b; font-size: .88rem; margin: .15rem 0; padding-left: 1.3rem; }

.auth { width: min(100% - 2rem, 25rem); margin: clamp(2rem, 13vh, 8rem) auto; }
.brand-auth { margin-bottom: .85rem; }
.login-panel { padding: clamp(1rem, 4vw, 1.65rem); }
.login-panel h1 { font-size: 2.25rem; }
.login-panel > :not(:first-child) { margin-top: .85rem; }
.login-panel form > .button { width: 100%; }

@media (max-width: 66rem) {
  .layout { grid-template-columns: 12.75rem minmax(0, 1fr); }
  .sidebar { padding-inline: .85rem; }
  .main { padding-inline: 1.35rem; }
}
@media (max-width: 60rem) {
  .registry thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .registry table, .registry tbody { display: block; }
  .registry tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: baseline;
    gap: .45rem .75rem;
    padding: .9rem 1rem;
  }
  .registry tr + tr { border-top: 1px solid var(--border); }
  .registry td, .registry th[scope="row"] { padding: 0; border: 0; min-width: 0; white-space: normal; }
  .registry-name { grid-column: 1 / 3; grid-row: 1; }
  .registry-status { grid-column: 3; grid-row: 1; justify-self: end; }
  .registry-id { grid-column: 1; grid-row: 2; }
  .registry-date { grid-column: 2; grid-row: 2; }
  .registry-source { grid-column: 1 / 3; grid-row: 3; color: var(--muted); }
  .registry-appointment { grid-column: 1 / 3; grid-row: 4; }
  .registry-edit { grid-column: 3; grid-row: 4; justify-self: end; }
  .mobile-label { display: inline; color: var(--muted); margin-right: .3rem; }
}
@media (max-width: 52rem) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 43rem) {
  .layout { display: block; }
  .sidebar { padding: .65rem .9rem; }
  .main { padding: 1.3rem .9rem 2rem; }
  .page-head { align-items: flex-start; flex-direction: column; margin-bottom: 1.1rem; }
  .filters .field:first-child { max-width: none; }
}
@media (max-width: 30rem) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { align-items: end; }
  .filters .field:first-child { flex-basis: 100%; }
  .filters .field:nth-child(2) { flex: 1 1 10rem; }
}

.records { overflow: hidden; }
.records td { vertical-align: middle; }
.records .cell-label { display: none; }
.record-fields { border-top: 0; padding-top: 0; }
.record-actions, .calendar-period { margin-bottom: 1rem; }
.calendar-period [aria-current] { background: #f4e7dc; border-color: #c8ac98; }
.related-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.related-list li { overflow-wrap: anywhere; }
.pagination { margin-top: 1rem; }
@media (max-width: 52rem) {
  .records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .records table, .records tbody { display: block; }
  .records tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; padding: .8rem 1rem; }
  .records tr + tr { border-top: 1px solid var(--border); }
  .records td, .records th[scope="row"] { padding: 0; border: 0; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .records th[scope="row"] { grid-column: 1 / -1; }
  .records .cell-label { display: block; font-size: .76rem; color: var(--muted); }
}

/* The registry and accounting sections share one navigation list. */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  align-self: start;
  overflow-y: auto;
  gap: 1.35rem;
}
.sidebar nav { gap: .85rem; }
.nav-section { display: grid; gap: .15rem; }
.nav-section p { color: #c6b9ad; font-size: .76rem; padding: 0 .7rem .2rem; }
.sidebar .nav-section a { padding: .42rem .7rem; }
@media (max-width: 43rem) {
  .sidebar { position: static; height: auto; overflow: visible; }
  .sidebar .nav-desktop, .sidebar .profile { display: none; }
}

.conversation-thread { display: flex; flex-direction: column; gap: .65rem; margin-block: 1rem; }
.thread-date, .thread-nav { align-self: center; color: var(--muted); margin: .35rem 0; font-size: .82rem; }
.thread-bubble { align-self: flex-start; max-width: min(80%, 42rem); width: max-content; padding: .6rem .85rem; border: 1px solid #ddd3c6; border-radius: .35rem .9rem .9rem .9rem; background: #f5efe7; overflow-wrap: anywhere; }
.thread-bubble.outgoing { align-self: flex-end; background: #e7ede1; border-color: #cfd8c9; border-radius: .9rem .35rem .9rem .9rem; }
.thread-byline { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .25rem .85rem; color: var(--muted); font-size: .76rem; }
.thread-byline a { color: inherit; }
.thread-bubble p { margin: .35rem 0 .1rem; }
.conversation-thread ~ details { margin-block: .65rem; }
@media (max-width: 640px) {
  .thread-bubble { max-width: 90%; }
}

.workday-rows > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding-block: .5rem; border-top: 1px solid var(--border); }
.follow-up-form { display: grid; justify-items: start; gap: .65rem; }
.follow-up-form .controls { align-items: end; }

.archive-tabs { margin-bottom: 1rem; }
.archive-tabs [aria-current="page"] { background: #f7e8df; border-color: #d4b29f; color: var(--accent-deep); }
