/* Notiz Cari sayfaları. Renkler sitenin belirteçlerinden (src/styles/tokens.css). */
:root {
  --ink: #14143c;
  --paper: #f4f5fb;
  --soft: #e7e9f8;
  --card: #ffffff;
  --line: #d7d9ee;
  --mute: #55577a;
  --primary: #4a3df0;
  --primary-hover: #3b2fd9;
  --ok: #0f7a4e;
  --danger: #b42318;
  --warn: #8a5a00;
  font:
    400 15px/1.45 Inter,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

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

.mute,
.who {
  color: var(--mute);
  margin: 0;
}

.message {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
}

.message:empty {
  display: none;
}

.message.error {
  background: #fdecea;
  color: var(--danger);
}

.message.ok {
  background: #e3f5ec;
  color: var(--ok);
}

/* Form alanları ve düğmeler */
.field {
  display: grid;
  gap: 6px;
  align-content: start;
  font-weight: 500;
}

.field em {
  font-style: normal;
  font-weight: 400;
  color: var(--mute);
}

input[type='text'],
input[type='search'],
input[type='date'],
input:not([type]) {
  font: inherit;
  color: inherit;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

select,
textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

/* Tarayıcının kendi oku kenara yapışıyordu; ok çizilir, yazı okun altına girmez. */
select {
  appearance: none;
  padding-right: 36px;
  background: var(--card)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2355577a' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 12px center / 16px;
}

textarea {
  resize: vertical;
}

select:focus-visible,
textarea:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

button.primary:hover {
  background: var(--primary-hover);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.link {
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--mute);
  font-weight: 500;
}

button.link:hover,
button.link:focus-visible {
  color: var(--danger);
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

/* Hasta arama: kutunun altında açılan liste */
.search {
  position: relative;
  margin-bottom: 24px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--mute);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  min-height: 48px;
  padding-left: 42px;
  box-shadow: 0 1px 2px rgb(20 20 60 / 0.05);
}

.results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  list-style: none;
  margin: 0;
  padding: 6px;
  display: grid;
  gap: 2px;
  max-height: 360px;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgb(20 20 60 / 0.12);
}

.results button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font-weight: 500;
}

.results button:hover,
.results button:focus-visible {
  background: var(--soft);
}

.results .phone {
  color: var(--mute);
  font-weight: 400;
}

.results .none {
  padding: 10px 12px;
  color: var(--mute);
}

/* Hasta özeti */
.patient {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* Hastanın bandı: ad ve telefon solda, üç toplam sağda; kaydırınca üstte kalır. Zemin renkli kenar
   payı kenarlara taşar, altından geçen içerik bandın çevresinde görünmez. */
.account-head {
  position: sticky;
  top: -1px; /* kesirli ölçekli ekranda üst kenardan alttaki içerik sızmasın */
  z-index: 10;
  margin: -13px -16px 4px;
  padding: 13px 16px 12px;
  background: var(--paper);
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 6px 16px -12px rgb(20 20 60 / 0.4);
}

#back {
  min-width: 40px;
  min-height: 40px;
  margin-right: -8px;
  padding: 0;
  font-size: 18px;
}

.who-is {
  flex: 1 1 180px;
  min-width: 0;
}

