/* ================================================
   KlearFlow Design System
   Premium dark theme with glassmorphism
   ================================================ */

:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-card-hover: #222842;
  --bg-input: #151a2e;
  --bg-sidebar: #0d1224;
  
  --glass-bg: rgba(26, 31, 53, 0.7);
  --glass-border: rgba(99, 102, 241, 0.15);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  
  --accent-primary: #6366f1;
  --accent-primary-light: #818cf8;
  --accent-primary-dark: #4f46e5;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --accent-gradient-hover: linear-gradient(135deg, #818cf8, #a78bfa);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-accent: #a5b4fc;
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  
  /* Kanban status colors */
  --status-new: #6366f1;
  --status-cad: #8b5cf6;
  --status-printing: #3b82f6;
  --status-finishing: #f59e0b;
  --status-shipping: #10b981;
  --status-completed: #059669;

  /* Spacing */
  --sidebar-width: 260px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ================================================
   Reset & Base
   ================================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ================================================
   Sidebar
   ================================================ */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease;
  overflow-x: hidden;
}

.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .brand-logo-wrap { margin-bottom: 12px; }
.sidebar.collapsed .sidebar-brand { flex-direction: column; padding: 16px 0; }
.sidebar.collapsed #sidebarToggle { margin-left: 0 !important; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-gradient);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: white;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
  font-weight: 500;
  font-size: 0.92rem;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.08);
}

.nav-item.active {
  color: var(--accent-primary-light);
  background: rgba(99, 102, 241, 0.12);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--accent-gradient);
  border-radius: 0 3px 3px 0;
}

.nav-item i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--glass-border);
}

.sidebar-version {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* ================================================
   Mobile Header
   ================================================ */

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--glass-border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 99;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--accent-primary-light);
}

.mobile-brand i {
  font-size: 1.3rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ================================================
   Main Content
   ================================================ */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  transition: margin-left 0.3s ease;
  min-width: 0;
}

.main-content.expanded {
  margin-left: 76px;
}

.page-container {
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 4px;
}

/* ================================================
   Cards & Glass
   ================================================ */

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.25);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.3);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.stat-card .stat-icon.purple { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary-light); }
.stat-card .stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-card .stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-card .stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card .stat-change {
  font-size: 0.78rem;
  margin-top: 8px;
  font-weight: 600;
}

.stat-card .stat-change.positive { color: var(--success); }
.stat-card .stat-change.negative { color: var(--danger); }

/* ================================================
   Charts Grid
   ================================================ */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* ================================================
   Tables
   ================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius);
  scrollbar-width: thin;
  scrollbar-color: var(--text-tertiary) rgba(99, 102, 241, 0.06);
}

.table-wrapper::-webkit-scrollbar {
  height: 10px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: rgba(99, 102, 241, 0.06);
  border-radius: 5px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 5px;
  min-width: 40px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table thead th {
  text-align: left;
  padding: 14px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

table tbody tr {
  transition: var(--transition-fast);
}

table tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.06);
  color: var(--text-primary);
}

/* ================================================
   Buttons
   ================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.btn-icon:hover {
  color: var(--accent-primary-light);
  border-color: var(--accent-primary);
}

/* ================================================
   Forms
   ================================================ */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

/* ================================================
   Badges & Tags
   ================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #a78bfa; }

.badge-status {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-new { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-cad { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.badge-printing { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-finishing { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-shipping { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-completed { background: rgba(5, 150, 105, 0.15); color: #34d399; }

/* ================================================
   Kanban Board
   ================================================ */

.kanban-board {
  display: flex !important;
  flex-wrap: nowrap;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  height: calc(100vh - 160px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--text-tertiary) rgba(99, 102, 241, 0.06);
}

