/* =============================================================
   CuraFlow Design System — styles.css
   Premium wellness SaaS UI
   ============================================================= */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Serif+Display:ital@0;1&display=swap');

/* =============================================================
   1. CSS VARIABLES / DESIGN TOKENS
   ============================================================= */

:root {
  /* Primary palette */
  --primary:        #0d9488;
  --primary-dark:   #0f766e;
  --primary-light:  #14b8a6;
  --primary-soft:   #ccfbf1;
  --primary-xsoft:  #f0fdfa;

  /* Accent */
  --accent:         #0891b2;
  --accent-soft:    #e0f2fe;

  /* Neutrals */
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface-raised: #ffffff;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  /* Text */
  --text:           #0f172a;
  --text-secondary: #334155;
  --muted:          #64748b;
  --subtle:         #94a3b8;
  --placeholder:    #cbd5e1;

  /* Status */
  --success:        #059669;
  --success-soft:   #d1fae5;
  --warning:        #d97706;
  --warning-soft:   #fef3c7;
  --danger:         #dc2626;
  --danger-soft:    #fee2e2;
  --info:           #0284c7;
  --info-soft:      #e0f2fe;

  /* Sidebar */
  --sidebar-bg:     #0f1923;
  --sidebar-width:  240px;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-hover:  rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(13,148,136,0.18);

  /* Spacing (8px base) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:     0 4px 6px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.06);
  --shadow-md:  0 8px 16px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:  0 20px 40px rgba(15,23,42,0.10), 0 4px 8px rgba(15,23,42,0.04);

  /* Typography */
  --font-sans:  'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;

  /* Font sizes */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition:        200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-height: 60px;
  --content-max:   1280px;
}

/* =============================================================
   2. RESET & BASE
   ============================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--primary); }

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol { list-style: none; }

button {
  cursor: pointer;
  font-family: var(--font-sans);
  border: none;
  background: none;
}

input, textarea, select {
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

/* =============================================================
   3. LAYOUT SYSTEM
   ============================================================= */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}

.page-content {
  flex: 1;
  padding: var(--space-8);
  padding-top: calc(var(--header-height) + var(--space-8));
  max-width: var(--content-max);
  width: 100%;
}

.page-content-full {
  flex: 1;
  padding: var(--space-8);
  padding-top: calc(var(--header-height) + var(--space-8));
  width: 100%;
}

.container {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* Grid helpers */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }
.grid-5 { grid-template-columns: repeat(5, 1fr); gap: var(--space-6); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* =============================================================
   4. SIDEBAR
   ============================================================= */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  padding: var(--space-6) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-mark svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.sidebar-logo-text {
  font-size: var(--text-md);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.sidebar-logo-text span {
  color: var(--primary-light);
}

.sidebar-section {
  padding: var(--space-5) var(--space-3);
  flex: 1;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(148,163,184,0.5);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary-light);
  border-radius: 0 3px 3px 0;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--primary-dark);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0d9488, #0891b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =============================================================
   5. HEADER
   ============================================================= */

.page-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-6);
  z-index: 90;
  transition: left var(--transition-slow);
}

.header-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4) 0 36px;
  font-size: var(--text-sm);
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
}

.header-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.header-search input::placeholder { color: var(--subtle); }

.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--subtle);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all var(--transition-fast);
  position: relative;
  background: none;
}

.header-icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.header-icon-btn svg { width: 18px; height: 18px; }

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.header-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.header-profile:hover { background: var(--bg); }

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0d9488, #0891b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
}

.header-profile-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
  overflow: hidden;
}

.profile-dropdown.open { display: block; }

.profile-dropdown-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.profile-dropdown-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.profile-dropdown-email {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 2px;
}

.profile-dropdown-menu {
  padding: var(--space-2);
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
}

.profile-dropdown-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.profile-dropdown-item svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.profile-dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-2) 0;
}

/* =============================================================
   6. PAGE HEADER SECTION
   ============================================================= */

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-6);
}

