:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #fbf9ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-2: rgba(252, 250, 255, 0.98);
  --surface-3: rgba(126, 87, 194, 0.1);
  --ink: #20172f;
  --muted: #756a89;
  --line: rgba(93, 64, 142, 0.15);
  --green: #7e57c2;
  --green-dark: #5e35b1;
  --mint: #f4efff;
  --blue: #8f7cf7;
  --orange: #ffb74d;
  --violet: #7e57c2;
  --violet-soft: #ede7f6;
  --vet-pink: #fce7f3;
  --vet-mint: #e7f8f1;
  --yellow: #ede9fe;
  --danger: #d94664;
  --accent-ink: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --tabs-bg: rgba(255, 255, 255, 0.94);
  --tab-bg: rgba(250, 247, 255, 0.96);
  --field-bg: #ffffff;
  --grid-line: rgba(126, 87, 194, 0.055);
  --shadow: 0 18px 52px rgba(50, 36, 84, 0.12);
  --radius: 8px;
  --header: 70px;
}

html[data-theme="dark"],
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #fbf9ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-2: rgba(252, 250, 255, 0.98);
  --surface-3: rgba(126, 87, 194, 0.1);
  --ink: #20172f;
  --muted: #756a89;
  --line: rgba(93, 64, 142, 0.15);
  --green: #7e57c2;
  --green-dark: #5e35b1;
  --mint: #f4efff;
  --blue: #8f7cf7;
  --orange: #ffb74d;
  --violet: #7e57c2;
  --violet-soft: #ede7f6;
  --vet-pink: #fce7f3;
  --vet-mint: #e7f8f1;
  --yellow: #ede9fe;
  --danger: #d94664;
  --accent-ink: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.86);
  --tabs-bg: rgba(255, 255, 255, 0.9);
  --tab-bg: rgba(248, 246, 255, 0.9);
  --field-bg: #ffffff;
  --grid-line: rgba(126, 87, 194, 0.055);
  --shadow: 0 18px 52px rgba(50, 36, 84, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(126, 87, 194, 0.1), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(252, 231, 243, 0.75), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #fbf9ff 42%, #ffffff 100%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.42;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(#000, transparent 74%);
}

body::after {
  content: "";
  position: fixed;
  inset: 72px 0 auto auto;
  width: min(46vw, 560px);
  height: min(46vw, 560px);
  pointer-events: none;
  background:
    radial-gradient(circle at 45% 50%, rgba(126, 87, 194, 0.11) 0 11%, transparent 12%),
    radial-gradient(circle at 30% 32%, rgba(126, 87, 194, 0.08) 0 6%, transparent 7%),
    radial-gradient(circle at 44% 24%, rgba(126, 87, 194, 0.08) 0 6%, transparent 7%),
    radial-gradient(circle at 58% 32%, rgba(126, 87, 194, 0.08) 0 6%, transparent 7%),
    radial-gradient(circle at 64% 48%, rgba(126, 87, 194, 0.07) 0 5%, transparent 6%);
  opacity: 0.65;
  transform: rotate(-16deg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 86px 18px 32px;
}

.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1440px, 100%);
  min-height: var(--header);
  padding: 12px 18px;
  transform: translateX(-50%);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-mark,