.kanban-board::-webkit-scrollbar {
  height: 10px;
}
.kanban-board::-webkit-scrollbar-track {
  background: rgba(99, 102, 241, 0.06);
  border-radius: 5px;
}
.kanban-board::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 5px;
  min-width: 40px;
}
.kanban-board::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.kanban-column {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--glass-border);
  min-width: 250px !important;
  flex: 0 0 250px !important;
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-column-header h4 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.kanban-count {
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.kanban-cards {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100px;
}

.kanban-cards.drag-over {
  background: rgba(99, 102, 241, 0.05);
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 14px;
  cursor: grab;
  transition: var(--transition);
  position: relative;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kanban-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.kanban-card .card-patient {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.kanban-card .card-ortho {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.kanban-card .card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.kanban-card .card-aligners {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-primary-light);
  font-weight: 600;
}

.kanban-card .card-value {
  color: var(--success);
  font-weight: 600;
}

/* ================================================
   Modal
   ================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.modal-body {
  padding: 24px;
}

/* ================================================
   Toast
   ================================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-primary);
  animation: toastIn 0.3s ease;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ================================================
   Filter Bar
   ================================================ */

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar .form-control {
  max-width: 200px;
}

.search-input {
  position: relative;
}

.search-input i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

.search-input .form-control {
  padding-left: 36px;
}

/* ================================================
   Top List / Ranking
   ================================================ */

.ranking-list {
  list-style: none;
}

.ranking-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(99, 102, 241, 0.06);
  gap: 12px;
}

.ranking-item:last-child {
  border-bottom: none;
}

.ranking-pos {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-card);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.ranking-pos.top-3 {
  background: var(--accent-gradient);
  color: white;
}

.ranking-info {
  flex: 1;
  min-width: 0;
}

.ranking-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.ranking-value {
  font-weight: 700;
  color: var(--success);
  font-size: 0.92rem;
  flex-shrink: 0;
}

/* ================================================
   Empty State
   ================================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.92rem;
}

/* ================================================
   Settings Sections
   ================================================ */

.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.cost-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
}

.cost-item .cost-name {
  font-weight: 500;
  font-size: 0.88rem;
}

.cost-item .cost-value {
  font-weight: 700;
  color: var(--accent-primary-light);
}

.cost-item input {
  width: 100px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  text-align: right;
  outline: none;
}

.cost-item input:focus {
  border-color: var(--accent-primary);
}

/* ================================================
   Import Section
   ================================================ */

.import-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.import-zone:hover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.05);
}

.import-zone i {
  font-size: 2.5rem;
  color: var(--accent-primary-light);
  margin-bottom: 12px;
}

