:root {
  --ink: #0f1f1c;
  --paper: #f8f9fa;
  --paper-deep: #edf0ef;
  --rose: #c9ada7;
  --green: #4a7c59;
  --line: rgba(15, 31, 28, 0.14);
  --muted: rgba(15, 31, 28, 0.62);
  --shadow: 0 24px 70px rgba(15, 31, 28, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(74, 124, 89, 0.08), transparent 34%),
    radial-gradient(circle at 80% 0%, rgba(201, 173, 167, 0.28), transparent 28%),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: var(--paper);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-size: 22px;
  letter-spacing: 0;
}

.brand small,
.metric small,
.appointment small,
.section-head p,
.calendar-slot small,
.report-score small {
  line-height: 1.55;
}

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

.tab {
  border: 1px solid rgba(248, 249, 250, 0.13);
  background: transparent;
  color: rgba(248, 249, 250, 0.72);
  border-radius: 8px;
  min-height: 42px;
  text-align: left;
  padding: 10px 12px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
  color: var(--paper);
  background: rgba(248, 249, 250, 0.11);
  transform: translateX(2px);
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(248, 249, 250, 0.16);
}

.rail-note strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

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

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

.eyebrow,
.mono {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail .mono {
  color: rgba(248, 249, 250, 0.56);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 62px);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 25px;
  line-height: 1.05;
}

h3 {
  margin-bottom: 5px;
  font-size: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.search-box input {
  width: min(300px, 58vw);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.14);
}

.icon-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
}

.icon-button {
  width: 44px;
  background: var(--ink);
  color: var(--paper);
  font-size: 20px;
}

.primary-button {
  background: var(--green);
  color: white;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.metric {
  min-height: 132px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.metric strong {
  display: block;
  font-size: 42px;
  line-height: 1;
}

.metric-warm {
  background: rgba(201, 173, 167, 0.22);
}

.metric-green {
  background: rgba(74, 124, 89, 0.16);
}

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

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

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

.timeline-panel,
.detail-sheet,
.treatment-sheet,
.audit-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 50px rgba(15, 31, 28, 0.08);
}

.timeline-panel,
.treatment-sheet,
.audit-panel {
  padding: 18px;
}

.detail-sheet {
  position: sticky;
  top: 24px;
  padding: 22px;
}

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

.section-head p,
.detail-sheet p,
.decision-card p,
.flow-step p {
  color: var(--muted);
  line-height: 1.7;
}

.stage-lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.lane {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-deep);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease;
}

.lane:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 124, 89, 0.45);
}

.lane strong {
  display: block;
  margin: 12px 0 5px;
  font-size: 30px;
}

.lane small {
  color: var(--muted);
}

.appointment-list {
  display: grid;
  gap: 10px;
}

.appointment {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 249, 250, 0.72);
  color: var(--ink);
  text-align: left;
}

.appointment.is-active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.appointment-time {
  color: var(--green);
  font-weight: 800;
}

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

.appointment-main strong,
.appointment-main small {
  display: block;
  overflow-wrap: anywhere;
}

.status-pill {
  border-radius: 999px;
  background: rgba(201, 173, 167, 0.3);
  padding: 6px 10px;
  white-space: nowrap;
}

.detail-sheet dl {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 18px 0;
}

.detail-sheet dt {
  color: var(--muted);
}

.detail-sheet dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.decision-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
}

.decision-card .mono,
.decision-card p {
  color: rgba(248, 249, 250, 0.7);
}

.decision-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 28px;
}

.decision-card .primary-button {
  width: 100%;
  margin-top: 8px;
  background: var(--rose);
  color: var(--ink);
}

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

.treatment-flow {
  display: grid;
  gap: 12px;
}

.flow-step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 82px;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.flow-step.is-done {
  border-color: rgba(74, 124, 89, 0.46);
  background: rgba(74, 124, 89, 0.08);
}

.flow-index {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.flow-key {
  color: var(--muted);
  text-align: right;
  overflow-wrap: anywhere;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.audit-row time {
  color: var(--green);
  font-weight: 800;
}

.audit-row p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.calendar-grid,
.report-grid {
  display: grid;
  gap: 12px;
}

.calendar-slot,
.report-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) minmax(130px, 220px) 58px;
  gap: 14px;
  align-items: center;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.calendar-slot time {
  color: var(--green);
  font-size: 24px;
  font-weight: 800;
}

.calendar-slot strong,
.calendar-slot small {
  display: block;
}

.load-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(15, 31, 28, 0.1);
  overflow: hidden;
}

.load-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--rose));
}

.report-row {
  grid-template-columns: minmax(0, 1fr) 110px 110px;
}

.report-row h3 {
  margin: 4px 0 0;
}

.report-score {
  text-align: right;
}

.report-score strong {
  display: block;
  font-size: 30px;
}

.report-score.muted strong {
  color: var(--green);
}

.empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

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

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

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

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

  .tab {
    text-align: center;
    padding-inline: 6px;
  }

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

  .detail-sheet {
    position: static;
  }

  .metric-grid,
  .stage-lanes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar,
  .section-head {
    display: grid;
  }

  h1 {
    font-size: 38px;
  }

  .toolbar,
  .search-box input {
    width: 100%;
  }

  .metric-grid,
  .stage-lanes,
  .tabs {
    grid-template-columns: 1fr;
  }

  .appointment,
  .calendar-slot,
  .report-row,
  .flow-step,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .status-pill,
  .flow-key,
  .report-score {
    width: fit-content;
    text-align: left;
  }
}
