/* ========================================================
   LabPro — Global Design System & App Styles
   ======================================================== */

/* 1. CSS Variables / Design Tokens */
:root {
  /* Colors */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-muted: #bfdbfe;

  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fef2f2;

  --gray-50: #f1f5f9;
  --gray-100: #e2e8f0;
  --gray-200: #cbd5e1;
  --gray-300: #94a3b8;
  --gray-400: #64748b;
  --gray-500: #475569;
  --gray-600: #334155;
  --gray-700: #1e293b;
  --gray-800: #0f172a;
  --gray-900: #020617;

  --white: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #cbd5e1;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  --text-2xl: 1.25rem;
  --text-3xl: 1.5rem;

  /* Spacing */
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  /* Transitions */
  --transition: 0.18s ease;
}

/* 2. Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
svg { flex-shrink: 0; }

/* 3. App Layout */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.brand-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  margin-top: 8px;
  margin-bottom: 4px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--gray-600);
  font-size: var(--text-sm);
  font-weight: 450;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}
.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
}
.user-name { font-size: var(--text-sm); color: var(--gray-800); font-weight: 500; }
.user-role { font-size: var(--text-xs); color: var(--gray-500); }

/* ---- Main Wrapper ---- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}
.main-wrapper.no-sidebar {
  margin-left: 0;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: none;
  padding: 7px;
  border-radius: 6px;
  color: var(--gray-500);
  transition: background var(--transition);
  display: none;
}
.sidebar-toggle:hover { background: var(--gray-100); }

.topbar-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-date {
  font-size: var(--text-sm);
  color: var(--gray-500);
  padding: 4px 10px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.btn-icon {
  width: 36px; height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  padding: 28px 28px;
  max-width: 1500px;
  min-height: calc(100vh - 64px);
  padding-bottom: 80px;
}

/* 4. Reusable Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.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-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn-lg { padding: 11px 22px; font-size: var(--text-md); }
.sit-option-btn { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; transition: all var(--transition); font-size: var(--text-sm); }
.sit-option-btn:hover { opacity: 0.85; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--gray-800);
}
.card-body { padding: 20px 22px; }

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h1 {
  display: none;
}
.page-header-left.has-title h1 {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.page-header-left p {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: 3px;
}
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card.clickable { cursor: pointer; }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #ecfdf5; color: var(--success); }
.stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.sky { background: #f0f9ff; color: var(--accent); }
.stat-value { font-size: var(--text-2xl); font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: var(--text-xs); color: var(--gray-500); margin-top: 3px; }
.stat-delta { font-size: var(--text-xs); margin-top: 5px; font-weight: 500; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--white);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead { background: var(--gray-50); }
th {
  padding: 11px 14px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--gray-700);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* Action Buttons in Table */
.table-actions { display: flex; gap: 4px; }
.action-btn {
  width: 30px; height: 30px;
  border: none;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  background: none;
  color: var(--gray-400);
}
.action-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.action-btn.danger:hover { background: var(--danger-light); color: var(--danger); }
.action-btn svg { width: 15px; height: 15px; }
.action-btn.os-view.active { background: var(--primary); color: white; }
.action-btn.os-view.active:hover { background: var(--primary-dark); color: white; }

tr.os-row-expanded { background: var(--gray-50); }
tr.os-row-expanded td { border-bottom: none; padding-bottom: 0; }