.content-header-left {}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-1);
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* =============================================================
   7. CARD SYSTEM
   ============================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-padded {
  padding: var(--space-6);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 2px;
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* =============================================================
   8. STAT CARDS
   ============================================================= */

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.stat-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card-accent.teal   { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card-accent.blue   { background: linear-gradient(90deg, var(--accent), #38bdf8); }
.stat-card-accent.green  { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card-accent.amber  { background: linear-gradient(90deg, var(--warning), #fbbf24); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 500;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-icon.teal  { background: var(--primary-soft); color: var(--primary-dark); }
.stat-card-icon.blue  { background: var(--accent-soft); color: var(--accent); }
.stat-card-icon.green { background: var(--success-soft); color: var(--success); }
.stat-card-icon.amber { background: var(--warning-soft); color: var(--warning); }

.stat-card-icon svg { width: 18px; height: 18px; }

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
}

.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.flat { color: var(--muted); }

.stat-trend svg { width: 12px; height: 12px; }

.stat-period {
  font-size: var(--text-xs);
  color: var(--subtle);
  margin-top: 2px;
}

/* =============================================================
   9. BUTTONS
   ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 36px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(13,148,136,0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(13,148,136,0.4);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary-dark);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover { background: #047857; color: #fff; }

.btn-sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  height: 44px;
  padding: 0 var(--space-8);
  font-size: var(--text-md);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

/* =============================================================
   10. BADGES
   ============================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-active    { background: var(--success-soft); color: var(--success); }
.badge-active::before { background: var(--success); }

.badge-paused    { background: var(--warning-soft); color: var(--warning); }
.badge-paused::before { background: var(--warning); }

.badge-completed { background: var(--primary-soft); color: var(--primary-dark); }
.badge-completed::before { background: var(--primary); }

.badge-draft     { background: var(--border-light); color: var(--muted); }
.badge-draft::before { background: var(--subtle); }

.badge-risk      { background: var(--danger-soft); color: var(--danger); }
.badge-risk::before { background: var(--danger); }

.badge-info      { background: var(--accent-soft); color: var(--accent); }
.badge-info::before { background: var(--accent); }

.badge-plain {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
}

.badge-plain::before { display: none; }

/* =============================================================
   11. TABLES
   ============================================================= */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead {
  border-bottom: 1px solid var(--border);
}

.table th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  background: var(--bg);
}

.table td {
  padding: var(--space-4) var(--space-5);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover { background: var(--bg); }

.table tbody tr:last-child td { border-bottom: none; }

.table-name {
  font-weight: 500;
  color: var(--text);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Table toolbar */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  flex-wrap: wrap;
}

.table-toolbar-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.table-toolbar-search input {
  width: 100%;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4) 0 32px;
  font-size: var(--text-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.table-toolbar-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.table-toolbar-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--subtle);
}

.table-toolbar select {
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

.table-toolbar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.table-count {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-left: auto;
}

/* =============================================================
   12. FORMS
   ============================================================= */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.form-label span {
  color: var(--muted);
  font-weight: 400;
  font-size: var(--text-xs);
}

.form-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-input::placeholder { color: var(--subtle); }

.form-select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  outline: none;
  resize: vertical;
  min-height: 100px;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--space-1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.form-section {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border-light);
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.form-section-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-6);
}

/* =============================================================
   13. PROGRESS BARS
   ============================================================= */

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.progress-fill.teal  { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.progress-fill.blue  { background: linear-gradient(90deg, var(--accent), #38bdf8); }
.progress-fill.green { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-fill.amber { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress-fill.red   { background: linear-gradient(90deg, var(--danger), #f87171); }

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.progress-label-text { font-size: var(--text-sm); color: var(--text-secondary); }
.progress-label-value { font-size: var(--text-sm); font-weight: 600; color: var(--text); }

/* =============================================================
   14. ALERT CARDS
   ============================================================= */

.alert-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: var(--space-3);
  position: relative;
}

.alert-card.warning  { background: var(--warning-soft); border-color: #fde68a; }
.alert-card.danger   { background: var(--danger-soft);  border-color: #fecaca; }
.alert-card.info     { background: var(--info-soft);    border-color: #bae6fd; }
.alert-card.success  { background: var(--success-soft); border-color: #a7f3d0; }

.alert-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-card.warning .alert-icon { background: rgba(217,119,6,0.15); color: var(--warning); }
.alert-card.danger  .alert-icon { background: rgba(220,38,38,0.12); color: var(--danger); }
.alert-card.info    .alert-icon { background: rgba(2,132,199,0.12); color: var(--info); }
.alert-card.success .alert-icon { background: rgba(5,150,105,0.12); color: var(--success); }

.alert-icon svg { width: 18px; height: 18px; }

.alert-body { flex: 1; }

.alert-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.alert-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-time {
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.alert-dismiss {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.alert-dismiss:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.alert-dismiss svg { width: 12px; height: 12px; }

/* =============================================================
   15. ACTIVITY FEED
   ============================================================= */

.activity-list { display: flex; flex-direction: column; gap: 0; }

.activity-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.teal    { background: var(--primary); }
.activity-dot.blue    { background: var(--accent); }
.activity-dot.green   { background: var(--success); }
.activity-dot.amber   { background: var(--warning); }
.activity-dot.red     { background: var(--danger); }
.activity-dot.neutral { background: var(--subtle); }

.activity-content { flex: 1; }

.activity-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong { color: var(--text); font-weight: 500; }

.activity-time {
  font-size: var(--text-xs);
  color: var(--subtle);
  margin-top: 2px;
}

/* =============================================================
   16. CHART CONTAINERS
   ============================================================= */

.chart-container {
  width: 100%;
  position: relative;
}

.chart-placeholder {
  width: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, var(--border-light) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.chart-placeholder.h-200 { height: 200px; }
.chart-placeholder.h-240 { height: 240px; }
.chart-placeholder.h-280 { height: 280px; }
.chart-placeholder.h-320 { height: 320px; }

/* SVG-based fake chart lines */
.chart-bars {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 var(--space-4);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80%;
}

.chart-bar {
  flex: 1;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.chart-bar:hover { opacity: 1; }
.chart-bar.muted { background: var(--border); }
.chart-bar.blue  { background: linear-gradient(180deg, var(--accent), #38bdf8); }
.chart-bar.green { background: linear-gradient(180deg, var(--success), #34d399); }
.chart-bar.amber { background: linear-gradient(180deg, var(--warning), #fbbf24); }

.chart-line-svg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.chart-label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: center;
  margin-top: var(--space-3);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0 0;
}

.chart-x-label {
  font-size: var(--text-xs);
  color: var(--subtle);
}

/* =============================================================
   17. PROGRESS / METRIC WIDGETS
   ============================================================= */

.metric-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.metric-widget-label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-3);
}

.metric-widget-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: var(--space-1);
}

.metric-widget-unit {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.metric-widget-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
}

.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-neutral { color: var(--muted); }

/* Donut chart placeholder */
.donut-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.donut-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0% var(--pct, 72%), var(--border) var(--pct, 72%) 100%);
}

.donut-placeholder::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
}

.donut-label {
  position: relative;
  z-index: 1;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text);
}

/* =============================================================
   18. TIMELINE BLOCKS
   ============================================================= */

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.timeline-marker.teal  { background: var(--primary-soft); color: var(--primary-dark); border: 2px solid var(--primary-light); }
.timeline-marker.green { background: var(--success-soft); color: var(--success); border: 2px solid #34d399; }
.timeline-marker.amber { background: var(--warning-soft); color: var(--warning); border: 2px solid #fbbf24; }
.timeline-marker.red   { background: var(--danger-soft);  color: var(--danger);  border: 2px solid #f87171; }
.timeline-marker.gray  { background: var(--border-light); color: var(--muted);   border: 2px solid var(--border); }

.timeline-marker svg { width: 13px; height: 13px; }

.timeline-content { flex: 1; padding-top: 4px; }

.timeline-date {
  font-size: var(--text-xs);
  color: var(--subtle);
  margin-bottom: 2px;
}

.timeline-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.timeline-desc {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
}

/* =============================================================
   19. SERVICE CARDS
   ============================================================= */

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.service-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.service-card.selected {
  border-color: var(--primary);
  background: var(--primary-xsoft);
}

.service-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.service-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.service-card-icon.physio  { background: #e0f2fe; }
.service-card-icon.massage { background: #fdf4ff; }
.service-card-icon.fitness { background: var(--success-soft); }
.service-card-icon.nutrition { background: var(--warning-soft); }
.service-card-icon.mindfulness { background: var(--primary-soft); }
.service-card-icon.recovery { background: #ede9fe; }

.service-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.service-card-category {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.service-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.service-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--muted);
}

.service-meta-item svg { width: 12px; height: 12px; }

.service-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
}

.service-price {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.contraindication-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
}

/* =============================================================
   20. TABS
   ============================================================= */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-item {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.tab-item:hover { color: var(--text); }

.tab-item.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

/* =============================================================
   21. PROFILE SUMMARY
   ============================================================= */

.profile-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.profile-summary-hero {
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1e3a3a 100%);
  padding: var(--space-8) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.profile-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 3px solid rgba(255,255,255,0.2);
}

.profile-summary-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.profile-summary-sub {
  font-size: var(--text-sm);
  color: rgba(148,163,184,0.9);
  margin-top: 2px;
}

.profile-summary-badges {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.profile-summary-body {
  padding: var(--space-6);
}

/* =============================================================
   22. RISK FLAGS
   ============================================================= */

.risk-flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.risk-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.risk-flag.high   { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.risk-flag.medium { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }
.risk-flag.low    { background: var(--info-soft); color: var(--info); border: 1px solid #bae6fd; }

/* =============================================================
   23. AI / RECOMMENDATION
   ============================================================= */

.ai-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 12px;
  background: linear-gradient(135deg, #1e293b, #0f2027);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary-light);
  letter-spacing: 0.3px;
}

.ai-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.confidence-meter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.confidence-dots {
  display: flex;
  gap: 4px;
}

.confidence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.confidence-dot.filled { background: var(--primary); }
.confidence-dot.half   { background: linear-gradient(90deg, var(--primary) 50%, var(--border) 50%); }

.confidence-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary-dark);
}

.evidence-block {
  background: var(--primary-xsoft);
  border: 1px solid var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
}

.evidence-block-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.evidence-block-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =============================================================
   24. EMPTY STATES
   ============================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
}

.empty-state-icon svg { width: 24px; height: 24px; color: var(--subtle); }

.empty-state-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  max-width: 320px;
  line-height: 1.6;
  margin-bottom: var(--space-5);
}

/* =============================================================
   25. LOGIN PAGE
   ============================================================= */

.login-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.login-left {
  flex: 1;
  background: linear-gradient(145deg, #0f1923 0%, #0d3333 50%, #0f2027 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-12);
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13,148,136,0.12) 0%, transparent 70%);
}

.login-left::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -80px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(8,145,178,0.08) 0%, transparent 70%);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  z-index: 1;
}

.login-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand-mark svg { width: 22px; height: 22px; color: #fff; }

.login-brand-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.login-brand-name span { color: var(--primary-light); }

.login-hero {
  position: relative;
  z-index: 1;
}

.login-hero-title {
  font-family: var(--font-serif);
  font-size: 38px;
  color: #fff;
  line-height: 1.2;
  margin-bottom: var(--space-5);
  font-weight: 400;
}

.login-hero-title em {
  font-style: italic;
  color: var(--primary-light);
}

.login-hero-desc {
  font-size: var(--text-base);
  color: rgba(148,163,184,0.85);
  line-height: 1.7;
  max-width: 380px;
}

.login-stats {
  display: flex;
  gap: var(--space-8);
  position: relative;
  z-index: 1;
}

.login-stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.login-stat-label {
  font-size: var(--text-xs);
  color: rgba(148,163,184,0.7);
  margin-top: 2px;
}

.login-right {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  background: var(--surface);
}

.login-form-container {
  width: 100%;
  max-width: 360px;
}

.login-form-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: var(--space-2);
}

.login-form-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-8);
}

.login-form-footer {
  text-align: center;
  margin-top: var(--space-6);
}

.login-form-footer p {
  font-size: var(--text-xs);
  color: var(--subtle);
  line-height: 1.6;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-divider span {
  font-size: var(--text-xs);
  color: var(--subtle);
}

/* =============================================================
   26. PROGRAM BUILDER
   ============================================================= */

.builder-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-6);
  align-items: start;
}

.builder-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.builder-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.builder-item:last-child { border-bottom: none; }
.builder-item:hover { background: var(--bg); }

.builder-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.builder-item-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.builder-item-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 1px;
}

.builder-item-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.frequency-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 2px;
}

.freq-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
}

.freq-btn:hover { background: var(--surface); color: var(--text); }

.freq-value {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  min-width: 20px;
  text-align: center;
}

/* Weekly schedule grid */
.schedule-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-header {
  background: var(--bg);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.schedule-time {
  background: var(--bg);
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: right;
}

.schedule-cell {
  background: var(--surface);
  min-height: 52px;
  padding: var(--space-1);
  position: relative;
}

.schedule-event {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--primary-dark);
  cursor: pointer;
  margin-bottom: 2px;
}

.schedule-event.blue  { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.schedule-event.green { background: var(--success-soft); border-color: var(--success); color: var(--success); }

/* =============================================================
   27. PRICING SUMMARY
   ============================================================= */

.pricing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-sm);
}

.pricing-row:last-child { border-bottom: none; }

.pricing-label { color: var(--text-secondary); }
.pricing-value { font-weight: 600; color: var(--text); }
.pricing-total .pricing-label { font-weight: 600; color: var(--text); font-size: var(--text-md); }
.pricing-total .pricing-value { font-size: var(--text-lg); color: var(--primary-dark); }

/* =============================================================
   28. SETTINGS
   ============================================================= */

.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-8);
  align-items: start;
}

.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  position: sticky;
  top: calc(var(--header-height) + var(--space-8));
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  margin-bottom: 2px;
}

.settings-nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.settings-nav-item.active { background: var(--primary-soft); color: var(--primary-dark); }
.settings-nav-item svg { width: 15px; height: 15px; }

.settings-nav-section {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--subtle);
  padding: var(--space-3) var(--space-3) var(--space-1);
  margin-top: var(--space-2);
}

/* =============================================================
   29. TRACKING PAGE
   ============================================================= */

.session-row-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green  { background: var(--success); }
.status-dot.red    { background: var(--danger); }
.status-dot.amber  { background: var(--warning); }
.status-dot.blue   { background: var(--accent); }
.status-dot.gray   { background: var(--subtle); }

/* =============================================================
   30. ANALYTICS
   ============================================================= */

.kpi-trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.kpi-trend-left { flex: 1; }

.kpi-trend-label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.kpi-trend-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.kpi-mini-chart {
  width: 80px;
  height: 40px;
  flex-shrink: 0;
}

/* =============================================================
   31. UTILITIES
   ============================================================= */

.divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-6) 0;
}

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-muted   { color: var(--muted); }
.text-subtle  { color: var(--subtle); }
.text-primary { color: var(--primary-dark); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-0  { padding: 0; }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded    { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: var(--space-4);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.info-item-label {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.info-item-value {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

/* =============================================================
   32. RESPONSIVE
   ============================================================= */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .page-header {
    left: 0;
  }

  .page-content {
    padding: var(--space-6);
    padding-top: calc(var(--header-height) + var(--space-6));
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }

  .sidebar-toggle {
    display: flex;
  }

  .builder-layout {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { width: 100%; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .content-header {
    flex-direction: column;
    gap: var(--space-4);
  }

  .content-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .form-row { grid-template-columns: 1fr; }

  .info-grid { grid-template-columns: 1fr; }

  .header-search { display: none; }

  .page-content { padding: var(--space-5); padding-top: calc(var(--header-height) + var(--space-5)); }
}

@media (max-width: 480px) {
  .header-profile-name { display: none; }
  .stat-value { font-size: var(--text-2xl); }
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
}

.sidebar-overlay.open { display: block; }

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover { background: var(--bg); color: var(--text); }
.sidebar-toggle svg { width: 20px; height: 20px; }

@media (max-width: 1024px) {
  .sidebar-toggle { display: flex; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--subtle); }

/* =============================================================
   33. MODAL
   ============================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: var(--space-5);
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-light);
}

.modal-title { font-size: var(--text-lg); font-weight: 600; }

.modal-body { padding: var(--space-6); }

.modal-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* =============================================================
   34. MISC
   ============================================================= */

.separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.page-section {
  margin-bottom: var(--space-8);
}

.page-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.page-section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
}

.two-col-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

.three-col-layout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 1024px) {
  .two-col-layout   { grid-template-columns: 1fr; }
  .three-col-layout { grid-template-columns: 1fr; }
}
@media (max-width:1280px) {
  .grid-cols-4{grid-template-columns:repeat(2,1fr)}
  .grid-cols-5{grid-template-columns:repeat(3,1fr)}
  .builder-layout{grid-template-columns:1fr}
  .builder-sidebar-panel{position:static}
  .settings-layout{grid-template-columns:1fr}
  .settings-nav{position:static;display:flex;flex-wrap:wrap;gap:var(--space-2);margin-bottom:var(--space-6)}
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Adherence ring */
.adherence-ring {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.adherence-ring svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.adherence-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.adherence-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 188;
  transition: stroke-dashoffset 0.8s ease;
}

.adherence-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }