/* ═══════════════════════════════════════════
   CSS VARIABLES & RESET
 ═══════════════════════════════════════════ */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f7f9fc;
  --border: #dde3ec;
  --primary: #1a4fa0;
  --primary-light: #2563eb;
  --primary-glow: rgba(26,79,160,0.12);
  --accent: #0ea5e9;
  --accent2: #06b6d4;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 12px;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:14px}
body{font-family:'DM Sans',sans-serif;background:var(--bg);color:var(--text);min-height:100vh;overflow-x:hidden}
input,select,textarea,button{font-family:inherit}
a{text-decoration:none;color:inherit}

/* ═══════════════════════════════════════════
   SCROLLBAR
 ═══════════════════════════════════════════ */
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:99px}

/* ═══════════════════════════════════════════
   LOGIN SCREEN
 ═══════════════════════════════════════════ */
#login-screen{
  display:flex;align-items:center;justify-content:center;
  min-height:100vh;
  background:linear-gradient(135deg,#0f172a 0%,#1a3a6b 50%,#1a4fa0 100%);
  position:relative;overflow:hidden;
}
#login-screen::before{
  content:'';position:absolute;inset:0;
  background:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3Ccircle cx='30' cy='30' r='10'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
}
.login-card{
  background:var(--surface);border-radius:20px;
  padding:48px 40px;width:420px;max-width:95vw;
  box-shadow:0 24px 80px rgba(0,0,0,0.4);
  position:relative;z-index:1;
  animation:fadeUp 0.5s ease;
}
@keyframes fadeUp{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:translateY(0)}}
.login-logo{text-align:center;margin-bottom:32px}
.login-logo .eye-icon{
  width:56px;height:56px;
  background:linear-gradient(135deg,var(--primary),var(--accent));
  border-radius:16px;display:inline-flex;align-items:center;justify-content:center;
  font-size:28px;margin-bottom:12px;
  box-shadow:0 8px 24px rgba(26,79,160,0.3);
}
.login-logo h1{font-family:'DM Serif Display',serif;font-size:24px;color:var(--text);margin-bottom:4px}
.login-logo p{color:var(--text-muted);font-size:13px}
.login-roles{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:24px}
.role-btn{
  flex:1;padding:10px 8px;border:2px solid var(--border);
  border-radius:10px;background:var(--surface2);cursor:pointer;
  font-size:12px;font-weight:600;color:var(--text-muted);
  transition:all 0.2s;text-align:center;
}
.role-btn:hover{border-color:var(--primary);color:var(--primary)}
.role-btn.active{border-color:var(--primary);background:var(--primary-glow);color:var(--primary)}
.form-group{margin-bottom:16px}
.form-group label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:0.05em}
.form-group input,.form-group select{
  width:100%;padding:11px 14px;
  border:2px solid var(--border);border-radius:10px;
  background:var(--surface2);color:var(--text);font-size:14px;
  transition:border-color 0.2s;outline:none;
}
.form-group input:focus,.form-group select:focus{border-color:var(--primary);background:white}
.btn-primary{
  width:100%;padding:13px;background:linear-gradient(135deg,var(--primary),var(--primary-light));
  color:white;border:none;border-radius:10px;font-size:14px;font-weight:600;
  cursor:pointer;transition:all 0.2s;letter-spacing:0.02em;
}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 8px 24px rgba(26,79,160,0.35)}
.btn-primary:active{transform:translateY(0)}
.login-hint{text-align:center;margin-top:20px;font-size:12px;color:var(--text-muted);background:var(--surface2);padding:12px;border-radius:8px;border:1px solid var(--border)}
.login-hint strong{color:var(--primary)}

/* ═══════════════════════════════════════════
   APP LAYOUT
 ═══════════════════════════════════════════ */
.app-layout{display:flex;min-height:100vh}

