:root{
  --bg:#0b0f14;
  --card:#121821;
  --card2:#18212d;
  --border:#263241;
  --gold:#d4af37;
  --text:#f5f7fa;
  --muted:#9ca9b8;
  --green:#19c37d;
  --danger:#ef4444;
}

*{
  box-sizing:border-box;
  margin:0;
  padding:0;
  -webkit-tap-highlight-color: transparent;
}

body{
  background:linear-gradient(to bottom,#0b0f14,#101722);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display",sans-serif;
  min-height:100vh;
}

.topbar{
  position:sticky;
  top:0;
  z-index:100;
  background:rgba(11,15,20,.95);
  backdrop-filter: blur(20px);
  border-bottom:1px solid rgba(255,255,255,.06);
  padding:18px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.topbar h1{
  font-size:24px;
  font-weight:800;
}

#status{
  color:var(--muted);
  font-size:13px;
  margin-top:4px;
}

.iconBtn{
  width:50px;
  height:50px;
  border-radius:16px;
  border:none;
  background:var(--card);
  color:var(--gold);
  font-size:20px;
}

.tabs{
  display:flex;
  gap:10px;
  padding:15px;
}

.tab{
  flex:1;
  border:none;
  border-radius:18px;
  background:var(--card);
  color:var(--muted);
  padding:14px;
  font-size:15px;
  font-weight:700;
}

.tab.active{
  background:linear-gradient(135deg,#d4af37,#8f6b10);
  color:black;
}

main{
  padding:18px;
}

.search{
  width:100%;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:22px;
  padding:18px;
  color:white;
  font-size:16px;
  margin-bottom:18px;
}

.search::placeholder{
  color:#6d7a8a;
}

.patientCard{
  background:linear-gradient(145deg,#131b26,#1a2432);
  border:1px solid rgba(255,255,255,.05);
  border-radius:28px;
  padding:20px;
  margin-bottom:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}

.patientCard h3{
  font-size:23px;
  margin-bottom:12px;
}

.pill{
  display:inline-flex;
  padding:8px 14px;
  border-radius:999px;
  background:#212c3a;
  color:#c9d4df;
  margin-right:8px;
  margin-bottom:10px;
  font-size:13px;
}

.actions{
  display:flex;
  gap:10px;
  margin-top:16px;
}

.actions button{
  flex:1;
  border:none;
  border-radius:18px;
  padding:14px;
  font-weight:700;
}

button{
  cursor:pointer;
}

.primary{
  background:linear-gradient(135deg,#d4af37,#8f6b10);
  color:black;
}

.secondary{
  background:#1f2937;
  color:white;
}

.danger{
  background:#3a1518;
  color:#ff7d7d;
}

form{
  background:var(--card);
  border-radius:30px;
  padding:22px;
  border:1px solid rgba(255,255,255,.05);
}

label{
  display:block;
  margin-bottom:16px;
  color:#d6dde7;
  font-size:14px;
}

input,
textarea,
select{
  width:100%;
  margin-top:8px;
  border:none;
  border-radius:20px;
  background:#0f1620;
  border:1px solid var(--border);
  padding:18px;
  color:white;
  font-size:16px;
}

textarea{
  min-height:120px;
}

.grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:12px;
}

.thumb{
  width:100%;
  border-radius:22px;
  object-fit:cover;
  aspect-ratio:1/1;
}

.card{
  background:var(--card);
  border-radius:28px;
  padding:20px;
  border:1px solid rgba(255,255,255,.06);
}

.hidden{
  display:none !important;
}
.page{
  display:none;
}

.page.active{
  display:block;
}

.kv{
  margin-top:18px;
  padding:16px;
  background:#0f1620;
  border:1px solid var(--border);
  border-radius:20px;
}

.kv b{
  display:block;
  color:var(--gold);
  margin-bottom:8px;
  font-size:14px;
}

.kv span{
  color:#e5edf6;
  white-space:pre-wrap;
  line-height:1.6;
}

.photoBox{
  background:#0f1620;
  border:1px dashed var(--gold);
  border-radius:24px;
  padding:18px;
  margin:20px 0;
}

.photoBox p{
  color:var(--muted);
  font-size:13px;
  margin-top:8px;
}

.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.92);
  z-index:999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}

.modal img{
  max-width:100%;
  max-height:85vh;
  border-radius:24px;
}

.modalClose{
  position:absolute;
  top:18px;
  right:18px;
  width:50px;
  height:50px;
  border-radius:50%;
  border:none;
  background:#1f2937;
  color:white;
  font-size:28px;
}

.qrBox{
  background:#111827;
  border:1px solid var(--gold);
  border-radius:28px;
  padding:24px;
  text-align:center;
}

#qrcode{
  background:white;
  padding:16px;
  border-radius:20px;
  margin:20px auto;
  width:max-content;
}

#reader{
  margin-top:20px;
  border-radius:24px;
  overflow:hidden;
}

.hidden{
  display:none !important;
}

#detail h2{
  margin-bottom:14px;
  font-size:28px;
}

#detail h3{
  margin:24px 0 14px;
  color:var(--gold);
}

#preview{
  margin-top:14px;
}

@media(max-width:500px){
  .actions{
    flex-direction:column;
  }

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

  .topbar h1{
    font-size:21px;
  }
}
.sectionTitle{
  margin-top:24px;
  margin-bottom:12px;
  color:var(--gold);
  font-size:22px;
  font-weight:900;
}

.miniGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-top:14px;
}

.miniCard{
  background:#0f1620;
  border:1px solid var(--border);
  border-radius:22px;
  padding:16px;
}

.miniCard b{
  display:block;
  color:var(--gold);
  margin-bottom:6px;
}

.money{
  font-size:22px;
  font-weight:900;
  color:var(--green);
}

.unpaid{
  color:#ff7676;
}

.appointment{
  background:#0f1620;
  border:1px solid var(--border);
  border-radius:20px;
  padding:14px;
  margin-top:10px;
}

.appointment b{
  color:var(--gold);
}

.visitDate{
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}
.toothChart{
  display:grid;
  grid-template-columns:repeat(8,1fr);
  gap:8px;
  margin-top:14px;
}

.tooth{
  background:#0f1620;
  border:1px solid var(--border);
  color:white;
  border-radius:14px;
  padding:10px 4px;
  text-align:center;
  font-size:13px;
  font-weight:800;
}

.tooth.healthy{border-color:#334155;}
.tooth.caries{background:#4a1d1d;color:#ff9b9b;}
.tooth.filling{background:#1e3a5f;color:#93c5fd;}
.tooth.rct{background:#3b2f13;color:#facc15;}
.tooth.crown{background:#3a2b00;color:#ffd700;}
.tooth.missing{background:#111827;color:#6b7280;text-decoration:line-through;}
.tooth.extraction{background:#3f1111;color:#f87171;}
.tooth.implant{background:#12352b;color:#5eead4;}

.toothLegend{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:12px;
}

.legendItem{
  background:#0f1620;
  border:1px solid var(--border);
  padding:8px 10px;
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}
