:root {
    --page-bg: #f3f6fb;
    --btn-bg: #1d4ed8;
    --btn-hover: #1e40af;
    --focus-color: #3b82f6;
    --focus-rgb: 59, 130, 246;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    background: var(--page-bg);
    color: #1f2937;
    line-height: 1.45;
}

body.clinic-theme {
    --page-bg: #e8efe8;
    --btn-bg: #1e3a8a;
    --btn-hover: #1e40af;
    --focus-color: #1e3a8a;
    --focus-rgb: 30, 58, 138;
}

body.shelter-theme {
    --page-bg: #f6f1bf;
    --btn-bg: #556b2f;
    --btn-hover: #475a28;
    --focus-color: #556b2f;
    --focus-rgb: 85, 107, 47;
}

.topbar {
    background: linear-gradient(90deg, #1f2937, #334155);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.topbar a {
    color: white;
    text-decoration: none;
    margin-left: 10px;
    opacity: 0.95;
}

.topbar a:hover { opacity: 1; text-decoration: underline; }

.container {
    max-width: 1200px;
    margin: 20px auto;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

input, select, textarea, button {
    font: inherit;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--focus-color);
    box-shadow: 0 0 0 3px rgba(var(--focus-rgb), 0.15);
}

button {
    cursor: pointer;
    background: var(--btn-bg);
    color: white;
    border: none;
    transition: background 0.15s ease;
}

button:hover { background: var(--btn-hover); }

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

th { background: #f8fafc; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.purple { background: #ede9fe; color: #6d28d9; }
.badge.gray { background: #e5e7eb; color: #1f2937; }

.muted { color: #6b7280; }
.alert {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #7f1d1d;
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
}

.login-wrap {
    max-width: 420px;
    margin: 60px auto;
    background: white;
    border-radius: 8px;
    padding: 20px;
}

.dental-chart-box {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

.dental-jaw-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin: 4px 0 6px 0;
}

.dental-row-block {
    margin-bottom: 8px;
}

.dental-row-head {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin: 0 0 4px 0;
}

.dental-row-teeth {
    margin: 0;
    gap: 6px;
    flex-wrap: nowrap;
}

.dental-tooth-btn,
.dental-tooth-readonly {
    position: relative;
    min-width: 54px;
    height: 36px;
    border: 1px solid #94a3b8;
    background: #ffffff;
    border-radius: 8px;
    font-weight: 700;
}

.dental-tooth-readonly {
    display: flex;
    align-items: center;
    justify-content: center;
}

.dental-tooth-btn[data-state="1"],
.dental-tooth-readonly[data-state="1"] {
    opacity: 1;
    background: transparent;
}

.dental-tooth-btn[data-state="2"],
.dental-tooth-readonly[data-state="2"] {
    border-color: transparent;
    background: transparent;
}

.dental-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 8px 0;
}

.dental-legend-item {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 3px 10px;
    background: #fff;
    font-size: 12px;
    color: #334155;
}

.dental-mouth {
    display: grid;
    gap: 14px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    position: relative;
    overflow: hidden;
}

.dental-mouth::before {
    content: "";
    position: absolute;
    inset: 8px;
    background-image: url('/assets/dental-mouth-guide-v2.svg');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.dental-mouth > * {
    position: relative;
    z-index: 2;
}

.dental-arch {
    border: none;
    background: transparent;
    padding: 8px 10px 10px;
    position: relative;
    overflow: hidden;
}

.dental-arch.upper {
    border-radius: 26px 26px 10px 10px;
}

.dental-arch.lower {
    border-radius: 10px 10px 26px 26px;
}

.dental-arch-label {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    position: relative;
    z-index: 2;
}

.dental-arch-row {
    display: grid;
    grid-template-columns: 1fr 18px 1fr;
    align-items: stretch;
    gap: 8px;
    position: relative;
    min-height: 86px;
    padding: 6px 4px;
    z-index: 2;
}

.dental-arch-row::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(251, 207, 232, 0.22) 0%, rgba(249, 168, 212, 0.22) 100%);
    border: 1px solid rgba(244, 114, 182, 0.35);
    z-index: 0;
}

.dental-arch::after {
    content: "";
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 96% 100%;
    opacity: 0.18;
    z-index: 1;
    pointer-events: none;
}

.dental-arch.upper::after {
    background-image: url('/assets/dental-maxilla.svg');
}

.dental-arch.lower::after {
    background-image: url('/assets/dental-mandible.svg');
}

.dental-arch.upper .dental-arch-row::before {
    top: 8px;
    height: 30px;
}

.dental-arch.lower .dental-arch-row::before {
    bottom: 8px;
    height: 30px;
}

.dental-midline {
    width: 2px;
    height: 78px;
    background: #94a3b8;
    margin: 0 auto;
    border-radius: 999px;
    z-index: 1;
}

.dental-quadrant {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: nowrap;
    z-index: 1;
}

.dental-quadrant-wrap {
    display: grid;
    gap: 4px;
    align-content: stretch;
}

.dental-quad-label {
    text-align: center;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.dental-tooth-btn,
.dental-tooth-readonly {
    min-width: 24px;
    width: 24px;
    height: 48px;
    border-radius: 16px 16px 12px 12px;
    border: none;
    background: transparent;
    color: #0f172a;
    font-size: 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    z-index: 1;
}

.dental-tooth-btn::before,
.dental-tooth-readonly::before {
    content: "";
    position: absolute;
    left: 1px;
    right: 1px;
    top: 3px;
    bottom: 12px;
    border: 1px solid #6b7280;
    border-radius: 12px 12px 8px 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 45%, #e2e8f0 100%);
    box-shadow: inset 0 -3px 0 rgba(148, 163, 184, 0.35), 0 1px 1px rgba(15, 23, 42, 0.22);
    clip-path: polygon(15% 0%, 85% 0%, 97% 22%, 90% 76%, 66% 100%, 34% 100%, 10% 76%, 3% 22%);
}

.dental-tooth-btn::after,
.dental-tooth-readonly::after {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 9px;
    height: 9px;
    border-radius: 0 0 6px 6px;
    background: rgba(148, 163, 184, 0.28);
}

.dental-arch.upper .dental-tooth-btn,
.dental-arch.upper .dental-tooth-readonly {
    margin-top: 20px;
}

.dental-arch.lower .dental-tooth-btn,
.dental-arch.lower .dental-tooth-readonly {
    margin-bottom: 20px;
    border-radius: 10px 10px 14px 14px;
}

.dental-arch.lower .dental-tooth-btn::before,
.dental-arch.lower .dental-tooth-readonly::before {
    clip-path: polygon(8% 26%, 32% 0%, 68% 0%, 92% 26%, 98% 82%, 88% 100%, 12% 100%, 2% 82%);
}

.dental-tooth-btn[data-tooth="104"],
.dental-tooth-btn[data-tooth="204"],
.dental-tooth-btn[data-tooth="304"],
.dental-tooth-btn[data-tooth="404"],
.dental-tooth-readonly[data-tooth="104"],
.dental-tooth-readonly[data-tooth="204"],
.dental-tooth-readonly[data-tooth="304"],
.dental-tooth-readonly[data-tooth="404"] {
    width: 40px;
    min-width: 40px;
    height: 66px;
}

.dental-tooth-btn[data-tooth="108"],
.dental-tooth-btn[data-tooth="208"],
.dental-tooth-btn[data-tooth="309"],
.dental-tooth-btn[data-tooth="409"],
.dental-tooth-readonly[data-tooth="108"],
.dental-tooth-readonly[data-tooth="208"],
.dental-tooth-readonly[data-tooth="309"],
.dental-tooth-readonly[data-tooth="409"] {
    width: 34px;
    min-width: 34px;
    height: 56px;
}

.dental-tooth-btn[data-state="1"]::before,
.dental-tooth-readonly[data-state="1"]::before {
    opacity: 0.2;
    filter: grayscale(0.6);
}

.dental-tooth-btn[data-state="2"]::before,
.dental-tooth-readonly[data-state="2"]::before {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #fef2f2 0%, #fecaca 100%);
}

.dental-tooth-btn[data-state="2"]::after,
.dental-tooth-readonly[data-state="2"]::after {
    background: rgba(185, 28, 28, 0.28);
}

.dental-tooth-btn span,
.dental-tooth-readonly span {
    pointer-events: none;
    position: relative;
    z-index: 3;
}

.dental-cross {
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    z-index: 4;
}

.dental-orientation {
    display: flex;
    justify-content: space-between;
    color: #64748b;
    font-size: 12px;
    margin: 2px 0 8px;
}

.dental-readable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.dental-readable-box {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    background: #ffffff;
}

.dental-readable-list {
    margin: 8px 0 0 18px;
    padding: 0;
    max-height: 170px;
    overflow: auto;
}

.dental-readable-list li {
    margin-bottom: 4px;
    color: #1f2937;
}

.dental-map {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    padding: 10px;
}

.dental-map-canvas {
    position: relative;
    width: 100%;
    max-width: 980px;
    height: 720px;
    margin: 0 auto;
    background-image: url('/assets/dental-mouth-guide-v2.svg');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

.dental-map-title {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 26px;
    font-weight: 800;
    color: #1f2937;
}

.dental-map-jaw {
    position: absolute;
    width: 150px;
    font-size: 14px;
    font-weight: 700;
    color: #6b7280;
    line-height: 1.2;
}

.dental-map-jaw.left { left: 6px; text-align: left; }
.dental-map-jaw.right { right: 6px; text-align: right; }
.dental-map-jaw.top { top: 62px; }
.dental-map-jaw.bottom { bottom: 56px; }

.dental-map-label {
    position: absolute;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.dental-map-label.incisors-top { top: 100px; left: 210px; }
.dental-map-label.canines-top { top: 152px; left: 164px; }
.dental-map-label.premolars-top { top: 248px; left: 122px; }
.dental-map-label.molars-top { top: 350px; left: 144px; }

.dental-map-label.incisors-bottom { bottom: 62px; left: 224px; }
.dental-map-label.canines-bottom { bottom: 154px; left: 160px; }
.dental-map-label.premolars-bottom { bottom: 252px; left: 116px; }
.dental-map-label.molars-bottom { bottom: 356px; left: 146px; }

.dental-map-label::after {
    content: "";
    position: absolute;
    width: 46px;
    border-top: 2px solid #6b7280;
    top: 50%;
    margin-top: -1px;
    left: calc(100% + 8px);
}

.dental-plot {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 42px;
    min-width: 28px;
    border: none;
    background: transparent;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.dental-plot::before {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    top: 3px;
    bottom: 12px;
    border: 1px solid #4b5563;
    border-radius: 12px 12px 8px 8px;
    background: linear-gradient(180deg, #ffffff 0%, #eef2f7 55%, #dbe4ee 100%);
    box-shadow: inset 0 -2px 0 rgba(148, 163, 184, 0.35), 0 1px 1px rgba(15, 23, 42, 0.2);
    clip-path: polygon(14% 0%, 86% 0%, 98% 24%, 92% 76%, 66% 100%, 34% 100%, 8% 76%, 2% 24%);
}

.dental-plot span {
    position: relative;
    z-index: 3;
    font-size: 11px;
    font-weight: 800;
    color: #111827;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

.dental-plot .dental-cross {
    z-index: 5;
}

.dental-plot[data-state="1"]::before {
    opacity: 0.25;
    filter: grayscale(0.7);
}

.dental-plot[data-state="2"]::before {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 38px;
    min-width: 38px;
    height: 74px;
}

.dental-plot[data-tooth="108"],
.dental-plot[data-tooth="208"],
.dental-plot[data-tooth="309"],
.dental-plot[data-tooth="409"] {
    width: 34px;
    min-width: 34px;
    height: 60px;
}

.dental-plot[data-tooth="101"] { left: 48%; top: 17%; }
.dental-plot[data-tooth="102"] { left: 46%; top: 18%; }
.dental-plot[data-tooth="103"] { left: 44%; top: 19.5%; }
.dental-plot[data-tooth="104"] { left: 40%; top: 26%; }
.dental-plot[data-tooth="106"] { left: 34.5%; top: 31.5%; }
.dental-plot[data-tooth="107"] { left: 32.5%; top: 37%; }
.dental-plot[data-tooth="108"] { left: 30%; top: 43%; }
.dental-plot[data-tooth="109"] { left: 29%; top: 48.5%; }

.dental-plot[data-tooth="201"] { left: 52%; top: 17%; }
.dental-plot[data-tooth="202"] { left: 54%; top: 18%; }
.dental-plot[data-tooth="203"] { left: 56%; top: 19.5%; }
.dental-plot[data-tooth="204"] { left: 60%; top: 26%; }
.dental-plot[data-tooth="206"] { left: 65.5%; top: 31.5%; }
.dental-plot[data-tooth="207"] { left: 67.5%; top: 37%; }
.dental-plot[data-tooth="208"] { left: 70%; top: 43%; }
.dental-plot[data-tooth="209"] { left: 71%; top: 48.5%; }

.dental-plot[data-tooth="409"] { left: 34%; top: 66.5%; }
.dental-plot[data-tooth="408"] { left: 36%; top: 73%; }
.dental-plot[data-tooth="407"] { left: 38%; top: 78%; }
.dental-plot[data-tooth="404"] { left: 43%; top: 86%; }
.dental-plot[data-tooth="403"] { left: 46%; top: 91.2%; }
.dental-plot[data-tooth="402"] { left: 48%; top: 92.3%; }
.dental-plot[data-tooth="401"] { left: 49.8%; top: 93%; }

.dental-plot[data-tooth="301"] { left: 50.2%; top: 93%; }
.dental-plot[data-tooth="302"] { left: 52%; top: 92.3%; }
.dental-plot[data-tooth="303"] { left: 54%; top: 91.2%; }
.dental-plot[data-tooth="304"] { left: 57%; top: 86%; }
.dental-plot[data-tooth="307"] { left: 62%; top: 78%; }
.dental-plot[data-tooth="308"] { left: 64%; top: 73%; }
.dental-plot[data-tooth="309"] { left: 66%; top: 66.5%; }

/* v4 feline chart cleanup */
.dental-map-canvas {
    max-width: 1020px;
    height: 760px;
    background-image: url('/assets/dental-feline-outline-v3.svg');
    background-size: 100% 100%;
}

.dental-map-title {
    top: 14px;
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #1f2937;
}

.dental-map-jaw {
    width: 170px;
    font-size: 22px;
    font-weight: 700;
    color: #6b7280;
}

.dental-map-jaw.top { top: 84px; }
.dental-map-jaw.bottom { bottom: 64px; }

.dental-map-label {
    font-size: 34px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.dental-map-label.small {
    font-size: 30px;
}

.dental-map-label.left::after {
    content: "";
    position: absolute;
    width: 88px;
    border-top: 3px solid #6b7280;
    top: 50%;
    margin-top: -1px;
    left: calc(100% + 10px);
}

.dental-map-label.right::after {
    content: "";
    position: absolute;
    width: 88px;
    border-top: 3px solid #6b7280;
    top: 50%;
    margin-top: -1px;
    right: calc(100% + 10px);
}

.dental-map-label.incisors-top.left { top: 126px; left: 198px; }
.dental-map-label.incisors-top.right { top: 126px; right: 198px; }
.dental-map-label.canines-top.left { top: 202px; left: 128px; }
.dental-map-label.canines-top.right { top: 202px; right: 128px; }
.dental-map-label.premolars-top.left { top: 300px; left: 78px; }
.dental-map-label.premolars-top.right { top: 300px; right: 78px; }
.dental-map-label.molars-top.left { top: 410px; left: 116px; }
.dental-map-label.molars-top.right { top: 410px; right: 116px; }

.dental-map-label.incisors-bottom.left { bottom: 54px; left: 212px; }
.dental-map-label.incisors-bottom.right { bottom: 54px; right: 212px; }
.dental-map-label.canines-bottom.left { bottom: 150px; left: 126px; }
.dental-map-label.canines-bottom.right { bottom: 150px; right: 126px; }
.dental-map-label.premolars-bottom.left { bottom: 256px; left: 68px; }
.dental-map-label.premolars-bottom.right { bottom: 256px; right: 68px; }
.dental-map-label.molars-bottom.left { bottom: 360px; left: 114px; }
.dental-map-label.molars-bottom.right { bottom: 360px; right: 114px; }

.dental-plot {
    width: 22px;
    min-width: 22px;
    height: 58px;
}

.dental-plot::before {
    display: none;
}

.dental-plot::after {
    content: "";
    position: absolute;
    left: 1px;
    right: 1px;
    top: 2px;
    bottom: 16px;
    border: 2px solid #4b5563;
    border-radius: 16px 16px 11px 11px;
    background: linear-gradient(180deg, #fdfefe 0%, #e8eef5 100%);
    box-shadow: inset 0 -2px 0 rgba(148, 163, 184, 0.35), 0 1px 1px rgba(15, 23, 42, 0.2);
    clip-path: polygon(16% 0%, 84% 0%, 97% 24%, 90% 78%, 66% 100%, 34% 100%, 10% 78%, 3% 24%);
    z-index: 2;
}

.dental-plot span {
    font-size: 24px;
    font-weight: 800;
    color: #111827;
    margin-top: 36px;
}

.dental-plot[data-tooth="101"],
.dental-plot[data-tooth="102"],
.dental-plot[data-tooth="103"],
.dental-plot[data-tooth="201"],
.dental-plot[data-tooth="202"],
.dental-plot[data-tooth="203"],
.dental-plot[data-tooth="301"],
.dental-plot[data-tooth="302"],
.dental-plot[data-tooth="303"],
.dental-plot[data-tooth="401"],
.dental-plot[data-tooth="402"],
.dental-plot[data-tooth="403"] {
    width: 18px;
    min-width: 18px;
    height: 44px;
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 42px;
    min-width: 42px;
    height: 96px;
}

.dental-plot[data-tooth="106"],
.dental-plot[data-tooth="107"],
.dental-plot[data-tooth="108"],
.dental-plot[data-tooth="206"],
.dental-plot[data-tooth="207"],
.dental-plot[data-tooth="208"],
.dental-plot[data-tooth="307"],
.dental-plot[data-tooth="308"],
.dental-plot[data-tooth="407"],
.dental-plot[data-tooth="408"] {
    width: 28px;
    min-width: 28px;
    height: 74px;
}

.dental-plot[data-tooth="109"],
.dental-plot[data-tooth="209"],
.dental-plot[data-tooth="309"],
.dental-plot[data-tooth="409"] {
    width: 34px;
    min-width: 34px;
    height: 76px;
}

.dental-plot[data-state="1"]::after {
    opacity: 0.3;
    filter: grayscale(0.8);
}

.dental-plot[data-state="2"]::after {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
}

.dental-plot[data-tooth="101"] { left: 48.5%; top: 16.8%; }
.dental-plot[data-tooth="102"] { left: 46.9%; top: 17.4%; }
.dental-plot[data-tooth="103"] { left: 45%; top: 18.4%; }
.dental-plot[data-tooth="104"] { left: 40.2%; top: 25.6%; }
.dental-plot[data-tooth="106"] { left: 35.3%; top: 31.2%; }
.dental-plot[data-tooth="107"] { left: 33.2%; top: 36.6%; }
.dental-plot[data-tooth="108"] { left: 31%; top: 42.8%; }
.dental-plot[data-tooth="109"] { left: 30.1%; top: 48.8%; }

.dental-plot[data-tooth="201"] { left: 51.5%; top: 16.8%; }
.dental-plot[data-tooth="202"] { left: 53.1%; top: 17.4%; }
.dental-plot[data-tooth="203"] { left: 55%; top: 18.4%; }
.dental-plot[data-tooth="204"] { left: 59.8%; top: 25.6%; }
.dental-plot[data-tooth="206"] { left: 64.7%; top: 31.2%; }
.dental-plot[data-tooth="207"] { left: 66.8%; top: 36.6%; }
.dental-plot[data-tooth="208"] { left: 69%; top: 42.8%; }
.dental-plot[data-tooth="209"] { left: 69.9%; top: 48.8%; }

.dental-plot[data-tooth="409"] { left: 36%; top: 67.2%; }
.dental-plot[data-tooth="408"] { left: 37.9%; top: 73.4%; }
.dental-plot[data-tooth="407"] { left: 40.1%; top: 78.5%; }
.dental-plot[data-tooth="404"] { left: 44.2%; top: 86.5%; }
.dental-plot[data-tooth="403"] { left: 47.2%; top: 91.7%; }
.dental-plot[data-tooth="402"] { left: 49.1%; top: 92.8%; }
.dental-plot[data-tooth="401"] { left: 50.2%; top: 93.4%; }

.dental-plot[data-tooth="301"] { left: 49.8%; top: 93.4%; }
.dental-plot[data-tooth="302"] { left: 50.9%; top: 92.8%; }
.dental-plot[data-tooth="303"] { left: 52.8%; top: 91.7%; }
.dental-plot[data-tooth="304"] { left: 55.8%; top: 86.5%; }
.dental-plot[data-tooth="307"] { left: 59.9%; top: 78.5%; }
.dental-plot[data-tooth="308"] { left: 62.1%; top: 73.4%; }
.dental-plot[data-tooth="309"] { left: 64%; top: 67.2%; }

/* v5 final cleanup: smaller, readable, feline-like */
.dental-map {
    padding: 8px;
}

.dental-map-canvas {
    width: min(100%, 760px);
    aspect-ratio: 3 / 2;
    height: auto;
    max-width: 760px;
    margin: 0 auto;
    background-image: url('/assets/dental-feline-outline-v4.svg');
    background-size: 100% 100%;
}

.dental-map-title {
    top: 6px;
    font-size: 24px;
    font-weight: 800;
}

.dental-map-jaw {
    display: none;
}

.dental-map-label {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    line-height: 1;
}

.dental-map-label.small {
    font-size: 11px;
}

.dental-map-label.left::after,
.dental-map-label.right::after {
    display: none;
}

.dental-map-label.incisors-top.left { top: 64px; left: 120px; }
.dental-map-label.incisors-top.right { top: 64px; right: 120px; }
.dental-map-label.canines-top.left { top: 98px; left: 82px; }
.dental-map-label.canines-top.right { top: 98px; right: 82px; }
.dental-map-label.premolars-top.left { top: 145px; left: 58px; }
.dental-map-label.premolars-top.right { top: 145px; right: 58px; }
.dental-map-label.molars-top.left { top: 194px; left: 80px; }
.dental-map-label.molars-top.right { top: 194px; right: 80px; }

.dental-map-label.incisors-bottom.left { bottom: 30px; left: 120px; }
.dental-map-label.incisors-bottom.right { bottom: 30px; right: 120px; }
.dental-map-label.canines-bottom.left { bottom: 72px; left: 80px; }
.dental-map-label.canines-bottom.right { bottom: 72px; right: 80px; }
.dental-map-label.premolars-bottom.left { bottom: 124px; left: 56px; }
.dental-map-label.premolars-bottom.right { bottom: 124px; right: 56px; }
.dental-map-label.molars-bottom.left { bottom: 172px; left: 78px; }
.dental-map-label.molars-bottom.right { bottom: 172px; right: 78px; }

.dental-plot {
    width: 18px;
    min-width: 18px;
    height: 44px;
}

.dental-plot::before {
    display: none;
}

.dental-plot::after {
    left: 1px;
    right: 1px;
    top: 1px;
    bottom: 10px;
    border: 1.5px solid #4b5563;
    border-radius: 10px 10px 7px 7px;
    background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
    clip-path: polygon(18% 0%, 82% 0%, 98% 24%, 92% 78%, 66% 100%, 34% 100%, 8% 78%, 2% 24%);
}

.dental-plot span {
    font-size: 11px;
    margin-top: 26px;
}

.dental-plot .dental-cross {
    font-size: 18px !important;
    line-height: 26px !important;
}

.dental-plot[data-tooth="101"],
.dental-plot[data-tooth="102"],
.dental-plot[data-tooth="103"],
.dental-plot[data-tooth="201"],
.dental-plot[data-tooth="202"],
.dental-plot[data-tooth="203"],
.dental-plot[data-tooth="301"],
.dental-plot[data-tooth="302"],
.dental-plot[data-tooth="303"],
.dental-plot[data-tooth="401"],
.dental-plot[data-tooth="402"],
.dental-plot[data-tooth="403"] {
    width: 14px;
    min-width: 14px;
    height: 30px;
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 30px;
    min-width: 30px;
    height: 72px;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 16px 16px 8px 8px;
    clip-path: polygon(22% 0%, 78% 0%, 92% 22%, 88% 70%, 68% 100%, 32% 100%, 12% 70%, 8% 22%);
}

.dental-plot[data-tooth="106"],
.dental-plot[data-tooth="107"],
.dental-plot[data-tooth="206"],
.dental-plot[data-tooth="207"],
.dental-plot[data-tooth="307"],
.dental-plot[data-tooth="308"],
.dental-plot[data-tooth="407"],
.dental-plot[data-tooth="408"] {
    width: 22px;
    min-width: 22px;
    height: 52px;
}

.dental-plot[data-tooth="108"],
.dental-plot[data-tooth="208"],
.dental-plot[data-tooth="309"],
.dental-plot[data-tooth="409"] {
    width: 26px;
    min-width: 26px;
    height: 56px;
}

.dental-plot[data-state="1"]::after {
    opacity: 0.28;
    filter: grayscale(0.75);
}

.dental-plot[data-state="2"]::after {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
}

.dental-plot[data-tooth="101"] { left: 48.7%; top: 16.8%; }
.dental-plot[data-tooth="102"] { left: 47.1%; top: 17.3%; }
.dental-plot[data-tooth="103"] { left: 45.4%; top: 18%; }
.dental-plot[data-tooth="104"] { left: 40.4%; top: 24.5%; }
.dental-plot[data-tooth="106"] { left: 35.8%; top: 30.1%; }
.dental-plot[data-tooth="107"] { left: 33.7%; top: 35.6%; }
.dental-plot[data-tooth="108"] { left: 31.4%; top: 41.5%; }
.dental-plot[data-tooth="109"] { left: 30.2%; top: 47.2%; }

.dental-plot[data-tooth="201"] { left: 51.3%; top: 16.8%; }
.dental-plot[data-tooth="202"] { left: 52.9%; top: 17.3%; }
.dental-plot[data-tooth="203"] { left: 54.6%; top: 18%; }
.dental-plot[data-tooth="204"] { left: 59.6%; top: 24.5%; }
.dental-plot[data-tooth="206"] { left: 64.2%; top: 30.1%; }
.dental-plot[data-tooth="207"] { left: 66.3%; top: 35.6%; }
.dental-plot[data-tooth="208"] { left: 68.6%; top: 41.5%; }
.dental-plot[data-tooth="209"] { left: 69.8%; top: 47.2%; }

.dental-plot[data-tooth="409"] { left: 37.2%; top: 66.4%; }
.dental-plot[data-tooth="408"] { left: 39.2%; top: 72.2%; }
.dental-plot[data-tooth="407"] { left: 41.2%; top: 77%; }
.dental-plot[data-tooth="404"] { left: 45%; top: 84.3%; }
.dental-plot[data-tooth="403"] { left: 47.7%; top: 89.2%; }
.dental-plot[data-tooth="402"] { left: 49.3%; top: 90%; }
.dental-plot[data-tooth="401"] { left: 50.2%; top: 90.4%; }

.dental-plot[data-tooth="301"] { left: 49.8%; top: 90.4%; }
.dental-plot[data-tooth="302"] { left: 50.7%; top: 90%; }
.dental-plot[data-tooth="303"] { left: 52.3%; top: 89.2%; }
.dental-plot[data-tooth="304"] { left: 55%; top: 84.3%; }
.dental-plot[data-tooth="307"] { left: 58.8%; top: 77%; }
.dental-plot[data-tooth="308"] { left: 60.8%; top: 72.2%; }
.dental-plot[data-tooth="309"] { left: 62.8%; top: 66.4%; }

/* v3 anatomical refinement */
.dental-mouth {
    padding: 14px;
}

.dental-arch-row {
    min-height: 108px;
}

.dental-quadrant {
    position: relative;
    padding: 10px 8px;
    align-items: flex-end;
}

.dental-arch.lower .dental-quadrant {
    align-items: flex-start;
}

.dental-quadrant::before {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    height: 20px;
    border: 1px solid rgba(236, 72, 153, 0.45);
    background: linear-gradient(180deg, rgba(251, 207, 232, 0.55) 0%, rgba(249, 168, 212, 0.35) 100%);
    border-radius: 999px;
    z-index: 0;
}

.dental-arch.upper .dental-quadrant::before {
    top: 3px;
}

.dental-arch.lower .dental-quadrant::before {
    bottom: 3px;
}

.dental-tooth-btn,
.dental-tooth-readonly {
    min-width: 24px;
    width: 24px;
    height: 64px;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    transform: translateY(0);
}

.dental-tooth-btn::before,
.dental-tooth-readonly::before {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(100, 116, 139, 0.35);
    background: rgba(241, 245, 249, 0.9);
    z-index: 1;
}

.dental-arch.upper .dental-tooth-btn::before,
.dental-arch.upper .dental-tooth-readonly::before {
    top: 11px;
}

.dental-arch.lower .dental-tooth-btn::before,
.dental-arch.lower .dental-tooth-readonly::before {
    bottom: 11px;
}

.dental-tooth-btn::after,
.dental-tooth-readonly::after {
    content: "";
    position: absolute;
    left: 1px;
    right: 1px;
    border: 1px solid #6b7280;
    background: linear-gradient(180deg, #ffffff 0%, #edf2f7 55%, #dde6ef 100%);
    box-shadow: inset 0 -3px 0 rgba(148, 163, 184, 0.35), 0 1px 1px rgba(15, 23, 42, 0.2);
    z-index: 2;
}

.dental-arch.upper .dental-tooth-btn::after,
.dental-arch.upper .dental-tooth-readonly::after {
    top: 16px;
    bottom: 2px;
    border-radius: 14px 14px 10px 10px;
    clip-path: polygon(16% 0%, 84% 0%, 98% 24%, 92% 76%, 68% 100%, 32% 100%, 8% 76%, 2% 24%);
}

.dental-arch.lower .dental-tooth-btn::after,
.dental-arch.lower .dental-tooth-readonly::after {
    top: 2px;
    bottom: 16px;
    border-radius: 10px 10px 14px 14px;
    clip-path: polygon(8% 24%, 32% 0%, 68% 0%, 92% 24%, 98% 76%, 84% 100%, 16% 100%, 2% 76%);
}

.dental-tooth-btn span,
.dental-tooth-readonly span {
    font-size: 10px;
    font-weight: 700;
    color: #0f172a;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
    z-index: 3;
}

.dental-arch.upper .dental-tooth-btn span,
.dental-arch.upper .dental-tooth-readonly span {
    margin-top: 34px;
}

.dental-arch.lower .dental-tooth-btn span,
.dental-arch.lower .dental-tooth-readonly span {
    margin-top: 10px;
}

.dental-tooth-btn[data-state="1"]::after,
.dental-tooth-readonly[data-state="1"]::after {
    opacity: 0.25;
    filter: grayscale(0.7);
}

.dental-tooth-btn[data-state="2"]::after,
.dental-tooth-readonly[data-state="2"]::after {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #fef2f2 0%, #fecaca 100%);
}

.dental-tooth-btn[data-tooth="104"],
.dental-tooth-btn[data-tooth="204"],
.dental-tooth-btn[data-tooth="304"],
.dental-tooth-btn[data-tooth="404"],
.dental-tooth-readonly[data-tooth="104"],
.dental-tooth-readonly[data-tooth="204"],
.dental-tooth-readonly[data-tooth="304"],
.dental-tooth-readonly[data-tooth="404"] {
    width: 38px;
    min-width: 38px;
    height: 82px;
}

.dental-tooth-btn[data-tooth="108"],
.dental-tooth-btn[data-tooth="208"],
.dental-tooth-btn[data-tooth="309"],
.dental-tooth-btn[data-tooth="409"],
.dental-tooth-readonly[data-tooth="108"],
.dental-tooth-readonly[data-tooth="208"],
.dental-tooth-readonly[data-tooth="309"],
.dental-tooth-readonly[data-tooth="409"] {
    width: 33px;
    min-width: 33px;
    height: 72px;
}

.dental-arch.upper [data-tooth="101"], .dental-arch.upper [data-tooth="102"], .dental-arch.upper [data-tooth="103"],
.dental-arch.upper [data-tooth="201"], .dental-arch.upper [data-tooth="202"], .dental-arch.upper [data-tooth="203"] { transform: translateY(12px); }

.dental-arch.upper [data-tooth="104"], .dental-arch.upper [data-tooth="204"] { transform: translateY(-2px); }

.dental-arch.upper [data-tooth="106"], .dental-arch.upper [data-tooth="107"],
.dental-arch.upper [data-tooth="206"], .dental-arch.upper [data-tooth="207"] { transform: translateY(2px); }

.dental-arch.upper [data-tooth="108"], .dental-arch.upper [data-tooth="109"], .dental-arch.upper [data-tooth="110"],
.dental-arch.upper [data-tooth="208"], .dental-arch.upper [data-tooth="209"], .dental-arch.upper [data-tooth="210"] { transform: translateY(8px); }

.dental-arch.lower [data-tooth="301"], .dental-arch.lower [data-tooth="302"], .dental-arch.lower [data-tooth="303"],
.dental-arch.lower [data-tooth="401"], .dental-arch.lower [data-tooth="402"], .dental-arch.lower [data-tooth="403"] { transform: translateY(-12px); }

.dental-arch.lower [data-tooth="304"], .dental-arch.lower [data-tooth="404"] { transform: translateY(2px); }

.dental-arch.lower [data-tooth="306"], .dental-arch.lower [data-tooth="307"], .dental-arch.lower [data-tooth="308"],
.dental-arch.lower [data-tooth="406"], .dental-arch.lower [data-tooth="407"], .dental-arch.lower [data-tooth="408"] { transform: translateY(-4px); }

.dental-arch.lower [data-tooth="309"], .dental-arch.lower [data-tooth="310"], .dental-arch.lower [data-tooth="311"],
.dental-arch.lower [data-tooth="409"], .dental-arch.lower [data-tooth="410"], .dental-arch.lower [data-tooth="411"] { transform: translateY(-8px); }

/* v6 layout + incisor correction */
.dental-layout {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(360px, 560px);
    gap: 12px;
    align-items: start;
}

.dental-side {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: var(--page-bg);
    padding: 10px;
}

.dental-map {
    padding: 6px;
    background: var(--page-bg);
}

.dental-map-canvas {
    width: min(100%, 560px);
    max-width: 560px;
    aspect-ratio: 3 / 2;
    height: auto;
    margin-left: auto;
    margin-right: 0;
    background-image: url('/assets/dental-feline-outline-v4.svg');
    background-size: 100% 100%;
}

.dental-map-title {
    font-size: 20px;
    top: 6px;
}

.dental-map-label {
    font-size: 11px;
    display: none;
}

.dental-map-label.small {
    font-size: 10px;
}

.dental-map-label.incisors-top.left { top: 50px; left: 90px; }
.dental-map-label.incisors-top.right { top: 50px; right: 90px; }
.dental-map-label.canines-top.left { top: 80px; left: 66px; }
.dental-map-label.canines-top.right { top: 80px; right: 66px; }
.dental-map-label.premolars-top.left { top: 118px; left: 44px; }
.dental-map-label.premolars-top.right { top: 118px; right: 44px; }
.dental-map-label.molars-top.left { top: 158px; left: 58px; }
.dental-map-label.molars-top.right { top: 158px; right: 58px; }

.dental-map-label.incisors-bottom.left { bottom: 24px; left: 90px; }
.dental-map-label.incisors-bottom.right { bottom: 24px; right: 90px; }
.dental-map-label.canines-bottom.left { bottom: 58px; left: 64px; }
.dental-map-label.canines-bottom.right { bottom: 58px; right: 64px; }
.dental-map-label.premolars-bottom.left { bottom: 100px; left: 42px; }
.dental-map-label.premolars-bottom.right { bottom: 100px; right: 42px; }
.dental-map-label.molars-bottom.left { bottom: 138px; left: 58px; }
.dental-map-label.molars-bottom.right { bottom: 138px; right: 58px; }

.dental-plot[data-tooth="401"],
.dental-plot[data-tooth="402"],
.dental-plot[data-tooth="403"],
.dental-plot[data-tooth="301"],
.dental-plot[data-tooth="302"],
.dental-plot[data-tooth="303"] {
    width: 12px;
    min-width: 12px;
    height: 30px;
}

.dental-plot[data-tooth="101"] span,
.dental-plot[data-tooth="102"] span,
.dental-plot[data-tooth="103"] span,
.dental-plot[data-tooth="201"] span,
.dental-plot[data-tooth="202"] span,
.dental-plot[data-tooth="203"] span,
.dental-plot[data-tooth="401"] span,
.dental-plot[data-tooth="402"] span,
.dental-plot[data-tooth="403"] span,
.dental-plot[data-tooth="301"] span,
.dental-plot[data-tooth="302"] span,
.dental-plot[data-tooth="303"] span {
    transform: rotate(-90deg);
    transform-origin: center;
    font-size: 9px;
    margin-top: 18px;
    white-space: nowrap;
}

.dental-plot[data-tooth="401"] { left: 45.8%; top: 90.8%; }
.dental-plot[data-tooth="402"] { left: 47.6%; top: 90.8%; }
.dental-plot[data-tooth="403"] { left: 49.4%; top: 90.8%; }
.dental-plot[data-tooth="301"] { left: 50.6%; top: 90.8%; }
.dental-plot[data-tooth="302"] { left: 52.4%; top: 90.8%; }
.dental-plot[data-tooth="303"] { left: 54.2%; top: 90.8%; }

@media (max-width: 980px) {
    .dental-layout {
        grid-template-columns: 1fr;
    }

    .dental-map-canvas {
        margin: 0 auto;
        width: min(100%, 520px);
    }
}

/* v7 contrast + canine/molar label tuning */
.dental-plot::after {
    border: 2px solid #334155;
    background: linear-gradient(180deg, #ffffff 0%, #f3f6fb 100%);
    box-shadow: inset 0 -2px 0 rgba(100, 116, 139, 0.32), 0 1px 2px rgba(15, 23, 42, 0.2);
}

.dental-plot span {
    color: #0f172a;
    font-weight: 800;
    text-shadow: none;
}

.dental-plot[data-tooth="104"] span,
.dental-plot[data-tooth="204"] span,
.dental-plot[data-tooth="304"] span,
.dental-plot[data-tooth="404"] span {
    margin-top: 36px;
    font-size: 10px;
}

.dental-plot[data-tooth="109"] span,
.dental-plot[data-tooth="209"] span,
.dental-plot[data-tooth="309"] span,
.dental-plot[data-tooth="409"] span {
    margin-top: 30px;
    font-size: 10px;
}

.dental-plot[data-tooth="106"] span,
.dental-plot[data-tooth="107"] span,
.dental-plot[data-tooth="108"] span,
.dental-plot[data-tooth="206"] span,
.dental-plot[data-tooth="207"] span,
.dental-plot[data-tooth="208"] span,
.dental-plot[data-tooth="307"] span,
.dental-plot[data-tooth="308"] span,
.dental-plot[data-tooth="407"] span,
.dental-plot[data-tooth="408"] span {
    margin-top: 28px;
    font-size: 10px;
}

/* v8 tighten click area + outside labels for canine/molars */
.dental-plot {
    overflow: visible;
}

.dental-plot::after {
    top: 0;
    bottom: 0;
}

.dental-plot span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 0;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
}

.dental-plot[data-tooth="101"] span,
.dental-plot[data-tooth="102"] span,
.dental-plot[data-tooth="103"] span,
.dental-plot[data-tooth="201"] span,
.dental-plot[data-tooth="202"] span,
.dental-plot[data-tooth="203"] span,
.dental-plot[data-tooth="401"] span,
.dental-plot[data-tooth="402"] span,
.dental-plot[data-tooth="403"] span,
.dental-plot[data-tooth="301"] span,
.dental-plot[data-tooth="302"] span,
.dental-plot[data-tooth="303"] span {
    transform: translate(-50%, -50%) rotate(-90deg);
    font-size: 8.5px;
}

.dental-plot[data-tooth="404"] span,
.dental-plot[data-tooth="405"] span,
.dental-plot[data-tooth="406"] span,
.dental-plot[data-tooth="407"] span,
.dental-plot[data-tooth="408"] span,
.dental-plot[data-tooth="409"] span,
.dental-plot[data-tooth="104"] span,
.dental-plot[data-tooth="105"] span,
.dental-plot[data-tooth="106"] span,
.dental-plot[data-tooth="107"] span,
.dental-plot[data-tooth="108"] span,
.dental-plot[data-tooth="109"] span {
    left: auto;
    right: calc(100% + 4px);
    transform: translateY(-50%);
    font-size: 9px;
}

.dental-plot[data-tooth="204"] span,
.dental-plot[data-tooth="205"] span,
.dental-plot[data-tooth="206"] span,
.dental-plot[data-tooth="207"] span,
.dental-plot[data-tooth="208"] span,
.dental-plot[data-tooth="209"] span,
.dental-plot[data-tooth="304"] span,
.dental-plot[data-tooth="305"] span,
.dental-plot[data-tooth="306"] span,
.dental-plot[data-tooth="307"] span,
.dental-plot[data-tooth="308"] span,
.dental-plot[data-tooth="309"] span {
    left: calc(100% + 4px);
    right: auto;
    transform: translateY(-50%);
    font-size: 9px;
}

/* v9 fix: label span vs cross span separation */
.dental-plot > span:not(.dental-cross) {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 0;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    z-index: 4;
}

.dental-plot[data-tooth="101"] > span:not(.dental-cross),
.dental-plot[data-tooth="102"] > span:not(.dental-cross),
.dental-plot[data-tooth="103"] > span:not(.dental-cross),
.dental-plot[data-tooth="201"] > span:not(.dental-cross),
.dental-plot[data-tooth="202"] > span:not(.dental-cross),
.dental-plot[data-tooth="203"] > span:not(.dental-cross),
.dental-plot[data-tooth="401"] > span:not(.dental-cross),
.dental-plot[data-tooth="402"] > span:not(.dental-cross),
.dental-plot[data-tooth="403"] > span:not(.dental-cross),
.dental-plot[data-tooth="301"] > span:not(.dental-cross),
.dental-plot[data-tooth="302"] > span:not(.dental-cross),
.dental-plot[data-tooth="303"] > span:not(.dental-cross) {
    transform: translate(-50%, -50%) rotate(-90deg);
    font-size: 8.5px;
}

.dental-plot[data-tooth="404"] > span:not(.dental-cross),
.dental-plot[data-tooth="405"] > span:not(.dental-cross),
.dental-plot[data-tooth="406"] > span:not(.dental-cross),
.dental-plot[data-tooth="407"] > span:not(.dental-cross),
.dental-plot[data-tooth="408"] > span:not(.dental-cross),
.dental-plot[data-tooth="409"] > span:not(.dental-cross),
.dental-plot[data-tooth="104"] > span:not(.dental-cross),
.dental-plot[data-tooth="105"] > span:not(.dental-cross),
.dental-plot[data-tooth="106"] > span:not(.dental-cross),
.dental-plot[data-tooth="107"] > span:not(.dental-cross),
.dental-plot[data-tooth="108"] > span:not(.dental-cross),
.dental-plot[data-tooth="109"] > span:not(.dental-cross) {
    left: auto;
    right: calc(100% + 4px);
    transform: translateY(-50%);
    font-size: 9px;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross),
.dental-plot[data-tooth="205"] > span:not(.dental-cross),
.dental-plot[data-tooth="206"] > span:not(.dental-cross),
.dental-plot[data-tooth="207"] > span:not(.dental-cross),
.dental-plot[data-tooth="208"] > span:not(.dental-cross),
.dental-plot[data-tooth="209"] > span:not(.dental-cross),
.dental-plot[data-tooth="304"] > span:not(.dental-cross),
.dental-plot[data-tooth="305"] > span:not(.dental-cross),
.dental-plot[data-tooth="306"] > span:not(.dental-cross),
.dental-plot[data-tooth="307"] > span:not(.dental-cross),
.dental-plot[data-tooth="308"] > span:not(.dental-cross),
.dental-plot[data-tooth="309"] > span:not(.dental-cross) {
    left: calc(100% + 4px);
    right: auto;
    transform: translateY(-50%);
    font-size: 9px;
}

.dental-plot .dental-cross {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    inset: auto !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
    line-height: 1 !important;
    font-size: 17px !important;
    pointer-events: none;
    z-index: 6;
}

/* v10 stability: non-overlapping hitboxes + realistic canines */
.dental-plot {
    z-index: 6;
}

.dental-plot[data-tooth^="1"],
.dental-plot[data-tooth^="2"] {
    z-index: 8;
}

.dental-plot[data-tooth^="3"],
.dental-plot[data-tooth^="4"] {
    z-index: 7;
}

.dental-plot[data-tooth="101"],
.dental-plot[data-tooth="102"],
.dental-plot[data-tooth="103"],
.dental-plot[data-tooth="201"],
.dental-plot[data-tooth="202"],
.dental-plot[data-tooth="203"],
.dental-plot[data-tooth="301"],
.dental-plot[data-tooth="302"],
.dental-plot[data-tooth="303"],
.dental-plot[data-tooth="401"],
.dental-plot[data-tooth="402"],
.dental-plot[data-tooth="403"] {
    width: 12px !important;
    min-width: 12px !important;
    height: 24px !important;
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 20px !important;
    min-width: 20px !important;
    height: 56px !important;
}

.dental-plot[data-tooth="106"],
.dental-plot[data-tooth="107"],
.dental-plot[data-tooth="108"],
.dental-plot[data-tooth="206"],
.dental-plot[data-tooth="207"],
.dental-plot[data-tooth="208"],
.dental-plot[data-tooth="307"],
.dental-plot[data-tooth="308"],
.dental-plot[data-tooth="407"],
.dental-plot[data-tooth="408"] {
    width: 18px !important;
    min-width: 18px !important;
    height: 36px !important;
}

.dental-plot[data-tooth="109"],
.dental-plot[data-tooth="209"],
.dental-plot[data-tooth="309"],
.dental-plot[data-tooth="409"] {
    width: 20px !important;
    min-width: 20px !important;
    height: 36px !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 14px 14px 8px 8px;
    clip-path: polygon(50% 0%, 88% 20%, 94% 62%, 70% 100%, 30% 100%, 6% 62%, 12% 20%);
}

.dental-plot[data-tooth="401"] { left: 44.8% !important; top: 90.8% !important; }
.dental-plot[data-tooth="402"] { left: 46.8% !important; top: 90.8% !important; }
.dental-plot[data-tooth="403"] { left: 48.8% !important; top: 90.8% !important; }
.dental-plot[data-tooth="301"] { left: 51.2% !important; top: 90.8% !important; }
.dental-plot[data-tooth="302"] { left: 53.2% !important; top: 90.8% !important; }
.dental-plot[data-tooth="303"] { left: 55.2% !important; top: 90.8% !important; }

.dental-plot[data-tooth="109"] { left: 29.2% !important; top: 46.4% !important; }
.dental-plot[data-tooth="209"] { left: 70.8% !important; top: 46.4% !important; }

.dental-plot[data-tooth="109"] > span:not(.dental-cross),
.dental-plot[data-tooth="209"] > span:not(.dental-cross) {
    font-size: 8.5px;
}

/* v11 user tune: incisors labels off tooth, 304/404 angle + oval shape */
.dental-plot[data-tooth="101"] > span:not(.dental-cross),
.dental-plot[data-tooth="102"] > span:not(.dental-cross),
.dental-plot[data-tooth="103"] > span:not(.dental-cross),
.dental-plot[data-tooth="201"] > span:not(.dental-cross),
.dental-plot[data-tooth="202"] > span:not(.dental-cross),
.dental-plot[data-tooth="203"] > span:not(.dental-cross) {
    top: -4px;
    left: 50%;
    right: auto;
    transform: translate(-50%, -100%) rotate(-90deg);
}

.dental-plot[data-tooth="401"] > span:not(.dental-cross),
.dental-plot[data-tooth="402"] > span:not(.dental-cross),
.dental-plot[data-tooth="403"] > span:not(.dental-cross),
.dental-plot[data-tooth="301"] > span:not(.dental-cross),
.dental-plot[data-tooth="302"] > span:not(.dental-cross),
.dental-plot[data-tooth="303"] > span:not(.dental-cross) {
    top: calc(100% + 4px);
    left: 50%;
    right: auto;
    transform: translate(-50%, 0) rotate(-90deg);
}

.dental-plot[data-tooth="404"] {
    left: 45.0% !important;
    top: 87.0% !important;
    width: 14px !important;
    min-width: 14px !important;
    height: 48px !important;
}

.dental-plot[data-tooth="304"] {
    left: 59.0% !important;
    top: 87.0% !important;
    width: 14px !important;
    min-width: 14px !important;
    height: 48px !important;
}

.dental-plot[data-tooth="404"]::after,
.dental-plot[data-tooth="304"]::after {
    border-radius: 999px !important;
    clip-path: none !important;
}

/* v12 final lock: correct 401->404 ordering + true pointed canines */
.dental-plot[data-tooth="401"] { left: 49.2% !important; top: 90.8% !important; }
.dental-plot[data-tooth="402"] { left: 47.4% !important; top: 90.8% !important; }
.dental-plot[data-tooth="403"] { left: 45.6% !important; top: 90.8% !important; }

.dental-plot[data-tooth="404"] {
    left: 45.6% !important;
    top: 84.8% !important;
    width: 16px !important;
    min-width: 16px !important;
    height: 58px !important;
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 16px !important;
    min-width: 16px !important;
    height: 58px !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 10px 10px 7px 7px !important;
    clip-path: polygon(50% 0%, 86% 18%, 92% 58%, 72% 100%, 28% 100%, 8% 58%, 14% 18%) !important;
}

/* v13: symmetry + explicit upper-label anchoring */
.dental-plot[data-tooth="404"] {
    left: 41.0% !important;
    top: 87.0% !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 3px !important;
    clip-path: polygon(50% 0%, 82% 14%, 90% 58%, 68% 100%, 32% 100%, 10% 58%, 18% 14%) !important;
}

.dental-plot[data-tooth="104"] > span:not(.dental-cross) {
    right: calc(100% + 10px) !important;
    top: 46% !important;
}

.dental-plot[data-tooth="106"] > span:not(.dental-cross) {
    right: calc(100% + 6px) !important;
    top: 48% !important;
}

.dental-plot[data-tooth="107"] > span:not(.dental-cross) {
    right: calc(100% + 6px) !important;
    top: 50% !important;
}

.dental-plot[data-tooth="108"] > span:not(.dental-cross) {
    right: calc(100% + 6px) !important;
    top: 52% !important;
}

.dental-plot[data-tooth="109"] > span:not(.dental-cross) {
    right: calc(100% + 7px) !important;
    top: 54% !important;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross) {
    left: calc(100% + 10px) !important;
    top: 46% !important;
}

.dental-plot[data-tooth="206"] > span:not(.dental-cross) {
    left: calc(100% + 6px) !important;
    top: 48% !important;
}

.dental-plot[data-tooth="207"] > span:not(.dental-cross) {
    left: calc(100% + 6px) !important;
    top: 50% !important;
}

.dental-plot[data-tooth="208"] > span:not(.dental-cross) {
    left: calc(100% + 6px) !important;
    top: 52% !important;
}

.dental-plot[data-tooth="209"] > span:not(.dental-cross) {
    left: calc(100% + 7px) !important;
    top: 54% !important;
}

/* v14 cleanup: lock upper labels to own tooth + remove circular canine feel */
.dental-plot[data-tooth="104"] > span:not(.dental-cross),
.dental-plot[data-tooth="106"] > span:not(.dental-cross),
.dental-plot[data-tooth="107"] > span:not(.dental-cross),
.dental-plot[data-tooth="108"] > span:not(.dental-cross),
.dental-plot[data-tooth="109"] > span:not(.dental-cross) {
    top: 50% !important;
    left: auto !important;
    right: calc(100% + 6px) !important;
    transform: translateY(-50%) !important;
    font-size: 8.5px !important;
}

.dental-plot[data-tooth="104"] > span:not(.dental-cross) {
    right: calc(100% + 11px) !important;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross),
.dental-plot[data-tooth="206"] > span:not(.dental-cross),
.dental-plot[data-tooth="207"] > span:not(.dental-cross),
.dental-plot[data-tooth="208"] > span:not(.dental-cross),
.dental-plot[data-tooth="209"] > span:not(.dental-cross) {
    top: 50% !important;
    left: calc(100% + 6px) !important;
    right: auto !important;
    transform: translateY(-50%) !important;
    font-size: 8.5px !important;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross) {
    left: calc(100% + 11px) !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 2px !important;
    box-shadow: none !important;
    clip-path: polygon(50% 0%, 80% 10%, 90% 40%, 86% 72%, 66% 100%, 34% 100%, 14% 72%, 10% 40%, 20% 10%) !important;
}

/* v15 hard reset: deterministic labels + canine rendering */
.dental-plot > span:not(.dental-cross) {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    font-size: 8.5px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    z-index: 7 !important;
}

.dental-plot[data-tooth="101"] > span:not(.dental-cross),
.dental-plot[data-tooth="102"] > span:not(.dental-cross),
.dental-plot[data-tooth="103"] > span:not(.dental-cross),
.dental-plot[data-tooth="201"] > span:not(.dental-cross),
.dental-plot[data-tooth="202"] > span:not(.dental-cross),
.dental-plot[data-tooth="203"] > span:not(.dental-cross) {
    top: -3px !important;
    left: 50% !important;
    transform: translate(-50%, -100%) rotate(-90deg) !important;
}

.dental-plot[data-tooth="401"] > span:not(.dental-cross),
.dental-plot[data-tooth="402"] > span:not(.dental-cross),
.dental-plot[data-tooth="403"] > span:not(.dental-cross),
.dental-plot[data-tooth="301"] > span:not(.dental-cross),
.dental-plot[data-tooth="302"] > span:not(.dental-cross),
.dental-plot[data-tooth="303"] > span:not(.dental-cross) {
    top: calc(100% + 4px) !important;
    left: 50% !important;
    transform: translate(-50%, 0) rotate(-90deg) !important;
}

.dental-plot[data-tooth="104"] > span:not(.dental-cross),
.dental-plot[data-tooth="106"] > span:not(.dental-cross),
.dental-plot[data-tooth="107"] > span:not(.dental-cross),
.dental-plot[data-tooth="108"] > span:not(.dental-cross),
.dental-plot[data-tooth="109"] > span:not(.dental-cross) {
    top: 50% !important;
    left: auto !important;
    right: calc(100% + 6px) !important;
    transform: translateY(-50%) !important;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross),
.dental-plot[data-tooth="206"] > span:not(.dental-cross),
.dental-plot[data-tooth="207"] > span:not(.dental-cross),
.dental-plot[data-tooth="208"] > span:not(.dental-cross),
.dental-plot[data-tooth="209"] > span:not(.dental-cross) {
    top: 50% !important;
    left: calc(100% + 6px) !important;
    right: auto !important;
    transform: translateY(-50%) !important;
}

.dental-plot[data-tooth="104"] > span:not(.dental-cross) { right: calc(100% + 10px) !important; }
.dental-plot[data-tooth="204"] > span:not(.dental-cross) { left: calc(100% + 10px) !important; }

.dental-plot .dental-cross {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    inset: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    pointer-events: none !important;
    z-index: 9 !important;
}

.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 16px !important;
    min-width: 16px !important;
    height: 58px !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 2px !important;
    box-shadow: none !important;
    clip-path: polygon(50% 0%, 80% 10%, 90% 40%, 86% 72%, 66% 100%, 34% 100%, 14% 72%, 10% 40%, 20% 10%) !important;
}

.dental-plot[data-tooth="304"] { left: 59.0% !important; top: 87.0% !important; }
.dental-plot[data-tooth="404"] { left: 41.0% !important; top: 87.0% !important; }

/* v16 precise fixes from review */
.dental-plot[data-tooth="104"],
.dental-plot[data-tooth="204"],
.dental-plot[data-tooth="304"],
.dental-plot[data-tooth="404"] {
    width: 13px !important;
    min-width: 13px !important;
    height: 66px !important;
    z-index: 12 !important;
}

.dental-plot[data-tooth="104"]::after,
.dental-plot[data-tooth="204"]::after,
.dental-plot[data-tooth="304"]::after,
.dental-plot[data-tooth="404"]::after {
    border-radius: 0 !important;
    box-shadow: none !important;
    clip-path: polygon(50% 0%, 66% 9%, 80% 28%, 88% 54%, 70% 100%, 30% 100%, 12% 54%, 20% 28%, 34% 9%) !important;
    border: 2px solid #1f2937 !important;
    background: linear-gradient(180deg, #ffffff 0%, #eef2f7 55%, #dbe4ee 100%) !important;
}

.dental-plot[data-tooth="104"]::after { transform: rotate(-12deg) !important; transform-origin: center; }
.dental-plot[data-tooth="204"]::after { transform: rotate(12deg) !important; transform-origin: center; }
.dental-plot[data-tooth="304"]::after { transform: rotate(12deg) !important; transform-origin: center; }
.dental-plot[data-tooth="404"]::after { transform: rotate(-12deg) !important; transform-origin: center; }

.dental-plot[data-tooth="104"] > span:not(.dental-cross) { right: calc(100% + 14px) !important; top: 36% !important; }
.dental-plot[data-tooth="106"] > span:not(.dental-cross) { right: calc(100% + 8px) !important; top: 43% !important; }
.dental-plot[data-tooth="107"] > span:not(.dental-cross) { right: calc(100% + 8px) !important; top: 49% !important; }
.dental-plot[data-tooth="108"] > span:not(.dental-cross) { right: calc(100% + 8px) !important; top: 56% !important; }
.dental-plot[data-tooth="109"] > span:not(.dental-cross) { right: calc(100% + 9px) !important; top: 61% !important; }

.dental-plot[data-tooth="204"] > span:not(.dental-cross) { left: calc(100% + 14px) !important; top: 36% !important; }
.dental-plot[data-tooth="206"] > span:not(.dental-cross) { left: calc(100% + 8px) !important; top: 43% !important; }
.dental-plot[data-tooth="207"] > span:not(.dental-cross) { left: calc(100% + 8px) !important; top: 49% !important; }
.dental-plot[data-tooth="208"] > span:not(.dental-cross) { left: calc(100% + 8px) !important; top: 56% !important; }
.dental-plot[data-tooth="209"] > span:not(.dental-cross) { left: calc(100% + 9px) !important; top: 61% !important; }

.dental-plot[data-tooth="401"] > span:not(.dental-cross),
.dental-plot[data-tooth="402"] > span:not(.dental-cross),
.dental-plot[data-tooth="403"] > span:not(.dental-cross),
.dental-plot[data-tooth="301"] > span:not(.dental-cross),
.dental-plot[data-tooth="302"] > span:not(.dental-cross),
.dental-plot[data-tooth="303"] > span:not(.dental-cross) {
    top: calc(100% + 8px) !important;
}

.dental-plot .dental-cross {
    display: none !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    transform: none !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
    font-size: 16px !important;
    pointer-events: none !important;
    z-index: 9 !important;
}

.dental-plot[data-state="2"] .dental-cross {
    display: flex !important;
}

/* v17: precise canine label anchor for 104/204 */
.dental-plot[data-tooth="104"] > span:not(.dental-cross) {
    right: calc(100% + 2px) !important;
    top: 30% !important;
}

.dental-plot[data-tooth="204"] > span:not(.dental-cross) {
    left: calc(100% + 2px) !important;
    top: 30% !important;
}

/* v18: Q1 first, mirrored to Q2 */
/* Q1 = 104,106,107,108,109 (left/outside) */
.dental-plot[data-tooth="104"] > span:not(.dental-cross) { right: calc(100% + 6px) !important; top: 34% !important; }
.dental-plot[data-tooth="106"] > span:not(.dental-cross) { right: calc(100% + 6px) !important; top: 42% !important; }
.dental-plot[data-tooth="107"] > span:not(.dental-cross) { right: calc(100% + 6px) !important; top: 48% !important; }
.dental-plot[data-tooth="108"] > span:not(.dental-cross) { right: calc(100% + 6px) !important; top: 54% !important; }
.dental-plot[data-tooth="109"] > span:not(.dental-cross) { right: calc(100% + 7px) !important; top: 60% !important; }

/* Q2 mirror = 204,206,207,208,209 (right/outside) */
.dental-plot[data-tooth="204"] > span:not(.dental-cross) { left: calc(100% + 6px) !important; top: 34% !important; }
.dental-plot[data-tooth="206"] > span:not(.dental-cross) { left: calc(100% + 6px) !important; top: 42% !important; }
.dental-plot[data-tooth="207"] > span:not(.dental-cross) { left: calc(100% + 6px) !important; top: 48% !important; }
.dental-plot[data-tooth="208"] > span:not(.dental-cross) { left: calc(100% + 6px) !important; top: 54% !important; }
.dental-plot[data-tooth="209"] > span:not(.dental-cross) { left: calc(100% + 7px) !important; top: 60% !important; }

/* v19: Q1 tweak - render 104 as banana-like shape */
.dental-plot[data-tooth="104"] {
    width: 18px !important;
    min-width: 18px !important;
    height: 62px !important;
}

.dental-plot[data-tooth="104"]::after {
    border: 2px solid #1f2937 !important;
    background: linear-gradient(180deg, #ffffff 0%, #eef2f7 58%, #dbe4ee 100%) !important;
    box-shadow: none !important;
    border-radius: 72% 24% 76% 28% / 54% 30% 76% 46% !important;
    clip-path: polygon(14% 6%, 42% 1%, 72% 8%, 90% 24%, 94% 52%, 84% 78%, 64% 95%, 36% 99%, 12% 88%, 4% 62%, 4% 34%) !important;
    transform: rotate(-24deg) skewX(-6deg) !important;
    transform-origin: center !important;
}

/* v20: make 104 banana effect clearly visible */
.dental-plot[data-tooth="104"] {
    width: 22px !important;
    min-width: 22px !important;
    height: 74px !important;
}

.dental-plot[data-tooth="104"]::after {
    left: 0 !important;
    right: 4px !important;
    top: 0 !important;
    bottom: 0 !important;
    border: 2.2px solid #111827 !important;
    border-radius: 88% 20% 92% 24% / 56% 24% 86% 42% !important;
    clip-path: polygon(10% 4%, 38% 0%, 70% 6%, 90% 20%, 96% 48%, 88% 74%, 70% 92%, 42% 100%, 18% 94%, 6% 70%, 2% 40%) !important;
    transform: rotate(-34deg) skewX(-10deg) !important;
    transform-origin: 55% 52% !important;
}
