:root {
  --ink: #1f2933;
  --paper: #fbfbf2;
  --blue: #4c6fff;
  --orange: #f9703e;
  --mint: #41b883;
  --line: rgba(31, 41, 51, 0.14);
  --soft: rgba(251, 251, 242, 0.72);
  --shadow: 0 20px 60px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.side-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(76, 111, 255, 0.18), transparent 42%),
    var(--ink);
  color: var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
}

.brand img {
  flex: 0 0 auto;
}

.rail-nav {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.rail-btn {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(251, 251, 242, 0.13);
  border-radius: 8px;
  background: transparent;
  color: rgba(251, 251, 242, 0.78);
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.rail-btn:hover,
.rail-btn.is-active {
  background: rgba(251, 251, 242, 0.12);
  color: var(--paper);
  transform: translateX(2px);
}

.rail-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(251, 251, 242, 0.1);
  color: var(--paper);
  font-size: 12px;
  font-weight: 800;
}

.rail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(251, 251, 242, 0.14);
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: rgba(31, 41, 51, 0.6);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.15;
}

.top-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  min-width: 280px;
  color: rgba(31, 41, 51, 0.64);
  font-size: 12px;
  font-weight: 700;
}

.search input,
.request-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

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

.icon-btn,
.primary-btn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.icon-btn {
  width: 42px;
  background: var(--ink);
  color: var(--paper);
}

.primary-btn {
  background: var(--blue);
  color: #fff;
}

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

.summary-cell {
  min-height: 78px;
  background: rgba(251, 251, 242, 0.95);
  padding: 12px;
}

.summary-cell strong {
  display: block;
  margin-bottom: 4px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.summary-cell span {
  color: rgba(31, 41, 51, 0.62);
  font-size: 12px;
  font-weight: 700;
}

.alert-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 2px;
}

.alert-pill {
  flex: 0 0 auto;
  max-width: 360px;
  border: 1px solid rgba(249, 112, 62, 0.28);
  border-radius: 8px;
  background: rgba(249, 112, 62, 0.08);
  padding: 10px 12px;
  font-size: 13px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: rise 220ms ease both;
}

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

.risk-layout {
  display: grid;
  grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.asset-graph {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(251, 251, 242, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(251, 251, 242, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 28% 22%, rgba(76, 111, 255, 0.38), transparent 28%),
    radial-gradient(circle at 72% 74%, rgba(249, 112, 62, 0.34), transparent 30%),
    var(--ink);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
}

.graph-line {
  position: absolute;
  height: 2px;
  background: rgba(251, 251, 242, 0.22);
  transform-origin: left center;
}

.line-a {
  left: 25%;
  top: 29%;
  width: 55%;
  transform: rotate(22deg);
}

.line-b {
  left: 20%;
  top: 64%;
  width: 62%;
  transform: rotate(-28deg);
}

.line-c {
  left: 36%;
  top: 18%;
  width: 42%;
  transform: rotate(88deg);
}

.node {
  position: absolute;
  display: grid;
  gap: 6px;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(251, 251, 242, 0.24);
  border-radius: 50%;
  background: rgba(31, 41, 51, 0.72);
  color: var(--paper);
  font-weight: 800;
  transition: transform 180ms ease, border-color 180ms ease;
}

.node:hover {
  transform: scale(1.05);
  border-color: var(--orange);
}

.node span {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.node-pet {
  left: 12%;
  top: 15%;
}

.node-visit {
  right: 9%;
  top: 27%;
}

.node-lab {
  left: 18%;
  bottom: 17%;
}

.node-owner {
  right: 16%;
  bottom: 14%;
}

.registry-workspace,
.visit-board,
.request-form,
.finance-side {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-head p,
.request-form p {
  margin-bottom: 0;
  color: rgba(31, 41, 51, 0.62);
  font-size: 14px;
}

.data-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  color: rgba(31, 41, 51, 0.58);
  font-size: 12px;
  text-transform: uppercase;
}

.pet-name {
  display: block;
  font-weight: 900;
}

.muted {
  color: rgba(31, 41, 51, 0.6);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.severity-critical {
  background: var(--orange);
  color: #fff;
}

.severity-high {
  background: rgba(249, 112, 62, 0.18);
  color: #9b3716;
}

.severity-medium {
  background: rgba(76, 111, 255, 0.14);
  color: #243ebf;
}

.severity-low {
  background: rgba(65, 184, 131, 0.14);
  color: #126b44;
}

.status-chip {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.loadbar {
  width: 116px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.09);
}

.loadbar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--orange));
}

.row-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.request-grid,
.finance-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
}

.request-form {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.request-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

.terminal {
  min-height: 96px;
  overflow: auto;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.visit-list,
.document-list,
.finance-list,
#finance-totals {
  display: grid;
  gap: 10px;
}

.visit-item,
.document-item,
.finance-item,
.total-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.visit-top,
.document-top,
.finance-top,
.total-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prescriptions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prescriptions span {
  border-radius: 999px;
  background: rgba(76, 111, 255, 0.1);
  padding: 5px 8px;
  color: #243ebf;
  font-size: 12px;
  font-weight: 700;
}

.finance-side {
  position: sticky;
  top: 112px;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.amount {
  font-size: 24px;
  font-weight: 900;
}

.is-loading {
  opacity: 0.62;
}

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

  .side-rail {
    position: static;
    height: auto;
    padding: 12px;
  }

  .rail-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 14px;
  }

  .rail-btn {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
  }

  .rail-footer {
    display: none;
  }

  .workspace {
    padding: 18px 14px 28px;
  }

  .topbar,
  .top-actions,
  .panel-head,
  .visit-top,
  .document-top,
  .finance-top {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    min-width: 0;
  }

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

  .risk-layout,
  .request-grid,
  .finance-layout {
    grid-template-columns: 1fr;
  }

  .asset-graph {
    min-height: 360px;
  }

  .node {
    width: 92px;
    height: 92px;
    font-size: 12px;
  }

  .node span {
    font-size: 25px;
  }

  .finance-side {
    position: static;
  }
}

@media (max-width: 520px) {
  .rail-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 34px;
  }

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

