/* ═══════════════════════════════════════════════════
   Patient Funnel Manager - Design System
   ═══════════════════════════════════════════════════ */

:root {
  --primary: #0f766e;
  --primary-light: #14b8a6;
  --primary-dark: #0d5f59;
  --primary-bg: #f0fdfa;
  --secondary: #6366f1;
  --secondary-light: #818cf8;
  --accent: #f59e0b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: rgba(20, 184, 166, 0.15);
  
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #14b8a6;
  
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --sidebar-width: 260px;
  --header-height: 60px;
  --transition: all 0.2s ease;
}

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

html, body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.app-loaded {
  overflow: hidden;
  height: 100vh;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Auth Screen ─── */
.auth-screen {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f766e 0%, #0d5f59 50%, #134e4a 100%);
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.auth-logo-icon svg { color: white; }
.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.auth-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}
.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border: none;
  background: transparent;
}
.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #0a4f49); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-full { width: 100%; }
.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}
.auth-error.show { display: block; }

/* ─── App Layout ─── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s ease;
  z-index: 100;
}
.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg { width: 20px; height: 20px; color: white; }
.sidebar-title {
  overflow: hidden;
}
.sidebar-title h2 {
  font-size: 15px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.sidebar-title small {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}
.nav-section {
  margin-bottom: 4px;
}
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-sidebar);
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active svg { opacity: 1; }
.nav-item-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-group-toggle {
  margin-left: auto;
  transition: transform 0.2s;
}
.nav-group-toggle.open { transform: rotate(180deg); }
.nav-group-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.nav-group-children.open { max-height: 500px; }
.nav-group-children .nav-item {
  padding-left: 42px;
  font-size: 12.5px;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-user:hover { background: var(--bg-sidebar-hover); }
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text-muted);
}
#userMenuChevron {
  transition: transform 0.2s ease;
}
#userMenuChevron svg { width: 16px; height: 16px; }

/* ─── User Popup Menu ─── */
.user-menu-chevron,
#userMenuChevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
#userMenuChevron svg { width: 16px; height: 16px; }
.user-popup-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 10px;
  right: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 999;
}
.user-popup-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.user-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s;
}
.user-popup-item:hover {
  background: var(--bg-hover);
}
.user-popup-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.user-popup-danger { color: var(--danger); }
.user-popup-danger svg { color: var(--danger); }
.user-popup-danger:hover { background: rgba(239, 68, 68, 0.08); }
.user-popup-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.main-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.main-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.main-header-title svg { color: var(--primary); }
.main-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.breadcrumb span { color: var(--text-secondary); }

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ─── Dashboard ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg { width: 24px; height: 24px; }
.stat-card-icon.teal { background: linear-gradient(135deg, #ccfbf1, #99f6e4); color: var(--primary); }
.stat-card-icon.blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: var(--info); }
.stat-card-icon.amber { background: linear-gradient(135deg, #fef3c7, #fde68a); color: var(--accent); }
.stat-card-icon.purple { background: linear-gradient(135deg, #ede9fe, #c4b5fd); color: var(--secondary); }
.stat-card-body { flex: 1; }
.stat-card-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-card-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; margin-top: 4px; }
.stat-card-sub { font-size: 11px; color: var(--success); font-weight: 500; margin-top: 4px; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg { color: var(--primary); width: 20px; height: 20px; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.quick-link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}
.quick-link-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.quick-link-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.quick-link-icon.teal-bg { background: var(--primary-bg); }
.quick-link-icon.blue-bg { background: #eff6ff; }
.quick-link-icon.amber-bg { background: #fffbeb; }
.quick-link-icon.purple-bg { background: #f5f3ff; }
.quick-link-text h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.quick-link-text p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Module Pages ─── */
.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.module-header .search-input {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.search-input {
  position: relative;
}
.search-input input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.search-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.1); }
.search-input svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.category-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-secondary);
}
.category-tab:hover { border-color: var(--primary); color: var(--primary); }
.category-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ─── Cards Grid ─── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}
.content-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.content-card-img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 36px;
}
.content-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.content-card-body {
  padding: 14px;
}
.content-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.content-card-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-bg);
  color: var(--primary);
}

/* ─── Pricing Table ─── */
.pricing-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pricing-table thead { background: var(--bg); }
.pricing-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.pricing-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.pricing-table tr:last-child td { border-bottom: none; }
.pricing-table tr:hover td { background: var(--bg); }
.price-value {
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}

/* ─── Case Detail ─── */
.case-detail-header {
  margin-bottom: 24px;
}
.case-detail-header h2 { font-size: 20px; font-weight: 700; }
.case-meta-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.meta-pill {
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.case-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.case-image-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.case-image-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.case-image-type {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: white;
}
.case-image-type.before { background: var(--info); }
.case-image-type.during { background: var(--accent); }
.case-image-type.after { background: var(--success); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overscroll-behavior: contain;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-light); padding: 4px 8px; border-radius: 6px; }
.modal-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .form-group.full { grid-column: 1 / -1; }

/* ─── Presentation Mode ─── */
.presentation-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.presentation-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.presentation-content img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}
.presentation-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2001;
  transition: var(--transition);
}
.presentation-close:hover { background: rgba(255,255,255,0.3); }
.presentation-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2001;
  transition: var(--transition);
}
.presentation-nav:hover { background: rgba(255,255,255,0.25); }
.presentation-nav.prev { left: 16px; }
.presentation-nav.next { right: 16px; }
.presentation-counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  z-index: 2001;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ─── Loading ─── */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── File upload area ─── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-bg); }
.upload-area svg { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 8px; }
.upload-area p { color: var(--text-secondary); font-size: 13px; }
.upload-preview {
  margin-top: 12px;
  max-width: 200px;
  border-radius: var(--radius-sm);
}