.who-is h2 {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.who-is p {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sums {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  margin: 0;
}

.sums div {
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 10px;
}

.sums dt {
  font-size: 12px;
  color: var(--mute);
}

.sums dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sums .due {
  background: #fdecea;
}

.sums .due dd {
  color: var(--danger);
}

.sums .due.clear {
  background: #e3f5ec;
}

.sums .due.clear dd {
  color: var(--ok);
}

@media (max-width: 600px) {
  .account-head {
    padding-block: 9px 8px;
    margin-top: -9px;
  }

  .account-bar {
    gap: 8px;
    padding: 8px;
  }

  .who-is {
    padding-left: 4px;
  }

  .sums {
    flex: 1 1 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sums div {
    padding: 6px 8px;
  }

  .sums dd {
    font-size: 16px;
  }
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  display: grid;
  align-content: start; /* yan yana kartlar eşit yükseklikte; içerik üstte kalır, satırlar açılmaz */
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.tile span,
.tile small {
  color: var(--mute);
}

.tile strong {
  font-size: 24px;
}

.tile.due strong {
  color: var(--danger);
}

.tile.due.clear strong {
  color: var(--ok);
}

.actions,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions {
  margin-bottom: 16px;
}

.panel {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.grid .wide {
  grid-column: span 2;
}

@media (max-width: 480px) {
  .grid .wide {
    grid-column: auto;
  }
}

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

/* Üst bant: kullanıcı adı ve Ayarlar */
.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Ayarlar: işlem formunun alanları */
.field-cards {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.field-cards .panel {
  margin: 0;
}

.card-top,
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.card-foot {
  justify-content: space-between;
}

.tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 600;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 500;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

button.small {
  min-width: 44px;
  padding: 8px 12px;
}

.save-row {
  margin-top: 16px;
}

/* Diş şeması (FDI): kuron, kök, çiğneme yüzü ve işlem katmanları (ledger/src/dental/teeth.mjs). Dişin
   güncel durumunu işlem geçmişinden public/dental.js hesaplar; görünen katmanları dişin data-t
   değeri, dolgulu yüzeyleri data-s seçer. Çekilen diş kendi biçimiyle soluk kalır (X yok, yazı yok);
   küçük işaretler çiğneme yüzü ile numara arasında, anatomiye değmez. */
:root {
  --t-dolgu: #2563eb;
  --t-kanal: #dc2626;
  --t-kaplama: #f5cf5f;
  --t-kaplama-line: #a77b0f;
  --t-implant: #1e3a8a;
  --t-detartraj: #0d9488;
  --t-diger: #4a3df0;
  --t-post: #57534e;
  --t-lamina: #fbcfe8;
  --t-lamina-line: #be185d;
  --t-fissur: #059669;
  --t-dis-eti: #db2777;
  --t-tamam: #16a34a; /* Planlandı'da yapılan işlemin tiki; detartrajın turkuazından ayrı */
  /* Çekilmiş diş: gri-bej, yarı saydam, kesikli çizgi; köprü gövdesinin kökünde de aynı */
  --t-ghost: #b3ad9f;
  --t-ghost-line: #5f5a4f;
  --t-ghost-opacity: 0.4;
}

.teeth-chart {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  -webkit-user-select: none;
  user-select: none;
}

.teeth-chart line {
  stroke: var(--line);
  stroke-width: 3;
}

.teeth-chart [data-n] {
  cursor: pointer;
  outline: 0;
}

.teeth-chart .t-hit {
  fill: transparent;
}

.teeth-chart [data-n]:hover .t-hit {
  fill: var(--soft);
}

/* Seçili diş, önizleme (menüde seçilen işlem, köprü seçimi), seçili köprünün öbür üyeleri */
.teeth-chart :is([data-t~='mark'], [aria-expanded='true']) .t-hit {
  fill: #e0e4ff;
}

.teeth-chart [data-group] .t-hit {
  fill: #fdf6dc;
}

.teeth-chart :is([aria-expanded='true'], [data-n]:focus-visible) .t-hit {
  stroke: var(--primary);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.teeth-chart .t-n {
  fill: var(--mute);
  font-size: 24px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}

.teeth-chart :is([data-t~='mark'], [aria-expanded='true']) .t-n {
  fill: var(--primary-hover);
  font-weight: 700;
}

.teeth-chart path {
  fill: none;
  stroke-width: 1px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.teeth-chart .t-root {
  fill: #f3e9bf;
  stroke: #cdbb7f;
}

.teeth-chart .t-back {
  fill: #e3d08d;
  stroke: #cdbb7f;
}

.teeth-chart .t-crown {
  fill: #fff;
  stroke: #a9b0bf;
}

.teeth-chart .t-view {
  fill: #f4f5f8;
  stroke: #a9b0bf;
}

.teeth-chart .t-fissure {
  stroke: #c7ccd7;
}

.teeth-chart :is(.t-canal, .t-post, .t-implant, .t-thread, .t-neck) {
  display: none;
  vector-effect: none;
}

/* Dolgu: yalnızca dolgulu yüzeyler mavi (M, O/I, D, B/F, L) */
.teeth-chart [data-s~='M'] .t-sM,
.teeth-chart [data-s~='O'] .t-sO,
.teeth-chart [data-s~='D'] .t-sD,
.teeth-chart [data-s~='B'] .t-sB,
.teeth-chart [data-s~='L'] .t-sL {
  fill: var(--t-dolgu);
  stroke: #fff;
}

/* Pulpotomi: kanal ağızlarında kısa, kalın kırmızı çizgi (kuronda pulpa alındı, kökler doğal) */
.teeth-chart [data-t~='pulpa'] .t-canal {
  display: inline;
  stroke: var(--t-kanal);
  stroke-width: 7;
  stroke-dasharray: 9 999;
}

/* Kanal: kökün içinde kırmızı çizgiler */
.teeth-chart [data-t~='kanal'] .t-canal {
  display: inline;
  stroke: var(--t-kanal);
  stroke-width: 5;
  stroke-dasharray: none;
}

/* Post: kanalın kuron tarafında kalın koyu gri çubuk (kronun altında da görünür) */
.teeth-chart [data-t~='post'] .t-post {
  display: inline;
  stroke: var(--t-post);
  stroke-width: 9;
  stroke-dasharray: 22 999;
}

/* Kron: doğal dişte, implantta ya da köprüde kuron ve çiğneme yüzü sarı */
.teeth-chart :is([data-t~='kaplama'], [data-t~='kopru']) :is(.t-crown, .t-view) {
  fill: var(--t-kaplama);
  stroke: var(--t-kaplama-line);
}

/* Lamina: dişin ön yüzü pembe; çiğneme yüzünde yalnızca yanak / dudak bölümü (kron bütün dişi örter) */
.teeth-chart [data-t~='lamina'] :is(.t-crown, .t-sB) {
  fill: var(--t-lamina);
  stroke: var(--t-lamina-line);
}

/* Fissür örtücü: çiğneme yüzündeki oluklar yeşil ve kalın */
.teeth-chart [data-t~='fissur'] .t-fissure {
  stroke: var(--t-fissur);
  stroke-width: 3px;
}

/* İmplant: kökün yerinde lacivert vida; protez kronu yoksa kuron çizilmez */
.teeth-chart [data-t~='implant'] .t-implant {
  display: inline;
  fill: var(--t-implant);
}

.teeth-chart [data-t~='implant'] .t-thread {
  display: inline;
  stroke: #fff;
  stroke-width: 4;
}

.teeth-chart :is([data-t~='implant'], [data-t~='yuva']) :is(.t-root, .t-back, .t-canal),
.teeth-chart
  :is([data-t~='implant'], [data-t~='yuva']):not([data-t~='kaplama'], [data-t~='kopru'])
  :is(.t-crown, .t-view, .t-fissure, .t-sM, .t-sO, .t-sD, .t-sB, .t-sL) {
  display: none;
}

/* Çekilmiş doğal diş: kendi biçimiyle soluk; köprü gövdesinde kök soluk, kron tam renkli */
.teeth-chart [data-t~='cekim'] :is(.t-root, .t-back, .t-crown, .t-view) {
  fill: var(--t-ghost);
  fill-opacity: var(--t-ghost-opacity);
  stroke: var(--t-ghost-line);
  stroke-width: 1.25px;
  stroke-dasharray: 4 3;
}

.teeth-chart [data-t~='cekim'] .t-fissure {
  display: none;
}

.teeth-chart [data-t~='cekim'][data-t~='kopru'] :is(.t-crown, .t-view) {
  fill: var(--t-kaplama);
  fill-opacity: 1;
  stroke: var(--t-kaplama-line);
  stroke-width: 1px;
  stroke-dasharray: none;
}

/* Çıkarılan implantın yeri: kesikli vida çizgisi; doğal diş geri gelmez */
.teeth-chart [data-t~='yuva'] .t-implant {
  display: inline;
  fill: none;
  stroke: var(--t-implant);
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
  opacity: 0.55;
}

/* Detartraj: diş boynunda yeşil şerit (ağızdaki diş ve implantta) */
.teeth-chart [data-t~='detartraj'] .t-neck {
  display: inline;
  stroke: var(--t-detartraj);
  stroke-width: 7;
}

/* Diş eti tedavisi: diş boynunda pembe kesikli şerit (detartrajdan ayrı biçim) */
.teeth-chart [data-t~='dis-eti'] .t-neck {
  display: inline;
  stroke: var(--t-dis-eti);
  stroke-width: 7;
  stroke-dasharray: 8 5;
}

/* Köprü: üyelerin kronları aralarındaki sarı bağlantıyla tek parça */
.teeth-chart .t-link {
  pointer-events: none;
}

.teeth-chart .t-link rect {
  fill: var(--t-kaplama);
}

.teeth-chart .t-link path {
  stroke: var(--t-kaplama-line);
}

/* Küçük işaretler: kanal yenileme (RT), kron onarımı, diğer işlem; planlanan ya da süren işlemde
   numara kesikli çerçeveli. */
.teeth-chart .t-mark {
  pointer-events: none;
}

.teeth-chart .t-plan {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.teeth-chart .m-rt {
  fill: var(--t-kanal);
  font-size: 14px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
}

.teeth-chart .m-onarim rect {
  fill: var(--t-kaplama);
  stroke: var(--t-kaplama-line);
  stroke-width: 1.5px;
}

.teeth-chart .m-onarim path {
  stroke: #6b4a00;
  stroke-width: 1.6px;
  vector-effect: none;
}

.teeth-chart path.m-diger {
  fill: var(--t-diger);
  stroke: none;
}

/* Planlandı sekmesinde yapılan işlemi olan diş */
.teeth-chart path.m-ok {
  stroke: var(--t-tamam);
  stroke-width: 2.6px;
  vector-effect: none;
}

/* Süt dişleri gizliyken şema kalıcı dişlerde biter (viewBox da kısalır). */
.teeth-chart:not(.milk) [data-milk] {
  display: none;
}

#milk[aria-pressed='true'] {
  border-color: var(--primary);
  background: #eef0ff;
  color: var(--primary-hover);
}

/* Hastanın diş şeması; dişin menüsü şemanın yanında (dar ekranda altında), şemayı örtmez */
.odontogram .card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.odontogram h3 {
  margin: 0;
}

/* Planlandı | Tamamlandı; şema tarihi gizliyken de Süt dişleri sağda kalır */
.odontogram .toggle {
  margin-right: auto;
}

/* Planlandı sekmesinde şema tarihi yok, açıklamada yeşil tik var */
.odontogram.plan .asof,
.odontogram:not(.plan) .plan-only {
  display: none;
}

.asof {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  white-space: nowrap;
  font-size: 13px;
  color: var(--mute);
}

.asof input {
  min-height: 36px;
  padding: 4px 8px;
}

.chart-row {
  position: relative;
}

.chart-wrap {
  max-width: 720px;
}

/* Dişin menüsü dişin yanında açılır (place()); iki yana da sığmazsa şemanın altında. */
.tooth-menu {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 6px;
  width: 340px;
  max-width: 100%;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 28px -8px rgb(20 20 60 / 0.25);
  overflow-y: auto; /* yüksekliği place() ekranın altına göre sınırlar */
  overscroll-behavior: contain;
}

.tooth-menu.below {
  position: static;
  width: auto;
  max-width: 380px;
  margin-top: 12px;
}

.tooth-menu .menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tooth-menu .menu-head .link {
  font-size: 20px;
  line-height: 1;
}

.tooth-menu .label {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--mute);
}

.tooth-menu ul,
.tooth-menu ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tooth-menu p {
  margin: 0;
}

.tooth-menu p.mute {
  color: var(--mute);
}

.tooth-menu .now {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tooth-menu .now li {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--soft);
  font-size: 13px;
}

.tooth-menu .history li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 8px;
  padding: 4px 0;
  border-top: 1px solid var(--soft);
}

.tooth-menu .history li > :not(:first-child, :nth-child(2)) {
  grid-column: 1 / -1;
}

.tooth-menu .history small {
  color: var(--mute);
}

.tooth-menu .history .planned > span {
  color: var(--primary-hover);
}

.tooth-menu .history .voided > span {
  color: var(--mute);
  text-decoration: line-through;
}

.tooth-menu .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tooth-menu .row-actions button,
.tooth-menu .inline button {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}

.tooth-menu .inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tooth-menu .inline input {
  flex: 1 1 140px;
  min-height: 32px;
  padding: 4px 8px;
}

/* Menüde iki sütun, dar telefonda tek */
.tooth-menu .options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
}

/* Eklenecek işlemler: şemadaki simgesiyle, tanıtımdaki menü gibi çerçevesiz satırlar */
.tooth-menu .options button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-color: transparent;
  text-align: left;
  font-weight: 500;
}

.tooth-menu .options button:hover {
  border-color: var(--primary);
  background: #eef0ff;
  color: var(--primary-hover);
}

.tooth-menu .options :is(svg, .no-icon) {
  flex: none;
  width: 16px;
  height: 16px;
}

.tooth-menu .problem {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff4e5;
  color: var(--warn);
}

.tooth-menu .problem button {
  display: block;
  margin-top: 6px;
}

/* Uyarı: kayıt girilebilir (yönetici onaylarsa); sert sorundan açık renk */
.tooth-menu .problem.soft {
  border: 1px solid #f1d58a;
  background: #fffbea;
  color: #7a5200;
}

/* Ana kategoriler: alt işlemleri açar (ok işareti); sık kullanılanlar kategorilerin üstünde */
.tooth-menu .options button.cat::after {
  content: '›' / '';
  margin-left: auto;
  color: var(--mute);
  font-size: 18px;
  line-height: 1;
}

.tooth-menu .options.top button {
  border-color: var(--line);
}

.tooth-menu .back {
  justify-self: start;
  padding: 2px 0;
  font-size: 13px;
}

/* Köprünün dişleri: destek / gövde düğmeyle değişir; implant destek sabit */
.tooth-menu .roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tooth-menu .roles button {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}

.tooth-menu .roles button[data-role='pontic'] {
  border-style: dashed;
  color: var(--mute);
}

.tooth-menu .picked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Kaydın durum geçmişi (girildi, devam ediyor, tamamlandı, iptal) */
.tooth-menu .log {
  margin: 4px 0 0;
  padding-left: 16px;
  list-style: decimal;
  font-size: 12.5px;
  color: var(--mute);
}

.tooth-menu .bridge {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid #e8d48a;
  border-radius: 10px;
  background: #fffbea;
}

.tooth-menu .bridge ol {
  display: flex;
  flex-wrap: wrap;
}

.tooth-menu .bridge ol li {
  padding: 2px 7px;
  border: 1px solid #ecdca0;
  border-radius: 8px;
  background: #fff;
  font-size: 12.5px;
}

.tooth-menu .bridge ol li.here {
  border-color: var(--primary);
  color: var(--primary-hover);
  font-weight: 600;
}

.tooth-menu .bridge dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  margin: 4px 0 0;
  font-size: 13px;
}

.tooth-menu .bridge dt {
  color: var(--mute);
}

.tooth-menu .bridge dd {
  margin: 0;
}

/* Ayarlar → Fiyat listesi: kategoriler açılır kapanır, her işlemin fiyatı, birimi ve menüde olup
   olmadığı */
.prices h4 {
  margin: 16px 0 6px;
}

.prices details {
  border-top: 1px solid var(--line);
}

.prices summary {
  padding: 8px 0;
  cursor: pointer;
  font-weight: 600;
}

.prices table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.prices :is(th, td) {
  padding: 4px 6px 4px 0;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.prices td input[type='text'] {
  width: 110px;
  min-height: 34px;
  padding: 4px 8px;
}

.prices td select {
  min-height: 34px;
  padding: 4px 28px 4px 8px;
}

.prices input.bad {
  border-color: var(--warn);
}

.prices .head th {
  font-size: 12px;
  color: var(--mute);
}

@media (max-width: 560px) {
  .prices tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    padding: 6px 0;
  }

  .prices th[scope='row'] {
    grid-column: 1 / -1;
  }

  .prices .head {
    display: none;
  }
}

.surfaces {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.surfaces button {
  min-width: 40px;
  min-height: 36px;
  padding: 4px 0;
  font-weight: 700;
}

.surfaces button[aria-pressed='true'] {
  border-color: var(--t-dolgu);
  background: var(--t-dolgu);
  color: #fff;
}

.surfaces.readonly span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mute);
}

.surfaces.readonly span.on {
  border-color: var(--t-dolgu);
  background: var(--t-dolgu);
  color: #fff;
}

/* Açıklama: renk tek başına anlam taşımaz, her işaretin kendi biçimi var */
.tooth-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--mute);
}