.os-expanded-row td { padding: 0; background: transparent; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-orange { background: #fffbeb; color: #d97706; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-sky { background: #f0f9ff; color: #0284c7; }

/* Filters Bar */
.filters-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* Form Controls */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control-sm { padding: 7px 10px; font-size: var(--text-xs); }
select.form-control { appearance: auto; }

.form-row {
  display: grid;
  gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Form Section */
.form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.form-section-header {
  padding: 14px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-header svg { width: 16px; height: 16px; color: var(--primary); }
.form-section-body { padding: 20px; overflow: visible; }

/* Material Dropdown */
.material-dropdown-content { 
  background: var(--white, #fff) !important; 
}
html.dark .material-dropdown-content { 
  background: #1e293b !important; 
}
html.dark .material-dropdown-content .material-item {
  border-color: #334155;
}
.material-item { 
  border-bottom: 1px solid #e2e8f0; 
}
.material-item:hover { 
  background: #f1f5f9; 
}
html.dark .material-item:hover { 
  background: #334155; 
}
.material-select-all {
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}
html.dark .material-select-all {
  background: #1e293b;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-overlay.open { display: block; opacity: 1; }

.modal-container {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%);
  z-index: 201;
  width: 90%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  display: none;
  opacity: 0;
  transition: all var(--transition);
}
.modal-container.open {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: var(--text-lg); font-weight: 700; color: var(--gray-900); }
.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 340px;
}
.toast.success { background: #064e3b; border-left: 3px solid var(--success); }
.toast.error { background: #7f1d1d; border-left: 3px solid var(--danger); }
.toast.info { background: #1e3a8a; border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; } }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state-icon {
  width: 60px; height: 60px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: var(--gray-400);
}
.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h3 { font-size: var(--text-lg); color: var(--gray-700); margin-bottom: 6px; }
.empty-state p { font-size: var(--text-sm); color: var(--gray-400); }

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.chart-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
}
.chart-canvas-wrapper { position: relative; height: 200px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  border-radius: 9px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  padding: 7px 14px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Search */
.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--gray-400);
}
.search-input-wrapper .form-control { padding-left: 34px; }

/* OS Status Select */
.status-select {
  border: none;
  border-radius: 20px;
  padding: 4px 24px 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

/* Odontogram */
.odontogram-wrapper {
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
}
.odontogram-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.odontogram-arch {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-bottom: 6px;
}
.odontogram-arch.lower { margin-top: 6px; margin-bottom: 0; }
.tooth-btn {
  width: 30px; height: 36px;
  border-radius: 6px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px;
  color: var(--gray-500);
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.tooth-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.tooth-btn.selected { border-color: var(--primary); background: var(--primary); color: white; }
.tooth-icon { font-size: 14px; line-height: 1; }
.odontogram-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Dynamic Services Table */
.services-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.services-table-header span { font-size: var(--text-sm); font-weight: 600; color: var(--gray-700); }

.services-inline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.services-inline-table th {
  background: var(--gray-50);
  padding: 8px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.services-inline-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.services-inline-table td input,
.services-inline-table td select {
  width: 100%;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: var(--text-xs);
  color: var(--gray-800);
  background: white;
  outline: none;
}
.services-inline-table td input:focus,
.services-inline-table td select:focus { border-color: var(--primary); }
.services-total-row td {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: none;
}

/* Calendar / Agenda */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-day-header {
  text-align: center;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.calendar-cell {
  min-height: 100px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px;
  background: var(--white);
  vertical-align: top;
  transition: background var(--transition);
}
.calendar-cell:hover { background: var(--gray-50); }
.calendar-cell.today { border-color: var(--primary); border-width: 2px; }
.calendar-cell.inactive { background: var(--gray-50); opacity: .5; }
.calendar-date {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.calendar-cell.today .calendar-date {
  background: var(--primary);
  color: white;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.calendar-event {
  background: var(--primary-light);
  color: var(--primary);
  border-left: 2px solid var(--primary);
  padding: 2px 6px;
  border-radius: 0 4px 4px 0;
  font-size: 10px;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.calendar-nav span {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-800);
  min-width: 180px;
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    overflow-x: hidden;
  }
  
  #app {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .main-wrapper {
    flex: 1;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition);
  }
  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; padding-bottom: 80px; }
  .page-content::after { content: ''; display: block; height: 70px; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  
  /* Mobile form-row */
  .form-row-4 { grid-template-columns: 1fr; }
  
  /* Mobile Odontograma */
  .odontogram-arch, .odontogram-arch.lower { width: 460px !important; }
  
  /* Services table - hide on mobile */
  .services-table-desktop { display: none; }
  .services-mobile-container { display: block; }
  #mobileTotal { display: block; }
  
  @media (min-width: 769px) {
    .services-table-desktop { display: block !important; }
    .services-mobile-container { display: none !important; }
    #mobileTotal { display: none !important; }
  }
  
  /* Estilo WhatsApp para Mobile */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { width: 100%; justify-content: center; }
  
  /* Barra inferior estilo WhatsApp - FIXADA COMPOSITION */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  }
  
  .mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    color: #667781;
    text-decoration: none;
    font-size: 11px;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
  }
  
  .mobile-bottom-nav-item.active {
    color: #128c7e;
  }
  
  .mobile-bottom-nav-item svg {
    width: 24px;
    height: 24px;
  }
  
  .mobile-bottom-nav-item .nav-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(12px);
    background: #25d366;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
  }
  
  /* Abas internas no topo estilo WhatsApp */
  .mobile-tabs {
    display: flex;
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    z-index: 50;
    margin: -16px -16px 16px -16px;
    padding: 0 8px;
  }
  
  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .mobile-tab {
    padding: 12px 16px;
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  
  .mobile-tab.active {
    color: #128c7e;
    border-bottom-color: #128c7e;
  }
  
  .mobile-tab:active {
    background: #f5f6f6;
  }
  
  /* Ocultar sidebar no mobile */
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  
  /* Ajustes de tabela */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper table { min-width: 600px; }
  
  /* Ajustes de modal */
  .modal { max-width: 95vw !important; margin: 16px; }
  
  /* Header mobile */
  .topbar { padding: 12px 16px; }
  .pageTitle { font-size: 18px; }
  
  /* search box mobile */
  .search-box { margin-bottom: 12px; }
  .search-box input { padding: 10px 12px 10px 36px; font-size: 14px; }
  
  /* Mobile Tabela de Preços */
  .tabela-layout { display: flex !important; flex-direction: column; }
  .tabela-sidebar { display: none !important; }
  .tabela-content { width: 100%; }
  
  /* Mobile Stats Grid - 2 colunas */
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .stat-card { padding: 12px 8px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 1rem !important; }
  
  /* Mobile Buttons */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }
  .btn-icon { width: 40px; height: 40px; }
  
  /* Mobile Form Controls */
  .form-control { min-height: 44px; font-size: 14px; padding: 10px 12px; }
  .form-control-sm { min-height: 36px; font-size: 13px; padding: 8px 10px; }
  
  /* Mobile Table */
  .table-wrapper { margin: 0 -16px; padding: 0 16px; }
  .table th, .table td { padding: 10px 8px; font-size: 13px; }
  .table-actions { gap: 4px; }
  .action-btn { width: 32px; height: 32px; padding: 6px; }
  
  /* Mobile Card */
  .card { border-radius: 8px; margin-bottom: 12px; }
  .card-body { padding: 12px; }
  .card-header { padding: 12px; flex-wrap: wrap; gap: 8px; }
  
  /* Mobile Modal */
  .modal { max-width: 95vw !important; max-height: 90vh; overflow-y: auto; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 12px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; min-width: 100px; }
  
  /* Mobile Filters */
  .filters-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; gap: 8px; }
  .filters-bar .form-control { min-width: 120px; }
  
  /* Mobile Page Header */
  .page-header { gap: 12px; }
  .page-header h1 { font-size: 20px; }
  
  /* Mobile Status Select */
  .status-select { min-width: 100px; padding: 6px 8px; font-size: 12px; }
  
  /* Mobile Badge */
  .badge { font-size: 11px; padding: 3px 8px; }
  
  /* Mobile Toast */
  .toast { max-width: calc(100vw - 32px); margin: 16px; }
  
  /* Mobile Sidebar (ocultar menu antigo) */
  .sidebar-toggle { display: none; }
  
  /* Mobile Empty State */
  .empty-state { padding: 40px 20px; }
  .empty-state svg { width: 48px; height: 48px; }
  .empty-state h3 { font-size: 16px; }
  .empty-state p { font-size: 13px; }
}

/* Ocultar bottom nav no desktop */
@media (min-width: 769px) {
  .mobile-bottom-nav { display: none !important; }
  .mobile-tabs { display: none !important; }
  .mobile-submenu, .mobile-submenu-overlay { display: none !important; }
}

/* Mobile Submenu */
.mobile-submenu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1001;
}
.mobile-submenu-overlay.open {
  display: block;
}
.mobile-submenu {
  display: none;
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 1002;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  animation: slideUp 0.3s ease;
}
.mobile-submenu.open {
  display: block;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.mobile-submenu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: #fff;
}
.mobile-submenu-header span {
  font-weight: 600;
  font-size: 16px;
  color: #128c7e;
}
.mobile-submenu-close {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
}
.mobile-submenu-close svg {
  width: 24px;
  height: 24px;
  color: #667781;
}
.mobile-submenu-items {
  padding: 8px;
}
.mobile-submenu-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-radius: 8px;
  color: #333;
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  font-size: 15px;
}
.mobile-submenu-item:hover {
  background: #f5f6f6;
}
.mobile-submenu-item svg {
  width: 20px;
  height: 20px;
  color: #128c7e;
}

/* Utility */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-gray { color: var(--gray-500); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* ======================================================
   LOGIN SCREEN
   ====================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 45%, #0ea5e9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  transition: opacity .4s ease, visibility .4s ease;
}
.login-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.login-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
  animation: loginCardIn .4s cubic-bezier(.22,.68,0,1.2);
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(30px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.login-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}
.login-subtitle {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-bottom: 28px;
}
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 16px;
  animation: toastIn .2s ease;
}