/* SIDEBAR */
.sidebar{
  width:var(--sidebar-w);min-height:100vh;
  background:linear-gradient(180deg,#0f172a 0%,#1a3a6b 100%);
  display:flex;flex-direction:column;
  position:fixed;top:0;left:0;z-index:100;
  transition:transform 0.3s ease;
}
.sidebar-header{padding:20px 20px 16px;border-bottom:1px solid rgba(255,255,255,0.08)}
.sidebar-brand{display:flex;align-items:center;gap:10px}
.brand-icon{
  width:38px;height:38px;background:linear-gradient(135deg,var(--primary-light),var(--accent));
  border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:18px;
  box-shadow:0 4px 12px rgba(14,165,233,0.3);
}
.brand-name{font-family:'DM Serif Display',serif;font-size:16px;color:white;line-height:1.2}
.brand-tagline{font-size:10px;color:rgba(255,255,255,0.4);font-weight:400}
.sidebar-user{padding:12px 16px;margin:8px 12px;border-radius:10px;background:rgba(255,255,255,0.06);display:flex;align-items:center;gap:10px}
.user-avatar{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--primary-light));display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:white;flex-shrink:0}
.user-info{min-width:0}
.user-name{font-size:13px;font-weight:600;color:white;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.user-role{font-size:10px;color:rgba(255,255,255,0.45);text-transform:uppercase;letter-spacing:0.05em}
.sidebar-nav{padding:8px 12px;flex:1;overflow-y:auto}
.nav-section{margin-bottom:8px}
.nav-label{font-size:10px;font-weight:700;color:rgba(255,255,255,0.3);text-transform:uppercase;letter-spacing:0.08em;padding:8px 12px 4px}
.nav-item{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:9px;cursor:pointer;
  font-size:13px;font-weight:500;color:rgba(255,255,255,0.6);
  transition:all 0.18s;margin-bottom:2px;
}
.nav-item:hover{background:rgba(255,255,255,0.08);color:rgba(255,255,255,0.9)}
.nav-item.active{background:linear-gradient(135deg,rgba(37,99,235,0.5),rgba(14,165,233,0.3));color:white;box-shadow:0 2px 8px rgba(14,165,233,0.15)}
.nav-item .nav-icon{font-size:16px;width:20px;text-align:center}
.sidebar-footer{padding:16px 12px;border-top:1px solid rgba(255,255,255,0.08)}
.logout-btn{
  display:flex;align-items:center;gap:10px;padding:10px 12px;
  border-radius:9px;cursor:pointer;font-size:13px;font-weight:500;
  color:rgba(255,255,255,0.5);transition:all 0.18s;width:100%;border:none;background:none;
}
.logout-btn:hover{background:rgba(239,68,68,0.15);color:#ef4444}

/* MAIN CONTENT */
.main-content{
  margin-left:var(--sidebar-w);flex:1;min-height:100vh;
  display:flex;flex-direction:column;
}
.topbar{
  height:var(--header-h);background:var(--surface);
  border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 24px;position:sticky;top:0;z-index:50;
}
.topbar-left{display:flex;align-items:center;gap:12px}
.page-title{font-size:16px;font-weight:700;color:var(--text)}
.page-breadcrumb{font-size:12px;color:var(--text-muted)}
.topbar-right{display:flex;align-items:center;gap:12px}
.topbar-date{font-size:12px;color:var(--text-muted);background:var(--surface2);padding:6px 12px;border-radius:20px;border:1px solid var(--border)}
.badge-pill{padding:3px 10px;border-radius:99px;font-size:11px;font-weight:700;display:inline-flex;align-items:center;gap:4px}
.badge-reception{background:#dbeafe;color:#1d4ed8}
.badge-doctor{background:#dcfce7;color:#166534}
.badge-admin{background:#fef3c7;color:#92400e}
.content-area{padding:24px;flex:1}

/* ═══════════════════════════════════════════
   CARDS & COMPONENTS
 ═══════════════════════════════════════════ */
.page-section{display:none}
.page-section.active{display:block}
.section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}
.section-title{font-size:18px;font-weight:700;color:var(--text)}
.section-subtitle{font-size:13px;color:var(--text-muted);margin-top:2px}
.card{background:var(--surface);border-radius:var(--radius);border:1px solid var(--border);box-shadow:var(--shadow)}
.card-header{padding:16px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between}
.card-title{font-size:14px;font-weight:700;color:var(--text)}
.card-body{padding:20px}

/* STAT CARDS */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:24px}
.stat-card{
  background:var(--surface);border-radius:var(--radius);padding:20px;
  border:1px solid var(--border);position:relative;overflow:hidden;
  transition:transform 0.2s,box-shadow 0.2s;
}
.stat-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg)}
.stat-card::before{content:'';position:absolute;top:0;left:0;right:0;height:3px}
.stat-card.blue::before{background:linear-gradient(90deg,var(--primary),var(--accent))}
.stat-card.green::before{background:linear-gradient(90deg,#10b981,#34d399)}
.stat-card.orange::before{background:linear-gradient(90deg,#f59e0b,#fbbf24)}
.stat-card.purple::before{background:linear-gradient(90deg,#8b5cf6,#a78bfa)}
.stat-icon{width:44px;height:44px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:20px;margin-bottom:12px}
.stat-card.blue .stat-icon{background:#dbeafe}
.stat-card.green .stat-icon{background:#dcfce7}
.stat-card.orange .stat-icon{background:#fef3c7}
.stat-card.purple .stat-icon{background:#ede9fe}
.stat-value{font-size:28px;font-weight:800;color:var(--text);line-height:1}
.stat-label{font-size:12px;color:var(--text-muted);margin-top:4px;font-weight:500}
.stat-change{font-size:11px;margin-top:6px;font-weight:600}
.stat-change.up{color:var(--success)}
.stat-change.down{color:var(--danger)}

/* TABLES */
.table-wrap{overflow-x:auto;border-radius:var(--radius);border:1px solid var(--border)}
table{width:100%;border-collapse:collapse;background:var(--surface)}
thead th{padding:11px 16px;text-align:left;font-size:11px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.05em;background:var(--surface2);border-bottom:1px solid var(--border)}
tbody td{padding:12px 16px;font-size:13px;border-bottom:1px solid var(--border);vertical-align:middle}
tbody tr:last-child td{border-bottom:none}
tbody tr:hover{background:var(--surface2)}
.status-badge{padding:3px 10px;border-radius:99px;font-size:11px;font-weight:700}
.status-waiting{background:#fef3c7;color:#92400e}
.status-consulting{background:#dbeafe;color:#1d4ed8}
.status-done{background:#dcfce7;color:#166534}
.status-consultation-completed{background:#dcfce7;color:#166534}
.status-ready-for-doctor{background:#ffedd5;color:#c2410c}
.status-scheduled{background:#ede9fe;color:#6d28d9}
.status-test-pending{background:#fee2e2;color:#991b1b}
.status-test-available{background:#ccfbf1;color:#0f766e}
.status-in-progress{background:#ffedd5;color:#c2410c}
.status-completed{background:#dcfce7;color:#166534}

/* BUTTONS */
.btn{padding:8px 16px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:none;transition:all 0.18s;display:inline-flex;align-items:center;gap:6px}
.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px}
.btn-blue{background:var(--primary);color:white}
.btn-blue:hover{background:var(--primary-light)}
.btn-outline{background:transparent;color:var(--primary);border:2px solid var(--primary)}
.btn-outline:hover{background:var(--primary-glow)}
.btn-success{background:var(--success);color:white}
.btn-success:hover{background:#059669}
.btn-danger{background:var(--danger);color:white}
.btn-danger:hover{background:#dc2626}
.btn-ghost{background:var(--surface2);color:var(--text);border:1px solid var(--border)}
.btn-ghost:hover{background:var(--border)}

/* FORMS */
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px}
.form-row{display:flex;gap:16px;flex-wrap:wrap}
.form-field{flex:1;min-width:200px}
.form-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:0.04em}
.form-field input,.form-field select,.form-field textarea{
  width:100%;padding:10px 13px;
  border:1.5px solid var(--border);border-radius:9px;
  background:var(--surface2);color:var(--text);font-size:13px;
  transition:border-color 0.2s;outline:none;resize:vertical;
}
.form-field input:focus,.form-field select:focus,.form-field textarea:focus{border-color:var(--primary);background:white}
.form-field.full{grid-column:1/-1}
.radio-group{display:flex;gap:12px;flex-wrap:wrap}
.radio-option{display:flex;align-items:center;gap:6px;cursor:pointer}
.radio-option input{width:auto;cursor:pointer}
.radio-option span{font-size:13px;color:var(--text)}
.form-section-title{font-size:13px;font-weight:700;color:var(--primary);margin:20px 0 12px;padding-bottom:6px;border-bottom:2px solid var(--primary-glow);display:flex;align-items:center;gap:6px}

/* MODAL */
.modal-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,0.55);
  z-index:1000;display:flex;align-items:center;justify-content:center;
  padding:20px;opacity:0;pointer-events:none;transition:opacity 0.25s;
}
.modal-overlay.open{opacity:1;pointer-events:all}
.modal{
  background:var(--surface);border-radius:16px;
  width:100%;max-width:750px;max-height:90vh;overflow:hidden;
  display:flex;flex-direction:column;
  transform:scale(0.95);transition:transform 0.25s;
  box-shadow:0 24px 80px rgba(0,0,0,0.3);
}
.modal-overlay.open .modal{transform:scale(1)}
.modal-header{padding:20px 24px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
.modal-title{font-size:16px;font-weight:700}
.modal-close{width:32px;height:32px;border-radius:8px;border:none;background:var(--surface2);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;color:var(--text-muted)}
.modal-close:hover{background:var(--border)}
.modal-body{padding:24px;overflow-y:auto}
.modal-footer{padding:16px 24px;border-top:1px solid var(--border);display:flex;justify-content:flex-end;gap:10px;flex-shrink:0}
.modal-lg .modal{max-width:900px}

/* SEARCH BAR */
.search-bar{display:flex;align-items:center;gap:8px;background:var(--surface2);border:1.5px solid var(--border);border-radius:10px;padding:0 14px;transition:border-color 0.2s;min-width:240px}
.search-bar:focus-within{border-color:var(--primary)}
.search-bar span{color:var(--text-muted)}
.search-bar input{border:none;background:transparent;padding:10px 0;font-size:13px;outline:none;flex:1;color:var(--text)}

/* EYE EXAM SPECIFIC */
.eye-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px}
.eye-card{background:var(--surface2);border-radius:12px;border:1.5px solid var(--border);overflow:hidden}
.eye-card-header{padding:12px 16px;font-size:13px;font-weight:700;display:flex;align-items:center;gap:8px}
.eye-card-header.right{background:linear-gradient(135deg,#dbeafe,#e0f2fe);color:#1d4ed8}
.eye-card-header.left{background:linear-gradient(135deg,#dcfce7,#d1fae5);color:#166534}
.eye-card-body{padding:16px}
.power-table{width:100%;border-collapse:collapse}
.power-table th{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.04em;color:var(--text-muted);padding:6px 10px;text-align:left;background:rgba(255,255,255,0.6)}
.power-table td{padding:6px 10px}
.power-table input{width:100%;border:1.5px solid var(--border);border-radius:6px;padding:6px 8px;font-size:13px;background:white;outline:none}
.power-table input:focus{border-color:var(--primary)}
.vision-select{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.vision-select label{font-size:12px;font-weight:600;color:var(--text-muted);min-width:100px}
.vision-select select{border:1.5px solid var(--border);border-radius:6px;padding:6px 10px;font-size:13px;background:white;outline:none;flex:1}

/* BILLING */
.billing-summary{background:linear-gradient(135deg,#0f172a,#1a3a6b);border-radius:12px;padding:20px;color:white;margin-top:16px}
.billing-row{display:flex;justify-content:space-between;padding:6px 0;font-size:13px;color:rgba(255,255,255,0.7);border-bottom:1px solid rgba(255,255,255,0.1)}
.billing-row:last-child{border-bottom:none;font-weight:700;font-size:15px;color:white;padding-top:10px;margin-top:4px}

/* QUEUE */
.queue-list{display:flex;flex-direction:column;gap:10px}
.queue-item{background:var(--surface);border-radius:10px;border:1px solid var(--border);padding:14px 16px;display:flex;align-items:center;gap:14px;transition:box-shadow 0.18s}
.queue-item:hover{box-shadow:var(--shadow)}
.queue-num{width:36px;height:36px;border-radius:10px;background:linear-gradient(135deg,var(--primary),var(--accent));color:white;font-weight:800;font-size:14px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.queue-info{flex:1;min-width:0}
.queue-name{font-size:14px;font-weight:600;color:var(--text)}
.queue-meta{font-size:12px;color:var(--text-muted);margin-top:2px}
.queue-time{font-size:12px;color:var(--text-muted);flex-shrink:0}

/* CHARTS */
.charts-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:20px}
.chart-card{background:var(--surface);border-radius:var(--radius);border:1px solid var(--border);padding:20px}
.chart-title{font-size:13px;font-weight:700;color:var(--text);margin-bottom:16px}
.chart-container{position:relative;height:220px}

/* CONFIG SETUP */
.config-screen{max-width:520px;margin:40px auto;padding:24px;background:var(--surface);border-radius:16px;border:1px solid var(--border);box-shadow:var(--shadow-lg)}
.config-screen h2{font-family:'DM Serif Display',serif;font-size:22px;margin-bottom:6px}
.config-screen p{color:var(--text-muted);font-size:13px;margin-bottom:24px}
.alert{padding:12px 16px;border-radius:8px;font-size:13px;margin-bottom:16px}
.alert-info{background:#dbeafe;color:#1e40af;border:1px solid #bfdbfe}
.alert-warning{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.alert-success{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.alert-error{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.divider{height:1px;background:var(--border);margin:20px 0}

/* MEDICINE TABLE */
.med-table-wrap{border:1.5px solid var(--border);border-radius:10px;overflow:hidden;margin-bottom:12px}
.med-table{width:100%;border-collapse:collapse}
.med-table th{background:var(--surface2);padding:9px 12px;font-size:11px;font-weight:700;text-transform:uppercase;color:var(--text-muted)}
.med-table td{padding:8px 12px;border-top:1px solid var(--border)}
.med-table td input{width:100%;border:1.5px solid var(--border);border-radius:6px;padding:5px 8px;font-size:12px;outline:none}
.med-table td input:focus{border-color:var(--primary)}
.med-table .del-btn{background:none;border:none;cursor:pointer;color:var(--danger);font-size:16px;padding:2px 6px}

/* ═══════════════════════════════════════════
   RESPONSIVE — COMPREHENSIVE MOBILE SUPPORT
 ═══════════════════════════════════════════ */

/* Hamburger toggle — hidden on desktop */
.toggle-sidebar{
  display:none;background:none;border:none;font-size:22px;
  cursor:pointer;padding:4px 6px;color:var(--text);line-height:1;
  border-radius:6px;transition:background 0.15s;
}
.toggle-sidebar:hover{background:var(--surface2)}

/* Sidebar overlay backdrop */
.sidebar-backdrop{
  display:none;position:fixed;inset:0;
  background:rgba(0,0,0,0.45);z-index:99;
}

/* ── Tablet: 1024px ── */
@media(max-width:1024px){
  :root{--sidebar-w:200px}
  .stats-grid{grid-template-columns:repeat(2,1fr)}
  .charts-grid{grid-template-columns:1fr}
  .form-grid{grid-template-columns:repeat(2,1fr)}
}

/* ── Mobile: 768px ── */
@media(max-width:768px){
  html{font-size:13px}

  /* Show hamburger, hide sidebar by default */
  .toggle-sidebar{display:flex;align-items:center;justify-content:center}

  /* Sidebar: slide-in drawer */
  .sidebar{
    transform:translateX(-100%);
    z-index:200;
    box-shadow:4px 0 24px rgba(0,0,0,0.35);
  }
  .sidebar.open{transform:translateX(0)}
  .sidebar-backdrop.show{display:block}

  /* Main content: full width */
  .main-content{margin-left:0}

  /* Topbar */
  .topbar{padding:0 14px;gap:8px}
  .topbar-right{gap:8px}
  .topbar-date{display:none}
  .page-title{font-size:14px}

  /* Content area */
  .content-area{padding:14px}

  /* Stats grid: 2 columns on mobile */
  .stats-grid{grid-template-columns:repeat(2,1fr);gap:10px;margin-bottom:16px}
  .stat-card{padding:14px 12px}
  .stat-value{font-size:22px}
  .stat-icon{width:36px;height:36px;font-size:16px;margin-bottom:8px}

  /* Charts: single column */
  .charts-grid{grid-template-columns:1fr;gap:12px}
  .chart-card{padding:14px}
  .chart-container{height:180px}

  /* Tables: scrollable */
  .table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:8px}
  table{min-width:600px}
  thead th{padding:9px 12px;font-size:10px}
  tbody td{padding:10px 12px;font-size:12px}

  /* Section header: stack on tiny screens */
  .section-header{flex-wrap:wrap;gap:8px}
  .section-title{font-size:15px}

  /* Forms */
  .form-grid{grid-template-columns:1fr !important}
  .form-row{flex-direction:column}
  .form-field{min-width:0}
  .form-field.full{grid-column:auto}

  /* Eye exam grid: single column */
  .eye-grid{grid-template-columns:1fr}

  /* Modal: nearly full screen */
  .modal-overlay{padding:10px}
  .modal{max-width:100%;border-radius:12px;max-height:95vh}
  .modal-header{padding:14px 16px}
  .modal-body{padding:16px}
  .modal-footer{padding:12px 16px;flex-wrap:wrap;gap:8px}
  .modal-footer .btn{flex:1;justify-content:center}

  /* Search bar */
  .search-bar{min-width:0;flex:1}

  /* Buttons in section headers */
  .section-header .btn{font-size:12px;padding:7px 12px}

  /* Queue items */
  .queue-item{padding:10px 12px;gap:10px}
  .queue-num{width:30px;height:30px;font-size:12px}
  .queue-name{font-size:13px}

  /* Billing summary */
  .billing-summary{padding:14px}

  /* Login card */
  .login-card{padding:28px 20px}
  .login-roles{grid-template-columns:repeat(2,1fr)}

  /* Cards */
  .card-body{padding:14px}
  .card-header{padding:12px 14px}
}

/* ── Small mobile: 480px ── */
@media(max-width:480px){
  /* Stats: single column on very small screens */
  .stats-grid{grid-template-columns:1fr;gap:8px}

  .topbar{padding:0 10px}
  .content-area{padding:10px}

  /* Hide badge pill on tiny screens */
  .badge-pill{display:none}

  /* Table actions: wrap buttons */
  tbody td .btn{font-size:11px;padding:4px 8px}

  .modal-title{font-size:14px}

  /* Sidebar width on very small screens */
  .sidebar{width:85vw}

  /* Login */
  .login-card{padding:22px 16px;border-radius:14px}
  .login-roles{gap:6px}
}

/* ── Landscape phone fix ── */
@media(max-width:768px) and (orientation:landscape){
  .sidebar{overflow-y:auto}
  .modal{max-height:98vh}
}

/* EMPTY STATE */
.empty-state{text-align:center;padding:60px 20px;color:var(--text-muted)}
.empty-state .empty-icon{font-size:48px;margin-bottom:12px}
.empty-state p{font-size:14px}

/* PRINT */
@media print{
  .sidebar,.topbar,.btn,.modal-overlay{display:none!important}
  .main-content{margin-left:0!important}
  .print-slip{display:block!important}
}
.print-slip{display:none}

/* ===============================
   MOBILE & TABLET RESPONSIVE PATCH
   Paste this at the bottom of styles.css
   =============================== */

/* 1) Allow horizontal scrolling when truly needed (prevents clipping) */
html { /* keep this in sync with your global font sizing if needed */ }
body {
  overflow-x: auto !important; /* override earlier overflow-x:hidden to avoid clipping on iPhones */
}

/* 2) Make charts/grid columns more flexible on narrow screens */
.charts-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
}

/* 3) Global table responsiveness - remove forced min width and enable wrapping */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

/* Ensure tables can shrink instead of forcing horizontal scroll */
.table-wrap table {
  width: 100%;
  min-width: 0 !important;       /* override any earlier min-width (e.g., 600px) */
  table-layout: fixed;           /* allows cells to wrap predictably */
  word-break: break-word;
  -webkit-font-smoothing: antialiased;
}

/* Allow cells and headers to wrap text */
.table-wrap th,
.table-wrap td {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Slightly tighter padding on very small screens */
@media (max-width: 480px) {
  .table-wrap th,
  .table-wrap td {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* keep sidebar drawer from being too wide */
  .sidebar {
    width: 85vw !important;
    max-width: 85vw;
  }
}

/* 4) Optional: card-style table transform for very small screens
   Usage: add the class `table-card` to the wrapping element:
   <div class="table-wrap table-card"> <table>...</table> </div>
   The CSS uses data-label on each <td> (see optional JS helper) or it will show blank labels.
*/
@media (max-width: 520px) {
  .table-wrap.table-card thead { display: none; }

  .table-wrap.table-card table,
  .table-wrap.table-card tbody,
  .table-wrap.table-card tr,
  .table-wrap.table-card td {
    display: block;
    width: 100%;
  }

  .table-wrap.table-card tr {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
  }

  .table-wrap.table-card td {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: none;
    gap: 8px;
  }

  /* Show the column label using data-label attribute (script can auto-inject them) */
  .table-wrap.table-card td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 700;
    margin-right: 10px;
    flex: 0 0 40%;
    white-space: normal;
  }

  .table-wrap.table-card td > * {
    flex: 1;
  }
}

/* 5) Tweak some other components that commonly force overflow on phones */
@media (max-width: 768px) {
  /* make stat cards slightly more compact */
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }

  /* ensure any remaining tables won't force overflow */
  table { min-width: 0 !important; }
}

/* 6) Defender rules: ensure any in-file mobile rule is overridden */
/* This catches residual rules like table{min-width:600px} inside earlier media queries */
@media (max-width: 1024px) {
  table { min-width: 0 !important; }
}

/* 7) Small visual polish on iPhone safe-area insets (optional, helpful for fixed elements) */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Example usage (if you have fixed footer/toast): add padding-bottom using var(--safe-bottom) */
#toast { padding-bottom: calc(24px + var(--safe-bottom)); }

/* ==========================================================================
   PRESCRIPTION TABLE (SUBJECTIVE REFRACTION REDESIGN)
   ========================================================================== */
.prescription-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #DADADA;
  border-radius: 8px;
  background: #ffffff;
  margin-top: 10px;
}
.prescription-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  background: #ffffff;
}
.prescription-table th {
  background: #F5F5F5;
  color: #555555;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 10px 8px;
  border-bottom: 1px solid #DADADA;
  border-right: 1px solid #DADADA;
  white-space: nowrap;
}
.prescription-table th:last-child {
  border-right: none;
}
.prescription-table td {
  padding: 6px;
  text-align: center;
  border-bottom: 1px solid #DADADA;
  border-right: 1px solid #DADADA;
  vertical-align: middle;
}
.prescription-table tr:last-child td {
  border-bottom: none;
}
.prescription-table td:last-child {
  border-right: none;
}
.prescription-table td.row-label {
  font-weight: bold;
  width: 80px;
  background: #F5F5F5;
  color: #333333;
  font-size: 13px;
  white-space: nowrap;
}
.prescription-table input {
  width: 100%;
  max-width: 100px;
  height: 34px;
  border: 1px solid transparent;
  background: transparent;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  outline: none;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.prescription-table input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.anterior-input {
  height: 40px !important;
  border-radius: 8px !important;
  border: 1px solid #D1D5DB !important;
  background: #FFFFFF !important;
  color: var(--text) !important;
}
.anterior-input::placeholder {
  color: #9CA3AF !important;
}

.lens-option-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
}
.lens-option-label {
  width: 150px;
  flex-shrink: 0;
  color: #64748B;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 8px;
}
.lens-option-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  max-width: 768px;
}
.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  min-height: 32px;
}
.checkbox-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
@media (max-width: 768px) {
  .lens-option-row {
    flex-direction: column;
    align-items: stretch;
  }
  .lens-option-label {
    width: auto;
    margin-bottom: 8px;
    padding-top: 0;
  }
}

/* End of responsive patch */

/* ═══════════════════════════════════════════
   CLINICAL COMPARISON UI STYLES
   ═══════════════════════════════════════════ */
.comparison-table-wrapper {
  margin-top: 12px;
  margin-bottom: 16px;
}
.comparison-section-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  margin-top: 10px;
}
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
  border: 1px solid var(--border);
}
.comparison-table th, .comparison-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  word-wrap: break-word;
}
.comparison-table th {
  background: var(--surface2);
  font-weight: 600;
  color: var(--text-muted);
}
.comparison-table td {
  background: var(--surface1);
  color: var(--text);
}
.comparison-table tr:hover td {
  background: var(--surface2);
}
.prescription-list-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════
   PHYSIOTHERAPY ASSESSMENT MODULE
 ═══════════════════════════════════════════ */

/* Assessment Section Cards */
.assessment-section {
  margin-bottom: 16px;
}
.assessment-section .card-header {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.assessment-section .card-header:hover {
  background: var(--surface2);
}
.assessment-section .section-toggle {
  transition: transform 0.3s ease;
  display: inline-block;
  font-size: 12px;
  margin-right: 6px;
}
.assessment-section .section-toggle.collapsed {
  transform: rotate(-90deg);
}
.assessment-section .card-body.collapsed {
  display: none;
}

/* Pain Map Grid */
.pain-map-section {
  margin-top: 8px;
}
.pain-map-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}
.pain-map-legend .legend-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pain-map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.pain-map-legend .legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
}
.pain-map-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.pain-map-grid-small {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.pain-map-canvas-wrapper {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pain-map-canvas-wrapper:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(26,79,160,0.1);
}
.pain-map-canvas-wrapper .view-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.pain-map-canvas-wrapper canvas {
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: crosshair;
  display: block;
  margin: 0 auto;
}

/* Pain Map Toolbar */
.pain-map-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}
.pain-map-toolbar .toolbar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  outline: none;
}
.color-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
  transform: scale(1.1);
}
.pain-map-toolbar .brush-slider {
  width: 80px;
  accent-color: var(--primary);
}
.pain-map-toolbar .toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.pain-map-canvas-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  justify-content: center;
}
.pain-map-canvas-actions button {
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}
.pain-map-canvas-actions button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* VAS Pain Slider */
.vas-slider-container {
  padding: 16px 0;
}
.vas-slider-track {
  position: relative;
  margin-bottom: 8px;
}
.vas-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #10b981 0%, #fbbf24 40%, #f97316 65%, #ef4444 85%, #991b1b 100%);
  outline: none;
  cursor: pointer;
}
.vas-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.vas-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.vas-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.vas-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.vas-value-display {
  text-align: center;
  font-size: 36px;
  font-weight: 800;
  margin-top: 8px;
  transition: color 0.3s;
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  background: var(--surface);
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}
.checkbox-group label:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}
.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-group input[type="checkbox"]:checked + span {
  color: var(--primary);
  font-weight: 600;
}

/* Dynamic Table (ROM, Special Tests) */
.dynamic-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.dynamic-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.dynamic-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.dynamic-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dynamic-table tr:last-child td {
  border-bottom: none;
}
.dynamic-table tr:hover {
  background: var(--surface2);
}
.dynamic-table input,
.dynamic-table select {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.dynamic-table input:focus,
.dynamic-table select:focus {
  border-color: var(--primary);
  background: white;
}
.dynamic-table .del-btn {
  padding: 4px 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  border-radius: 6px;
  transition: background 0.15s;
}
.dynamic-table .del-btn:hover {
  background: #fee2e2;
}

/* MMT Table */
.mmt-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.mmt-table th {
  padding: 10px 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.mmt-table th:first-child {
  text-align: left;
}
.mmt-table th:last-child {
  border-right: none;
}
.mmt-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}
.mmt-table td:first-child {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
}
.mmt-table td:last-child {
  border-right: none;
}
.mmt-table tr:last-child td {
  border-bottom: none;
}
.mmt-table select,
.mmt-table input {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}
.mmt-table select:focus,
.mmt-table input:focus {
  border-color: var(--primary);
  background: white;
}

/* Neurological Sections */
.neuro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.neuro-block {
  background: var(--surface2);
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.neuro-block .neuro-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.neuro-block .form-field {
  margin-bottom: 8px;
}

/* Assessment History Cards */
.assessment-history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: all 0.18s;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}
.assessment-history-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.assessment-history-card .ah-patient {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.assessment-history-card .ah-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.assessment-history-card .ah-vas {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

/* Allergy Toggle */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-switch input[type="checkbox"] {
  display: none;
}
.toggle-switch .toggle-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.25s;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--danger);
}
.toggle-switch .toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform 0.25s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}
.toggle-switch .toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Responsive adjustments for pain map */
@media (max-width: 900px) {
  .pain-map-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pain-map-grid-small {
    grid-template-columns: repeat(2, 1fr);
  }
  .neuro-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .pain-map-grid {
    grid-template-columns: 1fr;
  }
  .pain-map-grid-small {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══════════════════════════════════════════
   3D ANATOMY ASSESSMENT
   ═══════════════════════════════════════════ */
.anatomy-layout-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  margin-top: 16px;
}
@media (max-width: 1100px) {
  .anatomy-layout-grid {
    grid-template-columns: 1fr;
  }
}
.anatomy-viewport-card {
  position: relative;
  background: #0d1322;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  height: 680px;
}
#anatomy-3d-canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
}
#anatomy-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#anatomy-3d-canvas:active {
  cursor: grabbing;
}
.anatomy-controls-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}
.anatomy-controls-overlay > * {
  pointer-events: auto;
}
.anatomy-btn-group {
  display: flex;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.anatomy-tool-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.anatomy-tool-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}
.anatomy-tool-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.anatomy-preset-btns {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 6px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.anatomy-tooltip-card {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 10;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.anatomy-tooltip-card strong {
  color: #38bdf8;
  display: block;
  font-size: 14px;
}
.anatomy-marker-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.anatomy-marker-mild { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid #10b981; }
.anatomy-marker-mod { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid #f59e0b; }
.anatomy-marker-sev { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid #ef4444; }

.anatomy-pin-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.2s;
  cursor: pointer;
}
.anatomy-pin-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Ensure the Sketchfab iframe fills the viewport card height minus controls */
.anatomy-viewport-card #anatomy-3d-canvas-container {
  height: calc(100% - 52px);
  min-height: 560px;
}

/* Direct 3D Anatomy Pins on Model Canvas */
.direct-anatomy-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 8;
  transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.direct-anatomy-pin:hover {
  transform: translate(-50%, -108%) scale(1.2) !important;
  z-index: 12 !important;
}
.direct-pin-head {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.92);
  border: 1.5px solid #ef4444;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45);
  backdrop-filter: blur(4px);
}
.direct-anatomy-pin.pin-mild .direct-pin-head {
  border-color: #10b981;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}
.direct-anatomy-pin.pin-mod .direct-pin-head {
  border-color: #f59e0b;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45);
}
.direct-anatomy-pin.pin-sev .direct-pin-head {
  border-color: #ef4444;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.55);
}
.direct-pin-num {
  font-size: 10px;
  color: #38bdf8;
  font-weight: 800;
}
.direct-pin-pulse {
  position: absolute;
  bottom: -4px;
  width: 14px;
  height: 14px;
  background: rgba(239, 68, 68, 0.7);
  border-radius: 50%;
  animation: pinPulseRing 1.8s infinite;
  pointer-events: none;
}
.direct-anatomy-pin.pin-mild .direct-pin-pulse { background: rgba(16, 185, 129, 0.7); }
.direct-anatomy-pin.pin-mod .direct-pin-pulse { background: rgba(245, 158, 11, 0.7); }

@keyframes pinPulseRing {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}
.direct-pin-tooltip {
  position: absolute;
  bottom: 100%;
  margin-bottom: 6px;
  white-space: nowrap;
  background: #0f172a;
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.direct-anatomy-pin:hover .direct-pin-tooltip {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   ANATOMY — "PIN THE PAIN" UI (severity control, legend, marker cards)
   ═══════════════════════════════════════════════════════════════════ */
.pinpain-structure {
  width: 100%;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface2);
}

/* Severity block */
.pinpain-severity {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.pinpain-severity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pinpain-sev-title { font-size: 13px; font-weight: 700; color: var(--text); }

/* Gradient severity slider (fill + thumb tinted by severity via inline vars) */
.pinpain-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg,
    var(--sev-color, #f59e0b) var(--sev-pct, 50%),
    var(--border) var(--sev-pct, 50%));
}
.pinpain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--sev-color, #f59e0b);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform .12s;
}
.pinpain-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.pinpain-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--sev-color, #f59e0b);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.pinpain-slider::-moz-range-track { height: 8px; border-radius: 99px; background: transparent; }
.pinpain-scale-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  padding: 0 2px;
}

/* Quick-set severity chips */
.pinpain-sev-quick { display: flex; gap: 8px; margin-top: 12px; }
.sev-chip {
  flex: 1;
  padding: 7px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.sev-chip:hover { border-color: var(--primary-light); color: var(--text); }
.sev-chip.sev-mild.active { background: rgba(16, 185, 129, 0.15); border-color: #10b981; color: #059669; }
.sev-chip.sev-mod.active  { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #b45309; }
.sev-chip.sev-sev.active  { background: rgba(239, 68, 68, 0.15);  border-color: #ef4444; color: #dc2626; }

/* Severity legend (in panel) */
.pinpain-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--border);
}
.pinpain-legend b { color: var(--text); font-weight: 700; }
.pin-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.pin-dot-mild { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
.pin-dot-mod  { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.pin-dot-sev  { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }

/* On-canvas legend (rendered over the dark 3D strip) */
.canvas-legend {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  margin-left: 4px;
}

/* Severity colour bar down the side of each placed-marker card */
.anatomy-pin-card.pin-sev-mild { border-left: 4px solid #10b981; }
.anatomy-pin-card.pin-sev-mod  { border-left: 4px solid #f59e0b; }
.anatomy-pin-card.pin-sev-sev  { border-left: 4px solid #ef4444; }

/* ═══════════════════════════════════════════════════════════════════
   PATIENT VISIT SCHEDULE MODULE (new feature — additive styles)
   ═══════════════════════════════════════════════════════════════════ */
/* Light-theme tab strip (Pending/Completed, Day/Week/Month, etc.) */
.vs-tabs{display:inline-flex;gap:4px;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:4px;margin-bottom:18px;flex-wrap:wrap}
.vs-tab{padding:7px 16px;border:none;background:transparent;color:var(--text-muted);font-size:13px;font-weight:600;border-radius:7px;cursor:pointer;transition:all .18s;display:inline-flex;align-items:center;gap:6px}
.vs-tab:hover{color:var(--text)}
.vs-tab.active{background:var(--primary);color:#fff;box-shadow:0 2px 8px var(--primary-glow)}
.vs-tab-panel{display:block}
.vs-tab-panel[hidden]{display:none}
.vs-tab-count{background:rgba(255,255,255,.25);border-radius:99px;padding:1px 7px;font-size:11px;font-weight:700}
.vs-tab:not(.active) .vs-tab-count{background:var(--border);color:var(--text-muted)}

/* Extra visit status badges (extend the existing .status-badge palette) */
.status-checked-in{background:#dbeafe;color:#1d4ed8}
.status-in-progress{background:#ffedd5;color:#c2410c}
.status-missed{background:#fee2e2;color:#991b1b}
.status-cancelled{background:#f1f5f9;color:#475569}
.status-rescheduled{background:#fef9c3;color:#854d0e}
.status-not-scheduled{background:#f1f5f9;color:#64748b}
.status-active{background:#dbeafe;color:#1d4ed8}

/* Treatment progress bar */
.vs-progress{background:var(--surface2);border:1px solid var(--border);border-radius:99px;height:12px;overflow:hidden;width:100%}
.vs-progress-fill{height:100%;background:linear-gradient(90deg,var(--success),#34d399);border-radius:99px;transition:width .4s ease}

/* Weekday / custom-date chips used in the Schedule Visits dialog */
.vs-weekday-grid{display:flex;gap:6px;flex-wrap:wrap}
.vs-weekday{padding:7px 12px;border:1.5px solid var(--border);border-radius:8px;background:var(--surface2);color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;user-select:none;transition:all .15s}
.vs-weekday.on{background:var(--primary);color:#fff;border-color:var(--primary)}
.vs-date-chip{display:inline-flex;align-items:center;gap:6px;background:var(--surface2);border:1px solid var(--border);border-radius:99px;padding:4px 10px;font-size:12px;font-weight:600;margin:3px 4px 0 0}
.vs-date-chip button{border:none;background:none;color:var(--danger);cursor:pointer;font-size:13px;line-height:1}
.vs-preview{max-height:160px;overflow-y:auto;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:10px 12px;font-size:12px}
.vs-preview-item{display:flex;justify-content:space-between;padding:3px 0;border-bottom:1px dashed var(--border)}
.vs-preview-item:last-child{border-bottom:none}

/* Visit calendar (Day/Week/Month) */
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.cal-head{font-size:11px;font-weight:700;color:var(--text-muted);text-transform:uppercase;text-align:center;padding:4px 0}
.cal-cell{min-height:94px;background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:6px;overflow:hidden}
.cal-cell.dim{opacity:.4}
.cal-cell.today{border-color:var(--primary);box-shadow:inset 0 0 0 1px var(--primary)}
.cal-daynum{font-size:12px;font-weight:700;color:var(--text);margin-bottom:4px}
.cal-chip{display:block;font-size:10px;font-weight:600;padding:2px 6px;border-radius:5px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
.cal-more{font-size:10px;color:var(--text-muted);font-weight:600}
.cal-week{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.cal-daycol{background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:8px;min-height:130px}
.cal-daycol .cal-daynum{text-align:center;margin-bottom:8px}
.cal-dayview-item{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:10px 12px;background:var(--surface2);border:1px solid var(--border);border-radius:8px;margin-bottom:8px;font-size:13px}