/* ─── Responsive ─── */
/* ─── Responsive: Tablet ─── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -280px; height: 100vh; height: 100dvh; z-index: 200; transition: left 0.28s cubic-bezier(0.4,0,0.2,1); will-change: left; }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    transition: opacity 0.25s;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .main-body { padding: 16px; }
  .main-header { padding: 0 12px; gap: 8px; }
  .main-header-title { font-size: 15px; }
  .main-header-title svg { width: 18px; height: 18px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { max-width: calc(100vw - 24px); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); margin: 12px; }
  .modal-body { max-height: calc(100vh - 200px); max-height: calc(100dvh - 200px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .auth-card { margin: 16px; padding: 32px 24px; }
  .kb-col { min-width: 200px !important; }
  .kb-board { gap: 10px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .kb-col { scroll-snap-align: start; }
  .stat-card { padding: 14px; }
  .btn { min-height: 44px; } /* 44px touch target */
  .btn-sm { min-height: 36px; padding: 8px 14px; }
  .btn-icon { width: 44px; height: 44px; }
  .nav-item { padding: 12px 14px; min-height: 44px; } /* touch-friendly nav */
  .chat-header-btn { width: 44px; height: 44px; }
  /* Table horizontal scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }
}

/* ─── Responsive: Mobile ─── */
@media (max-width: 480px) {
  :root { --header-height: 52px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card-value { font-size: 20px; }
  .main-header { padding: 0 10px; height: var(--header-height); }
  .main-header-title { font-size: 14px; gap: 6px; }
  .main-body { padding: 10px; }
  .kb-col { min-width: 260px !important; max-width: 300px; }
  .auth-card { margin: 8px; padding: 24px 20px; max-width: 100%; }
  .modal { max-width: calc(100vw - 16px); border-radius: 12px; }
  .funnel-summary-grid { grid-template-columns: 1fr; }
  .btn { font-size: 13px; }
  /* Bottom safe area for iOS */
  .chat-input-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .sidebar-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (min-width: 1400px) {
  .kb-col { min-width: 280px; max-width: 360px; }
}

/* ─── Extra utilities ─── */
.is_active_0 { opacity: 0.5; }
textarea.form-input { resize: vertical; font-family: inherit; }
select.form-input { cursor: pointer; }
.post-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
hr { border: none; border-top: 1px solid var(--border); }

/* ─── Scrollbar styling for kanban ─── */
.kb-board::-webkit-scrollbar { height: 8px; }
.kb-board::-webkit-scrollbar-track { background: var(--border-light); border-radius: 4px; }
.kb-board::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
.kb-board::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ─── Selection & Focus ─── */
::selection { background: var(--primary-bg); color: var(--primary-dark); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.1); }

/* ─── Smooth transitions ─── */
.btn, .stat-card, .content-card, .post-card, .kb-card, .quick-link-card {
  transition: all 0.2s ease;
}

/* ─── Touch Active States ─── */
@media (hover: none) and (pointer: coarse) {
  .btn:active { transform: scale(0.97); opacity: 0.85; }
  .btn-primary:hover { transform: none; box-shadow: none; }
  .stat-card:hover, .post-card:hover, .kb-card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .nav-item:active { background: var(--bg-sidebar-active); }
  .chat-room-item:active { background: #dcfce7; }
  .chat-user-item:active { background: #dcfce7; }
  .chat-quick-item:active { background: #f0fdf4; border-color: #0f766e; }
}

/* ─── Loading Spinner ─── */
.loading-spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Page Transition ─── */
.main-body > * { animation: fadeIn 0.15s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Improved Scrolling ─── */
.main-body, .sidebar-nav, .chat-messages, .chat-room-list, .chat-user-list, .modal-body {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ─── Safe area (notch devices) ─── */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-layout { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* ─── Status Colors (global) ─── */
.status-urgent { color: #ef4444; }
.status-high { color: #f59e0b; }
.status-normal { color: #6366f1; }
.status-low { color: #94a3b8; }

/* ─── Kanban Board ─── */
.kb-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px 14px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kb-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 400px;
  align-items: flex-start;
}
.kb-col {
  min-width: 260px;
  max-width: 320px;
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.kb-col.kb-drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
  background: #f0fdfa;
}
.kb-col-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  border-bottom: 3px solid var(--col-color, var(--primary));
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-card);
}
.kb-col-count {
  font-size: 11px;
  font-weight: 700;
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.kb-col-body {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
}
.kb-col-empty {
  text-align: center;
  padding: 24px 8px;
  color: var(--text-muted);
  font-size: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.kb-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.15s, opacity 0.15s;
  border-left: 4px solid var(--accent, var(--primary));
  position: relative;
}
.kb-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kb-card:active { cursor: grabbing; }
.kb-card.kb-dragging {
  opacity: 0.4;
  transform: scale(0.95);
  box-shadow: none;
}
.kb-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}
.kb-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}
.kb-card-badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: color-mix(in srgb, var(--badge-color, #6366f1) 15%, transparent);
  color: var(--badge-color, #6366f1);
}
.kb-card-info {
  color: var(--text-muted);
  font-size: 11px;
}

/* ─── Hire Module ─── */
.hire-posting-card:hover, .hire-applicant-card:hover, .hire-interview-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.onboard-task:hover { background: var(--border-light) !important; }
#hireStatusFilter .active, #appStatusFilter .active {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
}

/* ─── Treatment Board Extra ─── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.tb-summary { margin-bottom: 8px; }

/* ═══════════════════════════════════════════════════
   Patient Funnel Analytics Styles
   ═══════════════════════════════════════════════════ */
.funnel-controls { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:12px; }
.funnel-tabs { display:flex; gap:2px; background:var(--bg); border-radius:var(--radius-sm); padding:3px; }
.funnel-tab-btn { padding:8px 16px; border:none; background:transparent; border-radius:4px; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; color:var(--text-secondary); transition:var(--transition); }
.funnel-tab-btn.active { background:var(--bg-card); color:var(--primary); box-shadow:var(--shadow-sm); }
.funnel-tab-btn:hover:not(.active) { color:var(--text); }
.funnel-period-btns { display:flex; gap:4px; }
.funnel-loading { text-align:center; padding:60px 20px; }
.funnel-empty { text-align:center; padding:40px; color:var(--text-muted); }
.funnel-empty-small { text-align:center; padding:20px; color:var(--text-muted); font-size:13px; }

/* Summary Cards */
.funnel-summary-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px; margin-bottom:20px; }
.funnel-summary-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; display:flex; align-items:center; gap:14px; transition:var(--transition); }
.funnel-summary-card:hover { box-shadow:var(--shadow-md); transform:translateY(-2px); }
.funnel-summary-icon { font-size:24px; width:48px; height:48px; border-radius:var(--radius); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.funnel-summary-body { flex:1; min-width:0; }
.funnel-summary-label { font-size:12px; color:var(--text-secondary); font-weight:500; }
.funnel-summary-value { font-size:24px; font-weight:800; line-height:1.2; margin-top:2px; }
.funnel-summary-sub { font-size:11px; color:var(--text-muted); margin-top:2px; }

/* Funnel Visualization */
.funnel-viz-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; margin-bottom:20px; }
.funnel-viz-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.funnel-viz-title { font-size:18px; font-weight:800; }
.funnel-viz-subtitle { font-size:12px; color:var(--text-muted); margin-top:2px; }
.funnel-viz-container { max-width:100%; }
.funnel-stage-row { display:flex; align-items:center; gap:10px; padding:6px 0; cursor:pointer; transition:background .15s; border-radius:var(--radius-sm); }
.funnel-stage-row:hover { background:var(--border-light); }
.funnel-stage-info { display:flex; align-items:center; gap:8px; width:130px; flex-shrink:0; }
.funnel-stage-icon { font-size:20px; width:28px; text-align:center; }
.funnel-stage-label-wrap { display:flex; flex-direction:column; }
.funnel-stage-label { font-size:13px; font-weight:700; }
.funnel-stage-desc { font-size:10px; color:var(--text-muted); display:none; }
.funnel-stage-bar-area { flex:1; display:flex; flex-direction:column; gap:2px; position:relative; }
.funnel-stage-bar-track { height:30px; background:var(--border-light); border-radius:6px; position:relative; overflow:hidden; margin:0 auto; border:1px solid var(--border); transition:all .2s; }
.funnel-stage-bar-fill { height:100%; border-radius:5px; transition:width .6s ease-out; }
.funnel-stage-count { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:800; color:var(--text); z-index:1; }
.funnel-stage-arrow { font-size:11px; font-weight:700; text-align:center; line-height:1; }
.funnel-stage-metrics { display:flex; align-items:center; gap:6px; width:180px; flex-shrink:0; justify-content:flex-end; }
.funnel-metric-badge { padding:2px 8px; border-radius:10px; font-size:11px; font-weight:600; white-space:nowrap; }
.funnel-metric-time { font-size:10px; color:var(--text-muted); white-space:nowrap; }
.funnel-trend { font-size:11px; font-weight:600; }
.funnel-trend.up { color:#22c55e; }
.funnel-trend.down { color:#ef4444; }

/* Amounts Row */
.funnel-amounts-row { display:flex; gap:12px; margin-top:20px; padding-top:16px; border-top:1px solid var(--border-light); }
.funnel-amount-item { flex:1; text-align:center; }
.funnel-amount-label { font-size:11px; color:var(--text-muted); display:block; }
.funnel-amount-value { font-size:18px; font-weight:800; margin-top:2px; display:block; }

/* Bottleneck Card */
.funnel-bottleneck-card { background:linear-gradient(135deg,#fef2f2,#fff7ed); border:1px solid #fecaca; border-radius:var(--radius); padding:18px 20px; margin-bottom:20px; display:flex; gap:14px; }
.funnel-bottleneck-header { display:flex; align-items:center; gap:14px; }
.funnel-bottleneck-icon { font-size:28px; flex-shrink:0; }
.funnel-bottleneck-title { font-size:15px; font-weight:700; color:#dc2626; }
.funnel-bottleneck-desc { font-size:12px; color:#92400e; margin-top:2px; }

/* Actions Card */
.funnel-actions-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; margin-bottom:20px; }
.funnel-actions-title { font-size:16px; font-weight:800; margin-bottom:16px; }
.funnel-actions-list { display:flex; flex-direction:column; gap:10px; }
.funnel-action-item { display:flex; gap:14px; padding:14px 16px; border-radius:var(--radius); border:1px solid var(--border); transition:var(--transition); }
.funnel-action-item:hover { box-shadow:var(--shadow-sm); }
.funnel-action-item.priority-critical { border-left:4px solid #ef4444; background:#fef2f2; }
.funnel-action-item.priority-high { border-left:4px solid #f59e0b; background:#fffbeb; }
.funnel-action-item.priority-medium { border-left:4px solid #22c55e; background:#f0fdf4; }
.funnel-action-priority { font-size:11px; font-weight:700; white-space:nowrap; padding-top:2px; }
.funnel-action-body { flex:1; min-width:0; }
.funnel-action-title-text { font-size:14px; font-weight:700; margin-bottom:4px; }
.funnel-action-desc { font-size:12px; color:var(--text-secondary); line-height:1.6; margin-bottom:4px; }
.funnel-action-impact { font-size:11px; color:var(--primary); font-weight:600; }

/* Insight Grid */
.funnel-insight-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:16px; margin-bottom:20px; }
.funnel-insight-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); padding:20px; }
.funnel-insight-title { font-size:14px; font-weight:700; margin-bottom:14px; }
.funnel-source-list { display:flex; flex-direction:column; gap:8px; }
.funnel-source-row { display:flex; align-items:center; gap:8px; }
.funnel-source-rank { width:20px; height:20px; border-radius:50%; background:var(--bg); font-size:10px; font-weight:700; display:flex; align-items:center; justify-content:center; color:var(--text-secondary); flex-shrink:0; }
.funnel-source-name { font-size:13px; font-weight:500; width:80px; flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.funnel-source-bar-wrap { flex:1; height:8px; background:var(--border-light); border-radius:4px; overflow:hidden; }
.funnel-source-bar { height:100%; background:var(--accent); border-radius:4px; transition:width .4s; }
.funnel-source-count { font-size:12px; font-weight:600; color:var(--text-secondary); white-space:nowrap; }

/* Patient Filter Tabs */
.funnel-filter-tabs { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:16px; }
.funnel-filter-tab { font-size:11px !important; }
.funnel-filter-tab.active { background:var(--primary) !important; color:white !important; border-color:var(--primary) !important; }

/* Patient Cards */
.funnel-patients-grid { display:grid; gap:8px; }
.funnel-patient-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:14px 18px; display:flex; align-items:center; gap:14px; cursor:pointer; transition:var(--transition); }
.funnel-patient-card:hover { box-shadow:var(--shadow-sm); }
.funnel-patient-icon { width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.funnel-patient-info { flex:1; min-width:0; }
.funnel-patient-name { display:flex; align-items:center; gap:8px; font-weight:700; font-size:14px; flex-wrap:wrap; }
.funnel-patient-stage { font-size:10px; padding:2px 8px; border-radius:8px; font-weight:600; }
.funnel-patient-source { font-size:10px; color:var(--text-muted); }
.funnel-patient-meta { font-size:11px; color:var(--text-muted); margin-top:3px; }
.funnel-patient-progress { display:flex; gap:4px; }
.funnel-progress-dot { width:8px; height:8px; border-radius:50%; background:#e5e7eb; transition:background .2s; }
.funnel-progress-dot.active { }

/* Detail Progress */
.funnel-detail-progress { display:flex; gap:4px; margin-bottom:12px; }
.funnel-detail-step { flex:1; height:6px; border-radius:3px; background:#e5e7eb; }
.funnel-detail-step.done { }

/* Skeleton UI */
.skeleton { background:linear-gradient(90deg,var(--border-light) 25%,var(--border) 50%,var(--border-light) 75%); background-size:200% 100%; animation:skeleton-pulse 1.5s ease-in-out infinite; border-radius:var(--radius-sm); }
@keyframes skeleton-pulse { 0% { background-position:200% 0; } 100% { background-position:-200% 0; } }
.skeleton-text { height:14px; margin-bottom:8px; }
.skeleton-card { height:80px; border-radius:var(--radius); margin-bottom:12px; }
.skeleton-stat { height:100px; border-radius:var(--radius); }

/* Error Boundary */
.error-boundary { background:#fef2f2; border:1px solid #fecaca; border-radius:var(--radius); padding:20px; text-align:center; }
.error-boundary-icon { font-size:32px; margin-bottom:8px; }
.error-boundary-title { font-size:15px; font-weight:700; color:#dc2626; margin-bottom:4px; }
.error-boundary-msg { font-size:13px; color:#92400e; margin-bottom:12px; }
.error-boundary-btn { padding:8px 16px; background:#ef4444; color:white; border:none; border-radius:var(--radius-sm); font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; }
.error-boundary-btn:hover { background:#dc2626; }

@media (max-width: 768px) {
  .funnel-summary-grid { grid-template-columns: 1fr 1fr; }
  .funnel-stage-info { width:80px; }
  .funnel-stage-desc { display:none !important; }
  .funnel-stage-metrics { width:100px; }
  .funnel-insight-grid { grid-template-columns: 1fr; }
  .funnel-controls { flex-direction:column; align-items:stretch; }
  .funnel-stage-row { gap:6px; }
  .funnel-metric-time { display:none; }
}
@media (max-width: 480px) {
  .funnel-summary-grid { grid-template-columns: 1fr; }
  .funnel-stage-metrics { width:80px; }
}

/* ═══════════════════════════════════════════════════
   Common Utility Classes (replaces inline styles)
   ═══════════════════════════════════════════════════ */

/* Layout */
.flex { display:flex; }
.flex-1 { flex:1; }
.flex-col { display:flex; flex-direction:column; }
.flex-center { display:flex; align-items:center; justify-content:center; }
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.flex-wrap { flex-wrap:wrap; }
.items-center { align-items:center; }
.gap-4 { gap:4px; } .gap-6 { gap:6px; } .gap-8 { gap:8px; } .gap-10 { gap:10px; } .gap-12 { gap:12px; } .gap-14 { gap:14px; } .gap-16 { gap:16px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* Spacing */
.mb-4 { margin-bottom:4px; } .mb-8 { margin-bottom:8px; } .mb-12 { margin-bottom:12px; } .mb-16 { margin-bottom:16px; } .mb-20 { margin-bottom:20px; } .mb-24 { margin-bottom:24px; }
.mt-4 { margin-top:4px; } .mt-8 { margin-top:8px; } .mt-12 { margin-top:12px; } .mt-16 { margin-top:16px; }
.p-14 { padding:14px; } .p-16 { padding:16px; } .p-20 { padding:20px; } .p-24 { padding:24px; }

/* Text */
.text-center { text-align:center; }
.text-right { text-align:right; }
.text-xs { font-size:10px; } .text-sm { font-size:11px; } .text-base { font-size:12px; } .text-md { font-size:13px; } .text-lg { font-size:14px; } .text-xl { font-size:16px; } .text-2xl { font-size:18px; } .text-3xl { font-size:24px; } .text-4xl { font-size:28px; }
.font-500 { font-weight:500; } .font-600 { font-weight:600; } .font-700 { font-weight:700; } .font-800 { font-weight:800; }
.text-muted { color:var(--text-muted); }
.text-secondary { color:var(--text-secondary); }
.text-primary { color:var(--primary); }
.text-success { color:#22c55e; }
.text-danger { color:#ef4444; }
.text-warning { color:#f59e0b; }
.text-info { color:#3b82f6; }
.truncate { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.whitespace-nowrap { white-space:nowrap; }

/* Common Card */
.card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); }
.card-lg { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; }
.card-sm { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:14px; text-align:center; }
.card:hover, .card-lg:hover { box-shadow:var(--shadow-sm); }

/* Module header pattern */
.mod-title { margin:0 0 14px; font-size:14px; font-weight:800; }
.mod-label { font-size:12px; font-weight:700; display:block; margin-bottom:4px; }
.mod-label-sm { font-size:13px; font-weight:600; display:block; margin-bottom:4px; }
.mod-sub { color:var(--text-muted); display:block; font-size:10px; margin-bottom:2px; }
.mod-muted-xs { font-size:10px; color:var(--text-muted); }
.mod-muted-sm { font-size:11px; color:var(--text-muted); }
.mod-muted-sm-bold { font-size:11px; color:var(--text-muted); font-weight:600; }
.mod-muted-xs-bold { font-size:10px; color:var(--text-muted); font-weight:600; }
.mod-empty { text-align:center; padding:40px; color:var(--text-muted); }

/* Common Input */
.input-sm { padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:12px; background:var(--bg-card); font-family:inherit; outline:none; }
.input-md { width:100%; padding:10px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:var(--bg-card); font-family:inherit; outline:none; }
.input-outline { width:100%; padding:10px; border:1px solid #d1d5db; border-radius:8px; font-family:inherit; outline:none; }
.input-sm:focus, .input-md:focus, .input-outline:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(15,118,110,0.1); }

/* Table styles */
.tbl-header { padding:10px 8px; text-align:left; font-weight:700; font-size:11px; color:var(--text-muted); }
.tbl-cell { padding:10px 8px; text-align:right; border-bottom:2px solid var(--border); }
.tbl-cell-center { padding:8px; text-align:center; }

/* Pill / Badge */
.pill { display:inline-flex; padding:2px 8px; border-radius:10px; font-size:11px; font-weight:600; }
.pill-sm { display:inline-flex; padding:1px 6px; border-radius:8px; font-size:10px; font-weight:600; }

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

/* ═══════════════════════════════════════
   Chat Panel (원내 메신저)
   ═══════════════════════════════════════ */

/* Backdrop */
.chat-panel-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.3); z-index:999; opacity:0; pointer-events:none; transition:opacity 0.2s; }
.chat-panel-backdrop.open { opacity:1; pointer-events:auto; }

/* Panel */
.chat-panel { position:fixed; top:0; right:-400px; width:380px; height:100vh; height:100dvh; background:#fff; z-index:1000; display:flex; flex-direction:column; box-shadow:-4px 0 24px rgba(0,0,0,0.12); transition:right 0.25s cubic-bezier(0.4,0,0.2,1); border-left:1px solid #e2e8f0; will-change:right; }
.chat-panel.open { right:0; }
@media(max-width:480px) { .chat-panel { width:100vw; right:-100vw; } .chat-panel.open { right:0; } }
@media(max-width:768px) { .chat-panel { width:100vw; right:-100vw; } .chat-panel.open { right:0; } }

/* Header */
.chat-panel-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #f1f5f9; background:#fafffe; min-height:52px; }
.chat-panel-header-title { display:flex; align-items:center; gap:8px; }
.chat-panel-header-title h3 { font-size:15px; font-weight:800; color:#0f766e; margin:0; }
.chat-panel-icon { font-size:20px; }
.chat-panel-header-actions { display:flex; align-items:center; gap:4px; }
.chat-btn-icon { width:36px; height:36px; border:none; background:transparent; border-radius:8px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:#64748b; transition:all 0.15s; min-width:36px; }
.chat-btn-icon:hover { background:#f1f5f9; color:#0f766e; }

/* Room List */
.chat-room-list { flex:1; overflow-y:auto; }
.chat-room-item { display:flex; align-items:center; padding:12px 16px; cursor:pointer; transition:background 0.12s; gap:12px; border-bottom:1px solid #f8fafc; }
.chat-room-item:hover { background:#f0fdf4; }
.chat-room-item.unread { background:#f0fdf4; }
.chat-room-avatar { width:42px; height:42px; border-radius:50%; background:#0f766e; color:white; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:16px; flex-shrink:0; }
.chat-room-avatar.group { background:#3b82f6; font-size:18px; }
.chat-room-info { flex:1; min-width:0; }
.chat-room-name { font-size:13px; font-weight:700; color:#1e293b; display:flex; align-items:center; gap:6px; }
.chat-room-count { font-size:10px; color:#94a3b8; font-weight:400; }
.chat-room-last-msg { font-size:12px; color:#94a3b8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.chat-room-meta { display:flex; flex-direction:column; align-items:flex-end; gap:4px; flex-shrink:0; }
.chat-room-time { font-size:10px; color:#94a3b8; white-space:nowrap; }
.chat-room-badge { background:#ef4444; color:white; font-size:10px; font-weight:700; min-width:18px; height:18px; border-radius:9px; display:flex; align-items:center; justify-content:center; padding:0 5px; }

/* Chat Empty */
.chat-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 20px; text-align:center; }

/* Messages */
.chat-messages { flex:1; overflow-y:auto; padding:12px 16px; background:#f8fafc; }

/* Date Divider */
.chat-date-divider { text-align:center; margin:16px 0 12px; position:relative; }
.chat-date-divider::before { content:''; position:absolute; top:50%; left:0; right:0; height:1px; background:#e2e8f0; }
.chat-date-divider span { position:relative; background:#f8fafc; padding:0 12px; font-size:11px; color:#94a3b8; font-weight:600; }

/* Message Bubbles */
.chat-msg { display:flex; gap:8px; margin-bottom:6px; }
.chat-msg.consecutive { margin-bottom:2px; }
.chat-msg.mine { justify-content:flex-end; }
.chat-msg.other { justify-content:flex-start; }

.chat-msg-avatar { width:32px; height:32px; border-radius:50%; color:white; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; flex-shrink:0; margin-top:4px; }
.chat-msg-avatar-spacer { width:32px; flex-shrink:0; }

.chat-msg-content { max-width:75%; }
.chat-msg-sender { display:flex; align-items:center; gap:6px; margin-bottom:2px; }
.chat-msg-sender-name { font-size:12px; font-weight:700; color:#1e293b; }
.chat-msg-sender-role { font-size:10px; color:#94a3b8; font-weight:500; }

.chat-bubble { padding:8px 12px; border-radius:16px; font-size:13px; line-height:1.5; word-break:break-word; }
.chat-bubble.mine { background:#0f766e; color:white; border-bottom-right-radius:4px; }
.chat-bubble.other { background:white; color:#1e293b; border:1px solid #e2e8f0; border-bottom-left-radius:4px; }

.chat-msg-meta { display:flex; align-items:center; gap:6px; margin-top:2px; }
.chat-msg-time { font-size:10px; color:#94a3b8; }
.chat-read-label { font-size:10px; color:#0f766e; font-weight:600; }
.chat-msg.mine .chat-msg-meta { justify-content:flex-end; }

.chat-msg-quick { background:rgba(255,255,255,0.2); padding:1px 6px; border-radius:4px; font-size:11px; }
.chat-bubble.other .chat-msg-quick { background:rgba(15,118,110,0.1); }

.chat-msg-board-link { margin-top:6px; padding:6px 10px; background:rgba(255,255,255,0.15); border-radius:8px; font-size:12px; cursor:pointer; transition:background 0.15s; }
.chat-msg-board-link:hover { background:rgba(255,255,255,0.25); }
.chat-bubble.other .chat-msg-board-link { background:#f0fdf4; }
.chat-bubble.other .chat-msg-board-link:hover { background:#dcfce7; }

/* Input Area */
.chat-input-area { display:flex; align-items:center; gap:8px; padding:12px 16px; border-top:1px solid #f1f5f9; background:white; }
.chat-input { flex:1; padding:10px 14px; border:1.5px solid #e2e8f0; border-radius:20px; font-size:13px; font-family:inherit; outline:none; transition:border-color 0.15s; }
.chat-input:focus { border-color:#0f766e; box-shadow:0 0 0 3px rgba(15,118,110,0.08); }
.chat-send-btn { width:44px; height:44px; border:none; background:#0f766e; color:white; border-radius:50%; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:background 0.15s; flex-shrink:0; }
.chat-send-btn:hover { background:#0d9488; }

/* Quick Message Bar */
.chat-quick-bar { border-top:1px solid #f1f5f9; background:#fafffe; max-height:200px; overflow-y:auto; }
.chat-quick-list { padding:8px 12px; }
.chat-quick-category { font-size:10px; font-weight:700; color:#94a3b8; text-transform:uppercase; padding:6px 4px 4px; }
.chat-quick-item { display:inline-flex; align-items:center; gap:4px; padding:6px 12px; margin:2px; border:1px solid #e2e8f0; background:white; border-radius:16px; font-size:12px; cursor:pointer; transition:all 0.12s; font-family:inherit; }
.chat-quick-item:hover { border-color:#0f766e; background:#f0fdf4; color:#0f766e; }
.chat-quick-item.emergency { border-color:#fca5a5; color:#ef4444; }
.chat-quick-item.emergency:hover { background:#fef2f2; border-color:#ef4444; }

/* Search Bar */
.chat-search-bar { padding:8px 16px; border-bottom:1px solid #f1f5f9; }
.chat-search-input { width:100%; padding:8px 12px; border:1.5px solid #e2e8f0; border-radius:10px; font-size:13px; font-family:inherit; outline:none; }
.chat-search-input:focus { border-color:#0f766e; }

/* User List */
.chat-user-list { flex:1; overflow-y:auto; }
.chat-user-item { display:flex; align-items:center; padding:10px 16px; gap:10px; cursor:pointer; transition:background 0.12s; border-bottom:1px solid #f8fafc; }
.chat-user-item:hover { background:#f0fdf4; }
.chat-user-avatar { width:36px; height:36px; border-radius:50%; color:white; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; flex-shrink:0; }
.chat-user-info { flex:1; min-width:0; }
.chat-user-name { font-size:13px; font-weight:600; color:#1e293b; }
.chat-user-role { font-size:11px; color:#94a3b8; }

/* Selected Members */
.chat-selected-members { display:flex; flex-wrap:wrap; gap:4px; }

/* Footer */
.chat-panel-footer { padding:12px 16px; border-top:1px solid #f1f5f9; background:white; }
.chat-create-group-btn { width:100%; padding:10px; background:#0f766e; color:white; border:none; border-radius:10px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit; }
.chat-create-group-btn:disabled { opacity:0.5; cursor:not-allowed; }
.chat-create-group-btn:not(:disabled):hover { background:#0d9488; }

/* Chat Nav Badge */
.chat-nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:16px; height:16px; padding:0 4px; background:#ef4444; color:white; border-radius:8px; font-size:9px; font-weight:700; margin-left:auto; }

/* Header Chat Button */
.chat-header-btn { position:relative; width:36px; height:36px; border:none; background:#f0fdf4; border-radius:10px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:#0f766e; transition:all 0.15s; }
.chat-header-btn:hover { background:#dcfce7; }

/* ═══════════════════════════════════════════════════
   Onboarding Wizard
   ═══════════════════════════════════════════════════ */
.ob-wrapper { min-height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg, #f0fdfa 0%, #e0f2fe 50%, #faf5ff 100%); padding:20px; }
.ob-container { background:white; border-radius:24px; box-shadow:0 25px 60px rgba(0,0,0,0.08); max-width:680px; width:100%; padding:40px; animation:obFadeIn 0.4s ease; }
@keyframes obFadeIn { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

/* Progress */
.ob-progress { margin-bottom:32px; }
.ob-progress-bar { height:4px; background:#e2e8f0; border-radius:4px; overflow:hidden; margin-bottom:16px; }
.ob-progress-fill { height:100%; background:linear-gradient(90deg, var(--primary), #14b8a6); border-radius:4px; transition:width 0.5s cubic-bezier(0.4,0,0.2,1); }
.ob-steps { display:flex; justify-content:space-between; }
.ob-step-dot { width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; border:2px solid #e2e8f0; color:#94a3b8; background:white; transition:all 0.3s; }
.ob-step-dot.active { border-color:var(--primary); color:var(--primary); background:#f0fdfa; box-shadow:0 0 0 4px rgba(15,118,110,0.1); }
.ob-step-dot.done { border-color:var(--success); color:white; background:var(--success); }

/* Header */
.ob-header { text-align:center; margin-bottom:28px; }
.ob-icon { font-size:48px; margin-bottom:12px; display:inline-block; animation:obBounce 0.6s ease; }
@keyframes obBounce { 0%,100% { transform:scale(1); } 50% { transform:scale(1.15); } }
.ob-title { font-size:22px; font-weight:800; color:var(--text); margin:0 0 6px; }
.ob-desc { font-size:14px; color:var(--text-secondary); margin:0; }

/* Content */
.ob-content { min-height:200px; margin-bottom:24px; }

/* Actions */
.ob-actions { display:flex; justify-content:space-between; align-items:center; padding-top:20px; border-top:1px solid var(--border-light); }
.ob-btn { padding:10px 24px; font-size:14px; font-weight:700; border-radius:12px; min-width:100px; }
.ob-skip-btn { background:none; border:none; color:var(--text-muted); font-size:13px; cursor:pointer; padding:8px 12px; border-radius:8px; transition:all 0.15s; }
.ob-skip-btn:hover { background:#f1f5f9; color:var(--text-secondary); }

/* Hint */
.ob-hint { text-align:center; font-size:12px; color:var(--text-muted); margin-top:16px; padding:10px; background:#f8fafc; border-radius:10px; }

/* Tip inside steps */
.ob-tip { font-size:12px; color:var(--text-secondary); background:#f0fdfa; border-left:3px solid var(--primary); padding:10px 14px; border-radius:0 8px 8px 0; margin-top:16px; line-height:1.7; }

/* Welcome */
.ob-welcome-hero { text-align:center; margin-bottom:24px; }
.ob-welcome-hero h3 { font-size:18px; font-weight:700; margin:0 0 8px; }
.ob-feature-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:12px; }
.ob-feature-card { background:#f8fafc; border:1px solid var(--border-light); border-radius:14px; padding:16px 12px; text-align:center; transition:all 0.2s; }
.ob-feature-card:hover { border-color:var(--primary-light); background:#f0fdfa; transform:translateY(-2px); }
.ob-feature-icon { font-size:28px; display:block; margin-bottom:8px; }
.ob-feature-card strong { display:block; font-size:13px; margin-bottom:2px; }
.ob-feature-card small { font-size:11px; color:var(--text-muted); }

/* Chips */
.ob-chip-grid { display:flex; flex-wrap:wrap; gap:10px; }
.ob-chip-sm { gap:8px; }
.ob-chip { display:inline-flex; align-items:center; gap:6px; padding:10px 16px; border:2px solid #e2e8f0; border-radius:12px; cursor:pointer; font-size:13px; font-weight:600; background:white; transition:all 0.2s; user-select:none; }
.ob-chip:hover { border-color:var(--primary-light); background:#f0fdfa; }
.ob-chip.selected { border-color:var(--primary); background:#f0fdfa; color:var(--primary); box-shadow:0 0 0 3px rgba(15,118,110,0.08); }
.ob-chip-icon { font-size:18px; }
.ob-chip-small { padding:6px 12px; font-size:12px; border-radius:8px; }
.ob-chip-small .ob-chip-icon { font-size:14px; }

/* Section */
.ob-section { margin-bottom:20px; }
.ob-label { display:block; font-size:14px; font-weight:700; color:var(--text); margin-bottom:10px; }
.ob-divider { height:1px; background:var(--border-light); margin:20px 0; }

/* Hours */
.ob-hours-grid { display:flex; flex-direction:column; gap:12px; }
.ob-hours-row { display:flex; align-items:center; gap:12px; padding:12px 16px; background:#f8fafc; border-radius:12px; }
.ob-hours-label { display:flex; align-items:center; gap:8px; min-width:160px; cursor:pointer; font-size:13px; }
.ob-hours-label input[type="checkbox"] { width:18px; height:18px; accent-color:var(--primary); cursor:pointer; }
.ob-hours-times { display:flex; align-items:center; gap:8px; flex:1; transition:opacity 0.2s; }
.ob-time-input { width:110px !important; font-size:13px !important; padding:6px 10px !important; }

/* Floors */
.ob-floor-card { background:#f8fafc; border:1px solid var(--border); border-radius:14px; padding:16px; margin-bottom:12px; }
.ob-floor-header { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
.ob-floor-del { background:none; border:1px solid var(--border); color:var(--text-muted); width:28px; height:28px; border-radius:8px; padding:0; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.ob-floor-del:hover { color:var(--danger); border-color:var(--danger); }
.ob-space-list { display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.ob-space-row { display:flex; align-items:center; gap:8px; padding:8px 10px; background:white; border:1px solid var(--border-light); border-radius:10px; }
.ob-add-btn { width:100%; margin-top:8px; border-style:dashed; border-radius:12px; }
.ob-add-space { font-size:12px; border-style:dashed; }

/* Staff Counter */
.ob-staff-grid { display:flex; flex-direction:column; gap:10px; }
.ob-staff-row { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; background:#f8fafc; border-radius:12px; }
.ob-staff-info { display:flex; align-items:center; gap:8px; font-size:14px; font-weight:600; }
.ob-staff-icon { font-size:20px; }
.ob-counter { display:flex; align-items:center; gap:0; background:white; border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.ob-counter-btn { width:36px; height:36px; border:none; background:none; font-size:18px; font-weight:700; cursor:pointer; color:var(--text-secondary); transition:all 0.15s; display:flex; align-items:center; justify-content:center; }
.ob-counter-btn:hover { background:var(--primary); color:white; }
.ob-counter-btn:active { transform:scale(0.9); }
.ob-counter-val { width:40px; text-align:center; font-size:16px; font-weight:800; color:var(--text); }
.ob-staff-total { text-align:center; padding:14px; background:#f0fdfa; border-radius:12px; margin-top:16px; font-size:14px; }

/* Mobile */
@media (max-width: 640px) {
  .ob-container { padding:24px 16px; border-radius:16px; }
  .ob-feature-grid { grid-template-columns:repeat(2, 1fr); }
  .ob-hours-row { flex-direction:column; align-items:flex-start; gap:8px; }
  .ob-hours-times { width:100%; }
  .ob-space-row { flex-wrap:wrap; }
  .ob-space-row .form-input { min-width:0; }
  .ob-step-dot { width:26px; height:26px; font-size:10px; }
  .ob-title { font-size:18px; }
}
.chat-header-badge { position:absolute; top:-2px; right:-2px; min-width:16px; height:16px; padding:0 4px; background:#ef4444; color:white; border-radius:8px; font-size:9px; font-weight:700; display:flex; align-items:center; justify-content:center; border:2px solid white; }
