:root {
  --bg: #b9c6b8;
  --surface: #f4fbf0;
  --surface-2: #e9f5e5;
  --ink: #111713;
  --muted: #637266;
  --green: #3ca166;
  --green-soft: #b9e7ca;
  --dark: #20262b;
  --line: rgba(17, 23, 19, 0.1);
  --yellow: #eef3bb;
  --danger: #de5c38;
  --shadow: 0 24px 70px rgba(36, 56, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(140deg, rgba(239, 250, 233, 0.44) 0 2px, transparent 2px 180px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.app-header,
.app-footer {
  width: 100%;
  background: rgba(244, 251, 240, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.app-header {
  min-height: 72px;
  border-radius: 26px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-footer {
  position: sticky;
  bottom: 14px;
  z-index: 12;
  border-radius: 26px;
  padding: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark,
.round-btn,
.info-button,
.nav-item {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
}

.brand-mark {
  width: 46px;
  height: 46px;
  object-fit: cover;
  background: white;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1;
}

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

.brand small,
.eyebrow,
.metric small,
label,
.patient-row small,
.visit-card small {
  color: var(--muted);
}

.nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 58px;
  padding: 10px 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--dark);
  line-height: 1;
}

.nav-item.active {
  background: var(--dark);
  color: white;
}

.nav-icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-body {
  align-self: stretch;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 6px 0 10px;
  display: flex;
  flex-direction: column;
}

.page-heading,
.panel-title,
.visit-card,
.patient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading {
  display: block;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
}

h2 {
  font-size: 24px;
  line-height: 1.12;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.info-button,
.status-pill,
.angle-badge {
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(244, 251, 240, 0.75);
  font-weight: 800;
}

.info-button {
  width: 44px;
  height: 44px;
  padding: 0;
  color: white;
  background: var(--green);
  font-size: 22px;
  font-weight: 900;
  font-family: Georgia, serif;
}

.install-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: white;
  background: var(--green);
  font-size: 14px;
  font-weight: 900;
}

.status-pill.ok {
  color: white;
  background: var(--green);
}

.status-pill.error {
  color: white;
  background: var(--danger);
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
}

.view.active {
  display: block;
}

.view:not(#dashboard).active {
  display: flex;
}

.view:not(#dashboard) > .panel,
.view:not(#dashboard) > .settings-grid {
  width: 100%;
  min-height: 100%;
}

.view:not(#dashboard) > .panel {
  display: flex;
  flex-direction: column;
}

.view:not(#dashboard) .visit-list,
.view:not(#dashboard) .patient-list,
.view:not(#dashboard) .form-grid {
  align-content: start;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: rgba(244, 251, 240, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 124px;
  border-radius: 30px;
  padding: 22px;
  display: grid;
  grid-template-columns: auto auto;
  place-items: center;
  justify-content: center;
  align-content: center;
  column-gap: 8px;
  row-gap: 4px;
  text-align: center;
}

.metric small {
  grid-column: 1 / -1;
}

.metric.green {
  background: var(--green-soft);
}

.metric.yellow {
  background: var(--yellow);
}

.metric-icon {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--green);
}

.metric strong {
  font-size: 34px;
}

.pain-state-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(3px, 0.7vw, 10px);
  margin-top: 18px;
}

.pain-state-card {
  min-width: 0;
  min-height: clamp(42px, 6vw, 72px);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: clamp(10px, 1.5vw, 18px);
  padding: 4px 2px;
  display: grid;
  place-items: center;
  align-content: center;
  background: var(--pain-color);
  box-shadow: var(--shadow);
  text-align: center;
}

.pain-state-card strong {
  color: white;
  font-size: clamp(16px, 2.4vw, 28px);
  line-height: 1;
}

.work-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.08fr);
  gap: 18px;
}

.settings-grid.single {
  grid-template-columns: 1fr;
}

.settings-grid.single > .panel {
  min-height: 100%;
}

.settings-entry,
.treatment-row {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 850;
  text-align: left;
}

.settings-entry:hover,
.settings-entry:focus-visible,
.treatment-row:hover,
.treatment-row:focus-visible {
  border-color: rgba(60, 161, 102, 0.45);
  background: var(--green-soft);
  outline: none;
}

.settings-entry > :last-child,
.treatment-row > :last-child {
  color: var(--green);
  font-size: 26px;
  line-height: 1;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-back {
  font-size: 28px;
}

.treatment-form {
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.treatment-search {
  max-width: 520px;
  margin-top: 18px;
}

.treatment-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.treatment-form .form-actions button {
  min-width: 118px;
}

.treatment-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.treatment-empty-state {
  min-height: 120px;
  border-radius: 20px;
  padding: 22px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.panel {
  border-radius: 32px;
  padding: clamp(18px, 3vw, 28px);
}

.round-btn {
  width: 54px;
  height: 54px;
  background: var(--dark);
  color: white;
  font-size: 24px;
}

.compact-round {
  width: 44px;
  height: 44px;
}

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

.form-grid.compact {
  margin-top: 8px;
}

.visit-layout {
  grid-template-columns: minmax(0, 2fr) minmax(210px, 1fr);
}

.visit-patient-field,
.visit-body-field {
  grid-column: 1;
}

.visit-date-field,
.visit-pain-field {
  grid-column: 2;
}

.visit-patient-field,
.visit-date-field {
  grid-row: 1;
}

.visit-body-field,
.visit-pain-field {
  grid-row: 2;
}

.add-patient-card,
.visit-form-card {
  margin-top: 18px;
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.body-picker-card {
  position: fixed;
  inset: clamp(8px, 2vh, 18px) clamp(8px, 2vw, 18px);
  z-index: 30;
  max-width: none;
  max-height: none;
  margin: auto;
  border-radius: 28px;
  padding: clamp(16px, 2.4vw, 24px);
  background: rgba(244, 251, 240, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 28px 90px rgba(17, 23, 19, 0.34);
  overflow: hidden;
}

.body-picker-card::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(17, 23, 19, 0.28);
  backdrop-filter: blur(6px);
}

.hidden {
  display: none !important;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  outline: none;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.autocomplete-field {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 18;
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(17, 23, 19, 0.18);
}

.autocomplete-option,
.autocomplete-empty {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 11px 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.autocomplete-option {
  display: grid;
  gap: 2px;
}

.autocomplete-option:hover,
.autocomplete-option:focus {
  background: var(--surface-2);
}

.autocomplete-option small,
.autocomplete-empty {
  color: var(--muted);
}

.icon-action {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--dark);
  font-size: 24px;
  font-weight: 900;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(60, 161, 102, 0.15);
}

input[type="range"] {
  --pain-color: var(--green);
  --pain-percent: 44.444%;
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  padding-inline: 0;
  background: transparent;
  accent-color: var(--pain-color);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #36a460 0%, #e0b338 50%, #de3d38 100%),
    linear-gradient(90deg, var(--pain-color) 0 var(--pain-percent), var(--dark) var(--pain-percent) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--pain-color);
  box-shadow: 0 4px 14px rgba(17, 23, 19, 0.22);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #36a460 0%, #e0b338 50%, #de3d38 100%);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--pain-color);
  box-shadow: 0 4px 14px rgba(17, 23, 19, 0.22);
}

.primary-action {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-weight: 900;
}

.secondary-action {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  color: var(--dark);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 900;
}

.treatment-selector {
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(30, 39, 45, 0.08);
  border-radius: 16px;
  padding: 10px 12px 12px;
  color: var(--muted);
  background: white;
  box-shadow: 0 12px 28px rgba(30, 39, 45, 0.16);
}

.treatment-selector legend {
  padding: 0 4px;
  font-weight: 700;
}

.treatment-selector legend small {
  margin-left: 6px;
  font-weight: 600;
}

.treatment-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.treatment-picker-search {
  margin-bottom: 10px;
  border-radius: 14px;
  padding-block: 10px;
}

.treatment-check {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  background: rgba(244, 251, 240, 0.72);
  box-shadow: none;
  cursor: pointer;
}

.treatment-check:has(input:checked) {
  border-color: var(--green);
  color: #174c2b;
  background: var(--green-soft);
}

.treatment-check.inactive {
  border-style: dashed;
  color: var(--muted);
}

.treatment-check input {
  appearance: auto;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  border: 0;
  border-radius: 3px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--green);
}

.treatment-empty {
  padding: 5px 2px;
  color: var(--muted);
}

.danger-action {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  padding-inline: 18px;
  color: white;
  background: var(--danger);
  font-weight: 900;
}

.pain-record-editor .primary-action,
.pain-record-editor .secondary-action,
.pain-record-editor .danger-action {
  min-height: 44px;
}

.pain-record-editor .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.body-panel {
  min-height: 680px;
  overflow: hidden;
}

.body-stage {
  position: relative;
  min-height: 0;
  height: 100%;
  margin: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.8), transparent 22%),
    linear-gradient(180deg, rgba(192, 230, 184, 0.7), rgba(235, 246, 229, 0.5));
  overflow: hidden;
}

.body-picker-layout {
  display: block;
  margin-top: 14px;
  align-items: stretch;
  height: calc(100% - 168px);
  min-height: 0;
}

.body-search-field {
  position: relative;
  margin-top: 14px;
  max-width: min(560px, 100%);
}

.body-search-field .search {
  max-width: none;
}

.body-search-field .autocomplete-list {
  z-index: 40;
  max-height: min(320px, 42vh);
}

#bodyCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.model-fallback {
  position: absolute;
  inset: auto 24px 24px;
  display: none;
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(32, 38, 43, 0.88);
  color: white;
  text-align: center;
  font-weight: 800;
}

.chip-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.chip {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: white;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
}

.chip.active {
  background: var(--dark);
  color: white;
}

.search {
  max-width: 260px;
}

.list-toolbar,
.visits-toolbar {
  justify-content: space-between;
}

.list-toolbar .search,
.visits-toolbar .search {
  max-width: min(420px, calc(100% - 72px));
}

.list-toolbar .round-btn,
.visits-toolbar .round-btn {
  flex: 0 0 54px;
}

.patient-toolbar-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 116px;
  white-space: nowrap;
}

.sort-control { position: relative; display: flex; flex: 0 0 54px; }
.sort-button { width: 54px; height: 54px; font-size: 25px; }
.sort-menu {
  position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; width: 190px;
  padding: 6px; border: 1px solid rgba(30, 39, 45, 0.08); border-radius: 16px;
  background: white; box-shadow: 0 12px 28px rgba(30, 39, 45, 0.16);
}
.sort-menu button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 11px;
  background: transparent; color: var(--dark); text-align: left; font: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.sort-menu button:hover, .sort-menu button:focus-visible, .sort-menu button.selected {
  background: var(--green-soft); color: var(--green);
}

.visit-list,
.patient-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.visit-card,
.patient-row {
  border-radius: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.pain-dot {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: white;
  background: var(--pain-color, var(--green));
  font-weight: 900;
}

.patient-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.edit-visit-button,
.edit-patient-button {
  border: 0;
}

.edit-visit-button:hover,
.edit-visit-button:focus,
.edit-patient-button:hover,
.edit-patient-button:focus {
  background: var(--green);
  color: white;
  box-shadow: 0 0 0 4px rgba(60, 161, 102, 0.16);
}

.patient-main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
  align-content: center;
}

.visit-card-editable {
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.visit-card-editable:hover,
.visit-card-editable:focus-visible {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 3px rgba(60, 161, 102, 0.16);
  outline: none;
  transform: translateY(-1px);
}

.patient-row-link {
  cursor: pointer;
  border-radius: 12px;
  padding: 6px;
  margin: -6px;
}

.patient-row-link:hover,
.patient-row-link:focus-visible {
  background: rgba(60, 161, 102, 0.08);
  outline: none;
}

.patient-main strong,
.patient-main small {
  display: block;
}

.visit-treatment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.visit-treatment-tags span {
  border-radius: 999px;
  padding: 4px 8px;
  color: #174c2b;
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 800;
}

.visit-treatment-tags span.inactive {
  color: var(--muted);
  background: rgba(99, 114, 102, 0.12);
}

.patient-pain-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.pain-trend {
  display: inline-flex;
  align-items: center;
  min-width: 46px;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 900;
}

.pain-trend.empty {
  min-width: 42px;
  justify-content: center;
}

.pain-mini {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--pain-color, var(--green));
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.pain-value {
  font-size: 16px;
  line-height: 1;
}

.open-pain-chart-button:hover,
.open-pain-chart-button:focus {
  box-shadow: 0 0 0 4px rgba(17, 23, 19, 0.12);
}

.trend-arrow {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-size: 20px;
  font-weight: 1000;
  line-height: 1;
  -webkit-text-stroke: 0.45px currentColor;
  text-shadow: 0 1px 1px rgba(17, 23, 25, 0.18);
}

.pain-trend.up .trend-arrow {
  color: #de3d38;
}

.pain-trend.down .trend-arrow {
  color: #36a460;
}

.pain-trend.same .trend-arrow {
  color: var(--muted);
}

.visit-pain-trend {
  flex: 0 0 auto;
}

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(120px);
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 22px;
  padding: 14px 18px;
  background: var(--dark);
  color: white;
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 23, 19, 0.28);
  backdrop-filter: blur(6px);
}

.chart-card {
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 28px;
  padding: clamp(16px, 2.4vw, 24px);
  background: rgba(244, 251, 240, 0.96);
  box-shadow: 0 28px 90px rgba(17, 23, 19, 0.34);
}

.pain-chart {
  margin-top: 18px;
  border-radius: 22px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.chart-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.chart-add-button {
  background: var(--green);
}

.pain-record-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  scroll-margin-bottom: 18px;
}

.pain-record-editor .panel-title,
.pain-record-editor .form-actions {
  grid-column: 1 / -1;
}

.pain-record-editor .panel-title {
  align-items: baseline;
}

.pain-record-editor label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.pain-record-editor input[type="date"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
}

.pain-record-editor input[type="range"] {
  --pain-color: var(--green);
  --pain-percent: 44.444%;
  width: 100%;
  accent-color: var(--pain-color);
  background: linear-gradient(90deg, var(--pain-color) 0 var(--pain-percent), var(--dark) var(--pain-percent) 100%);
}

.pain-record-editor output {
  color: var(--ink);
  font-size: 18px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 10px 4px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--green);
}

.legend-dot.standalone {
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 0 1px var(--green);
  transform: rotate(45deg);
}

.pain-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: rgba(99, 114, 102, 0.24);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--muted);
  stroke-width: 2;
}

.chart-line {
  fill: none;
  stroke: var(--dark);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-point {
  fill: var(--pain-color);
  stroke: white;
  stroke-width: 4;
}

.chart-point.standalone {
  fill: var(--pain-color);
  stroke: var(--dark);
}

.chart-point-hit {
  cursor: pointer;
  outline: none;
}

.chart-point-hit:focus .chart-point,
.chart-point-hit:hover .chart-point {
  stroke-width: 6;
}

.chart-y-label,
.chart-x-label,
.chart-axis-title,
.chart-point-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.chart-y-label {
  text-anchor: end;
}

.chart-point-label {
  fill: var(--ink);
}

.chart-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.app-info-modal {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 23, 19, 0.28);
  backdrop-filter: blur(6px);
}

.app-info-card {
  width: min(360px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 28px;
  padding: 28px;
  display: grid;
  place-items: center;
  gap: 14px;
  background: rgba(244, 251, 240, 0.96);
  box-shadow: 0 28px 90px rgba(17, 23, 19, 0.34);
  text-align: center;
}

.app-info-logo {
  width: 82px;
  height: 82px;
  border-radius: 24px;
  object-fit: cover;
  background: white;
}

.app-loader {
  width: 46px;
  height: 46px;
  border: 5px solid rgba(60, 161, 102, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.app-info-card p {
  color: var(--muted);
  font-weight: 800;
}

.app-info-modal.from-info .app-loader {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .app-shell {
    padding: 12px 14px;
    gap: 12px;
  }

  .work-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .pain-state-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    gap: 8px;
  }

  .metric {
    min-height: 96px;
    padding: 12px 8px;
  }

  .metric strong {
    font-size: 28px;
  }

  .pain-state-grid {
    gap: 3px;
    margin-top: 12px;
  }

  .visit-patient-field,
  .visit-date-field,
  .visit-pain-field,
  .visit-body-field {
    grid-column: auto;
    grid-row: auto;
  }

  .wide {
    grid-column: auto;
  }

  .treatment-selector {
    grid-column: auto;
  }

  .treatment-form .form-actions {
    flex-wrap: wrap;
  }

  .treatment-form .form-actions button {
    flex: 1 1 120px;
  }

  .app-header {
    border-radius: 22px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand strong {
    font-size: 15px;
  }

  .nav {
    gap: 6px;
  }

  .nav-item {
    min-height: 56px;
    padding: 9px 5px;
  }

  .page-heading,
  .panel-title {
    align-items: flex-start;
  }

  .body-stage {
    min-height: 0;
    height: 100%;
  }

  .body-picker-card {
    inset: 10px;
    height: calc(100dvh - 20px);
    padding: 14px;
  }

  .body-picker-layout {
    height: calc(100% - 154px);
    margin-top: 10px;
  }

  .chip {
    padding: 9px 10px;
    font-size: 12px;
  }

  .patient-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
  }

  .patient-pain-summary {
    width: auto;
    justify-content: flex-end;
  }

  .panel,
  .metric {
    border-radius: 24px;
  }

  .pain-record-editor {
    grid-template-columns: 1fr;
  }

  .pain-record-editor .panel-title,
  .pain-record-editor .form-actions {
    grid-column: auto;
  }
}
