:root {
  color-scheme: light;
  --bg: #f4ebde;
  --bg-strong: #efe0cb;
  --surface: rgba(255, 251, 244, 0.88);
  --surface-solid: #fffaf2;
  --ink: #241913;
  --ink-soft: #5f4b3d;
  --muted: #8c7560;
  --line: rgba(88, 59, 37, 0.16);
  --line-strong: rgba(88, 59, 37, 0.26);
  --leather: #7b4a2e;
  --leather-dark: #3d2418;
  --gold: #c99b5d;
  --coral: #df756a;
  --amber: #e0aa51;
  --green: #7d9b74;
  --blue: #697acb;
  --lavender: #a98cc6;
  --danger: #a33b31;
  --rail-width: 72px;
  --rail-open-width: 280px;
  --shadow: 0 24px 70px rgba(65, 40, 22, 0.16);
  --shadow-soft: 0 12px 34px rgba(65, 40, 22, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(201, 155, 93, 0.24), transparent 330px),
    radial-gradient(circle at 88% 18%, rgba(223, 117, 106, 0.17), transparent 360px),
    radial-gradient(circle at 68% 92%, rgba(125, 155, 116, 0.14), transparent 360px),
    url("/assets/botanical.svg") right 4vw top 96px / 250px auto no-repeat,
    url("/assets/paper-grain.svg"),
    var(--bg);
}

body.is-locked {
  height: 100dvh;
  overflow: hidden;
}

body.is-locked .app-shell,
body.is-unlocked .unlock-screen {
  display: none !important;
}

body.is-unlocked {
  overflow: auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 250, 242, 0.82);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

button:hover {
  border-color: rgba(123, 74, 46, 0.36);
  box-shadow: 0 12px 26px rgba(65, 40, 22, 0.1);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(201, 155, 93, 0.34);
  outline-offset: 2px;
}

button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.primary {
  border-color: #734329;
  background: linear-gradient(180deg, #a96d42, var(--leather));
  color: #fff8ec;
  box-shadow: 0 16px 32px rgba(123, 74, 46, 0.24);
}

.danger {
  color: var(--danger);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.unlock-screen {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.unlock-card {
  position: relative;
  width: min(470px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 30px;
  background:
    linear-gradient(145deg, rgba(255, 251, 244, 0.96), rgba(255, 244, 227, 0.84)),
    url("/assets/paper-grain.svg");
  box-shadow: var(--shadow);
  overflow: hidden;
}

.unlock-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(123, 74, 46, 0.1);
  border-radius: var(--radius);
  pointer-events: none;
}

.unlock-card::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 240px;
  height: 320px;
  background: url("/assets/botanical.svg") center / contain no-repeat;
  opacity: 0.36;
  pointer-events: none;
}

.unlock-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.unlock-logo {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  box-shadow: 0 16px 38px rgba(123, 74, 46, 0.2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid rgba(125, 155, 116, 0.32);
  border-radius: 999px;
  padding: 4px 10px;
  color: #516b48;
  background: rgba(125, 155, 116, 0.1);
  font-size: 0.8rem;
  font-weight: 760;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(125, 155, 116, 0.14);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--leather);
  font-size: 0.76rem;
  font-weight: 820;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 26px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 9vw, 3.5rem);
  line-height: 0.96;
}

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.04;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.unlock-subtitle {
  position: relative;
  z-index: 1;
  max-width: 34ch;
  margin-bottom: 24px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.unlock-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 720;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(88, 59, 37, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 252, 247, 0.9);
  color: var(--ink);
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

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

.unlock-submit {
  width: 100%;
  margin-top: 2px;
}

.fine-print {
  position: relative;
  z-index: 1;
  min-height: 21px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-shell {
  min-height: 100dvh;
}

.rail-scrim {
  display: none;
}

.side-rail {
  position: fixed;
  z-index: 20;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: var(--rail-width);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius);
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(246, 232, 211, 0.9)),
    url("/assets/paper-grain.svg");
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 220ms ease, box-shadow 220ms ease;
}

body.rail-open .side-rail {
  width: var(--rail-open-width);
}

.rail-toggle {
  width: 50px;
  min-height: 50px;
  padding: 0;
  color: #fff8ec;
  background: linear-gradient(180deg, #a96d42, var(--leather));
  border-color: rgba(123, 74, 46, 0.4);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  margin: 14px 0 12px;
  white-space: nowrap;
}

.rail-brand img {
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  box-shadow: 0 12px 26px rgba(65, 40, 22, 0.14);
}

.rail-brand div,
.tab span {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

body.rail-open .rail-brand div,
body.rail-open .tab span {
  opacity: 1;
  transform: translateX(0);
}

.rail-brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.14rem;
}

.rail-brand span {
  display: block;
  max-width: 188px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  min-height: 50px;
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  padding: 0 14px;
  color: var(--ink-soft);
  background: transparent;
  white-space: nowrap;
}

.tab svg {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
}

.tab:hover {
  background: rgba(123, 74, 46, 0.08);
  box-shadow: none;
}

.tab.is-active {
  color: var(--leather);
  background: rgba(123, 74, 46, 0.11);
  border-color: rgba(123, 74, 46, 0.12);
}

.content-shell {
  min-height: 100dvh;
  margin-left: calc(var(--rail-width) + 30px);
  padding: 20px 22px 52px 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  margin-bottom: 16px;
  padding: 10px 0;
  backdrop-filter: blur(16px);
}

.page-title .eyebrow {
  margin-bottom: 4px;
}

.top-actions,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button {
  background: rgba(255, 250, 242, 0.82);
}

.workspace {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

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

.metric,
.panel,
.list-item,
.person-card,
.doc-card,
.contact-card,
.timeline-item,
.health-card {
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 250, 242, 0.92), rgba(255, 245, 230, 0.78)),
    url("/assets/paper-grain.svg");
  box-shadow: var(--shadow-soft);
}

.metric {
  min-height: 116px;
  padding: 16px;
}

.metric::before {
  content: "";
  display: block;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: rgba(223, 117, 106, 0.16);
}

.metric:nth-child(2)::before {
  background: rgba(105, 122, 203, 0.15);
}

.metric:nth-child(3)::before {
  background: rgba(224, 170, 81, 0.18);
}

.metric:nth-child(4)::before {
  background: rgba(169, 140, 198, 0.17);
}

.metric strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 12px;
}