.import-zone p {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.import-zone .import-hint {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ================================================
   Responsive
   ================================================ */

@media (max-width: 1024px) {
  .kanban-board {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  .mobile-header {
    display: flex;
  }
  
  .main-content {
    margin-left: 0;
    padding: 72px 16px 16px;
  }
  
  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-bar .form-control {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================
   Loading
   ================================================ */

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================================
   Tabs
   ================================================ */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent-primary-light);
  border-bottom-color: var(--accent-primary);
}

/* ================================================
   Pricing tier cards
   ================================================ */

.tier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.tier-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
}

.tier-card:hover {
  border-color: var(--accent-primary);
}

.tier-card .tier-name {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.tier-card.bronze .tier-name { color: #cd7f32; }
.tier-card.prata .tier-name { color: #c0c0c0; }
.tier-card.ouro .tier-name { color: #ffd700; }

.tier-card .tier-prices {
  margin-top: 16px;
}

.tier-card .tier-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.85rem;
}

.tier-card .tier-price-row:last-child { border-bottom: none; }

.tier-card .tier-price-row .price-label {
  color: var(--text-secondary);
}

.tier-card .tier-price-row input {
  width: 80px;
  padding: 5px 8px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: right;
  outline: none;
}

.tier-card .tier-price-row input:focus {
  border-color: var(--accent-primary);
}
/* Light Theme */
body.light-theme {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  --bg-sidebar: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: #e5e7eb;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
}
body.light-theme .kanban-card { box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid var(--border-color); }
body.light-theme .table-wrapper table th { background: #f9fafb; color: #374151; }
body.light-theme .sidebar-brand .brand-text h1 { color: var(--accent-primary); }
body.light-theme .card { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); border: 1px solid var(--border-color); }
body.light-theme .stat-card { border: 1px solid var(--border-color); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
body.light-theme .modal { border: 1px solid var(--border-color); }
body.light-theme .nav-item:not(.active) { color: var(--text-secondary); }
body.light-theme .nav-item:not(.active):hover { background: #f3f4f6; color: var(--accent-primary); }
body.light-theme .sidebar { border-right: 1px solid var(--border-color); }
body.light-theme .table-wrapper table td { white-space: nowrap; }

.kanban-column { flex: 0 0 250px; }
.table-wrapper table th, .table-wrapper table td { white-space: nowrap; }
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  width: 100%;
  max-height: calc(100vh - 200px);
}
.orders-table-wrapper {
  /* Defined precisely by updateOrdersTableHeight after the page is rendered. */
  max-height: calc(100vh - 360px);
}
.table-wrapper table {
  min-width: 1200px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-wrapper table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-secondary);
}

/* Privacy Mode */
.privacy-blur .stat-value,
.privacy-blur .cost-value,
.privacy-blur .ranking-value,
.privacy-blur .chart-wrapper canvas,
.privacy-blur td:nth-child(5),
.privacy-blur td:nth-child(6) {
  filter: blur(6px);
  user-select: none;
  opacity: 0.8;
  transition: all 0.3s ease;
}
.privacy-blur .stat-value:hover,
.privacy-blur .cost-value:hover,
.privacy-blur .ranking-value:hover,
.privacy-blur .chart-wrapper canvas:hover,
.privacy-blur td:nth-child(5):hover,
.privacy-blur td:nth-child(6):hover {
  filter: blur(0px);
  opacity: 1;
}

/* ================================================
   STL 3D Viewer
   ================================================ */

.stl-viewer-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  height: calc(100vh - 160px);
  min-height: 500px;
}

.stl-sidebar {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stl-search-box {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
}

.stl-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.stl-empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  text-align: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 0.88rem;
  padding: 20px;
}

.stl-folder-group {
  margin-bottom: 4px;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.stl-folder-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stl-folder-header:hover {
  background: rgba(99, 102, 241, 0.12);
}

.stl-folder-header i:first-child {
  color: var(--accent-primary-light);
  font-size: 1.1rem;
}

.stl-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stl-folder-count {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.stl-folder-arrow {
  transition: transform 0.2s;
  color: var(--text-tertiary);
}

.stl-folder-group.collapsed .stl-folder-arrow {
  transform: rotate(-90deg);
}

.stl-folder-group.collapsed .stl-folder-files {
  display: none;
}

.stl-folder-files {
  padding: 4px 0 4px 16px;
}

.stl-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.stl-file-item:hover {
  background: rgba(99, 102, 241, 0.08);
}

.stl-file-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-left: 3px solid var(--accent-primary);
}

.stl-file-item i {
  font-size: 1.2rem;
  color: var(--accent-primary-light);
  flex-shrink: 0;
}

.stl-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stl-file-item-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stl-file-item-size {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* 3D Viewer Panel */
.stl-viewer-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stl-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.15);
}

.stl-file-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stl-viewer-actions {
  display: flex;
  gap: 6px;
}

.stl-canvas-container {
  flex: 1;
  position: relative;
  min-height: 400px;
}

.stl-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.stl-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-tertiary);
}

.stl-placeholder i {
  font-size: 4rem;
  opacity: 0.3;
}

.stl-placeholder p {
  font-size: 1rem;
  font-weight: 500;
}

.stl-placeholder span {
  font-size: 0.8rem;
  opacity: 0.6;
}

.stl-info-bar {
  display: flex;
  gap: 20px;
  padding: 10px 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.15);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stl-info-bar span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stl-info-bar i {
  color: var(--accent-primary-light);
}

/* STL Viewer Responsive */
@media (max-width: 900px) {
  .stl-viewer-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .stl-sidebar {
    max-height: 300px;
  }
  .stl-canvas-container {
    min-height: 350px;
  }
}

/* ================================================
   Labels Printing & Preview
   ================================================ */

.labels-modal-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: var(--text-primary);
}

.labels-config-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--glass-border);
}