/* ======================================================
   DARK THEME — activated via <html class="dark">
   ====================================================== */
html.dark {
  --primary-light: rgba(37,99,235,.15);
  --white: #1e293b;
  --surface: #1e293b;
  --surface-2: #0f172a;
  --border: #334155;
  --gray-50: #0f172a;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --gray-900: #f8fafc;
  --danger-light: rgba(239,68,68,.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
}
html.dark body { background: #0f172a; color: #e2e8f0; }

/* Sidebar */
html.dark .sidebar { background: #0d1829; border-right: 1px solid #1e293b; }
html.dark .sidebar-brand { border-bottom: 1px solid #1e293b; }
html.dark .brand-name { color: #f1f5f9; }
html.dark .nav-item { color: #94a3b8; }
html.dark .nav-item:hover { background: #1e293b; color: #f1f5f9; }
html.dark .nav-item.active { background: var(--primary); color: #ffffff; }
html.dark .user-name { color: #f1f5f9; }
html.dark .sidebar-footer { border-top: 1px solid #1e293b; }

/* Topbar */
html.dark .topbar { background: #1e293b; border-color: #334155; }
html.dark .topbar-date { background: #0f172a; border-color: #334155; color: #94a3b8; }
html.dark .topbar-title { color: #f1f5f9; }

/* Cards / surfaces */
html.dark .card,
html.dark .stat-card,
html.dark .chart-card { background: #1e293b; border-color: #334155; }
html.dark .card-title { color: #f1f5f9; }
html.dark .chart-card-title { color: #cbd5e1; }
html.dark .filters-bar { background: #1e293b; border-color: #334155; }
html.dark .form-section { background: #1e293b; border-color: #334155; }
html.dark .form-section-header { background: #0f172a; color: #cbd5e1; border-color: #334155; }

/* Tables */
html.dark .table-wrapper { background: #1e293b; border-color: #334155; }
html.dark thead { background: #0f172a; }
html.dark th { color: #94a3b8; border-color: #334155; }
html.dark td { border-color: #334155; color: #cbd5e1; }
html.dark tbody tr:hover { background: rgba(255,255,255,.03); }

/* Form controls */
html.dark .form-control { background: #0f172a; border-color: #334155; color: #e2e8f0; }
html.dark .form-control::placeholder { color: #475569; }
html.dark .form-control:focus { border-color: var(--primary); }
html.dark .form-label { color: #94a3b8; }
/* Buttons */
html.dark .btn-secondary { background: #334155; color: #e2e8f0; }
html.dark .btn-secondary:hover { background: #475569; }
html.dark .btn-icon { color: #94a3b8; }
html.dark .btn-icon:hover { background: #334155; color: #e2e8f0; }
html.dark .action-btn { color: #64748b; }
html.dark .action-btn:hover { background: #334155; color: #e2e8f0; }
html.dark .action-btn.danger:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* Badges */
html.dark .badge-gray { background: #334155; color: #cbd5e1; }
html.dark .badge-blue { background: rgba(37,99,235,.2); color: #93c5fd; }
html.dark .badge-green { background: rgba(16,185,129,.15); color: #6ee7b7; }
html.dark .badge-orange { background: rgba(245,158,11,.15); color: #fcd34d; }
html.dark .badge-red { background: rgba(239,68,68,.15); color: #fca5a5; }
html.dark .badge-purple { background: rgba(124,58,237,.15); color: #c4b5fd; }
html.dark .badge-sky { background: rgba(14,165,233,.15); color: #7dd3fc; }

/* Tabs */
html.dark .tabs { background: #0f172a; }
html.dark .tab-btn { color: #64748b; }
html.dark .tab-btn.active { background: #1e293b; color: var(--primary); }

/* Modal */
html.dark .modal { background: #1e293b; }
html.dark .modal-header,
html.dark .modal-footer { border-color: #334155; }
html.dark .modal-title { color: #f1f5f9; }
html.dark .modal-close { background: #334155; color: #94a3b8; }
html.dark .modal-close:hover { background: #475569; }

/* Stat icons */
html.dark .stat-icon.blue { background: rgba(37,99,235,.2); }
html.dark .stat-icon.green { background: rgba(16,185,129,.15); }
html.dark .stat-icon.orange { background: rgba(245,158,11,.15); }
html.dark .stat-icon.red { background: rgba(239,68,68,.15); }
html.dark .stat-icon.sky { background: rgba(14,165,233,.15); }
html.dark .stat-value { color: #f1f5f9; }

/* Services table */
html.dark .services-inline-table th { background: #0f172a; border-color: #334155; }
html.dark .services-inline-table td { border-color: #334155; }
html.dark .services-inline-table td input,
html.dark .services-inline-table td select { background: #0f172a; border-color: #334155; color: #e2e8f0; }
html.dark .services-total-row td { background: rgba(37,99,235,.15); color: #93c5fd; }

/* Odontogram */
html.dark .odontogram-wrapper { background: #0f172a; border-color: #334155; }
html.dark .tooth-btn { background: #1e293b; border-color: #475569; color: #94a3b8; }
html.dark .tooth-btn:hover { background: rgba(37,99,235,.15); border-color: var(--primary); color: #93c5fd; }
html.dark .odontogram-divider { background: #334155; }

/* Calendar */
html.dark .calendar-cell { background: #1e293b; border-color: #334155; }
html.dark .calendar-cell:hover { background: #0f172a; }
html.dark .calendar-cell.inactive { background: #0a111e; opacity: .4; }
html.dark .calendar-day-header { color: #64748b; }
html.dark .calendar-date { color: #94a3b8; }
html.dark .calendar-event { background: rgba(37,99,235,.2); color: #93c5fd; border-color: var(--primary); }

/* Empty state */
html.dark .empty-state-icon { background: #1e293b; color: #475569; }
html.dark .empty-state h3 { color: #94a3b8; }

/* Login card in dark */
html.dark .login-card { background: #1e293b; }
html.dark .login-title { color: #f1f5f9; }
html.dark .login-subtitle { color: #64748b; }

/* Page header */
html.dark .page-header-left.has-title h1 { color: #f1f5f9; }
html.dark .page-header-left.has-title p { color: #64748b; }

/* Inline Filters Row */
.filter-row th {
  padding: 6px 8px !important;
  background: var(--gray-50) !important;
  border-bottom: 2px solid var(--border) !important;
  vertical-align: middle;
}
.filter-row .form-control-sm {
  font-size: 11px !important;
  height: 26px !important;
  padding: 2px 6px !important;
  background: var(--white);
  border-radius: 6px;
}
.filter-row select.form-control-sm {
  padding-right: 18px !important;
}

/* Dashboard Filter Bar */
.page-header-actions .dash-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Dark Mode Variants */
html.dark .filter-row th {
  background: #1e293b !important;
  border-color: #334155 !important;
}
html.dark .filter-row .form-control-sm {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

/* Layout Utilities for Filters */
.flex-nowrap { flex-wrap: nowrap !important; }
.w-auto { width: auto !important; }
.flex-1 { flex: 1 !important; }

.filter-group-horizontal {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 6px;
  flex-shrink: 0 !important;
  min-width: max-content;
}
.filter-group-horizontal .form-control {
  width: 140px !important;
  min-width: 140px !important;
  flex: 0 0 auto !important;
}

/* Dashboard Filter Bar */
.page-header-actions .dash-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Dark Mode Variants */
html.dark .page-header-actions .dash-filter-bar {
  background: #1e293b;
  border-color: #334155;
}

/* Responsive */
@media (max-width: 768px) {
  .filter-row { display: none; } /* Hide on small screens to avoid mess */
}

/* Smooth theme transition */
*, *::before, *::after { transition: background-color var(--transition), border-color var(--transition); }
/* But NOT transform/box-shadow for performance */
.btn, .stat-card, .nav-item { transition: all var(--transition); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-700);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination-btn:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination-btn svg {
  width: 14px;
  height: 14px;
}
