
:root{--blue:#1a5fa8;--blue-dark:#0d3a6b;--blue-light:#e6f1fb;--sidebar-w:240px;--sidebar-bg:#0d2d52;--topbar-h:60px;--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
body{font-family:var(--font);font-size:14px;color:#1a1a2e;background:#f4f6fa;}
a{color:var(--blue);text-decoration:none;}
a:hover{text-decoration:underline;}
.app-wrapper{display:flex;min-height:100vh;}
.sidebar{width:var(--sidebar-w);background:var(--sidebar-bg);display:flex;flex-direction:column;flex-shrink:0;position:sticky;top:0;height:100vh;overflow-y:auto;transition:width .22s ease;z-index:100;}
.sidebar.collapsed{width:64px;}
.sidebar.collapsed .brand-text,.sidebar.collapsed .sidebar-section-label,.sidebar.collapsed .sidebar-nav span,.sidebar.collapsed .user-details,.sidebar.collapsed .sidebar-footer-links{display:none;}
.sidebar.collapsed .sidebar-brand{justify-content:center;padding:1rem 0;}
.sidebar.collapsed .nav-link{justify-content:center;padding:12px 0;}
.sidebar-brand{display:flex;align-items:center;gap:10px;padding:1.25rem 1rem;border-bottom:1px solid rgba(255,255,255,.08);}
.brand-icon{width:40px;height:40px;background:var(--blue);border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.brand-name{font-size:15px;font-weight:600;color:#fff;line-height:1.2;}
.brand-sub{font-size:11px;color:rgba(255,255,255,.5);}
.sidebar-section-label{font-size:10px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:rgba(255,255,255,.35);padding:1rem 1rem .4rem;}
.sidebar-nav{list-style:none;padding:0 .5rem;}
.sidebar-nav .nav-link{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:8px;color:rgba(255,255,255,.7);font-size:13.5px;transition:background .15s,color .15s;margin-bottom:2px;}
.sidebar-nav .nav-link i{font-size:16px;flex-shrink:0;}
.sidebar-nav .nav-link:hover{background:rgba(255,255,255,.08);color:#fff;text-decoration:none;}
.sidebar-nav .nav-link.active{background:var(--blue);color:#fff;}
.sidebar-footer{margin-top:auto;border-top:1px solid rgba(255,255,255,.08);padding:1rem;}
.user-info{display:flex;align-items:center;gap:10px;margin-bottom:12px;}
.user-avatar{width:36px;height:36px;border-radius:50%;background:var(--blue);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:600;font-size:14px;flex-shrink:0;}
.user-name{font-size:13px;font-weight:500;color:#fff;}
.user-role{font-size:11px;color:rgba(255,255,255,.45);}
.sidebar-footer-links{display:flex;flex-direction:column;gap:4px;}
.footer-link{font-size:12px;color:rgba(255,255,255,.55);padding:4px 0;display:flex;align-items:center;gap:6px;}
.footer-link:hover{color:#fff;text-decoration:none;}
.main-content{flex:1;display:flex;flex-direction:column;min-width:0;}
.topbar{height:var(--topbar-h);background:#fff;border-bottom:1px solid #e8edf4;display:flex;align-items:center;gap:12px;padding:0 1.5rem;position:sticky;top:0;z-index:50;}
.sidebar-toggle{background:none;border:none;font-size:20px;color:#555;cursor:pointer;padding:4px 8px;border-radius:6px;}
.topbar-title{font-size:16px;font-weight:600;color:#1a1a2e;flex:1;}
.topbar-actions{display:flex;gap:8px;align-items:center;}
.content-area{padding:1.5rem;flex:1;}
.flash-container{margin-bottom:1rem;}
.dashboard-greeting{font-size:15px;color:#555;margin-bottom:1.5rem;}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:1rem;margin-bottom:1rem;}
.stat-card{background:#fff;border-radius:12px;padding:1.25rem;display:flex;align-items:center;gap:1rem;border:1px solid #e8edf4;}
.stat-icon{width:48px;height:48px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:20px;flex-shrink:0;}
.stat-value{font-size:18px;font-weight:700;color:#1a1a2e;line-height:1.2;overflow-wrap:break-word;word-break:break-word;}
.stat-label{font-size:12px;color:#777;margin-top:4px;}
.section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:.75rem;}
.section-title{font-size:15px;font-weight:600;margin:0;}
.card{background:#fff;border:1px solid #e8edf4;border-radius:12px;}
.card-body{padding:1.25rem;}
.filter-bar{background:#fff;border:1px solid #e8edf4;border-radius:10px;padding:.75rem 1rem;display:flex;align-items:center;}
.table{font-size:13.5px;}
.table thead th{background:#f8fafc;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#666;border-bottom:1px solid #e8edf4;padding:10px 12px;}
.table td{padding:10px 12px;border-bottom:1px solid #f0f4f8;vertical-align:middle;}
.table-hover tbody tr:hover{background:#f8fafc;}
.patient-avatar-placeholder{width:32px;height:32px;border-radius:50%;background:#e6f1fb;color:#1a5fa8;display:flex;align-items:center;justify-content:center;font-weight:600;font-size:13px;flex-shrink:0;}
.patient-avatar-lg-placeholder{width:100px;height:100px;border-radius:50%;background:#e6f1fb;color:#1a5fa8;display:flex;align-items:center;justify-content:center;font-size:36px;font-weight:700;}
.patient-avatar-sm{width:32px;height:32px;border-radius:50%;object-fit:cover;}
.patient-avatar-lg{width:100px;height:100px;border-radius:50%;object-fit:cover;border:3px solid #e6f1fb;}
.form-section-title{font-size:13px;font-weight:600;color:var(--blue);margin-bottom:1rem;padding-bottom:.5rem;border-bottom:1px solid #e8edf4;}
.form-label{font-size:13px;font-weight:500;color:#444;margin-bottom:4px;}
.form-control,.form-select{font-size:13.5px;border-color:#d1d9e0;border-radius:8px;}
.form-control:focus,.form-select:focus{border-color:var(--blue);box-shadow:0 0 0 3px rgba(26,95,168,.12);}
.input-group-text{background:#f4f6fa;border-color:#d1d9e0;font-size:13px;}
.detail-label{font-size:11px;color:#888;font-weight:500;text-transform:uppercase;letter-spacing:.04em;margin-bottom:3px;}
.detail-value{font-size:14px;color:#1a1a2e;}
.btn-primary{background:var(--blue);border-color:var(--blue);}
.btn-primary:hover{background:var(--blue-dark);border-color:var(--blue-dark);}
.btn-outline-primary{color:var(--blue);border-color:var(--blue);}
.btn-outline-primary:hover{background:var(--blue);border-color:var(--blue);}
.btn{border-radius:8px;font-size:13px;}
.login-page{min-height:100vh;display:flex;}
.login-left{width:420px;background:var(--sidebar-bg);display:flex;flex-direction:column;justify-content:center;align-items:center;padding:3rem 2.5rem;flex-shrink:0;}
.login-brand{text-align:center;margin-bottom:3rem;}
.login-clinic-name{font-size:26px;font-weight:700;color:#fff;margin-top:1rem;}
.login-tagline{font-size:13px;color:rgba(255,255,255,.5);}
.login-features{width:100%;}
.login-feature{display:flex;align-items:center;gap:12px;color:rgba(255,255,255,.7);font-size:14px;padding:10px 0;border-bottom:1px solid rgba(255,255,255,.08);}
.login-feature i{color:var(--blue);font-size:16px;}
.login-right{flex:1;display:flex;align-items:center;justify-content:center;background:#f4f6fa;padding:2rem;}
.login-card{background:#fff;border-radius:16px;padding:2.5rem;width:100%;max-width:400px;border:1px solid #e8edf4;}
.login-card-title{font-size:22px;font-weight:700;color:#1a1a2e;margin-bottom:4px;}
.login-card-sub{color:#888;font-size:13px;margin-bottom:1.5rem;}
.login-hint{margin-top:1.5rem;font-size:12px;color:#aaa;background:#f8fafc;border-radius:8px;padding:.75rem;line-height:1.8;}
.rx-card{border:1.5px solid #e8edf4;border-left:4px solid var(--blue);border-radius:10px;padding:1rem 1.25rem;background:#fff;margin-bottom:1rem;}
.rx-card-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:.75rem;}
.rx-date-badge{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;color:var(--blue);background:#e6f1fb;border-radius:6px;padding:3px 10px;}
.rx-doctor{font-size:12px;color:#64748b;margin-top:2px;}
.rx-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:.5rem;}
.rx-table th{background:#f8fafc;font-size:11px;font-weight:600;text-transform:uppercase;color:#64748b;padding:7px 10px;border-bottom:1px solid #e8edf4;text-align:left;}
.rx-table td{padding:8px 10px;border-bottom:1px solid #f1f5f9;vertical-align:top;}
.rx-table tr:last-child td{border-bottom:none;}
.rx-med-name{font-weight:500;}
.rx-dosage-badge{display:inline-block;font-size:11px;font-weight:600;background:#eaf3de;color:#3b6d11;border-radius:4px;padding:1px 7px;}
.rx-general-notes{font-size:12px;color:#64748b;background:#f8fafc;border-radius:6px;padding:6px 10px;margin-top:.5rem;border-left:3px solid #d1d9e0;}
.rx-input-table{width:100%;border-collapse:collapse;}
.rx-input-table th{font-size:11px;font-weight:600;text-transform:uppercase;color:#64748b;background:#f8fafc;padding:7px 8px;border-bottom:1px solid #e8edf4;text-align:left;}
.rx-input-table td{padding:4px;}
.val-checklist{display:flex;flex-direction:column;gap:8px;}
.val-item{display:flex;align-items:center;gap:8px;font-size:13px;color:#64748b;}
.val-item i{font-size:15px;flex-shrink:0;}
.invoice-error-banner{background:#fef2f2;border:1.5px solid #fca5a5;border-radius:10px;padding:12px 16px;}
.invoice-error-banner ul{margin:4px 0 0;padding-left:18px;}
.invoice-error-banner li{font-size:13px;color:#b91c1c;}
@keyframes btn-shake{0%{transform:translateX(0)}15%{transform:translateX(-5px)}30%{transform:translateX(5px)}45%{transform:translateX(-4px)}60%{transform:translateX(4px)}75%{transform:translateX(-2px)}90%{transform:translateX(2px)}100%{transform:translateX(0)}}
.btn-shake{animation:btn-shake .45s ease;}
.form-control.is-invalid,.form-select.is-invalid{border-color:#ef4444!important;box-shadow:0 0 0 3px rgba(239,68,68,.12)!important;}
.invalid-feedback{display:block;font-size:12px;color:#dc2626;margin-top:4px;}
.card.border-danger{border-color:#ef4444!important;border-width:1.5px!important;}
@media print{.sidebar,.topbar,.topbar-actions,.flash-container{display:none!important;}.main-content{margin:0!important;}}
@media(max-width:768px){.sidebar{width:64px;}.sidebar .brand-text,.sidebar .sidebar-section-label,.sidebar .sidebar-nav span,.sidebar .user-details,.sidebar .sidebar-footer-links{display:none;}.login-left{display:none;}.stats-grid{grid-template-columns:1fr 1fr;}}

/* ═══════════════════════════════════════════════════════════
   TOOTH CHART
   ═══════════════════════════════════════════════════════════ */
.tooth-chart-wrap { overflow-x: auto; padding: 8px 0; }
.jaw-label { text-align: center; font-size: 11px; font-weight: 600;
  color: #64748b; text-transform: uppercase; letter-spacing: .06em;
  margin: 4px 0; }
.tooth-row { display: flex; justify-content: center; gap: 4px; flex-wrap: nowrap; }
.tooth-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tooth-wrap.lower { flex-direction: column-reverse; }
.tooth-num { font-size: 10px; color: #94a3b8; font-weight: 600;
  text-align: center; line-height: 1; min-width: 26px; }
.tooth-btn { width: 26px; height: 32px; border-radius: 4px 4px 2px 2px;
  border: 1.5px solid #d1d9e0; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all .15s;
  position: relative; background: #f8fafc; }
.tooth-btn:hover { transform: scale(1.18); z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.tooth-btn.tooth-readonly { cursor: default; }
.tooth-btn.tooth-readonly:hover { transform: none; box-shadow: none; }
.tooth-svg { width: 18px; height: 24px; display: block; }
.jaw-divider { text-align: center; font-size: 10px; color: #cbd5e1;
  letter-spacing: .1em; margin: 6px 0; border-top: 1px dashed #e2e8f0;
  padding-top: 4px; }
.tooth-legend { display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-bottom: 12px; }
.tooth-legend-item { display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #64748b; }
.tooth-legend-dot { width: 10px; height: 10px; border-radius: 2px;
  flex-shrink: 0; }

/* Tooth modal */
.tooth-modal-backdrop { display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 1060;
  align-items: center; justify-content: center; }
.tooth-modal-backdrop.show { display: flex; }
.tooth-modal-card { background: #fff; border-radius: 14px; padding: 1.5rem;
  width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.tooth-modal-title { font-size: 15px; font-weight: 600;
  color: var(--blue, #1a5fa8); margin-bottom: 1rem; }
.tooth-status-grid { display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-bottom: 1rem; }
.tooth-status-btn { padding: 7px 10px; border-radius: 8px; border: 1.5px solid #e2e8f0;
  background: #f8fafc; font-size: 12px; font-weight: 500; cursor: pointer;
  text-align: center; transition: all .12s; display: flex;
  align-items: center; gap: 6px; }
.tooth-status-btn:hover { border-color: var(--blue, #1a5fa8);
  background: var(--blue-light, #e6f1fb); }
.tooth-status-btn.selected { border-color: var(--blue, #1a5fa8);
  background: var(--blue, #1a5fa8); color: #fff; }
.tooth-status-dot { width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; }

/* Pediatric card */
.pedo-badge { display: inline-flex; align-items: center; gap: 5px;
  background: #eaf3de; color: #3b6d11; font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: 20px; border: 1px solid #c0dd97; }

/* Export / import action buttons on index */
.action-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Lab module — sub-navigation ─────────────────────────────────── */
.report-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 1.25rem;
  border-bottom: 1.5px solid #e8edf4;
  padding-bottom: 0;
}
.subnav-link {
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  text-decoration: none;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.subnav-link:hover {
  color: var(--blue, #1a5fa8);
  text-decoration: none;
}
.subnav-link.active {
  color: var(--blue, #1a5fa8);
  border-bottom-color: var(--blue, #1a5fa8);
  font-weight: 600;
}

/* ── Issue 1: Visit timeline ──────────────────────────────────────── */
.timeline-container { position: relative; padding-left: 0; }
.timeline-item {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 100px;
  top: 32px;
  bottom: -1.25rem;
  width: 2px;
  background: repeating-linear-gradient(to bottom, #d1d9e0 0, #d1d9e0 4px, transparent 4px, transparent 8px);
}
.timeline-date {
  flex: 0 0 96px;
  text-align: right;
  padding-top: 4px;
}
.timeline-date-badge {
  display: inline-block;
  background: var(--blue, #1a5fa8);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 8px;
  line-height: 1.3;
  white-space: nowrap;
}
.timeline-date-time {
  font-size: 10px;
  margin-top: 3px;
  text-align: right;
}
.timeline-content {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e8edf4;
  border-left: 3px solid var(--blue, #1a5fa8);
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
}
.timeline-content::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue, #1a5fa8);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--blue, #1a5fa8);
}

/* ── Prescription frequency checkboxes ───────────────────────────── */
.rx-freq-checks {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}
.rx-freq-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: 0;
}
.rx-freq-cb {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--blue, #1a5fa8);
  margin: 0;
}
.rx-freq-err {
  display: none;
  font-size: 11px;
  color: #dc2626;
  margin-top: 2px;
}