.labels-config-panel .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.labels-config-panel label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.labels-preview-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ================================================================
   LABEL SYSTEM — Exact replica of the physical Ortoklear sticker
   Physical size: 100mm × 60mm (landscape thermal label)
   
   Strategy: Build the card in PORTRAIT (60mm W × 100mm H) with
   normal text flow. Then rotate the ENTIRE card -90deg so it
   fits in a 100mm × 60mm landscape thermal sticker.
   ================================================================ */

.labels-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
  max-height: 520px;
  overflow-y: auto;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius);
  border: 1px solid var(--glass-border);
}

.label-preview-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 15px;
  border-radius: var(--border-radius);
  align-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  transition: var(--transition-fast);
}

.label-preview-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.label-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
}

.label-preview-header input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ================================================================
   Fixed 105mm x 75mm physical label layout
   ================================================================ */

.label-card-wrapper {
  width: 105mm;
  height: 75mm;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
}

.labels-preview-grid .label-card-wrapper {
  transform: scale(0.86);
  transform-origin: top center;
}

.label-card {
  width: 105mm;
  height: 75mm;
  position: relative;
  display: block;
  background: #ffffff !important;
  color: #000000 !important;
  border: 0.2mm solid #bfbfbf;
  border-radius: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
  user-select: none;
  overflow: hidden;
}

/* All label child elements use absolute positioning for pixel-perfect layout */
.lbl-logo-panel,
.lbl-divider,
.lbl-template-attachment,
.lbl-arch-block,
.lbl-arch-label,
.lbl-arch-count,
.lbl-big-number,
.lbl-arch-tags,
.lbl-patient-name,
.lbl-ortho-name,
.lbl-comentarios-title,
.lbl-comentarios,
.lbl-date-box,
.lbl-badge-box {
  position: absolute;
  box-sizing: border-box;
}

/* ---- Logo Panel (left side, rotated -90°, spans nearly full height) ---- */
.lbl-logo-panel {
  left: 3mm;
  top: 72mm;
  width: 68mm;
  height: 17mm;
  transform: rotate(-90deg);
  transform-origin: left top;
}

.lbl-main-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---- Vertical Divider Lines ---- */
.lbl-divider {
  width: 0;
  border-left: 0.45mm solid #000000;
}

/* Short divider: separates number area from arch info */
.lbl-divider-left {
  left: 33.8mm;
  top: 14mm;
  height: 31mm;
}

/* Tall divider: separates arch info from patient name */
.lbl-divider-center {
  left: 48.3mm;
  top: 5mm;
  height: 63mm;
}

/* Tall divider: separates patient/doctor from comments */
.lbl-divider-right {
  left: 65.2mm;
  top: 5mm;
  height: 63mm;
}

/* ---- Template Attachment text (plate 0 only, rotated -90°) ---- */
.lbl-template-attachment {
  left: 30.8mm;
  top: 44mm;
  width: 38mm;
  font-size: 8pt;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  transform: rotate(-90deg);
  transform-origin: left top;
}

