:root {
  color-scheme: light;
  --ink: #1f2933;
  --paper: #fbfbf2;
  --paper-strong: #ffffff;
  --blue: #4c6fff;
  --orange: #f9703e;
  --line: rgba(31, 41, 51, 0.16);
  --muted: rgba(31, 41, 51, 0.62);
  --shadow: 0 18px 55px rgba(31, 41, 51, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 41, 51, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 41, 51, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100svh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  color: var(--paper);
  background: var(--ink);
  border-right: 1px solid rgba(251, 251, 242, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: 0;
}

.brand img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

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

.nav-tab {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(251, 251, 242, 0.14);
  border-radius: 8px;
  color: rgba(251, 251, 242, 0.78);
  background: transparent;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--paper);
  background: rgba(76, 111, 255, 0.28);
  transform: translateX(2px);
}

.rail-note {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(251, 251, 242, 0.14);
}

.rail-note span {
  display: block;
  margin-bottom: 8px;
  color: rgba(251, 251, 242, 0.56);
  font-size: 12px;
  text-transform: uppercase;
}

.rail-note strong {
  display: block;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 58px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(420px, 100%);
}

.search label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.search input,
.request-form input,
.request-form textarea,
.request-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

.request-form textarea {
  min-height: 104px;
  resize: vertical;
}

.search input:focus,
.request-form input:focus,
.request-form textarea:focus,
.request-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.12);
}

.search button,
.primary {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--paper);
  background: var(--blue);
  font-weight: 760;
}

.summary-row {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.metric {
  min-width: 0;
  padding: 14px;
  background: rgba(251, 251, 242, 0.96);
}

.metric span,
.finance-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 0.95;
  letter-spacing: 0;
}

.metric.danger strong {
  color: var(--orange);
}

.screen {
  display: none;
  animation: rise 260ms ease both;
}

.screen.active {
  display: block;
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.table-zone,
.graph-zone,
.request-form,
.flow-preview,
.document-list,
.finance-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 251, 242, 0.88);
}

.table-zone,
.graph-zone {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
}

table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 13px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.11);
  text-align: left;
  vertical-align: top;
}

th {
  color: rgba(31, 41, 51, 0.72);
  background: rgba(31, 41, 51, 0.04);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

td small {
  display: block;
  max-width: 280px;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

tr.risk-red {
  box-shadow: inset 4px 0 0 #d62839;
}

tr.risk-orange {
  box-shadow: inset 4px 0 0 var(--orange);
}

tr.risk-blue {
  box-shadow: inset 4px 0 0 var(--blue);
}

tr.risk-green {
  box-shadow: inset 4px 0 0 #36a269;
}

.pet-cell {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 150px;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.pet-cell strong {
  font-size: 16px;
}

.pet-cell span {
  color: var(--muted);
  font-size: 13px;
}

.rx-text {
  display: block;
  max-width: 330px;
  line-height: 1.35;
}

.pay {
  display: inline-flex;
  min-width: 76px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  background: rgba(31, 41, 51, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.pay.paid {
  color: #1c6b46;
  background: rgba(54, 162, 105, 0.16);
}

.pay.pending {
  color: #78511d;
  background: rgba(249, 112, 62, 0.16);
}

.pay.overdue {
  color: #9c2330;
  background: rgba(214, 40, 57, 0.15);
}

.graph-zone {
  position: sticky;
  top: 112px;
}

.graph {
  display: grid;
  gap: 13px;
  padding: 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
}

.node {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px solid rgba(251, 251, 242, 0.16);
  border-radius: 8px;
  color: var(--paper);
  text-align: center;
  overflow-wrap: anywhere;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.node.selected {
  border-color: rgba(76, 111, 255, 0.8);
  background: rgba(76, 111, 255, 0.18);
  transform: translateY(-1px);
}

.edge {
  width: 3px;
  height: 28px;
  margin: 0 auto;
  background: var(--blue);
}

.edge.hot {
  background: var(--orange);
  box-shadow: 0 0 18px rgba(249, 112, 62, 0.65);
}

.heatmarks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.heatmark {
  min-height: 72px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.heatmark span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.heatmark strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
  line-height: 1;
}

.heatmark.high strong {
  color: #d62839;
}

.heatmark.medium strong {
  color: var(--orange);
}

.heatmark.low strong {
  color: var(--blue);
}

.split-flow {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(260px, 1fr);
  gap: 18px;
}

.request-form {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.request-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.form-status {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--blue);
  font-weight: 700;
}

.flow-preview {
  display: grid;
  align-content: center;
  gap: 12px;
  min-height: 420px;
  padding: 24px;
  background: var(--ink);
}

.flow-step {
  min-height: 74px;
  display: flex;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(251, 251, 242, 0.2);
  border-radius: 8px;
  color: rgba(251, 251, 242, 0.7);
  transition: transform 180ms ease, color 180ms ease, border-color 180ms ease;
}

.flow-step.active,
.flow-step:hover {
  color: var(--paper);
  border-color: var(--orange);
  transform: translateX(4px);
}

.document-list {
  overflow: hidden;
}

.document-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(90px, 140px) minmax(150px, 240px);
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.document-row:last-child {
  border-bottom: 0;
}

.document-row span,
.document-row small {
  color: var(--muted);
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.finance-grid div {
  min-height: 180px;
  padding: 22px;
  background: rgba(251, 251, 242, 0.94);
}

.finance-grid strong {
  display: block;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: relative;
    height: auto;
    padding: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-tab {
    text-align: center;
  }

  .rail-note {
    margin-top: 0;
  }

  .board-grid,
  .split-flow {
    grid-template-columns: 1fr;
  }

  .graph-zone {
    position: relative;
    top: auto;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 16px;
  }

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

  h1 {
    font-size: 34px;
    line-height: 1;
  }

  .summary-row {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-row .metric:first-child {
    grid-column: 1 / -1;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .document-row,
  .finance-grid {
    grid-template-columns: 1fr;
  }

  .flow-preview {
    min-height: 280px;
  }
}

@media (max-width: 430px) {
  .workspace,
  .rail {
    padding: 12px;
  }

  h1 {
    font-size: 30px;
  }

  .summary-row,
  .heatmarks {
    grid-template-columns: 1fr;
  }

  .metric strong,
  .finance-grid strong {
    font-size: 31px;
  }
}

