button:disabled {
  cursor: wait;
  opacity: .62;
}

.branch-picker {
  cursor: pointer;
}

.form-grid > .full {
  grid-column: 1 / -1;
  width: auto;
  height: auto;
  margin-top: 0;
  justify-content: initial;
}

.record-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.record-summary div {
  padding: 14px;
  border: 1px solid #e5ebf3;
  border-radius: 10px;
  background: #f8faff;
  text-align: center;
}

.record-summary small {
  display: block;
  color: #7f8da0;
}

.record-summary b {
  display: block;
  margin-top: 5px;
  color: #2865e4;
  font-size: 18px;
}

.record-details,
.guide-copy {
  padding: 15px;
  border: 1px solid #e5ebf3;
  border-radius: 11px;
  background: #fbfcfe;
}

.record-details p,
.guide-copy p {
  margin: 5px 0;
  color: #62738a;
  font-size: 9px;
  line-height: 1.9;
}

.guide-copy > b {
  font-size: 11px;
}

.notification-list {
  display: grid;
  gap: 8px;
}

.notification-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 11px 12px;
  border: 1px solid #e6ebf2;
  border-radius: 9px;
  background: #fbfcfe;
}

.notification-row b {
  font-size: 9px;
}

.notification-row span {
  color: #52667f;
  font-size: 8px;
}

.notification-row small {
  grid-column: 1 / -1;
  color: #929faf;
  font-size: 7px;
}

.modal-card.wide {
  width: min(1180px, 96vw);
}

.dental-history {
  min-height: 120px;
  overflow: hidden;
  border: 1px solid #dfe8f5;
  border-radius: 13px;
  background: #f8fbff;
}

.history-loading,
.history-error {
  padding: 35px;
  color: #718198;
  text-align: center;
  font-size: 9px;
}

.history-error {
  color: #b94753;
  background: #fff2f3;
}

.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e4ebf4;
  background: #fff;
}

.history-title div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-title b {
  font-size: 11px;
}

.history-title span {
  color: #7a899d;
  font-size: 8px;
}

.history-title em {
  padding: 6px 10px;
  border-radius: 20px;
  color: #2362d5;
  background: #eaf1ff;
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
}

.patient-alerts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
}

.patient-alerts > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e5eaf1;
  border-radius: 9px;
  background: #fff;
}

.patient-alerts b {
  color: #50647d;
  font-size: 8px;
}

.patient-alerts span {
  color: #718198;
  font-size: 8px;
}

.patient-alerts .danger {
  border-color: #f4cbd0;
  background: #fff5f6;
}

.patient-alerts .warning {
  border-color: #f2dfb8;
  background: #fffaf0;
}

.patient-alerts .ok {
  border-color: #cfe9df;
  background: #f3fbf8;
}

.history-groups {
  max-height: 190px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  overflow: auto;
  padding: 0 12px 12px;
}

.history-group {
  padding: 10px;
  border: 1px solid #e5eaf1;
  border-radius: 10px;
  background: #fff;
}

.history-group h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  font-size: 9px;
}

.history-group h4 span {
  min-width: 22px;
  padding: 3px 6px;
  border-radius: 20px;
  color: #2765df;
  background: #edf3ff;
  text-align: center;
}

.history-group article {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 0;
  border-top: 1px solid #edf1f5;
}

.history-group article:first-child {
  border-top: 0;
}

.history-group article b {
  font-size: 8px;
}

.history-group article span,
.history-group article small,
.history-empty {
  margin: 0;
  color: #8592a4;
  font-size: 7px;
  line-height: 1.6;
}

.odontogram {
  padding: 16px;
  overflow: hidden;
  border: 1px solid #dfe6f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #f9fbff, #f3f8fb);
}

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

.odontogram h3 {
  margin: 0;
  font-size: 12px;
}

.odontogram p {
  margin: 5px 0 0;
  color: #7e8c9f;
  font-size: 8px;
}

.tooth-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tooth-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid #e3e8ef;
  border-radius: 20px;
  color: #64758b;
  background: #fff;
  font-size: 6.5px;
}

.tooth-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8493a8;
}

.tooth-legend [data-legend="caries"] i,
.tooth-legend [data-legend="extraction"] i,
.tooth-legend [data-legend="fracture"] i {
  background: #e5525d;
}

.tooth-legend [data-legend="filling"] i,
.tooth-legend [data-legend="root_canal"] i {
  background: #2d68e2;
}

.tooth-legend [data-legend="crown"] i,
.tooth-legend [data-legend="implant"] i {
  background: #9b6ce0;
}

.dental-arch {
  position: relative;
  width: 740px;
  min-width: 740px;
  height: 440px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #dce6f2;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 25%, rgba(36, 104, 229, .055), transparent 28%),
    radial-gradient(circle at 50% 75%, rgba(20, 169, 162, .055), transparent 28%),
    #fff;
}

.arch-teeth {
  position: absolute;
  inset: 0;
}

.tooth-button {
  position: absolute;
  z-index: 3;
  left: var(--tooth-x);
  top: var(--tooth-y);
  width: 56px;
  height: 60px;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  transform: translate(-50%, -50%);
  transition: border-color .16s, background .16s, box-shadow .16s, transform .16s;
}