/* ---- Arch Block (unused container) ---- */
.lbl-arch-block {
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

/* ---- Arch Labels and Counts (rotated -90°) ---- */
.lbl-arch-label,
.lbl-arch-count {
  font-size: 8pt;
  line-height: 1;
  white-space: nowrap;
  transform: rotate(-90deg);
  transform-origin: left top;
}

.lbl-arch-label {
  font-weight: 400;
}

.lbl-arch-superior-label {
  left: 35.8mm;
  top: 43.5mm;
}

.lbl-arch-inferior-label {
  left: 40.2mm;
  top: 43.5mm;
}

.lbl-arch-superior-count {
  left: 44.8mm;
  top: 43.5mm;
}

.lbl-arch-inferior-count {
  left: 44.8mm;
  top: 30mm;
}

.lbl-arch-count strong {
  font-size: 11.5pt;
  font-weight: 900;
}

.lbl-arch-part {
  display: inline-block;
}

.lbl-arch-de {
  margin: 0 0.7mm;
  font-size: 8pt;
  font-weight: 400;
}

/* ---- Big Plate Number ---- */
.lbl-big-number {
  left: 23mm;
  top: 52mm;
  width: 14mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 47pt;
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: -1px;
}

/* ---- Superior/Inferior Arch Tags (below the big number) ---- */
.lbl-arch-tags {
  left: 27mm;
  top: 68mm;
  width: 18mm;
  font-size: 7pt;
  font-weight: 400;
  line-height: 1.05;
  text-align: center;
  transform: rotate(-90deg);
  transform-origin: left top;
}

.lbl-arch-tags span {
  display: block;
}

/* ---- Patient Name (large, bold, rotated -90°) ---- */
.lbl-patient-name {
  left: 52mm;
  top: var(--patient-top, 65mm);
  width: 60mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--patient-font-size, 17pt);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  transform: rotate(-90deg);
  transform-origin: left top;
}

/* ---- Orthodontist Name (rotated -90°) ---- */
.lbl-ortho-name {
  left: 60mm;
  top: var(--ortho-top, 65mm);
  width: 58mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--ortho-font-size, 8.8pt);
  font-weight: 400;
  color: #000000;
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  transform: rotate(-90deg);
  transform-origin: left top;
}

/* ---- Comments Title (italic, underlined, rotated -90°) ---- */
.lbl-comentarios-title {
  left: 66.5mm;
  top: 66mm;
  width: 24mm;
  font-size: 7.5pt;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  text-decoration: underline;
  transform: rotate(-90deg);
  transform-origin: left top;
}

/* ---- Comments Text (rotated -90°) ---- */
.lbl-comentarios {
  left: 74mm;
  top: 66mm;
  width: 56mm;
  font-size: 8.8pt;
  font-weight: 400;
  line-height: 1.55;
  margin: 0;
  transform: rotate(-90deg);
  transform-origin: left top;
}

/* ---- Date Box (bottom-right, rotated -90°) ---- */
.lbl-date-box {
  left: 94mm;
  top: 69mm;
  width: 40mm;
  font-size: 9.5pt;
  font-weight: 700;
  line-height: 1;
  margin: 0;
  white-space: nowrap;
  transform: rotate(-90deg) scaleX(0.72);
  transform-origin: left top;
}

