:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 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,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--gray-50); color: var(--gray-800); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }

/* Layout */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: white; border-bottom: 1px solid var(--gray-200); padding: 0 24px; height: 64px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.topbar .logo { font-size: 20px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.topbar .logo span { background: var(--primary); color: white; padding: 4px 10px; border-radius: 8px; font-size: 14px; }
.topbar .user-info { display: flex; align-items: center; gap: 12px; }
.topbar .user-info .role-badge { background: var(--primary-light); color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.main-content { flex: 1; padding: 24px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* Cards */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-value { font-size: 32px; font-weight: 800; color: var(--gray-900); }
.stat-label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; color: var(--gray-800); background: white; transition: border-color .15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--gray-200); }
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
tr:hover td { background: var(--gray-50); }

/* Badges */
.badge { display: inline-flex; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-paused { background: var(--warning-light); color: var(--warning); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-scheduled { background: var(--gray-100); color: var(--gray-600); }
.badge-checked_in { background: #e0f2fe; color: #0284c7; }
.badge-cancelled, .badge-no_show { background: var(--danger-light); color: var(--danger); }

/* Pain Level */
.pain-bar { display: flex; gap: 4px; align-items: center; }
.pain-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; cursor: pointer; transition: transform .15s; }
.pain-dot:hover { transform: scale(1.2); }
.pain-dot.selected { transform: scale(1.3); box-shadow: 0 0 0 3px rgba(0,0,0,.15); }
.pain-1, .pain-2 { background: #22c55e; }
.pain-3, .pain-4 { background: #84cc16; }
.pain-5, .pain-6 { background: #eab308; }
.pain-7, .pain-8 { background: #f97316; }
.pain-9, .pain-10 { background: #ef4444; }

/* Progress bar */
.progress-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }

/* Login */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.login-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-card h1 { text-align: center; margin-bottom: 8px; color: var(--gray-900); }
.login-card p { text-align: center; color: var(--gray-500); margin-bottom: 24px; }
.login-tabs { display: flex; margin-bottom: 24px; border-radius: 8px; background: var(--gray-100); padding: 4px; }
.login-tab { flex: 1; padding: 10px; text-align: center; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--gray-500); transition: all .2s; }
.login-tab.active { background: white; color: var(--primary); box-shadow: var(--shadow); }

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

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { background: white; border-radius: 16px; padding: 32px; width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--gray-100); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot { position: absolute; left: -24px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.timeline-dot.green { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-date { font-size: 13px; color: var(--gray-400); margin-bottom: 4px; }
.timeline-content { background: var(--gray-50); padding: 12px 16px; border-radius: 8px; }

/* Chart placeholder */
.chart-container { width: 100%; height: 250px; position: relative; }

/* Mood icons */
.mood { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.mood-icon { font-size: 18px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--gray-800); color: white; padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 2000; animation: slideUp .3s; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

/* Hidden */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { margin: 16px; padding: 24px; }
}