.tooth-button:hover,
.tooth-button.selected {
  border-color: #94b5f2;
  background: #eaf2ff;
  box-shadow: 0 5px 14px rgba(42, 101, 225, .12);
  transform: translate(-50%, -50%) scale(1.07);
}

.tooth-button svg {
  position: absolute;
  left: 7px;
  width: 42px;
  height: 42px;
  overflow: visible;
  transform: rotate(var(--tooth-angle));
  filter: drop-shadow(0 3px 3px rgba(55, 77, 104, .1));
}

.tooth-button.upper svg {
  top: 15px;
}

.tooth-button.lower svg {
  top: 1px;
}

.tooth-button svg .tooth-body {
  fill: #fff;
  stroke: #526b86;
  stroke-width: 1.75;
  transition: .16s;
}

.tooth-button svg .tooth-detail {
  fill: none;
  stroke: #8b9bae;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tooth-button b {
  position: absolute;
  left: 0;
  width: 100%;
  color: #53667e;
  font-size: 10px;
  line-height: 1;
  text-align: center;
}

.tooth-button.upper b {
  top: 2px;
}

.tooth-button.lower b {
  bottom: 2px;
}

.tooth-button[data-condition="caries"] svg .tooth-body,
.tooth-button[data-condition="extraction"] svg .tooth-body,
.tooth-button[data-condition="fracture"] svg .tooth-body {
  fill: #ffe1e3;
  stroke: #d94b57;
}

.tooth-button[data-condition="filling"] svg .tooth-body,
.tooth-button[data-condition="root_canal"] svg .tooth-body {
  fill: #dce9ff;
  stroke: #2d68e2;
}

.tooth-button[data-condition="crown"] svg .tooth-body,
.tooth-button[data-condition="implant"] svg .tooth-body {
  fill: #eee4ff;
  stroke: #8058c8;
}

.tooth-button[data-condition="missing"] svg .tooth-body {
  fill: #eef1f4;
  stroke: #a3acb7;
  stroke-dasharray: 3 2;
}

.tooth-button[data-condition="mobility"] svg .tooth-body,
.tooth-button[data-condition="other"] svg .tooth-body {
  fill: #fff0cc;
  stroke: #c88619;
}

.arch-axis {
  position: absolute;
  z-index: 1;
  display: block;
  background: #cfdae8;
  pointer-events: none;
}

.arch-axis-horizontal {
  right: 8%;
  left: 8%;
  top: 50%;
  height: 2px;
}

.arch-axis-vertical {
  top: 4%;
  bottom: 4%;
  left: 50%;
  width: 2px;
}

.arch-center-label,
.arch-side-label {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.arch-center-label {
  left: 50%;
  padding: 7px 13px;
  border-radius: 20px;
  color: #233c5b;
  background: rgba(244, 248, 253, .9);
  font-size: 14px;
}

.upper-title {
  top: 31%;
}

.lower-title {
  top: 69%;
}

.arch-side-label {
  top: 50%;
  padding: 4px 8px;
  color: #5f7490;
  background: #fff;
  font-size: 10px;
  font-weight: 700;
}

.patient-right {
  left: 27%;
}

.patient-left {
  left: 73%;
}

.odontogram {
  overflow: visible;
}

.teeth-canvas {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 5px;
  scrollbar-width: thin;
  scrollbar-color: #b9c7da #edf2f7;
}

.teeth-canvas::-webkit-scrollbar {
  height: 7px;
}

.teeth-canvas::-webkit-scrollbar-track {
  border-radius: 8px;
  background: #edf2f7;
}

.teeth-canvas::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: #b9c7da;
}

.tooth-editor {
  padding: 14px;
  border: 1px solid #dfe6ef;
  border-radius: 12px;
  background: #fff;
}

.tooth-editor-empty {
  padding: 20px;
  color: #8290a2;
  text-align: center;
  font-size: 9px;
}

.tooth-editor-fields {
  display: grid;
  grid-template-columns: 110px 1fr 1.4fr;
  gap: 12px;
  align-items: end;
}

.selected-tooth {
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #2869e8, #16a9a1);
}

.selected-tooth span {
  color: #e9f5ff;
  font-size: 7px;
}

.selected-tooth b {
  font-size: 20px;
}

.tooth-editor-fields label,
.surface-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.surface-field > span {
  color: #5f6f83;
  font-size: 8px;
  font-weight: 700;
}

.surface-picker {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.surface-picker label {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  color: #5a6d84;
  background: #f8fafc;
  font-size: 8px;
  cursor: pointer;
}

.surface-picker input {
  display: none;
}

.surface-picker label:has(input:checked) {
  border-color: #2868e7;
  color: #fff;
  background: #2868e7;
}

.tooth-editor-fields .wide-field {
  grid-column: span 3;
}

@media (max-width: 650px) {
  .form-grid > .full {
    grid-column: auto;
  }

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

  .table-toolbar .secondary {
    display: inline-flex;
  }

  .patient-alerts,
  .history-groups {
    grid-template-columns: 1fr;
  }

  .odontogram-head {
    flex-direction: column;
  }

  .tooth-legend {
    justify-content: flex-start;
  }

  .tooth-editor-fields {
    grid-template-columns: 1fr;
  }

  .tooth-editor-fields .wide-field {
    grid-column: auto;
  }
}