.tooth-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tooth-legend svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.preview {
  font-weight: 400;
  color: var(--mute);
  min-height: 1.2em;
}

fieldset.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.choice legend {
  width: 100%;
  margin-bottom: 6px;
  padding: 0;
  font-weight: 500;
}

fieldset.choice label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.warn {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff4dc;
  color: var(--warn);
}

.warn button {
  margin-left: 8px;
}

/* Hareket tablosu */
.section {
  margin: 8px 0 10px;
}

.table-wrap {
  /* Ekran okuyucuya özel sütun etiketi, kayan tablonun içinde kalır. */
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  font-size: 13px;
  font-weight: 600;
  color: var(--mute);
  white-space: nowrap;
}

.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td small {
  display: block;
  color: var(--mute);
}

tr.voided td {
  color: var(--mute);
}

tr.voided .num {
  text-decoration: line-through;
}

td .void-note {
  color: var(--danger);
}

td form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 240px;
}

/* Hareketler: işlem ve ödeme etiketiyle ayrılır, ödemenin tutarı yeşil; ayrıntı, iptal ve giren
   kişi adın altında. */
#ledger td {
  font-size: 14px;
}

#ledger .when {
  white-space: nowrap;
  color: var(--mute);
}

/* Dar ekranda adın sütunu daralıp kelime kelime kırılmasın; tablo yana kayar. */
#ledger td:nth-child(2) {
  min-width: 220px;
}