.lbl-date-box span {
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---- Badge "Alto em Sorrisos Alinhados" (upper-right corner) ---- */
.lbl-badge-box {
  left: 91mm;
  top: 5mm;
  width: 12.5mm;
  height: 15mm;
  display: block;
}

.lbl-badge-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Ajustes exportados pelo editor visual da etiqueta */
.lbl-logo-panel {
  left: 3mm;
  top: 63.8mm;
  width: 54mm;
  height: 17.7mm;
  font-size: 5.6pt;
  transform: rotate(-90deg);
}

.lbl-divider-left {
  left: 37.1mm;
  top: 12.8mm;
  width: 0.3mm;
  height: 31mm;
  font-size: 10.5pt;
}

.lbl-divider-center {
  left: 67.3mm;
  top: 7.5mm;
  width: 0.6mm;
  height: 59.1mm;
  font-size: 10.5pt;
}

.lbl-divider-right {
  left: 51.3mm;
  top: 7.4mm;
  width: 0.3mm;
  height: 59.1mm;
  font-size: 7.4pt;
}

.lbl-template-attachment {
  left: 33.7mm;
  top: 37mm;
  width: 24.1mm;
  height: 1.8mm;
  font-size: 7pt;
  text-align: right;
  text-transform: none;
  transform: rotate(-90deg);
}

.lbl-arch-superior-label {
  left: 38.8mm;
  top: 45.4mm;
  width: 16.3mm;
  height: 1.8mm;
  font-size: 7pt;
  text-align: center;
  transform: rotate(-90deg);
}

.lbl-arch-superior-count {
  left: 43.7mm;
  top: 42.4mm;
  width: 10.1mm;
  height: 4.1mm;
  font-size: 3.5pt;
  transform: rotate(-90deg);
}

.lbl-arch-superior-count .lbl-arch-superior-current {
  font-size: 11.5pt;
}

.lbl-arch-superior-count .lbl-arch-superior-de {
  font-size: 8pt;
}

.lbl-arch-superior-count .lbl-arch-superior-total {
  font-size: 11.5pt;
}

.lbl-arch-inferior-label {
  left: 38.9mm;
  top: 27.6mm;
  width: 14.4mm;
  height: 1.8mm;
  font-size: 7pt;
  text-align: center;
  transform: rotate(-90deg);
}

.lbl-arch-inferior-count {
  left: 43.6mm;
  top: 26.3mm;
  width: 10.1mm;
  height: 4.1mm;
  font-size: 4.6pt;
}

.lbl-arch-inferior-count .lbl-arch-inferior-current {
  font-size: 11.5pt;
}

.lbl-arch-inferior-count .lbl-arch-inferior-de {
  font-size: 8pt;
}

.lbl-arch-inferior-count .lbl-arch-inferior-total {
  font-size: 11.5pt;
}

.lbl-big-number {
  left: 22.8mm;
  top: 53mm;
  width: 14mm;
  height: 12.9mm;
  font-size: 63pt;
  transform: rotate(-90deg);
}

.lbl-arch-tags {
  left: 43.1mm;
  top: 68.1mm;
  width: 18mm;
  height: 5.2mm;
  font-size: 7pt;
}

.lbl-patient-name {
  left: 53.5mm;
  top: 66.5mm;
  width: 60mm;
  height: 6mm;
  font-size: 14pt;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  text-transform: none;
  transform: rotate(-90deg);
}

.lbl-ortho-name {
  left: 62mm;
  top: 65.9mm;
  width: 58mm;
  height: 3.1mm;
  font-size: 9pt;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  text-transform: none;
  transform: rotate(-90deg);
}

.lbl-comentarios-title {
  left: 69.7mm;
  top: 66mm;
  width: 24mm;
  height: 2.6mm;
  font-size: 7.5pt;
}

.lbl-comentarios {
  left: 75.7mm;
  top: 66.1mm;
  width: 60.8mm;
  height: 18.2mm;
  font-size: 8pt;
  transform: rotate(-90deg);
}

.lbl-date-box {
  left: 98.4mm;
  top: 67mm;
  width: 40mm;
  height: 3.4mm;
  font-size: 8pt;
  font-family: Arial, Helvetica, sans-serif;
  transform: rotate(-90deg);
}

.lbl-badge-box {
  left: 89.9mm;
  top: 4.6mm;
  width: 12.5mm;
  height: 15mm;
  font-size: 7.9pt;
  transform: rotate(-90deg);
}

/* ================================================================
   CASH FLOW
   ================================================================ */

.finance-privacy-btn {
  background: transparent;
  border: 0;
  font-size: 1.25rem;
}

.financial-tabs {
  display: flex;
  gap: 8px;
  margin: -6px 0 22px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--glass-border);
}

.financial-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.financial-tab:hover,
.financial-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.cashflow-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 16px 18px;
}

.cashflow-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1;
}

.cashflow-filters .form-group {
  margin: 0;
  min-width: 132px;
}

.cashflow-filters .form-group.compact {
  max-width: 175px;
}

.cashflow-filters label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.73rem;
  color: var(--text-tertiary);
}

.cashflow-search {
  min-width: 230px !important;
  flex: 1;
  max-width: 340px;
}

.cashflow-search-row,
.cashflow-actions,
.cashflow-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cashflow-source-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 10px 14px;
  border: 1px solid rgba(16, 185, 129, 0.24);
  border-radius: var(--border-radius);
  background: rgba(16, 185, 129, 0.08);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.cashflow-source-note i {
  color: var(--success);
  font-size: 1.1rem;
}

