:root {
  --brand: #0b6b6b;
  --brand-dark: #084f4f;
  --accent: #b5651d;
  --bg: #f4f7f7;
  --panel: #ffffff;
  --line: #cdd9d9;
  --text: #1d2b2b;
  --caries: #d92b2b;
  --restoration: #2b6fd9;
  --composite: #7a4fd9;
  --sealant: #1f9d55;
  --crown: #d99a2b;
  --rct: #c026d3;
  --implant: #0891b2;
  --missing: #6b7280;
  --watch: #eab308;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
}
h1 {
  font-size: 1.3rem;
  margin: 0;
  color: var(--brand-dark);
}
.sub {
  font-size: 0.8rem;
  color: #5a6a6a;
  margin: 2px 0 14px;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}
.fld {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fld label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #465959;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fld input {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 150px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.seg button {
  border: none;
  background: #fff;
  padding: 7px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
}
.seg button.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tlabel {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #465959;
  margin-right: 2px;
}
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 0.8rem;
  background: #fff;
  user-select: none;
}
.swatch .dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.swatch.active {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  font-weight: 600;
}
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text);
}
.btn:hover {
  background: #eef4f4;
}
.btn.toggle.on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
.btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--brand-dark);
}
.btn.danger {
  color: #b91c1c;
  border-color: #f3c4c4;
}
/* Bridge status bar */
.bridgebar {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  background: #fdf3e8;
  border: 1px solid #e7c9a3;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #7a4a12;
}
.bridgebar.show {
  display: flex;
}
.bridgebar .dotpulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}
.bridgebar .mini {
  border: 1px solid #e7c9a3;
  background: #fff;
  border-radius: 5px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 0.78rem;
  color: #7a4a12;
}
.bridgebar .mini:hover {
  background: #fbe9d4;
}
.chartscroll {
  overflow-x: auto;
  padding-bottom: 6px;
}
.chartstage {
  position: relative;
  min-width: max-content;
  margin: 0 auto;
}
.bridgeLayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.bridgeLayer line {
  pointer-events: stroke;
  cursor: pointer;
}
.arch {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-width: max-content;
  padding: 6px 0;
  position: relative;
  z-index: 2;
}
.arch.lower {
  margin-top: 4px;
}
.archlabel {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #566;
  letter-spacing: 0.05em;
  margin: 8px 0 2px;
}
.tooth {
  width: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.tooth .num {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  min-height: 14px;
}
.tooth .alt {
  font-size: 0.56rem;
  color: #889;
  line-height: 1;
  min-height: 9px;
  text-align: center;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  grid-template-rows: repeat(3, 12px);
  gap: 1px;
  margin: 2px 0;
}
.surf {
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid #bcc;
  cursor: pointer;
  font-size: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #789;
  line-height: 1;
}
.g-tl,
.g-tr,
.g-bl,
.g-br {
  visibility: hidden;
}
.bar {
  width: 38px;
  height: 11px;
  background: #fff;
  border: 1px solid #bcc;
  border-radius: 2px;
  cursor: pointer;
  margin-top: 1px;
}
.crownx {
  position: absolute;
  pointer-events: none;
}
.tooth.bridge-pending {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  background: #fdf3e8;
}
.tooth.bridge-anchor .bar {
  background: #f4dcc0 !important;
  border-color: var(--accent) !important;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.74rem;
  color: #445;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.hint {
  font-size: 0.74rem;
  color: #5a6a6a;
  margin-top: 8px;
  line-height: 1.5;
}
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-dark);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 50;
}
.toast.show {
  opacity: 1;
}
canvas {
  display: none;
}
@media (max-width: 640px) {
  .fld input {
    min-width: 120px;
  }
}
