:root {
  color-scheme: light;
  --bg: #edf5f3;
  --ink: #12312d;
  --muted: #617773;
  --panel: #ffffff;
  --line: #d5e4e0;
  --accent: #087f77;
  --accent-strong: #045a55;
  --coral: #d95858;
  --mint: #dff3e9;
  --gold: #efb94f;
  --shadow: 0 18px 52px rgba(19, 66, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  min-height: calc(100vh - 76px);
  padding: 20px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0 20px 20px;
  min-height: 56px;
  padding: 12px 18px;
  border: 1px solid rgba(197, 220, 214, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer strong {
  color: var(--accent-strong);
}

.site-footer a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.workspace,
.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(197, 220, 214, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.panel {
  overflow-y: auto;
  border-radius: 8px;
  padding: 18px;
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.statusbar {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  line-height: 1.05;
}

.topbar h1 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar h1::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.account-usage {
  display: grid;
  gap: 2px;
  min-width: 178px;
  margin-left: auto;
  padding: 9px 12px;
  border: 1px solid rgba(8, 127, 119, 0.22);
  border-radius: 8px;
  background: #f1faf7;
}

.account-usage[hidden] {
  display: none;
}

.account-usage span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.account-usage strong {
  color: var(--accent-strong);
  font-size: 1.02rem;
  line-height: 1.1;
}

.account-usage.is-limit-reached {
  border-color: rgba(185, 55, 55, 0.34);
  background: #fff0ef;
}

.account-usage.is-limit-reached span,
.account-usage.is-limit-reached strong {
  color: #8b3030;
}

.actions,
.zoom-controls,
.command-grid,
.segmented,
.toggle-row {
  display: flex;
  gap: 8px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button,
.actions button,
.zoom-controls button,
.command-grid button,
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  background: #eef7f5;
  color: var(--ink);
  font-weight: 800;
  border: 1px solid rgba(8, 127, 119, 0.2);
}

.actions button,
.file-button,
.command-grid button:first-child {
  background: var(--accent);
  color: #ffffff;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button.is-disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.canvas-stage {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  background:
    linear-gradient(90deg, rgba(18, 49, 45, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(18, 49, 45, 0.045) 1px, transparent 1px),
    #e5efec;
  background-size: 28px 28px;
  touch-action: none;
}

.canvas-stage.is-mouth-tool {
  cursor: crosshair;
}

.canvas-stage.is-erase-tool {
  cursor: cell;
}

.canvas-stage canvas,
.split-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#imageCanvas {
  z-index: 1;
}

#maskCanvas {
  z-index: 2;
}

.drop-overlay {
  position: absolute;
  inset: 18px;
  z-index: 5;
  display: none;
  place-items: center;
  border: 2px dashed rgba(8, 127, 119, 0.62);
  border-radius: 8px;
  background: rgba(241, 250, 247, 0.82);
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 900;
  pointer-events: none;
  backdrop-filter: blur(3px);
}

.canvas-stage.is-drop-active .drop-overlay {
  display: grid;
}

.split-line {
  z-index: 3;
  display: none;
  pointer-events: none;
  inset: auto;
  top: 0;
  bottom: 0;
  left: var(--split-position, 50%);
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(18, 49, 45, 0.16), 0 0 18px rgba(18, 49, 45, 0.24);
}

.split-line::after {
  content: "↔";
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(18, 49, 45, 0.26);
  font-size: 1.15rem;
  font-weight: 900;
}

.canvas-stage.is-comparing .split-line {
  display: block;
}

.canvas-stage.is-comparing {
  cursor: ew-resize;
}

.compare-label {
  position: absolute;
  top: 16px;
  z-index: 4;
  display: none;
  min-width: 68px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(4, 68, 63, 0.78);
  color: #ffffff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 900;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.compare-before {
  left: 16px;
}

.compare-after {
  right: 16px;
}

.canvas-stage.is-comparing .compare-label {
  display: block;
}

.ai-loader {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: rgba(4, 48, 45, 0.62);
  color: #ffffff;
  backdrop-filter: blur(3px);
}

.ai-loader[hidden] {
  display: none;
}

.ai-loader strong {
  font-size: 1.15rem;
}

.ai-loader span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.hourglass {
  width: 54px;
  height: 54px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: hourglass-turn 1.5s ease-in-out infinite;
}

.hourglass-sand {
  fill: var(--gold);
  stroke: var(--gold);
  animation: hourglass-sand 1.5s ease-in-out infinite;
  transform-origin: center;
}

@keyframes hourglass-turn {
  0%,
  72% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(180deg);
  }
}

@keyframes hourglass-sand {
  0%,
  20% {
    opacity: 1;
    transform: scaleY(1);
  }
  68% {
    opacity: 0.5;
    transform: scaleY(0.45);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hourglass,
  .hourglass-sand {
    animation: none;
  }
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-state.is-hidden {
  display: none;
}

.empty-art {
  width: min(260px, 56vw);
  aspect-ratio: 1.55;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 28%, #f3c7c4 0 18%, transparent 19%),
    radial-gradient(ellipse at 50% 67%, #ffffff 0 30%, transparent 31%),
    linear-gradient(160deg, #087f77, #dff3e9);
  border: 1px solid rgba(8, 127, 119, 0.24);
}

.empty-state h2 {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(1.5rem, 2.6vw, 2.3rem);
  line-height: 1.08;
}

.empty-state p {
  margin-bottom: 0;
}

.photo-guide {
  display: grid;
  gap: 5px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.84rem;
  list-style: none;
}

.photo-guide li {
  padding: 7px 10px;
  border: 1px solid rgba(8, 127, 119, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.statusbar strong {
  display: block;
  font-size: 0.9rem;
}

.statusbar span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.zoom-controls button {
  width: 42px;
  padding: 0;
}

.brand-block {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand-block h2 {
  margin-bottom: 6px;
  font-size: 1.5rem;
}

.brand-block p {
  margin-bottom: 0;
  color: var(--muted);
}

.control-group {
  padding: 18px 0 0;
}

.control-group h3 {
  margin-bottom: 10px;
  font-size: 0.86rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px;
  background: #e8f1ef;
  border-radius: 8px;
}

.segmented button {
  width: 100%;
  min-width: 0;
  padding-right: 10px;
  padding-left: 10px;
  background: transparent;
  border-color: transparent;
  white-space: nowrap;
}

.canvas-stage.is-tooth-tool {
  cursor: crosshair;
}

.segmented button.is-active {
  background: #ffffff;
  color: var(--accent-strong);
}

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

.treatment {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 12px;
  text-align: left;
  background: #f3f8f7;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
}

.treatment span {
  font-weight: 900;
}

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

.treatment.is-active {
  background: #e2f4ef;
  border-color: rgba(8, 127, 119, 0.48);
}

.slider-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.slider-row input {
  width: 100%;
  accent-color: var(--accent);
}

.slider-row output {
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.select-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.select-row select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 0 10px;
}

.toggle-row {
  flex-direction: column;
}

.toggle-row label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  background: #f1f7f5;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  order: 2;
}

.consent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(8, 127, 119, 0.18);
  border-radius: 8px;
  background: #f1f7f5;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.consent-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  accent-color: var(--accent);
}

.teeth-map {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.teeth-map button {
  min-height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 900;
}

.teeth-map button.is-selected {
  background: var(--coral);
  border-color: var(--coral);
  color: #ffffff;
}

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

.command-grid button {
  width: 100%;
}

.command-grid button:last-child {
  background: #fff0ef;
  color: #8b3030;
  border-color: rgba(217, 88, 88, 0.3);
}

#aiButton {
  background: var(--gold);
  color: #3d2b08;
  border-color: rgba(239, 185, 79, 0.58);
}

#saveTreatmentButton.is-saved {
  background: #dff3e9;
  color: var(--accent-strong);
  border-color: rgba(8, 127, 119, 0.34);
}

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

  .panel {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin: 0 10px 10px;
  }

  .topbar,
  .statusbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .zoom-controls {
    justify-content: stretch;
  }

  .actions > *,
  .zoom-controls button {
    flex: 1;
  }

  .canvas-stage {
    min-height: 360px;
  }

  .treatment-grid,
  .command-grid {
    grid-template-columns: 1fr;
  }

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

.auth-overlay,
.patient-overlay,
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 48, 45, 0.62);
  backdrop-filter: blur(8px);
}

.patient-overlay {
  z-index: 90;
}

.confirm-overlay {
  z-index: 110;
}

.auth-overlay[hidden],
.patient-overlay[hidden],
.confirm-overlay[hidden] {
  display: none;
}

.auth-dialog,
.patient-dialog,
.confirm-dialog {
  width: min(100%, 430px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(4, 48, 45, 0.28);
}

.auth-dialog {
  padding: 24px;
}

.confirm-dialog {
  padding: 18px;
}

.confirm-details {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.confirm-details div {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f1f7f5;
}

.confirm-details dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.confirm-details dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.confirm-note {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.confirm-note small {
  color: var(--muted);
  font-weight: 700;
}

.confirm-note textarea {
  width: 100%;
  min-height: 82px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  resize: vertical;
  background: #f9fcfb;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}

.confirm-note textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 119, 0.12);
}

.confirm-warning {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(217, 88, 88, 0.24);
  border-radius: 8px;
  background: #fff0ef;
  color: #783232;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

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

.confirm-actions button {
  min-height: 42px;
  border-radius: 8px;
  background: #e8f1ef;
  color: var(--accent-strong);
  font-weight: 900;
}

.auth-brand,
.patient-dialog-header,
.patient-list-toolbar,
.patient-form-actions,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-brand {
  justify-content: flex-start;
  margin-bottom: 20px;
}

.auth-brand h2,
.patient-dialog-header h2 {
  margin-bottom: 0;
}

.health-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.8rem;
  font-weight: 700;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 8px;
  background: #e8f1ef;
}

.auth-tabs button[hidden] {
  display: none;
}

.auth-tabs button {
  min-height: 40px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.is-active {
  background: #ffffff;
  color: var(--accent-strong);
}

.auth-dialog form,
.patient-form {
  display: grid;
  gap: 12px;
}

.auth-footer {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
}

.auth-footer strong {
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.auth-footer a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-dialog label,
.patient-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.auth-dialog input,
.patient-form input,
.patient-form textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  outline: 0;
  background: #f9fcfb;
  color: var(--ink);
}

.patient-form textarea {
  resize: vertical;
}

.auth-dialog input:focus,
.patient-form input:focus,
.patient-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 119, 0.12);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: #a13232;
  font-size: 0.84rem;
  font-weight: 700;
}

.primary-command,
.danger-command,
.patient-list-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-command,
.patient-list-toolbar button {
  background: var(--accent);
  color: #ffffff;
}

.danger-command {
  background: #fff0ef;
  color: #8b3030;
  border: 1px solid rgba(217, 88, 88, 0.3);
}

.patient-dialog {
  width: min(1040px, 100%);
}

.patient-dialog-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.icon-command {
  display: inline-grid !important;
  place-items: center;
  width: 42px;
  min-width: 42px;
  padding: 0 !important;
}

.current-patient {
  max-width: 190px;
  overflow: hidden;
  background: #eef7f5 !important;
  color: var(--accent-strong) !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-button {
  background: #eef7f5;
  color: var(--accent-strong);
}

.patient-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 540px;
}

.patient-list-pane {
  border-right: 1px solid var(--line);
  background: #f4f9f7;
}

.patient-list-toolbar {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.patient-list-toolbar button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.84rem;
}

.patient-search {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 7px;
  margin: 12px 12px 6px;
  padding: 0 7px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.patient-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 119, 0.12);
}

.patient-search > .icon {
  color: var(--muted);
}

.patient-search input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
}

.patient-search input::-webkit-search-cancel-button {
  display: none;
}

.patient-search button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #eef7f5;
  color: var(--accent-strong);
}

.patient-search button[hidden] {
  display: none;
}

.patient-search-status {
  min-height: 20px;
  margin: 0;
  padding: 0 14px 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.patient-list {
  display: grid;
}

.patient-row {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.patient-row strong {
  font-size: 0.92rem;
}

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

.patient-row .patient-birth-date {
  font-size: 0.74rem;
  opacity: 0.86;
}

.patient-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.patient-row.is-active {
  background: #dff3e9;
  box-shadow: inset 3px 0 0 var(--accent);
}

.patient-empty,
.history-empty {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.patient-detail-pane {
  min-width: 0;
  padding: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.prompt-grid {
  display: grid;
  gap: 10px;
}

.prompt-grid textarea {
  min-height: 82px;
  resize: vertical;
}

.patient-form-actions {
  justify-content: flex-start;
}

.history-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.history-header h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.history-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.history-tools input,
.history-tools button,
.history-actions button {
  min-height: 32px;
  border: 1px solid rgba(8, 127, 119, 0.2);
  border-radius: 8px;
  background: #eef7f5;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.history-tools input {
  padding: 0 8px;
}

.history-tools button,
.history-actions button {
  padding: 0 10px;
}

.history-header span {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8f1ef;
  color: var(--accent-strong);
  font-weight: 900;
}

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

.history-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fcfb;
}

.history-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 2.2;
  background: #e5efec;
}

.history-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-meta {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
}

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

.history-actions {
  display: flex;
  justify-content: flex-start;
}

@media (max-width: 760px) {
  .patient-layout {
    grid-template-columns: 1fr;
  }

  .patient-list-pane {
    max-height: 220px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .field-grid,
  .treatment-history {
    grid-template-columns: 1fr;
  }
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 48, 45, 0.62);
  backdrop-filter: blur(8px);
}

.admin-overlay[hidden] {
  display: none;
}

.admin-dialog {
  width: min(1180px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(4, 48, 45, 0.28);
}

.admin-content {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.admin-metric {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f8f7;
}

.admin-metric strong {
  font-size: 1.35rem;
}

.admin-metric span,
.admin-section small {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.admin-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-section h3 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.history-header button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 11px;
  background: #e8f1ef;
  color: var(--accent-strong);
  font-weight: 800;
}

.client-table-wrap {
  overflow-x: auto;
}

.client-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.client-table th,
.client-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

.client-identity {
  display: grid;
  gap: 2px;
}

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

.client-limit-editor {
  display: grid;
  grid-template-columns: 92px 34px;
  align-items: center;
  gap: 6px;
}

.client-limit-editor input {
  width: 92px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.client-limit-editor input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(8, 127, 119, 0.12);
}

.client-limit-editor button {
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
}

.client-limit-state {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.client-limit-state.is-reached {
  color: #a33434;
}

.access-toggle {
  min-height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  font-weight: 800;
}

.access-toggle.is-active {
  background: #dff3e9;
  color: var(--accent-strong);
}

.access-toggle:not(.is-active) {
  background: #fff0ef;
  color: #8b3030;
}

@media (max-width: 900px) {
  .admin-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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