.icon-button,
.record-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-mark {
  width: 46px;
  height: 46px;
  color: var(--violet);
  background:
    linear-gradient(145deg, rgba(126, 87, 194, 0.14), rgba(126, 87, 194, 0.04)),
    #ffffff;
  border: 1px solid rgba(126, 87, 194, 0.28);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px rgba(126, 87, 194, 0.06),
    0 14px 30px rgba(126, 87, 194, 0.12);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.brand-mark .pulse-line {
  stroke-width: 1.7;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: fit-content;
  padding: 4px 5px 4px 8px;
  color: #ffffff;
  background: var(--violet);
  border-radius: 8px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 1.05rem;
  line-height: 1;
}

.brand strong span {
  color: var(--violet);
  background: #ffffff;
  border-radius: 6px;
  padding: 1px 4px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.nav-toggle {
  display: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.icon-button svg,
.record-button svg,
.dropzone svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.theme-toggle {
  display: none;
  position: relative;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  transition: opacity 160ms ease, transform 160ms ease;
}

html[data-theme="dark"] .theme-toggle .moon-icon,
html[data-theme="light"] .theme-toggle .sun-icon {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="dark"] .theme-toggle .sun-icon,
html[data-theme="light"] .theme-toggle .moon-icon {
  opacity: 0;
  transform: scale(0.72);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
}

.button-primary {
  color: var(--accent-ink);
  background: var(--green);
  box-shadow: 0 12px 30px rgba(126, 87, 194, 0.2);
}

.button-soft {
  color: var(--violet);
  background: var(--mint);
  border-color: rgba(124, 58, 237, 0.2);
}

.cloud-button {
  white-space: nowrap;
}

.cloud-button.is-connected,
.cloud-button[data-action="cloud-logout"] {
  color: #ffffff;
  background: var(--violet);
  border-color: var(--violet);
}

.text-button {
  padding: 0;
  color: var(--green);
  background: transparent;
  border: 0;
  font-weight: 800;
}

.full-width {
  width: 100%;
}

.app-tabs {
  position: sticky;
  top: var(--header);
  z-index: 15;
  display: flex;
  gap: 8px;
  margin: -4px -18px 20px;
  padding: 10px 18px;
  overflow-x: auto;
  background: var(--tabs-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar {
  display: none;
}

.app-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--tab-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-tabs a.is-active {
  color: var(--accent-ink);
  background: var(--green);
  border-color: var(--green);
}

.screen {
  display: none;
  animation: fadeIn 220ms ease both;
}

.screen.is-active {
  display: block;
}

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

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

.screen-head {
  margin-bottom: 18px;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 16px;
}

.module-actions .button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  align-self: end;
  min-height: 44px;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.screen-head h1,
.panel h2,
.panel h3,
.site-preview h3,
.site-preview h4 {
  margin: 0;
  letter-spacing: 0;
}

.screen-head h1 {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(1.9rem, 5vw, 3.8rem);
  line-height: 0.98;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-grid,
.module-strip,
.channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card,
.panel,
.module-strip article,
.channel-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric-card {
  position: relative;
  min-height: 142px;
  padding: 18px;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 18px 18px auto;
  width: 42px;
  height: 42px;
  border: 9px solid currentColor;
  border-radius: 50%;
  opacity: 0.18;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 12px 0 6px;
  font-size: 2.5rem;
  line-height: 0.9;
}

.accent-green {
  color: var(--green);
}

.accent-blue {
  color: var(--blue);
}

.accent-orange {
  color: var(--orange);
}

.accent-violet {
  color: var(--violet);
}

.two-column,
.agenda-layout,
.patient-layout,
.contacts-layout,
.consult-grid,
.cash-layout,
.builder-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.two-column {
  grid-template-columns: 1.35fr 0.9fr;
}

.agenda-layout {
  grid-template-columns: 1.25fr 0.75fr;
}

.patient-layout {
  grid-template-columns: 360px 1fr;
}

.contacts-layout {
  grid-template-columns: 1.45fr 0.75fr;
}

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

.consult-grid .panel:last-child {
  grid-column: 1 / -1;
}

.cash-layout,
.builder-layout {
  grid-template-columns: 1fr 1fr 0.85fr;
}

.panel {
  padding: 18px;
}

.panel h2 {
  font-size: 1.08rem;
}

.panel h3 {
  font-size: 0.98rem;
}

.panel p,
.subtle {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--accent-ink);
  background: var(--green);
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.warning {
  color: #1c0b00;
  background: #ffb267;
}

.status-pill.neutral {
  color: var(--violet);
  background: var(--violet-soft);
  border-color: rgba(126, 87, 194, 0.22);
}

.workflow,
.action-list,
.treatment-list,
.checkout-list,
.stock-alerts,
.patient-list,
.command-results {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.workflow article {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.workflow article span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent-ink);
  background: var(--green);
  border-radius: var(--radius);
  font-weight: 900;
}

.workflow p,
.workflow h3 {
  margin: 0;
}

.workflow p {
  margin-top: 4px;
}

.action-list label,
.treatment-list label {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 700;
}

.action-list input,
.treatment-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.module-strip {
  margin-top: 16px;
}

.module-strip article,
.channel-grid article {
  padding: 16px;
  box-shadow: none;
}

.module-strip b,
.module-strip span,
.channel-grid strong,
.channel-grid p {
  display: block;
}

.module-strip span,
.channel-grid p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.contact-toolbar {
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  white-space: nowrap;
}

.segmented button.is-active {
  color: var(--accent-ink);
  background: var(--green);
}

.search-box,
.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.search-box {
  min-width: 280px;
}

.search-box.full {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.appointment {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
}

.appointment b,
.appointment strong,
.appointment small {
  display: block;
}

.appointment b {
  color: var(--green);
}

.appointment small {
  margin-top: 3px;
  color: var(--muted);
}

.patient-list-panel {
  align-self: start;
}

.new-patient-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.patient-card {
  width: 100%;
  padding: 14px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.patient-card.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

.patient-card strong,
.patient-card span {
  display: block;
}

.patient-card strong {
  font-size: 1rem;
}

.patient-card span {
  margin-top: 4px;
  color: var(--muted);
}

.patient-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.patient-tags i,
.file-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  color: var(--accent-ink);
  background: var(--green);
  border-radius: 999px;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
}

.profile-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.profile-title {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.profile-head h2 {
  font-size: 1.9rem;
}

.profile-facts,
.clinical-feed,
.media-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.profile-facts {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.profile-facts div,
.clinical-feed article,
.media-grid article {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.profile-facts span,
.clinical-feed time {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-facts b,
.clinical-feed strong {
  display: block;
  margin-top: 4px;
}

.clinical-feed p {
  margin: 6px 0 0;
}

.editable-profile,
.patient-ai-box,
.profile-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.patient-ai-box {
  display: grid;
  gap: 12px;
}

.custom-fields-grid,
.patient-note-composer {
  display: grid;
  gap: 12px;
}

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

.patient-note-composer {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.media-grid article {
  min-height: 86px;
}

.media-grid article span,
.media-grid article p {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  text-align: center;
}

.empty-state p {
  max-width: 360px;
}

.voice-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  background: rgba(113, 232, 255, 0.1);
  border: 1px solid rgba(113, 232, 255, 0.24);
  border-radius: var(--radius);
}

.voice-card h3,
.voice-card p {
  margin: 0;
}

.voice-card p {
  margin-top: 5px;
}

.record-button {
  width: 52px;
  height: 52px;
  color: var(--accent-ink);
  background: var(--blue);
  border: 0;
  border-radius: var(--radius);
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  margin-top: 14px;
  padding: 18px;
  color: var(--green);
  text-align: center;
  background: repeating-linear-gradient(
    -45deg,
    var(--surface-2),
    var(--surface-2) 12px,
    var(--surface-3) 12px,
    var(--surface-3) 24px
  );
  border: 1px dashed rgba(124, 58, 237, 0.5);
  border-radius: var(--radius);
}

.dropzone span {
  color: var(--muted);
}

.ai-answer {
  margin-top: 14px;
  padding: 14px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: var(--radius);
}

.ai-answer p:last-child {
  margin: 0;
  color: var(--ink);
}

.table-panel {
  min-width: 0;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.product-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.product-photo {
  display: grid;
  place-items: center;
  min-height: 108px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--green), var(--violet-soft));
  border-radius: var(--radius);
  font-size: 1.8rem;
  font-weight: 950;
}

.product-photo.tone-2 {
  background: linear-gradient(135deg, #ede7ff, #7c3aed);
}

.product-photo.tone-3 {
  background: linear-gradient(135deg, #ffffff, #c5f7ff);
}

.product-photo.tone-4 {
  background: linear-gradient(135deg, #f6f1ff, #d8c7ff);
}

.product-card span,
.product-card p {
  color: var(--muted);
  font-weight: 800;
}

.product-card h3,
.product-card p {
  margin: 6px 0 0;
}

.product-card strong {
  display: block;
  margin-top: 8px;
  color: var(--violet);
}

.product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.responsive-table {
  margin-top: 16px;
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

.stock-alerts article {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stock-alerts p {
  margin: 7px 0 0;
}

.checkout-list article {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.checkout-list article.is-selected {
  border-color: var(--green);
  background: var(--surface-3);
}

.checkout-list strong,
.checkout-list span {
  display: block;
}

.checkout-list span {
  margin-top: 4px;
  color: var(--muted);
}

.receipt {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.receipt div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.receipt .total {
  font-size: 1.35rem;
  font-weight: 900;
}

.payment-methods {
  width: 100%;
  margin: 16px 0;
}

.payment-methods button {
  flex: 1;
}

.summary-bars {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.summary-bars div {
  display: grid;
  grid-template-columns: 82px 1fr 70px;
  gap: 10px;
  align-items: center;
}

.summary-bars b {
  display: block;
  height: 12px;
  max-width: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  border-radius: 999px;
}

.summary-bars em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

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

.block-palette button {
  min-height: 48px;
  color: var(--accent-ink);
  background: var(--green);
  border: 1px solid rgba(124, 58, 237, 0.26);
  border-radius: var(--radius);
  font-weight: 900;
}

.phone-preview {
  width: min(360px, 100%);
  margin: 16px auto 0;
  padding: 12px;
  background: #ffffff;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 32px;
  box-shadow: 0 22px 52px rgba(50, 36, 84, 0.14);
}

.phone-top {
  width: 88px;
  height: 6px;
  margin: 0 auto 10px;
  background: rgba(124, 58, 237, 0.22);
  border-radius: 999px;
}

.site-preview {
  min-height: 560px;
  padding: 12px;
  overflow: hidden;
  color: #0a1415;
  --muted: #5f6b68;
  --line: rgba(14, 30, 36, 0.14);
  --green: #7c3aed;
  background: #fbfaff;
  border-radius: 22px;
}

.site-block {
  margin-bottom: 10px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.site-block h3 {
  font-size: 1.7rem;
  line-height: 1;
}

.site-block h4 {
  font-size: 1.05rem;
}

.site-block p {
  margin: 8px 0 0;
  color: var(--muted);
}

.site-block small {
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.site-block button {
  min-height: 36px;
  margin-top: 12px;
  padding: 0 12px;
  color: #ffffff;
  background: #7c3aed;
  border: 0;
  border-radius: var(--radius);
  font-weight: 900;
}

.hero-block {
  color: #191525;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(243, 236, 255, 0.9)),
    linear-gradient(45deg, #ffffff, #ede9fe);
  border-color: rgba(124, 58, 237, 0.18);
}

.hero-block p,
.hero-block small {
  color: #746b86;
}

.channel-grid {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  padding: 92px 16px 16px;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(10px);
}

.command-palette[hidden] {
  display: none;
}

.command-box {
  width: min(680px, 100%);
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.command-box input {
  margin-top: 14px;
}

.command-results button {
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.command-results strong,
.command-results span {
  display: block;
}

.command-results span {
  margin-top: 4px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 15px;
  color: var(--accent-ink);
  background: var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.workflow-modal {
  width: min(720px, calc(100vw - 28px));
  max-height: min(820px, calc(100dvh - 28px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  overflow: visible;
}

.workflow-modal::backdrop {
  background: rgba(32, 23, 47, 0.38);
  backdrop-filter: blur(12px);
}

.workflow-modal-card {
  display: grid;
  max-height: min(820px, calc(100dvh - 28px));
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 88% 8%, rgba(126, 87, 194, 0.13), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #fbf9ff 100%);
  border: 1px solid rgba(126, 87, 194, 0.2);
  border-radius: var(--radius);
  box-shadow: 0 28px 90px rgba(32, 23, 47, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  max-width: 560px;
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(1.45rem, 5vw, 2.25rem);
  line-height: 1;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 16px 0;
}

.modal-body label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-body input[type="checkbox"],
.modal-body input[type="radio"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

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

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

.full-field {
  grid-column: 1 / -1;
}

.modal-choice,
.modal-checks {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.appointment-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.appointment-panel.is-hidden {
  display: none;
}

.appointment-mode {
  margin-bottom: 2px;
}

.modal-choice label,
.modal-checks label {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  text-transform: none;
}

.modal-new-patient-fields {
  padding: 12px;
  background: rgba(126, 87, 194, 0.06);
  border: 1px dashed rgba(126, 87, 194, 0.24);
  border-radius: var(--radius);
}

.modal-flow-note,
.modal-preview-card,
.account-card {
  padding: 13px;
  color: var(--muted);
  background: rgba(126, 87, 194, 0.08);
  border: 1px solid rgba(126, 87, 194, 0.18);
  border-radius: var(--radius);
  font-weight: 700;
}

.account-card strong,
.account-card span,
.modal-preview-card small,
.modal-preview-card strong,
.modal-preview-card p {
  display: block;
}

.account-card strong,
.modal-preview-card strong {
  color: var(--ink);
  font-size: 1.12rem;
}

.account-card span,
.modal-preview-card p {
  margin-top: 5px;
}

.modal-preview-card small {
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.modal-receipt {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.demo-brief {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.demo-brief > div {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.demo-brief h2 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(1.35rem, 2.4vw, 2.3rem);
  line-height: 1.05;
}

.demo-brief p {
  margin: 12px 0 0;
  color: var(--muted);
}

.case-switcher {
  display: grid;
  gap: 10px;
}

.case-option,
.action-grid button,
.flow-step,
.context-banner {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.case-option {
  display: grid;
  gap: 4px;
  padding: 13px;
  color: var(--ink);
}

.case-option.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

.case-option span,
.case-option small,
.flow-step span,
.flow-step small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.case-option strong,
.action-grid strong {
  display: block;
  font-size: 1rem;
}

.flow-panel {
  margin-top: 14px;
}

.journey {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.flow-step {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  min-height: 184px;
  padding: 12px;
}

.flow-step button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--accent-ink);
  background: var(--green);
  border: 0;
  border-radius: var(--radius);
  font-weight: 900;
}

.flow-step h3,
.flow-step p {
  margin: 0;
}

.flow-step h3 {
  margin-top: 4px;
  font-size: 1rem;
}

.flow-step p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.93rem;
}

.flow-step small {
  grid-column: 1 / -1;
  align-self: end;
}

.flow-step.is-pending {
  opacity: 0.68;
}

.flow-step.is-current {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14);
}

.flow-step.is-done button {
  color: var(--green);
  background: var(--accent-ink);
  border: 1px solid var(--green);
}

.case-card-large {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
}

.pet-avatar {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  overflow: hidden;
  color: var(--accent-ink);
  background: var(--green);
  border-radius: 50%;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
}

.pet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pet-avatar.small {
  width: 42px;
  height: 42px;
  font-size: 0.85rem;
}

.case-card-large h3 {
  margin: 0;
  font-size: 1.6rem;
}

.case-card-large p {
  margin: 5px 0 0;
}

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

.case-facts div {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.case-facts span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.case-facts b {
  display: block;
  margin-top: 5px;
}

.case-note {
  margin: 14px 0 0;
  padding: 13px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.action-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.action-grid button {
  padding: 13px;
  color: var(--ink);
}

.action-grid span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.context-banner {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
}

.context-banner strong,
.context-banner span {
  display: block;
}

.context-banner span {
  margin-top: 3px;
  color: var(--muted);
}

.appointment.is-active-case {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.appointment .status-pill {
  justify-content: center;
  border-radius: 999px;
}

.dropzone {
  width: 100%;
}

.config-layout,
.data-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.config-layout {
  grid-template-columns: 1.08fr 0.92fr 0.92fr;
}

.config-layout .ai-builder-panel {
  grid-row: span 2;
}

.config-layout [data-config-products] {
  grid-column: 2 / -1;
}

.data-layout {
  grid-template-columns: 0.8fr 1.25fr 0.85fr;
}

.ai-prompt {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.prompt-chips button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
}

.config-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.config-list article {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.config-list strong,
.config-list span {
  display: block;
}

.config-list span {
  margin-top: 5px;
  color: var(--muted);
}

.compact-form {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.chart-summary article {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chart-summary span,
.chart-summary strong {
  display: block;
}

.chart-summary span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.chart-summary strong {
  margin-top: 6px;
  font-size: 1.6rem;
}

.data-bars {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 320px;
  margin-top: 18px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  height: 100%;
  min-height: 260px;
  text-align: center;
}

.data-bar b {
  align-self: end;
  display: block;
  height: max(14px, var(--bar));
  background: linear-gradient(180deg, var(--green), var(--blue));
  border-radius: 999px 999px 4px 4px;
}

.data-bars.is-line .data-bar b {
  height: 10px;
  margin-bottom: calc(var(--bar) * 0.85);
  border-radius: 999px;
}

.data-bar span,
.data-bar em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.data-bar em {
  color: var(--ink);
}

.donut-chart {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.donut-chart > div {
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface-2) 0 45%, transparent 46%),
    conic-gradient(var(--green) 0 var(--p), var(--blue) var(--p) 70%, var(--orange) 70% 88%, var(--violet) 88% 100%);
}

.donut-chart section {
  display: grid;
  gap: 8px;
}

.donut-chart article {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (max-width: 1180px) {
  .demo-brief,
  .journey,
  .config-layout,
  .data-layout {
    grid-template-columns: 1fr;
  }

  .config-layout .ai-builder-panel,
  .config-layout [data-config-products] {
    grid-column: auto;
    grid-row: auto;
  }

  .flow-step {
    min-height: 0;
  }

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

  .two-column,
  .agenda-layout,
  .patient-layout,
  .contacts-layout,
  .consult-grid,
  .cash-layout,
  .builder-layout {
    grid-template-columns: 1fr;
  }

  .consult-grid .panel:last-child {
    grid-column: auto;
  }

  .patient-list-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  :root {
    --header: 66px;
  }

  .app-shell {
    padding: 0 12px 28px;
  }

  .app-header {
    position: sticky;
    left: auto;
    width: auto;
    margin: 0 -12px;
    padding: 10px 12px;
    transform: none;
  }

  .header-actions {
    flex-shrink: 0;
    gap: 6px;
  }

  .app-tabs {
    position: sticky;
    top: 0;
    z-index: 18;
    display: none;
    grid-template-columns: 1fr;
    margin: 0 -12px 12px;
    padding: 10px 12px;
    overflow: visible;
  }

  .app-tabs.is-open {
    display: grid;
  }

  .app-tabs a {
    justify-content: flex-start;
    width: 100%;
    min-height: 42px;
  }

  .nav-toggle {
    display: inline-grid;
    order: -1;
  }

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

  .brand small {
    display: none;
  }

  .button {
    min-height: 40px;
    padding: 0 12px;
  }

  .screen-head {
    display: grid;
  }

  .screen-head .button {
    width: 100%;
  }

  .metric-grid,
  .module-strip,
  .profile-facts,
  .media-grid,
  .case-facts,
  .chart-summary {
    grid-template-columns: 1fr;
  }

  .data-bars {
    min-height: 240px;
    overflow-x: auto;
  }

  .data-bar {
    min-width: 54px;
  }

  .donut-chart {
    grid-template-columns: 1fr;
  }

  .context-banner {
    grid-template-columns: 42px 1fr;
  }

  .context-banner .text-button {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .profile-head {
    grid-template-columns: 1fr;
  }

  .profile-head .button {
    justify-self: start;
  }

  .demo-brief > div {
    padding: 14px;
  }

  .metric-card {
    min-height: 118px;
  }

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

  .search-box {
    min-width: 0;
  }

  .appointment {
    grid-template-columns: 58px 1fr;
  }

  .appointment .status-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .form-grid,
  .custom-fields-grid,
  .block-palette,
  .modal-grid,
  .modal-grid.compact {
    grid-template-columns: 1fr;
  }

  .workflow-modal {
    width: min(100vw - 18px, 720px);
    max-height: calc(100dvh - 18px);
  }

  .workflow-modal-card {
    max-height: calc(100dvh - 18px);
    padding: 14px;
  }

  .modal-head {
    align-items: flex-start;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-head .status-pill {
    max-width: 100%;
    white-space: normal;
  }

  .profile-head {
    grid-template-columns: 1fr;
  }

  .site-preview {
    min-height: 500px;
  }

  .summary-bars div {
    grid-template-columns: 76px 1fr 58px;
  }
}

@media (max-width: 480px) {
  .header-actions [data-install] {
    display: none;
  }
}

@media (display-mode: standalone) {
  .app-header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}