.cashflow-stats .stat-card {
  min-height: 138px;
}

.stat-subline {
  margin-top: 7px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
}

.cashflow-negative,
.cashflow-expense,
.cashflow-unreconciled {
  color: var(--danger) !important;
}

.cashflow-income,
.cashflow-reconciled {
  color: var(--success) !important;
}

.cashflow-monthly-card,
.cashflow-entries-card {
  margin-top: 20px;
  padding: 0;
  overflow: hidden;
}

.cashflow-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.cashflow-section-header h3 {
  font-size: 1rem;
}

.cashflow-section-header h3 i {
  margin-right: 6px;
  color: var(--accent-primary);
}

.cashflow-section-header p {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.76rem;
}

.cashflow-monthly-table,
.cashflow-entries-table {
  border-radius: 0;
  max-height: 520px;
}

.cashflow-monthly-table table,
.cashflow-entries-table table {
  min-width: 1120px;
}

.cashflow-selected-row td {
  background: rgba(99, 102, 241, 0.09);
}

.cashflow-status,
.cashflow-type,
.cashflow-source,
.cashflow-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.cashflow-status.realized {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
}

.cashflow-status.planned {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.13);
}

.cashflow-type.income {
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
}

.cashflow-type.expense {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

.cashflow-source {
  color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.12);
}

.cashflow-source.historical {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
}

.cashflow-code {
  margin-right: 4px;
  border-radius: 6px;
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
}

.cashflow-row-actions .btn-icon.danger {
  color: var(--danger);
}

.cashflow-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--glass-border);
}

.cashflow-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.light-theme .cashflow-source-note {
  background: #ecfdf5;
}

body.light-theme .cashflow-selected-row td {
  background: #eef2ff;
}

@media (max-width: 900px) {
  .cashflow-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .cashflow-actions {
    justify-content: flex-end;
  }

  .cashflow-search {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .financial-tabs {
    overflow-x: auto;
  }

  .financial-tab {
    white-space: nowrap;
  }

  .cashflow-filters .form-group,
  .cashflow-filters .form-group.compact {
    width: 100%;
    max-width: none;
  }

  .cashflow-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */

#labelsPrintArea {
  display: none;
}

@media print {
  :root {
    /* ZD220: measured output was 92x48mm; these compensate to reach 100x60mm. */
    --label-print-scale-x: 1.035;
    --label-print-scale-y: 1;
    --label-print-safe-x: 2.5mm;
    --label-print-safe-y: 7.5mm;
  }

  /* Force page background to white to completely eliminate dark mode printing bars */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 105mm !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body > *:not(#labelsPrintArea) {
    display: none !important;
  }

  .modal-overlay {
    display: none !important;
  }

  #labelsPrintArea {
    display: block !important;
    position: static !important;
    left: 0;
    top: 0;
    margin: 0 !important;
    padding: 0 !important;
    width: 105mm !important;
    min-width: 105mm !important;
    max-width: 105mm !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    overflow: visible !important;
  }

  .print-label-card {
    display: block !important;
    page-break-after: always !important;
    page-break-before: auto !important;
    page-break-inside: avoid !important;
    break-after: page !important;
    break-before: auto !important;
    break-inside: avoid;
    width: 105mm !important;
    min-width: 105mm !important;
    max-width: 105mm !important;
    height: 75mm !important;
    min-height: 75mm !important;
    max-height: 75mm !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    color: #000000 !important;
    overflow: hidden !important;
  }

  .print-label-card .label-card {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    position: relative !important;
    width: 105mm !important;
    min-width: 105mm !important;
    max-width: 105mm !important;
    height: 75mm !important;
    min-height: 75mm !important;
    max-height: 75mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    transform: translate(var(--label-print-safe-x), var(--label-print-safe-y)) scale(var(--label-print-scale-x), var(--label-print-scale-y)) !important;
    transform-origin: left top !important;
  }

  .print-label-card:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  @page {
    size: 105mm 75mm;
    margin: 0;
  }
}