.panel-title {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(88, 59, 37, 0.12);
}

.panel-title button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 999px;
  color: #fff8ec;
  background: linear-gradient(180deg, #a96d42, var(--leather));
}

.item-list,
.card-grid,
.timeline,
.health-grid {
  padding: 12px;
}

.item-list,
.timeline {
  display: grid;
  gap: 10px;
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 18px;
  background: rgba(255, 252, 247, 0.46);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.list-main {
  min-width: 0;
}

.list-main strong,
.doc-card strong,
.contact-card strong,
.timeline-item strong,
.health-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(88, 59, 37, 0.16);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 250, 242, 0.72);
  font-size: 0.8rem;
}

.chip.warn {
  border-color: rgba(223, 117, 106, 0.35);
  color: var(--coral);
  background: rgba(223, 117, 106, 0.1);
}

.chip.good {
  border-color: rgba(125, 155, 116, 0.35);
  color: #5f7a56;
  background: rgba(125, 155, 116, 0.11);
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.record-actions button {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.people-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 12px;
}

.member-rail {
  display: grid;
  gap: 10px;
  align-content: start;
}

.person-card {
  width: 100%;
  min-height: 90px;
  display: grid;
  gap: 2px;
  justify-content: start;
  padding: 14px;
  text-align: left;
}

.person-card.is-active {
  border-color: rgba(123, 74, 46, 0.35);
  background: linear-gradient(135deg, rgba(224, 170, 81, 0.16), rgba(255, 250, 242, 0.88));
}

.person-panel {
  padding: 16px;
}

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

.grid-form .wide {
  grid-column: 1 / -1;
}

.health-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.health-card,
.doc-card,
.contact-card,
.timeline-item {
  padding: 14px;
}

.health-card {
  border-left: 4px solid var(--coral);
}

.health-card:nth-child(2) {
  border-left-color: var(--green);
}

.health-card:nth-child(3) {
  border-left-color: var(--amber);
}

.timeline-item {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.date-pill {
  min-height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(224, 170, 81, 0.16);
  color: var(--leather);
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.date-pill span {
  display: block;
  color: var(--muted);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.doc-card,
.contact-card {
  min-height: 156px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(47, 32, 22, 0.38);
  backdrop-filter: blur(8px);
}

.dialog-card {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 250, 242, 0.98), rgba(255, 245, 230, 0.92)),
    url("/assets/paper-grain.svg");
  box-shadow: var(--shadow);
}

.dialog-heading {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

#closeDialogButton {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.2rem;
}

#recordFields {
  padding: 18px;
}

menu {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

menu .danger {
  margin-right: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: var(--leather-dark);
  color: #fff8ec;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .content-shell {
    margin-left: calc(var(--rail-width) + 18px);
    padding-right: 14px;
  }

  .metric-grid,
  .dashboard-grid,
  .people-layout,
  .health-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  body.rail-open .rail-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 18;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: rgba(36, 25, 19, 0.28);
    box-shadow: none;
    transform: none;
  }

  .side-rail {
    top: 10px;
    left: 10px;
    bottom: 10px;
  }

  body.rail-open .side-rail {
    width: min(280px, calc(100vw - 20px));
  }

  .content-shell {
    margin-left: 0;
    padding: 86px 12px 40px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 42px;
  }

  .top-actions button span {
    display: none;
  }

  .view-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .member-rail {
    grid-template-columns: 1fr;
  }

  menu {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  menu .danger {
    margin-right: 0;
  }
}

@media (max-width: 520px) {
  .unlock-screen {
    padding: 14px;
  }

  .unlock-card {
    padding: 22px;
  }

  .unlock-logo {
    width: 62px;
    height: 62px;
  }
}
