:root {
  color-scheme: light;
  --app-width: 840px;
  --bg: #eef1f2;
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --surface-pressed: #eeeeef;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #dedfe1;
  --line-strong: #c9cace;
  --accent: #087d75;
  --accent-dark: #05645e;
  --accent-soft: #e8f4f2;
  --danger: #b42336;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

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

button,
a,
input,
select,
textarea { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(8, 125, 117, 0.2);
  outline-offset: 1px;
}

[hidden] { display: none !important; }

.auth-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background: linear-gradient(160deg, #f8fbfb 0%, #eef1f2 70%);
}
.auth-card {
  width: min(100%, 420px);
  padding: 30px 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(28, 46, 49, 0.10);
}
.auth-logo-frame { display: block; width: 190px; height: 58px; margin-bottom: 22px; overflow: hidden; }
.auth-logo-frame img { width: 284px; max-width: none; transform: translate(-58px, -59px); }
.auth-card h1 { margin: 3px 0 8px; font-size: 32px; letter-spacing: -0.035em; }
.auth-status { margin: 0; color: var(--muted); }
.auth-card form { display: grid; gap: 15px; margin-top: 24px; }
.auth-card .primary-button { width: 100%; min-height: 50px; }
.auth-error { margin: -2px 0 0; color: var(--danger); font-size: 13px; }

.app-shell {
  width: min(100%, var(--app-width));
  min-height: 100vh;
  margin: 0 auto;
  overflow: clip;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  background: var(--surface-soft);
}

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(64px + var(--safe-top));
  padding: calc(8px + var(--safe-top)) 20px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px) saturate(160%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-logo-frame {
  position: relative;
  display: block;
  flex: 0 0 130px;
  width: 130px;
  height: 38px;
  overflow: hidden;
}

.brand-logo {
  position: absolute;
  top: -39px;
  left: -39px;
  display: block;
  width: 191px;
  max-width: none;
  height: auto;
}

.brand strong {
  display: block;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.profile-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #eceff0;
  color: #525256;
  font-size: 12px;
  font-weight: 650;
}

.app-main {
  width: 100%;
  min-width: 0;
  padding: 34px 24px calc(42px + var(--safe-bottom));
}

.view {
  width: 100%;
  min-width: 0;
  animation: view-in 0.18s ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-heading { margin-bottom: 24px; }
.page-heading.compact { margin-bottom: 20px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(31px, 7vw, 42px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.page-heading > p:last-child {
  max-width: 540px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.search-box {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.search-icon {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1.7px solid #77777d;
  border-radius: 50%;
}

.search-icon::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.7px;
  border-radius: 2px;
  background: #77777d;
  content: "";
  transform: rotate(45deg);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.search-box input::placeholder { color: #929298; }

.clear-search {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-pressed);
  color: #77777d;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.primary-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-action strong,
.primary-action small { display: block; }

.primary-action strong {
  font-size: 17px;
  font-weight: 650;
}

.primary-action small {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 450;
}

.primary-action small { color: rgba(255, 255, 255, 0.76); }
.chevron { font-size: 25px; font-weight: 300; line-height: 1; }

.admin-action {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  margin-top: 10px;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.admin-action-symbol { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); font-size: 19px; font-weight: 700; }
.admin-action-copy strong,
.admin-action-copy small { display: block; }
.admin-action-copy strong { font-size: 15px; font-weight: 650; }
.admin-action-copy small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.directory-add-button {
  width: 100%;
  min-height: 48px;
  margin: 12px 0 16px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.content-section { margin-top: 32px; }

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

.patient-list-heading { margin-top: 26px; }

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.section-heading button {
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.record-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.record-list:empty { display: none; }

.record-list.spacious { margin-top: 18px; }

.patient-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 70px;
  padding: 12px 15px;
  border: 0;
  border-bottom: 1px solid #ececef;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.patient-row:last-child { border-bottom: 0; }
.patient-row:active { background: #f2f2f3; }

.row-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e9efef;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 650;
}

.row-copy,
.row-meta { min-width: 0; }
.row-copy strong,
.row-copy small,
.row-meta strong { display: block; }
.row-copy strong { overflow: hidden; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-copy small { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: #929298; font-size: 11px; text-align: right; }
.row-meta strong { margin-bottom: 3px; color: #5e5e63; font-size: 11px; font-weight: 600; }
.row-trailing { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.row-chevron { color: #b0b0b5; font-size: 21px; font-weight: 300; line-height: 1; }

.empty-state {
  padding: 34px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state h3 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; }
.empty-state p { margin: 6px auto 0; max-width: 340px; font-size: 13px; }
.empty-symbol { display: block; margin-bottom: 8px; color: var(--accent); font-size: 26px; }
.inline-empty { padding: 18px; color: var(--muted); font-size: 13px; text-align: center; }

.back-button {
  min-height: 38px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
}

.patient-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.patient-avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 650;
}

.patient-hero h1 { overflow: hidden; margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -0.025em; text-overflow: ellipsis; white-space: nowrap; }
.patient-hero a { color: var(--muted); font-size: 14px; text-decoration: none; }
.quiet-icon-button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: #f0f0f1; color: var(--muted); cursor: pointer; }

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

.document-actions button {
  min-width: 0;
  min-height: 82px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.document-actions button:active { background: var(--surface-pressed); }
.document-actions button::after { float: right; margin-top: -20px; color: #b0b0b5; font-size: 21px; font-weight: 300; line-height: 1; content: "›"; }
.document-actions strong,
.document-actions small { display: block; }
.document-actions strong { font-size: 15px; font-weight: 600; }
.document-actions small { margin-top: 4px; color: var(--muted); font-size: 12px; }

.bottom-nav {
  position: fixed;
  z-index: 45;
  right: auto;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: min(100%, var(--app-width));
  min-height: calc(66px + var(--safe-bottom));
  padding: 7px 12px var(--safe-bottom);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px) saturate(160%);
  transform: translateX(-50%);
}

.bottom-nav button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #77777d;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.bottom-nav button.is-active { color: var(--accent); font-weight: 650; }
.nav-symbol { display: none; }

.editor-view { width: 100%; max-width: 720px; margin: 0 auto; }
.is-editor .app-header { display: none; }
.is-editor .app-main { padding-top: 0; }

.editor-header {
  position: sticky;
  z-index: 42;
  top: 0;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 8px;
  margin: 0 -24px 18px;
  padding: calc(9px + var(--safe-top)) 24px 9px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px) saturate(160%);
}

.editor-header > div { min-width: 0; text-align: center; }
.editor-header h1 { overflow: hidden; margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.015em; text-overflow: ellipsis; white-space: nowrap; }
.editor-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }

.engine-status {
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}
.engine-status::before { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #b1b1b6; content: ""; vertical-align: 1px; }
.engine-status.is-ready { color: var(--accent-dark); }
.engine-status.is-ready::before { background: var(--accent); }

.form-card {
  margin-bottom: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.form-card-heading {
  display: block;
  margin-bottom: 18px;
}
.form-card-heading > span { display: none; }
.form-card-heading h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.form-card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.prices-view { max-width: 720px; margin: 0 auto; }
.price-settings-form { display: grid; gap: 12px; }
.price-admin-list { display: grid; gap: 12px; }
.price-admin-row { display: grid; grid-template-columns: minmax(92px, .72fr) repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px; min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.price-admin-row legend { float: left; width: 100%; margin: 0; padding: 0 8px 0 0; align-self: center; color: var(--ink); font-size: 17px; font-weight: 700; }
.currency-input { display: grid; grid-template-columns: minmax(0, 1fr) 38px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; }
.currency-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(19, 137, 127, .12); }
.currency-input input { width: 100%; min-width: 0; min-height: 48px; padding: 0 10px 0 12px; border: 0 !important; border-radius: 0 !important; outline: 0; box-shadow: none !important; font-size: 16px; font-weight: 600; }
.currency-input > span { display: grid; place-items: center; border-left: 1px solid var(--line); background: #f5f7f7; color: var(--muted); font-weight: 650; }
.price-settings-note { margin: 16px 0 0; padding: 12px 13px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); font-size: 13px; line-height: 1.45; }
.price-settings-actions { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 10px; }
.price-settings-actions button { min-height: 52px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  min-width: 0;
}
.field { display: grid; min-width: 0; gap: 7px; }
.field.is-wide { grid-column: 1 / -1; }

.field > span:not(.toggle-copy),
.field-label {
  color: #4c4c51;
  font-size: 13px;
  font-weight: 550;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input[type="date"],
.field input[type="time"] {
  display: block;
  align-self: stretch;
  box-sizing: border-box;
  inline-size: 100%;
  width: 100%;
  min-inline-size: 0;
  min-width: 0;
  max-inline-size: 100%;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}
.field input[type="date"]::-webkit-date-and-time-value,
.field input[type="time"]::-webkit-date-and-time-value {
  display: block;
  box-sizing: border-box;
  inline-size: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  text-align: left;
}
.field input[type="date"]::-webkit-datetime-edit,
.field input[type="time"]::-webkit-datetime-edit {
  display: block;
  inline-size: 100%;
  width: 100%;
  min-width: 0;
  padding: 0;
  text-align: left;
}
.field textarea { min-height: 96px; padding-top: 12px; padding-bottom: 12px; resize: vertical; line-height: 1.45; }
.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 125, 117, 0.1); }
.field input[readonly] { border-color: #e4e4e7; background: #f5f5f6; color: #57575c; cursor: default; }
.field input[readonly]:focus { border-color: #e4e4e7; box-shadow: none; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 11px; }

.segmented,
.multi-select {
  display: grid;
  grid-template-columns: repeat(var(--columns, 2), minmax(0, 1fr));
  gap: 5px;
  min-width: 0;
  padding: 4px;
  border-radius: 12px;
  background: #efeff1;
}

.segmented button,
.multi-select button {
  min-width: 0;
  min-height: 40px;
  padding: 6px 7px;
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #646469;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  cursor: pointer;
}
.segmented button.is-selected,
.multi-select button.is-selected { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.13); font-weight: 600; }

.toggle-row {
  position: relative;
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 2px 0 14px;
  border-bottom: 1px solid #ececef;
  cursor: pointer;
}
.toggle-row:last-child { padding-bottom: 2px; border-bottom: 0; }
.toggle-row > span:last-child { position: relative; flex: 0 0 50px; width: 50px; height: 30px; }
.toggle-copy { min-width: 0; }
.toggle-copy strong,
.toggle-copy small { display: block; }
.toggle-copy strong { font-size: 14px; font-weight: 550; }
.toggle-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.switch-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  opacity: 0;
}
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c7c7cc;
  transition: background 0.15s ease;
}
.switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  content: "";
  transition: transform 0.15s ease;
}
.switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(20px); }

.pricing-note {
  grid-column: 1 / -1;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 550;
}

.medicine-list { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.medicine-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; padding: 11px 12px; border-bottom: 1px solid #ececef; }
.medicine-item:last-child { border-bottom: 0; }
.medicine-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #f0f1f2; color: var(--muted); font-size: 10px; font-weight: 600; }
.medicine-copy { min-width: 0; }
.medicine-copy strong,
.medicine-copy small { display: block; }
.medicine-copy strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.medicine-copy small { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.medicine-actions { display: flex; gap: 5px; }
.medicine-actions button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: #f0f1f2; color: #5d5d62; font-size: 12px; cursor: pointer; }
.medicine-actions button:first-child { background: var(--accent-soft); color: var(--accent-dark); font-weight: 750; }
.add-medicine { width: 100%; min-height: 45px; margin-top: 9px; border: 1px dashed var(--line-strong); border-radius: 12px; background: transparent; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }

.editor-spacer { height: 88px; }

.editor-actions {
  position: fixed;
  z-index: 48;
  bottom: calc(12px + var(--safe-bottom));
  left: 50%;
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(170px, 1.2fr);
  gap: 9px;
  width: min(calc(100% - 32px), 700px);
  padding: 9px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(18px) saturate(160%);
  transform: translateX(-50%);
}

.primary-button,
.secondary-button {
  min-height: 47px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:active { background: var(--accent-dark); }
.primary-button:disabled { border-color: #b6b6bb; background: #b6b6bb; cursor: wait; }
.secondary-button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); }

.preview-sheet {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding-top: var(--safe-top);
  background: #dfe2e4;
}
.preview-sheet.is-open { display: grid; }
.preview-sheet > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.97);
}
.preview-sheet header small,
.preview-sheet header strong { display: block; }
.preview-sheet header small { margin-bottom: 2px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: 0.08em; }
.preview-sheet header strong { font-size: 15px; font-weight: 600; }
.preview-sheet header button { min-height: 40px; padding: 0 6px; border: 0; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; }
.preview-viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.preview-sheet iframe { position: absolute; top: 0; left: 50%; display: block; border: 0; background: #fff; transform-origin: top center; }
.engine-loading { position: absolute; inset: calc(58px + var(--safe-top)) 0 0; display: grid; place-items: center; background: #eceeef; color: var(--muted); font-size: 14px; }
.engine-loading.is-hidden { display: none; }

.engine-frame {
  position: fixed;
  top: 0;
  left: 0;
  width: 1440px;
  height: 1200px;
  border: 0;
  opacity: 0.001;
  pointer-events: none;
  transform: scale(0.001);
  transform-origin: top left;
  z-index: -2147483647;
}

.record-dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}
.record-dialog::backdrop { background: rgba(0, 0, 0, 0.32); backdrop-filter: blur(4px); }
.record-dialog [hidden] { display: none !important; }
.record-dialog form { display: grid; gap: 20px; padding: 20px; }
.record-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.record-dialog header > div { min-width: 0; }
.record-dialog header small { display: block; margin-bottom: 5px; color: var(--accent-dark); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; }
.record-dialog h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.record-dialog header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.dialog-close { flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: #efeff1; color: var(--muted); font-size: 20px; cursor: pointer; }
.record-dialog-fields { display: grid; gap: 14px; }
.record-dialog footer { display: flex; align-items: center; gap: 9px; padding-top: 4px; border-top: 1px solid #ececef; }
.dialog-footer-spacer { flex: 1; }
.record-dialog footer .primary-button,
.record-dialog footer .secondary-button,
.danger-button { min-width: 100px; }
.danger-button {
  min-height: 47px;
  padding: 0 14px;
  border: 1px solid #e3b8be;
  border-radius: 12px;
  background: #fff4f5;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.medicine-dialog {
  width: min(calc(100% - 24px), 540px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}
.medicine-dialog::backdrop { background: rgba(0, 0, 0, 0.32); backdrop-filter: blur(4px); }
.medicine-dialog [hidden] { display: none !important; }
.medicine-library-view {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  height: min(720px, calc(100dvh - 24px));
  min-height: 460px;
  padding: 18px;
}
.medicine-dialog form { display: grid; gap: 14px; padding: 18px; }
.medicine-dialog header,
.medicine-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.medicine-dialog h2 { margin: 0; font-size: 19px; font-weight: 650; }
.medicine-dialog header small { display: block; margin-bottom: 3px; color: var(--accent-dark); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; }
.medicine-library-view header > div { min-width: 0; }
.medicine-library-view header p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.medicine-dialog header button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: #efeff1; color: var(--muted); font-size: 20px; cursor: pointer; }
.medicine-dialog form header { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; }
.medicine-dialog form header h2 { overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.medicine-dialog footer { margin-top: 4px; }
.medicine-dialog footer button { flex: 1; }

.medicine-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #fff;
}
.medicine-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 125, 117, 0.1); }
.medicine-search > span { color: var(--muted); font-size: 21px; line-height: 1; }
.medicine-search input { width: 100%; min-width: 0; height: 46px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.medicine-search input::-webkit-search-cancel-button { cursor: pointer; }

.medicine-library-list {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 0;
  padding-right: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.medicine-library-group { display: grid; gap: 9px; }
.medicine-library-group + .medicine-library-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e5e5e8; }
.medicine-library-group-title { display: grid; gap: 2px; padding: 3px 4px 5px; }
.medicine-library-group-title strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.medicine-library-group-title span { color: var(--muted); font-size: 10px; }
.medicine-library-group.is-similar .medicine-library-group-title strong { color: var(--accent-dark); }
.medicine-library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.medicine-library-card.is-selected { border-color: #9ccdc8; background: var(--accent-soft); }
.medicine-library-card.is-similar { border-color: #9ccdc8; box-shadow: 0 0 0 2px rgba(8, 125, 117, 0.05); }
.medicine-library-copy { min-width: 0; }
.medicine-library-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.medicine-library-title strong { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.medicine-library-title span { flex: 0 0 auto; padding: 3px 6px; border-radius: 999px; background: #d7eeeb; color: var(--accent-dark); font-size: 9px; font-weight: 650; }
.medicine-library-title .similar-badge { background: var(--accent); color: #fff; }
.medicine-library-copy small,
.medicine-library-copy em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.medicine-library-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.medicine-library-copy em { margin-top: 6px; color: var(--accent-dark); font-size: 10px; font-style: normal; font-weight: 650; }
.medicine-library-copy p { margin: 6px 0 0; color: #9b5b11; font-size: 10px; font-weight: 550; line-height: 1.3; }
.medicine-library-action {
  align-self: start;
  min-width: 74px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.medicine-library-card.is-selected .medicine-library-action { background: var(--accent); color: #fff; }
.medicine-variant { display: grid; grid-column: 1 / -1; gap: 5px; }
.medicine-variant span { color: var(--muted); font-size: 10px; font-weight: 550; }
.medicine-variant select { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: #fff; color: var(--ink); font-size: 14px; }
.medicine-library-empty { display: grid; place-items: center; align-content: center; gap: 5px; min-height: 180px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; }
.medicine-library-empty strong { color: var(--ink); font-size: 14px; }
.medicine-library-empty span { font-size: 12px; }

.toast {
  position: fixed;
  z-index: 150;
  right: 16px;
  bottom: calc(92px + var(--safe-bottom));
  left: 16px;
  max-width: 460px;
  margin: auto;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgba(29, 29, 31, 0.94);
  color: #fff;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: rgba(151, 38, 55, 0.96); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .app-shell { min-height: 100dvh; border: 0; }
  .app-header {
    min-height: calc(60px + var(--safe-top));
    padding: calc(7px + var(--safe-top)) 14px 7px;
  }
  .brand { min-width: 0; gap: 8px; }
  .brand-logo-frame { flex-basis: 122px; width: 122px; height: 36px; }
  .brand-logo { top: -36px; left: -36px; width: 180px; }
  .brand strong { overflow: hidden; padding-left: 9px; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
  .profile-mark { flex: 0 0 auto; width: 36px; height: 36px; font-size: 11px; }
  .app-main { padding: 22px 14px calc(32px + var(--safe-bottom)); }
  .page-heading { margin-bottom: 19px; }
  .eyebrow { margin-bottom: 6px; font-size: 10px; }
  .page-heading h1 { font-size: clamp(31px, 9vw, 35px); line-height: 1.05; }
  .page-heading > p:last-child { margin-top: 8px; font-size: 14px; line-height: 1.42; }
  .search-box {
    position: sticky;
    z-index: 24;
    top: calc(68px + var(--safe-top));
    min-height: 52px;
    border-radius: 15px;
    box-shadow: 0 5px 18px rgba(27, 44, 46, 0.06);
  }
  .search-box input { height: 50px; }
  .primary-action { min-height: 76px; margin-top: 12px; padding: 15px 17px; border-radius: 16px; }
  .primary-action strong { font-size: 16px; }
  .primary-action small { font-size: 12px; }
  .admin-action { min-height: 62px; border-radius: 15px; }
  .admin-action-symbol { width: 40px; height: 40px; }
  .patient-list-heading { margin-top: 25px; margin-bottom: 10px; }
  .record-list.spacious { margin-top: 0; }
  .record-list { border-radius: 15px; }
  .patient-row { min-height: 72px; padding: 11px 13px; }
  .row-copy strong { font-size: 16px; }
  .row-copy small { font-size: 13px; }
  .row-trailing { gap: 5px; }
  .row-meta { max-width: 58px; font-size: 11px; }
  .row-chevron { font-size: 22px; }
  .empty-state { padding: 30px 18px; }
  .back-button { min-width: 54px; min-height: 44px; font-size: 16px; }
  .patient-hero { grid-template-columns: 52px minmax(0, 1fr) 44px; gap: 12px; margin-top: 7px; padding: 16px 14px; border-radius: 18px; }
  .patient-avatar { width: 52px; height: 52px; font-size: 15px; }
  .patient-hero h1 { font-size: 20px; }
  .patient-hero a { font-size: 14px; }
  .quiet-icon-button { width: 44px; height: 44px; }
  .content-section { margin-top: 26px; }
  .section-heading h2 { font-size: 19px; }
  .document-actions { gap: 9px; }
  .document-actions button { min-height: 84px; padding: 14px; border-radius: 15px; }
  .document-actions strong { font-size: 16px; }
  .document-actions small { padding-right: 14px; font-size: 12px; line-height: 1.25; }
  .form-card { margin-bottom: 10px; padding: 17px 14px; border-radius: 16px; }
  .form-card-heading { margin-bottom: 15px; }
  .form-card-heading h2 { font-size: 18px; }
  .form-card-heading p { margin-top: 3px; font-size: 12px; line-height: 1.35; }
  .price-admin-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 9px; padding: 14px 12px; }
  .price-admin-row legend { grid-column: 1 / -1; margin-bottom: 2px; font-size: 17px; }
  .currency-input input { min-height: 49px; font-size: 16px; }
  .price-settings-actions { position: sticky; z-index: 35; bottom: calc(8px + var(--safe-bottom)); padding: 9px; border: 1px solid rgba(213, 217, 217, .9); border-radius: 16px; background: rgba(255, 255, 255, .94); box-shadow: 0 8px 28px rgba(25, 42, 43, .12); backdrop-filter: blur(18px); }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .field.is-wide,
  .toggle-row,
  .pricing-note { grid-column: auto; }
  .field-grid { gap: 15px; }
  .field { gap: 6px; }
  .field { scroll-margin-top: calc(78px + var(--safe-top)); }
  .field > span:not(.toggle-copy), .field-label { font-size: 13px; }
  .field input:not([type="checkbox"]):not([type="radio"]),
  .field select,
  .field textarea { min-height: 50px; border-radius: 12px; font-size: 16px; }
  .field textarea { min-height: 104px; }
  .segmented,
  .multi-select { grid-template-columns: repeat(var(--mobile-columns, var(--columns, 2)), minmax(0, 1fr)); gap: 6px; padding: 5px; border-radius: 13px; }
  .segmented button,
  .multi-select button { min-height: 44px; padding: 7px 6px; border-radius: 9px; font-size: 13px; white-space: normal; }
  .toggle-row { min-height: 58px; padding: 5px 0 13px; }
  .toggle-copy strong { font-size: 15px; }
  .toggle-copy small { font-size: 12px; }
  .pricing-note { padding: 12px 13px; font-size: 13px; line-height: 1.4; }
  .patient-summary-card { padding: 13px 14px; }
  .patient-summary-card .form-card-heading { margin-bottom: 10px; }
  .patient-summary-card .form-card-heading p { display: none; }
  .patient-summary-card .field-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 8px; }
  .patient-summary-card .field { min-width: 0; }
  .patient-summary-card .field > span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
  .patient-summary-card .field input:not([type="checkbox"]):not([type="radio"]) { min-height: 42px; padding: 0 10px; overflow: hidden; font-size: 13px; font-weight: 550; text-overflow: ellipsis; }
  .editor-header {
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    min-height: calc(60px + var(--safe-top));
    margin: 0 -14px 10px;
    padding: calc(7px + var(--safe-top)) 14px 7px;
  }
  .editor-header .back-button span { font-size: 0; }
  .editor-header .back-button span::after { font-size: 15px; content: "Geri"; }
  .editor-header h1 { font-size: 16px; }
  .engine-status { max-width: 58px; font-size: 10px; line-height: 1.15; text-align: right; }
  .engine-status::before { display: none; }
  .editor-spacer { height: 86px; }
  .editor-actions { bottom: 0; width: 100%; gap: 8px; padding: 9px 10px calc(9px + var(--safe-bottom)); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 17px 17px 0 0; }
  .editor-actions .primary-button,
  .editor-actions .secondary-button { min-height: 50px; padding: 0 10px; font-size: 15px; }
  .medicine-list { border-radius: 12px; }
  .medicine-item { gap: 8px; padding: 11px 9px; }
  .medicine-number { width: 28px; height: 28px; }
  .medicine-copy strong { font-size: 14px; }
  .medicine-actions { gap: 4px; }
  .medicine-actions button { width: 40px; height: 40px; }
  .add-medicine { min-height: 48px; font-size: 14px; }
  .preview-sheet > header { min-height: 56px; padding: 7px 14px; }
  .preview-sheet header button { min-width: 50px; min-height: 44px; }
  .medicine-dialog,
  .record-dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: calc(100dvh - var(--safe-top)); margin: 0; border-radius: 24px 24px 0 0; }
  .medicine-library-view { height: calc(100dvh - var(--safe-top)); min-height: 0; padding: 17px 14px calc(14px + var(--safe-bottom)); }
  .medicine-dialog form { min-height: calc(100dvh - var(--safe-top)); padding: 17px 14px calc(14px + var(--safe-bottom)); overflow-y: auto; }
  .medicine-dialog header button,
  .dialog-close { width: 40px; height: 40px; }
  .medicine-search { min-height: 50px; }
  .medicine-library-card { gap: 8px; padding: 12px 11px; }
  .medicine-library-title strong { font-size: 15px; }
  .medicine-library-copy small { font-size: 12px; }
  .medicine-library-action { min-width: 76px; min-height: 42px; }
  .record-dialog form { padding: 19px 16px calc(14px + var(--safe-bottom)); }
  .record-dialog h2 { font-size: 24px; }
  .record-dialog header p { font-size: 13px; }
  .record-dialog footer { position: sticky; bottom: 0; flex-wrap: wrap; padding-top: 10px; background: #fff; }
  .record-dialog footer .danger-button { order: 2; width: 100%; min-height: 46px; }
  .record-dialog footer .dialog-footer-spacer { display: none; }
  .record-dialog footer .secondary-button,
  .record-dialog footer .primary-button { flex: 1; min-height: 50px; }
  .toast { right: 10px; bottom: calc(76px + var(--safe-bottom)); left: 10px; padding: 13px 14px; border-radius: 13px; font-size: 14px; }
}

@media (max-width: 390px) {
  .brand-logo-frame { flex-basis: 113px; width: 113px; }
  .brand strong { font-size: 14px; }
  .app-main { padding-right: 12px; padding-left: 12px; }
  .segmented button,
  .multi-select button { padding-right: 4px; padding-left: 4px; font-size: 12px; }
  .patient-row { gap: 9px; padding-right: 12px; padding-left: 12px; }
  .row-avatar { width: 38px; height: 38px; }
  .row-meta { display: none; }
  .editor-header { margin-right: -12px; margin-left: -12px; padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 340px) {
  .brand-logo-frame { flex-basis: 100px; width: 100px; }
  .brand-logo { top: -32px; left: -32px; width: 163px; }
  .brand strong { max-width: 108px; padding-left: 7px; font-size: 13px; }
  .profile-mark { width: 34px; height: 34px; }
  .page-heading h1 { font-size: 29px; }
  .patient-summary-card .field-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-actions { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
  .editor-actions .primary-button,
  .editor-actions .secondary-button { font-size: 14px; }
}

@media (hover: hover) {
  .patient-row:hover,
  .document-actions button:hover { background: #f7fafa; }
  .primary-action:hover,
  .primary-button:hover { background: var(--accent-dark); }
}

@media (pointer: coarse) {
  button,
  a,
  input,
  select,
  textarea { touch-action: manipulation; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@font-face {
  font-family: "OfferTitle";
  src: url("assets/offer-title.woff") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}