#ledger .what {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 2px;
  font-size: 15px;
}

#ledger .what strong {
  font-weight: 600;
}

.kind {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.kind.charge {
  background: #eef0ff;
  color: var(--primary-hover);
}

.kind.payment {
  background: #e3f5ec;
  color: var(--ok);
}

.kind.refund {
  background: #fff4dc;
  color: var(--warn);
}

.kind.void {
  background: #fdecea;
  color: var(--danger);
}

#ledger tr.voided .kind:not(.void) {
  background: var(--soft);
  color: var(--mute);
}

#ledger tr:is(.payment, .refund):not(.voided) td:nth-child(4) {
  color: var(--ok);
  font-weight: 600;
}

#ledger tr.charge:not(.voided) td:nth-child(3) {
  font-weight: 600;
}

#ledger .act {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

#ledger .act button {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}

/* Silme onayı alt alta: sütun genişleyip tabloyu sıkıştırmasın */
#ledger .confirm {
  display: grid;
  gap: 6px;
}

button.danger-line {
  border-color: #f3c4bf;
  color: var(--danger);
}

button.danger-line:hover {
  background: #fdecea;
}

.empty {
  color: var(--mute);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Pano gömmesi */
.ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ranges button {
  min-height: 36px;
  padding: 6px 12px;
  font-weight: 500;
}

.ranges button[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.note {
  margin: 12px 0 0;
  color: var(--mute);
  font-size: 13px;
}

.notice {
  max-width: 560px;
  padding-top: 64px;
}

/* Genel bakış. Seri renkleri dataviz denetiminden geçti (beyaz zeminde ΔE 24,7): ciro mavi,
   tahsilat turuncu; tek serili çubuklar da bu kimliği taşır. Yazı hiçbir zaman seri rengini almaz. */
:root {
  --charged: #2a78d6;
  --collected: #eb6834;
  --grid: #eceef8;
  --axis: #c9cce3;
  --up: #006300;
}

.overview {
  transition: opacity 0.15s;
}

.overview.loading {
  opacity: 0.55;
}

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

.tile .label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.key,
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.charged {
  --series: var(--charged);
}

.collected {
  --series: var(--collected);
}

.key,
.swatch,
.bar,
.hfill,
.line {
  background: var(--series);
}

.tile .delta {
  font-weight: 600;
}

.tile .delta:empty {
  display: none;
}

.delta.up {
  color: var(--up);
}

.delta.down {
  color: var(--danger);
}

.card {
  position: relative;
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.card h3 {
  font-size: 15px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.card-head figcaption {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-right: auto;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--mute);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.toggle button {
  min-height: 32px;
  padding: 4px 12px;
  border: 0;
  border-radius: 0;
  font-weight: 500;
}

.toggle button[aria-pressed='true'] {
  background: var(--soft);
}

/* Günlük ya da aylık sütunlar: her dönemde ciro ve tahsilat yan yana, tek eksen */
.chart {
  position: relative;
}

.plot {
  position: relative;
  height: 220px;
  margin-left: 48px;
}

.gridlines,
.cols {
  position: absolute;
  inset: 0;
}

.gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--grid);
}

.gridline.base {
  border-top-color: var(--axis);
}

.gridline span {
  position: absolute;
  right: calc(100% + 8px);
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cols {
  display: flex;
}

.col {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  border-radius: 6px;
  outline: 0;
}

.col:hover,
.col.active {
  background: rgb(74 61 240 / 0.06);
}

.col:focus-visible {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.bar {
  display: block;
  width: min(24px, 36%);
  border-radius: 4px 4px 0 0;
}

.xaxis {
  display: flex;
  margin: 6px 0 0 48px;
}

.xaxis span {
  flex: 1;
  font-size: 12px;
  color: var(--mute);
  text-align: center;
  white-space: nowrap;
}

.chart .empty {
  margin: 0;
  padding: 24px 0;
}

.chart .empty.overlay {
  position: absolute;
  inset: 0 0 24px 48px;
  display: grid;
  place-items: center;
  padding: 0;
  pointer-events: none;
}

.tip {
  position: absolute;
  z-index: 10;
  min-width: 170px;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(20 20 60 / 0.12);
  pointer-events: none;
}

.tip-title {
  margin-bottom: 6px;
  color: var(--mute);
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tip-row strong {
  font-variant-numeric: tabular-nums;
}

.tip-row span {
  color: var(--mute);
}

.line {
  display: inline-block;
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

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

.cards .card {
  margin: 0;
}

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

/* Yatay çubuklar: yöntemler ve işlemler; değer çubuğun üstünde, sağda */
.hbars {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.hrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: baseline;
}

.hlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hlabel small {
  margin-left: 6px;
  color: var(--mute);
}

.hvalue {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.htrack {
  grid-column: 1 / -1;
  height: 10px;
}

.hfill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
}

/* Hasta listeleri: en yüksek borçlar ve son hareketler */
.list {
  display: grid;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.list li + li {
  border-top: 1px solid var(--grid);
}

.list button {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-weight: 400;
  text-align: left;
}

.list button:hover {
  background: var(--paper);
}

.who-line {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.who-line strong,
.who-line small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-line strong {
  font-weight: 600;
}

.who-line small {
  color: var(--mute);
}

.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount.owed {
  color: var(--danger);
}

.list .voided strong,
.list .voided .amount {
  color: var(--mute);
  text-decoration: line-through;
}

.list .empty {
  padding: 12px 8px;
}

.amount .key {
  margin-right: 8px;
  vertical-align: 1px;
}

/* Dişin menüsünde işlemin kaydı: tarih, ücret, ek alanlar, Kaydet */
.menu-form {
  display: grid;
  gap: 8px;
}

.menu-form .field {
  gap: 4px;
  font-size: 13px;
}

.menu-form input,
.menu-form select {
  min-height: 38px;
  padding: 6px 10px;
}

.menu-form select {
  padding-right: 32px;
  background-position: right 8px center;
}

.menu-form .buttons button {
  min-height: 38px;
}

.menu-form .warn {
  margin: 0;
  font-size: 13px;
}

.cari-brand {
  display: grid;
  gap: 4px;
}
.cari-brand a {
  color: var(--ink, #14143c);
  font-size: 14px;
  text-underline-offset: 3px;
}
.person-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.person-tools .search {
  flex: 1;
  min-width: min(15rem, 100%);
}
.native-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
.native-mode input {
  width: 18px;
  height: 18px;
}
#person-dialog {
  border: 0;
  border-radius: 16px;
  width: min(400px, 92vw);
  padding: 24px;
  color: #14143c;
  background: white;
}
#person-dialog::backdrop {
  background: #14143c66;
}
#new-person {
  display: grid;
  gap: 16px;
}
#new-person label {
  display: grid;
  gap: 6px;
}
#new-person input {
  width: 100%;
}
#person-error {
  color: #b42318;
  margin: 0;
}
@media (max-width: 500px) {
  .top {
    flex-wrap: wrap;
  }
  .person-tools .search {
    width: 100%;
  }
}
