/* Основные переменные и глобальные стили */
:root {
  --bg-main: #f4f6fb;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-highlight: #edf1ff;
  --border-color: #e5e9f2;
  --text-primary: #1d2333;
  --text-secondary: #5c6378;
  --brand-primary: #37c074;
  --brand-secondary: #2f8fed;
  --accent-warning: #ffba5a;
  --badge-danger: #ff5d5d;
  --shadow-soft: 0 12px 32px rgba(24, 35, 82, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 24px;
  
  /* Schedule scale variables */
  --schedule-row-height: 3.33px;
  --schedule-column-width: 220px;
  --schedule-font-scale: 1;
  --schedule-time-column-width: 80px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-main);
  color: var(--text-primary);
}

/* ========== LOGIN PAGE ========== */
.login-page {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  height: 36px;
  width: auto;
  display: block;
  margin: 0 auto 10px auto;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  justify-content: center;
}

.brand.login-brand {
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.6px;
}

.login-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: #1a202c;
  margin: 0 0 8px 0;
}

.login-header p {
  font-size: 16px;
  color: #718096;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: #2d3748;
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:disabled {
  background-color: #f7fafc;
  cursor: not-allowed;
}

/* Password visibility toggle */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  width: 100%;
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #718096;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: #4a5568;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

.login-error {
  padding: 12px;
  background-color: #fed7d7;
  border: 1px solid #fc8181;
  border-radius: 8px;
  color: #c53030;
  font-size: 14px;
  text-align: center;
}

.login-button {
  padding: 14px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.login-button:active:not(:disabled) {
  transform: translateY(0);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========== APP SHELL ========== */
.app-shell {
  min-height: 100vh;
  background-color: var(--bg-main);
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 12px;
  background-color: var(--bg-sidebar);
  box-shadow: 1px 0 0 rgba(18, 27, 56, 0.06);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width 0.25s ease, padding 0.25s ease, box-shadow 0.25s ease;
}

/* Sidebar expanded state */
.sidebar.expanded {
  width: 280px;
  padding: 16px 24px;
  z-index: 200;
  box-shadow: 4px 0 24px rgba(18, 27, 56, 0.15);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background-color: rgba(47, 143, 237, 0.08);
  color: var(--brand-secondary);
}

.sidebar-toggle-icon {
  transition: transform 0.25s ease;
}

.sidebar.expanded .sidebar-toggle-icon {
  transform: rotate(90deg);
}

/* Sidebar navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Sidebar icon */
.sidebar-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: currentColor;
}

/* Sidebar text */
.sidebar-text {
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  margin-left: 12px;
}

.sidebar.expanded .sidebar-text {
  opacity: 1;
  visibility: visible;
}

.sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.sidebar-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar.expanded .sidebar-label {
  opacity: 1;
  visibility: visible;
}

.sidebar-entry {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-md);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, padding 0.25s ease;
  cursor: pointer;
  gap: 0;
}

.sidebar.expanded .sidebar-entry {
  padding: 10px 14px;
}

.sidebar-entry:hover {
  background-color: rgba(47, 143, 237, 0.08);
}

.sidebar-entry.active {
  background-color: rgba(47, 143, 237, 0.12);
  color: var(--brand-secondary);
  font-weight: 600;
}

.sidebar-entry.secondary {
  color: var(--text-secondary);
}

.sidebar-entry.secondary:hover {
  color: var(--text-primary);
}

.sidebar-entry .badge {
  justify-content: flex-end;
  margin-left: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar.expanded .sidebar-entry .badge {
  opacity: 1;
  visibility: visible;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
}

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

/* ========== MAIN AREA ========== */
.main-area {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  margin-left: 64px;
  height: 100vh;
  overflow-y: auto;
  transition: margin-left 0.25s ease;
}

/* ========== TOP BAR ========== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  position: sticky;
  top: 0;
  background-color: var(--bg-main);
  z-index: 200;
  flex-shrink: 0;
}

.top-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: rgba(18, 27, 56, 0.06);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-menu-btn:hover {
  background-color: rgba(47, 143, 237, 0.08);
  color: var(--brand-secondary);
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 22px;
  text-decoration: none;
}

.brand-mark {
  color: var(--brand-secondary);
}

.brand-accent {
  color: var(--brand-primary);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: none;
  background-color: #ffffff;
  box-shadow: 0 4px 10px rgba(31, 46, 85, 0.08);
  cursor: pointer;
  color: var(--text-secondary);
  transition: transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(31, 46, 85, 0.12);
  color: var(--brand-secondary);
}

.user-card-wrapper {
  position: relative;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background-color: #ffffff;
  box-shadow: 0 6px 18px rgba(31, 46, 85, 0.08);
  cursor: pointer;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  font-size: var(--font-size-md);
}

.user-role {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  overflow: hidden;
  z-index: 1000;
  display: none;
}

.user-menu.show {
  display: block;
}

.user-menu-item {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: var(--font-size-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.2s;
  display: block;
  text-decoration: none;
}

.user-menu-item:hover {
  background-color: rgba(47, 143, 237, 0.08);
}

.user-menu-item.logout {
  color: #e53e3e;
  border-top: 1px solid var(--border-color);
}

.user-menu-item.logout:hover {
  background-color: rgba(229, 62, 62, 0.08);
}

/* ========== GLOBAL PATIENT SEARCH ========== */
.global-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin: 0 24px;
}

.global-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.global-search-icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.2s;
}

.global-search-input {
  width: 100%;
  padding: 10px 120px 10px 40px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #ffffff;
  transition: all 0.2s;
}

.global-search-input:focus {
  outline: none;
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.12);
}

.global-search-input:focus + .global-search-icon,
.global-search-box:focus-within .global-search-icon {
  color: var(--brand-secondary);
}

.global-search-clear {
  position: absolute;
  right: 80px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.global-search-clear:hover {
  color: #64748b;
  background: #f1f5f9;
}

.global-search-shortcut {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.global-search-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.global-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  max-height: 420px;
  overflow: hidden;
  z-index: 1000;
}

.global-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: #64748b;
  font-size: 14px;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--brand-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.global-search-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.global-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s;
}

.global-search-item:hover,
.global-search-item.focused {
  background: #f1f5f9;
}

.global-search-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.global-search-item-info {
  flex: 1;
  min-width: 0;
}

.global-search-item-name {
  font-weight: 600;
  font-size: 14px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-search-item-details {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.global-search-item-phone {
  display: flex;
  align-items: center;
  gap: 4px;
}

.global-search-item-id {
  color: #94a3b8;
  font-size: 12px;
}

.global-search-item-birth {
  color: #64748b;
  font-size: 12px;
}

.global-search-item-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.global-search-item-badge.vip {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
}

.global-search-item-arrow {
  color: #cbd5e1;
  transition: transform 0.2s, color 0.2s;
}

.global-search-item:hover .global-search-item-arrow {
  color: var(--brand-secondary);
  transform: translateX(4px);
}

.global-search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.global-search-empty-text {
  font-size: 15px;
  font-weight: 500;
  color: #64748b;
}

.global-search-empty-hint {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Responsive global search */
@media (max-width: 992px) {
  .global-search-wrapper {
    max-width: 280px;
    margin: 0 16px;
  }
  
  .global-search-shortcut {
    display: none;
  }
  
  .global-search-input {
    padding-right: 40px;
  }
  
  .global-search-clear {
    right: 12px;
  }
}

@media (max-width: 768px) {
  .global-search-wrapper {
    display: none;
  }
}

.icon {
  display: block;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  padding: 0 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-x: auto;
  overflow-y: auto;
  min-height: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-shrink: 0;
}

.content-header h1 {
  margin: 0;
  font-size: var(--font-size-xl);
}

.content-tools {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Scale control for schedule grid */
.scale-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.scale-control button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scale-control button:hover {
  background: white;
  color: var(--brand-secondary);
}

.scale-control button.active {
  background: white;
  color: var(--brand-secondary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-sidebar-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.header-sidebar-toggle:hover {
  background: var(--bg-highlight);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary);
}

.header-sidebar-toggle.active {
  background: var(--brand-secondary);
  color: white;
  border-color: var(--brand-secondary);
}

.search-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background-color: #ffffff;
  box-shadow: 0 6px 16px rgba(31, 46, 85, 0.08);
  color: var(--text-secondary);
}

.search-field input {
  border: none;
  outline: none;
  font-size: var(--font-size-md);
  width: 180px;
  color: var(--text-primary);
  background: transparent;
}

.search-field input::placeholder {
  color: var(--text-secondary);
}

.primary-button {
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  border: none;
  background: linear-gradient(135deg, #2f8fed, #5ea8ff);
  color: #ffffff;
  font-weight: 600;
  font-size: var(--font-size-md);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(47, 143, 237, 0.2);
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(47, 143, 237, 0.3);
}

.secondary-button {
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-weight: 600;
  font-size: var(--font-size-md);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.secondary-button:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* ========== APPOINTMENTS PAGE COMPACT LAYOUT ========== */
.main-content:has(.appointments-layout) {
  gap: 8px;
}

/* ========== TASKS PAGE COMPACT LAYOUT ========== */
.main-content:has(.tasks-header) {
  gap: 0;
  padding-top: 16px;
  overflow-x: hidden;
}

.main-content:has(.tasks-section-tabs) {
  padding: 16px 0 0 0;
}

.main-content:has(.tasks-section-tabs) .tasks-section-tabs,
.main-content:has(.tasks-section-tabs) .tasks-header,
.main-content:has(.tasks-section-tabs) .filters-panel {
  padding-left: 32px;
  padding-right: 32px;
}

.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.tasks-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.tasks-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tasks-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tasks-header-actions .ghost-button {
  padding: 7px 12px;
  font-size: 13px;
  gap: 6px;
}

.tasks-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tasks-header-right .primary-button {
  padding: 8px 16px;
  font-size: 13px;
}

.tasks-header-right .view-buttons {
  padding: 3px;
}

.tasks-header-right .view-toggle-button {
  padding: 5px 12px;
  font-size: 13px;
}

.search-field-compact {
  padding: 6px 12px;
  min-width: 160px;
  max-width: 200px;
  gap: 6px;
}

.search-field-compact .icon {
  flex-shrink: 0;
  color: #9ca3af;
}

.search-field-compact input {
  width: 120px;
  font-size: 13px;
}

/* ========== TASKS TOOLBAR (LEGACY) ========== */
.tasks-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 12px;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(29, 35, 51, 0.08);
  background-color: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.ghost-button:hover {
  background-color: rgba(47, 143, 237, 0.05);
}

.view-buttons {
  display: flex;
  gap: 4px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
}

.view-toggle-button {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-weight: 500;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-button:hover {
  background: #e5e7eb;
  color: #374151;
}

.view-toggle-button.active {
  background: white;
  color: #1f2937;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Filters Panel */
.filters-panel {
  margin-top: 12px;
  padding: 16px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  z-index: 100;
}

.filters-panel.hidden {
  display: none;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filters-panel .filter-group {
  overflow: visible;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-bottom: 1px;
}

.custom-multiselect {
  position: relative;
  width: 100%;
}

/* ========== LOADING & ERROR STATES ========== */
.loading-state,
.error-state,
.info-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
}

.loading-state p,
.error-state p,
.info-state p {
  font-size: 16px;
  color: #64748b;
  margin: 0;
}

.error-state {
  color: #d32f2f;
}

.info-state {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 40px;
  margin: 40px 0;
}

.info-state p {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-more-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
}

.loading-more-indicator .spinner {
  width: 30px;
  height: 30px;
  border-width: 3px;
}

.loading-more-indicator p {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

.retry-button {
  padding: 10px 20px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.retry-button:hover {
  background: #2563eb;
}

/* ========== KANBAN BOARD ========== */
.patients-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
}

/* Patients Page Header */
.patients-page .page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.patients-page .page-header-left h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.patients-page .page-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 320px;
  padding: 10px 40px 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.1);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.clear-search-btn:hover {
  color: #4b5563;
}

/* Filter Group */
.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-select {
  padding: 10px 36px 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  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='%239ca3af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filter-select:focus {
  outline: none;
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.1);
}

/* Button Styles */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.button-primary {
  background: var(--brand-secondary);
  color: white;
}

.button-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(47, 143, 237, 0.3);
}

.button-secondary {
  background: #f3f4f6;
  color: var(--text-primary);
}

.button-secondary:hover {
  background: #e5e7eb;
}

.button-info {
  background: #dbeafe;
  color: #1e40af;
}

.button-info:hover {
  background: #bfdbfe;
}

.button-icon {
  font-size: 18px;
  font-weight: 700;
}

.button-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 4px 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #475569;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.button-icon-sm:hover {
  background: #e0f2fe;
  border-color: #0ea5e9;
  color: #0369a1;
}

.kanban-board {
  display: flex;
  gap: 16px;
  flex: 1;
  padding: 20px;
  background: #f8fafc;
  min-width: 0;
  overflow-x: auto;
}

.kanban-column {
  display: flex;
  flex-direction: column;
  min-width: 300px;
  max-width: 350px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.kanban-column-header {
  padding: 14px 16px;
  background: #fff;
  border-top: 4px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
  overflow: visible;
  z-index: 10;
}

.kanban-column-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.kanban-column-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-sort-dropdown {
  position: relative;
}

.column-sort-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.column-sort-btn:hover {
  background: #fff;
  border-color: #cbd5e1;
  color: #475569;
}

.column-sort-btn:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.sort-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow: hidden;
}

.sort-dropdown-menu.show {
  display: block;
}

.sort-dropdown-option {
  padding: 10px 14px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s;
}

.sort-dropdown-option:hover {
  background: #f1f5f9;
}

.sort-dropdown-option.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 500;
}

.column-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.column-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #e2e8f0;
  color: #64748b;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
  transition: all 0.2s;
  position: relative;
}

.column-help-icon:hover {
  background: #3b82f6;
  color: #fff;
  transform: scale(1.1);
}

.column-help-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
  max-width: 240px;
  text-align: left;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.column-help-icon::before {
  content: '';
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1e293b;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 10001;
}

.column-help-icon:hover::after,
.column-help-icon:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Payment status tooltip - uses JS for positioning to avoid overflow clipping */
.payment-tooltip {
  position: relative;
  cursor: help;
}

/* Tooltip container created by JS */
.payment-tooltip-popup {
  position: fixed;
  background: #1e293b;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: pre-line;
  min-width: 200px;
  max-width: 400px;
  text-align: left;
  line-height: 1.5;
  pointer-events: none;
  z-index: 100000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: tooltipFadeIn 0.15s ease-out;
}

.payment-tooltip-popup::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}

/* Tooltip показывается снизу когда не помещается сверху */
.payment-tooltip-popup.tooltip-bottom::before {
  bottom: auto;
  top: -6px;
  border-top-color: transparent;
  border-bottom-color: #1e293b;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Realization tooltip styles */
.realization-tooltip-popup {
  min-width: 220px;
  max-width: 350px;
}

.realization-tooltip-popup .tooltip-section {
  padding: 4px 0;
}

.realization-tooltip-popup .tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 3px 0;
}

.realization-tooltip-popup .tooltip-label {
  color: #94a3b8;
  font-size: 11px;
  flex-shrink: 0;
}

.realization-tooltip-popup .tooltip-value {
  color: #fff;
  font-size: 12px;
  text-align: right;
}

.realization-tooltip-popup .tooltip-header {
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.realization-tooltip-popup .tooltip-divider {
  height: 1px;
  background: #334155;
  margin: 8px 0;
}

.realization-tooltip-popup .tooltip-procedures {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.realization-tooltip-popup .tooltip-proc-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.realization-tooltip-popup .tooltip-proc-name {
  color: #e2e8f0;
  font-size: 12px;
  flex: 1;
}

.realization-tooltip-popup .tooltip-proc-price {
  color: #10b981;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.realization-tooltip-popup .tooltip-linked-stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.realization-tooltip-popup .tooltip-stage-item {
  padding: 6px 8px;
  background: #334155;
  border-radius: 4px;
}

.realization-tooltip-popup .tooltip-stage-name {
  color: #fff;
  font-size: 12px;
  margin-bottom: 4px;
}

.realization-tooltip-popup .tooltip-plan-name {
  color: #94a3b8;
}

.realization-tooltip-popup .tooltip-stage-details {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 8px;
}

.realization-tooltip-popup .tooltip-stage-doctor {
  color: #6366f1;
  font-size: 11px;
  font-weight: 500;
}

.realization-tooltip-popup .tooltip-stage-date {
  color: #94a3b8;
  font-size: 11px;
}

.realization-tooltip-popup .tooltip-stage-amount {
  color: #10b981;
  font-size: 12px;
  font-weight: 500;
}

.patient-count {
  background: #e2e8f0;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.kanban-column-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  background-color: #f8fafc;
  transition: background-color 0.2s;
}

.kanban-column-content.drag-over {
  background-color: #f1f5f9;
}

.empty-column {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.kanban-column-content::-webkit-scrollbar {
  width: 6px;
}

.kanban-column-content::-webkit-scrollbar-track {
  background: transparent;
}

.kanban-column-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.kanban-column-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========== PATIENT CARD ========== */
.patient-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.patient-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.15);
  transform: translateY(-3px);
}

.patient-card:active {
  cursor: grabbing;
}

.patient-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.patient-card-header {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.patient-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
}

.patient-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.patient-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

.info-icon {
  font-size: 14px;
  flex-shrink: 0;
}

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

.patient-notes {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #854d0e;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(251, 191, 36, 0.2);
  border-left: 3px solid #f59e0b;
  position: relative;
}

.patient-notes::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 20px;
  width: 40px;
  height: 4px;
  background: rgba(251, 191, 36, 0.3);
  border-radius: 2px;
}

.notes-icon {
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1.4;
}

.notes-text {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.5;
  word-break: break-word;
  font-weight: 500;
}

/* Sticky Note стиль для textarea в модальном окне */
.sticky-note-textarea {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  padding: 12px;
  font-size: 14px;
  color: #854d0e;
  min-height: 100px;
  resize: vertical;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 2px rgba(251, 191, 36, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  transition: all 0.2s ease;
  position: relative;
}

.sticky-note-textarea::placeholder {
  color: #b45309;
  opacity: 0.6;
}

.sticky-note-textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(251, 191, 36, 0.2);
  background: linear-gradient(135deg, #fef9e7 0%, #fef3c7 100%);
}

/* ========== TASK CARD ========== */
.task-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.task-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.task-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.task-card.urgent {
  border-left: 3px solid #ef4444;
}

/* Выполненные задачи - с зелёной границей */
.task-card.done {
  border-left: 3px solid #22c55e;
}

/* Просроченные задачи - с красной границей */
.task-card.overdue {
  border-left: 3px solid #ef4444;
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  line-height: 1.4;
  flex: 1;
}

.priority-badge {
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.priority-badge.urgent {
  background: #ef4444;
}

.priority-badge.high {
  background: #f97316;
}

.priority-badge.medium {
  background: #eab308;
}

.priority-badge.low {
  background: #6b7280;
}

.task-type,
.task-dates,
.task-files,
.task-patients,
.task-assigned,
.task-doctor,
.task-date {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  color: #6b7280;
}

.task-label {
  color: #6b7280;
  font-weight: 500;
}

.task-value {
  color: #1f2937;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-description {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.task-modal {
  max-width: 800px;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #1e293b;
}

#modalTitle {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

#modalTitle .modal-title-sub {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
}

.patient-allergy-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  cursor: default;
}

.patient-allergy-badge .patient-allergy-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
  word-break: break-word;
  max-width: 280px;
  min-width: 120px;
  width: max-content;
  text-align: left;
  line-height: 1.5;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.patient-allergy-badge .patient-allergy-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1e293b;
}

.patient-allergy-badge:hover .patient-allergy-tooltip {
  display: block;
}

.sanitized-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: #64748b;
}

.sanitized-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #22c55e;
  cursor: pointer;
  margin: 0;
}

.sanitized-checkbox-label input[type="checkbox"]:checked + .sanitized-checkbox-text {
  color: #22c55e;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

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

/* Компактная таблица этапов */
#stagesListContent table {
  table-layout: auto;
}

#stagesListContent table tbody tr {
  transition: background-color 0.15s ease;
}

#stagesListContent table tbody tr:hover {
  background-color: #f8fafc;
}

#stagesListContent table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

/* Ограничение высоты модалки для компактного отображения */
#stagesModal .modal-body {
  max-height: calc(100vh - 200px);
  padding: 16px;
}

/* Стили для переключателя режима просмотра этапов */
.view-mode-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.view-mode-btn:hover {
  background: #e2e8f0;
  color: #334155;
}

.view-mode-btn.active {
  background: white;
  color: #0369a1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 14px;
  font-weight: 500;
  color: #475569;
}

.form-field input,
.form-field textarea,
.form-field select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

.form-field select {
  background: white;
  cursor: pointer;
}

/* ========== FORM SECTIONS (Секции формы пациента) ========== */
.form-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

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

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.form-section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title .section-icon {
  font-size: 16px;
  opacity: 0.8;
}

/* Вертикальный layout формы с фиксированной шириной инпутов */
.form-grid-narrow {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 450px;
  margin-left: auto;
}

.form-grid-narrow .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid-narrow .form-field input,
.form-grid-narrow .form-field select,
.form-grid-narrow .form-field textarea,
.form-grid-narrow .form-field .custom-select {
  width: 100%;
}

/* Строка из двух полей (напр. Дата рождения + Пол, Место работы + Должность) */
.form-row-inline {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  width: 100%;
}

.form-row-inline .form-field {
  flex: 1 1 auto;
}

.form-row-inline .form-field input,
.form-row-inline .form-field select {
  width: 100%;
}

.form-row-inline .form-field.flex-grow {
  flex: 1 1 140px;
}

.form-row-inline .form-field.compact {
  flex: 0 0 80px;
}

/* Секция представителя пациента */
.representative-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 20px;
  margin-top: 8px;
}

.representative-section .form-section-title {
  color: #0369a1;
}

.representative-section.auto-expanded {
  animation: highlightSection 2s ease-out;
}

@keyframes highlightSection {
  0% { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border-color: #fbbf24; }
  100% { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border-color: #bae6fd; }
}

.child-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #fef3c7;
  color: #a16207;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  margin-left: 8px;
}

/* Кнопки переключения типа приёма */
.appointment-type-btn {
  padding: 10px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.appointment-type-btn:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.appointment-type-btn.active {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

.appointment-type-btn.active.technical {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #b45309;
}

/* Стили для ошибок валидации */
.form-field.error label {
  color: #dc2626;
}

.form-field.error input,
.form-field.error textarea,
.form-field.error select {
  border-color: #dc2626;
  background-color: #fef2f2;
}

.form-field.error .month-btn {
  border-color: #fecaca;
}

.form-field.error::after {
  content: 'Это поле обязательно для заполнения';
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}

/* Time Picker Dropdown Styles */
.time-picker-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-dropdown-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.time-input {
  width: 44px;
  padding: 8px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px 0 0 6px;
  font-size: 14px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  text-align: center;
  cursor: text;
  transition: all 0.2s;
  background: white;
  caret-color: #3b82f6;
}

.time-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: #f8fafc;
  color: #64748b;
  font-size: 8px;
  cursor: pointer;
  transition: all 0.2s;
  height: 34px;
}

.time-dropdown-toggle:hover {
  background: #e2e8f0;
  color: #475569;
}

.time-dropdown-wrapper.open .time-dropdown-toggle {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.time-input:hover,
.time-input:hover + .time-dropdown-toggle {
  border-color: #94a3b8;
}

.time-input:focus,
.time-dropdown-wrapper.open .time-input {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.time-input:focus + .time-dropdown-toggle,
.time-dropdown-wrapper.open .time-input + .time-dropdown-toggle {
  border-color: #3b82f6;
}

.time-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.time-dropdown-wrapper.open .time-dropdown {
  display: block;
}

.time-dropdown-option {
  padding: 8px 12px;
  font-size: 14px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}

.time-dropdown-option:hover {
  background: #f1f5f9;
}

.time-dropdown-option.selected {
  background: #3b82f6;
  color: white;
}

.time-dropdown-option.selected:hover {
  background: #2563eb;
}

.time-separator {
  font-size: 16px;
  font-weight: 600;
  color: #64748b;
  padding: 0 2px;
}

/* Duration Buttons */
.duration-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.duration-label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  min-width: 16px;
  text-align: right;
}

.duration-buttons {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.duration-btn {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-width: 28px;
  text-align: center;
}

.duration-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.duration-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.duration-btn.active:hover {
  background: #2563eb;
  border-color: #2563eb;
}

/* Appointment modal - wider */
#appointmentModal .modal-content {
  max-width: 820px;
}

/* Prep Section */
.prep-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prep-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prep-checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.prep-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #3b82f6;
  cursor: pointer;
  margin: 0;
}

.prep-duration-buttons {
  margin-left: 0;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e2e8f0;
}

.footer-left,
.footer-right {
  display: flex;
  gap: 12px;
}

/* Follow-up menu styles */
.follow-up-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  font-size: 14px;
  color: #3b82f6;
  cursor: pointer;
  transition: background 0.15s;
}

.follow-up-option:hover {
  background: #f1f5f9;
}

.follow-up-option:not(:last-child) {
  border-bottom: 1px solid #f1f5f9;
}

.button {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: inherit;
}

.button-secondary {
  background: #f1f5f9;
  color: #475569;
}

.button-secondary:hover {
  background: #e2e8f0;
}

.button-info {
  background: #dbeafe;
  color: #1e40af;
}

.button-info:hover {
  background: #bfdbfe;
}

.button-primary {
  background: #3b82f6;
  color: white;
}

.button-primary:hover {
  background: #2563eb;
}

.button-primary.disabled,
.button-primary:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

.button-danger {
  background: #ef4444;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}

.button-danger:hover:not(:disabled) {
  background: #dc2626;
}

.button-danger:disabled {
  background: #fca5a5;
  cursor: not-allowed;
}

.button-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.button-warning:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Комментарии */
.comments-section {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid #e2e8f0;
}

.comments-section h3 {
  margin: 0 0 20px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.comment-form textarea {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  transition: all 0.2s;
}

.comment-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.comment-form button {
  align-self: flex-end;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
}

.comments-list::-webkit-scrollbar {
  width: 6px;
}

.comments-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.no-comments {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.comment-item {
  padding: 12px 12px 12px 16px;
  background: linear-gradient(to right, rgba(16, 185, 129, 0.08) 0%, transparent 100%);
  border-radius: 8px;
  border: 1px solid #d1fae5;
  border-left: 3px solid #10b981;
  position: relative;
}

.comment-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.comment-icon {
  font-size: 16px;
  line-height: 1;
  color: #10b981;
}

.comment-author {
  font-weight: 600;
  color: #047857;
  font-size: 13px;
}

.comment-date {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  margin-left: auto;
}

.comment-text {
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Системные комментарии */
.comment-item.system-comment {
  background: linear-gradient(to right, rgba(245, 158, 11, 0.08) 0%, transparent 100%);
  border: 1px solid #fef3c7;
  border-left: 3px solid #f59e0b;
}

.comment-item.system-comment .comment-icon {
  color: #d97706;
}

.comment-item.system-comment .comment-author {
  color: #b45309;
}

/* Комментарии о звонках */
.comment-item.call-comment {
  background: linear-gradient(to right, rgba(99, 102, 241, 0.08) 0%, transparent 100%);
  border: 1px solid #e0e7ff;
  border-left: 3px solid #6366f1;
}

.comment-item.call-comment .comment-icon {
  color: #6366f1;
}

.comment-item.call-comment .comment-author {
  color: #4338ca;
}

.call-provider-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e0e7ff;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.call-recording {
  margin-top: 8px;
}

.btn-play-recording {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #6366f1;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-play-recording:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #4338ca;
}

.btn-play-recording:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-play-recording svg {
  flex-shrink: 0;
}

.call-audio-player {
  margin-top: 4px;
}

.call-audio-player audio {
  border-radius: 8px;
}

.recording-unavailable {
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

/* События */
.event-item {
  padding: 12px 12px 12px 16px;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.03) 0%, transparent 100%);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #3b82f6;
  position: relative;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.event-icon {
  font-size: 16px;
  line-height: 1;
}

.event-type {
  font-weight: 600;
  color: #1e293b;
  font-size: 13px;
}

.event-date {
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
  white-space: nowrap;
}

.event-description {
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.event-changes {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  font-size: 12px;
}

.event-old-value {
  color: #ef4444;
  text-decoration: line-through;
  opacity: 0.7;
}

.event-arrow {
  color: #94a3b8;
}

.event-new-value {
  color: #10b981;
  font-weight: 500;
}

.event-user {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
  font-style: italic;
}

/* Кастомный мультиселект с чекбоксами */
.custom-multiselect {
  position: relative;
  width: 100%;
  z-index: 1;
}

/* Увеличиваем z-index когда мультиселект активен */
.custom-multiselect.is-open {
  z-index: 1050;
}

.multiselect-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 42px;
}

.multiselect-trigger:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.multiselect-trigger.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.multiselect-placeholder {
  color: #64748b;
  font-size: 14px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multiselect-placeholder.has-selections {
  color: #1e293b;
}

.multiselect-arrow {
  color: #94a3b8;
  font-size: 12px;
  transition: transform 0.2s;
  margin-left: 8px;
}

.multiselect-trigger.active .multiselect-arrow {
  transform: rotate(180deg);
}

.selected-patients-display {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-patient-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  transition: all 0.2s;
}

.selected-patient-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.selected-patient-item svg {
  color: #64748b;
  flex-shrink: 0;
}

.selected-patient-link {
  color: #0284c7;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.selected-patient-link:hover {
  color: #0369a1;
  text-decoration: underline;
}

.multiselect-dropdown {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1100;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.multiselect-search {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.multiselect-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.multiselect-search input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.multiselect-stages {
  padding: 8px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.stage-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.stage-btn:active {
  transform: scale(0.98);
}

.stage-btn.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
  font-weight: 500;
}

.stage-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.multiselect-options {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 250px;
  padding: 4px;
}

.multiselect-option {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
  font-size: 13px;
}

.multiselect-option:hover {
  background: #f8fafc;
}

.multiselect-option.hidden {
  display: none;
}

.multiselect-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.multiselect-option.selected .multiselect-checkbox {
  background: #3b82f6;
  border-color: #3b82f6;
}

.multiselect-checkbox::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
  display: none;
}

.multiselect-option.selected .multiselect-checkbox::after {
  display: block;
}

.multiselect-option-content {
  flex: 1;
  min-width: 0;
}

.multiselect-option-name {
  font-size: 14px;
  color: #1e293b;
  font-weight: 500;
  margin-bottom: 2px;
}

.multiselect-option-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Стили для иерархической структуры категорий */
.category-item {
  margin-bottom: 4px;
}

.category-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.category-header:hover {
  background: #f1f5f9;
}

.category-arrow {
  width: 16px;
  font-size: 10px;
  color: #64748b;
  margin-right: 8px;
  transition: transform 0.2s;
}

.category-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.category-count {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-left: 8px;
}

.category-content {
  margin-left: 20px;
  margin-top: 4px;
  padding-left: 4px;
  border-left: 2px solid #e2e8f0;
}

.subcategory-wrapper {
  margin-bottom: 4px;
}

.subcategory-item {
  padding: 8px 12px;
  margin-bottom: 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid #e2e8f0;
}

.subcategory-item:hover {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.subcategory-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
}

.subcategory-count {
  font-size: 11px;
  color: #64748b;
  margin-left: 8px;
}

.subcategory-content {
  margin-left: 20px;
  margin-top: 4px;
  padding-left: 4px;
  border-left: 2px solid #e2e8f0;
}

.service-item {
  padding: 8px 12px;
  margin-bottom: 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  background: white;
  border: 1px solid #e2e8f0;
}

.service-item:hover {
  background: #f0fdf4;
  border-color: #86efac;
  transform: translateX(2px);
}

.service-name {
  font-size: 13px;
  color: #0f172a;
  margin-bottom: 4px;
  font-weight: 500;
}

.service-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}

.service-price {
  color: #0369a1;
  font-weight: 600;
}

.service-code {
  color: #64748b;
  font-size: 10px;
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 3px;
}

.multiselect-option-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 11px;
  color: #475569;
}

.multiselect-empty {
  padding: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* ========== APPOINTMENTS PAGE ========== */
.appointments-layout {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 400px;
  overflow: visible;
  transition: gap 0.3s ease;
}

.appointments-layout .schedule-container {
  flex: 1 !important;
  min-width: 400px;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.3s ease;
  position: relative;
}

.appointments-sidebar {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: width 0.3s ease, padding 0.3s ease;
  position: relative;
}

.appointments-sidebar.collapsed {
  width: 48px;
  padding: 12px 8px;
  overflow: visible;
}

.appointments-sidebar.collapsed .sidebar-content {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.appointments-sidebar.collapsed .sidebar-collapsed-icons {
  display: flex;
}

.sidebar-collapsed-icons {
  display: none;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding-top: 8px;
}

.sidebar-collapsed-icons button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.sidebar-collapsed-icons button:hover {
  background: var(--brand-secondary);
  color: white;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  z-index: 10;
}

.sidebar-toggle-btn:hover {
  background: var(--brand-secondary);
  color: white;
}

.appointments-sidebar.collapsed .sidebar-toggle-btn {
  position: static;
  margin: 0 auto 8px;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.schedule-toolbar-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
}

.schedule-toolbar-compact .toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-toolbar-compact .select-field {
  width: 100%;
}

.schedule-toolbar-compact .select-field select {
  width: 100%;
}

.date-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.ghost-button-sm {
  padding: 8px 10px;
  min-width: 36px;
}

/* Doctor Calendar Styles */
.doctor-calendar-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 0;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.calendar-header span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.calendar-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.calendar-nav-btn:hover {
  background: var(--bg-highlight);
  color: var(--brand-secondary);
}

.calendar-months-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-month {
  min-width: 0;
}

.calendar-month-label {
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  padding-bottom: 4px;
  grid-column: 1 / -1;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-day-header {
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 0;
}

.calendar-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background 0.2s;
}

.calendar-day:not(.empty):hover {
  background: var(--bg-highlight);
}

.calendar-day.today:hover {
  background: var(--brand-secondary);
  filter: brightness(1.1);
}

.calendar-day.selected:hover {
  background: var(--brand-primary);
  filter: brightness(1.1);
}

.calendar-day.today.selected:hover {
  background: var(--brand-primary);
  filter: brightness(1.1);
}

.calendar-day.empty {
  cursor: default;
}

.calendar-day.today {
  background: var(--brand-secondary);
  color: white;
  font-weight: 600;
}

.calendar-day.selected {
  background: var(--brand-primary);
  color: white;
  font-weight: 600;
}

.calendar-day.today.selected {
  background: var(--brand-primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--brand-secondary);
}

.calendar-day.has-appointment {
  background: #dcfce7;
  border: 1.5px solid #22c55e;
  color: #15803d;
  font-weight: 600;
}

.calendar-day.has-appointment:not(.today):not(.selected):hover {
  background: #bbf7d0;
}

.calendar-day.fully-booked {
  background: #fee2e2;
  border: 1.5px solid #ef4444;
  color: #b91c1c;
  font-weight: 600;
}

.calendar-day.fully-booked:not(.today):not(.selected):hover {
  background: #fecaca;
}

.calendar-day.today.has-appointment {
  background: var(--brand-secondary);
  color: white;
  box-shadow: 0 0 0 2.5px #22c55e;
  border: none;
}

.calendar-day.today.fully-booked {
  background: var(--brand-secondary);
  color: white;
  box-shadow: 0 0 0 2.5px #ef4444;
  border: none;
}

.calendar-day.selected.has-appointment {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 0 0 2.5px #22c55e;
  border: none;
}

.calendar-day.selected.fully-booked {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 0 0 2.5px #ef4444;
  border: none;
}

.calendar-day.today.selected.has-appointment {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 0 0 2.5px #22c55e;
  border: none;
}

.calendar-day.today.selected.fully-booked {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 0 0 2.5px #ef4444;
  border: none;
}

.calendar-day-number {
  position: relative;
  z-index: 1;
}

.calendar-legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.calendar-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid transparent;
}

.calendar-legend-dot.has-appointment {
  background: #dcfce7;
  border-color: #22c55e;
}

.calendar-legend-dot.fully-booked {
  background: #fee2e2;
  border-color: #ef4444;
}

/* Past day styling for calendar */
.calendar-day.past-day {
  color: var(--text-tertiary);
  opacity: 0.5;
  cursor: not-allowed !important;
}

.calendar-day.past-day:hover {
  background: transparent;
}

/* Reschedule modal calendar */
.reschedule-calendar {
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
}

.appointments-sidebar .sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
}

.appointments-sidebar .sidebar-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.appointments-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 12px;
  background: var(--brand-secondary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.appointments-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.appointments-list::-webkit-scrollbar {
  width: 6px;
}

.appointments-list::-webkit-scrollbar-track {
  background: transparent;
}

.appointments-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.appointments-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.appointment-list-item {
  padding: 14px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appointment-list-item:hover {
  transform: translateX(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--brand-secondary);
}

.appointment-list-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-secondary);
  letter-spacing: 0.3px;
}

.appointment-list-patient {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.appointment-list-details {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.appointment-list-doctor {
  font-weight: 500;
}

.appointment-list-divider {
  color: var(--border-color);
}

.appointment-list-room {
  font-weight: 400;
}

.appointment-list-status {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.no-appointments {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
  font-size: 14px;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.loading-appointments {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 20px;
}

/* Patient Modal Layout */
.patient-modal-layout {
  display: flex;
  gap: 0;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.patient-form-section {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f2f2f7;
}

.patient-form-section::-webkit-scrollbar {
  width: 6px;
}

.patient-form-section::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.patient-form-section::-webkit-scrollbar-thumb {
  background: #c5c5c7;
  border-radius: 3px;
}

.patient-form-section::-webkit-scrollbar-thumb:hover {
  background: #a0a0a3;
}

/* ========== iOS-STYLE FORM SECTIONS ========== */

.patient-form-section .form-section {
  margin-bottom: 24px;
  padding-bottom: 0;
  border-bottom: none;
}

.patient-form-section .form-section:last-child {
  margin-bottom: 0;
}

.patient-form-section .form-section-header {
  margin-bottom: 8px;
  padding: 0 16px;
}

.patient-form-section .form-section-title {
  font-size: 13px;
  font-weight: 400;
  color: #6d6d72;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.patient-form-section .form-section-title .section-icon {
  display: none;
}

.patient-form-section .form-grid-narrow {
  width: 100%;
  margin-left: 0;
  gap: 0;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

.patient-form-section .form-grid-narrow .form-field {
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 11px 16px;
  border-bottom: 0.5px solid #c6c6c8;
  min-height: 44px;
  box-sizing: border-box;
}

.patient-form-section .form-grid-narrow .form-field:last-child {
  border-bottom: none;
}

.patient-form-section .form-grid-narrow .form-field label {
  width: 130px;
  min-width: 130px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 400;
  color: #1c1c1e;
  margin: 0;
}

.patient-form-section .form-grid-narrow .form-field input#lastName,
.patient-form-section .form-grid-narrow .form-field input#firstName,
.patient-form-section .form-grid-narrow .form-field input#middleName {
  font-size: 17px;
  font-weight: 500;
}

.patient-form-section .form-grid-narrow .form-field input,
.patient-form-section .form-grid-narrow .form-field select,
.patient-form-section .form-grid-narrow .form-field textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  font-size: 14px;
  color: #1c1c1e;
  flex: 1;
  min-width: 0;
  width: auto;
}

.patient-form-section .form-grid-narrow .form-field input:focus,
.patient-form-section .form-grid-narrow .form-field select:focus,
.patient-form-section .form-grid-narrow .form-field textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.patient-form-section .form-grid-narrow .form-field input::placeholder,
.patient-form-section .form-grid-narrow .form-field textarea::placeholder {
  color: #c7c7cc;
}

.patient-form-section .form-grid-narrow .form-field select {
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23c7c7cc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 16px;
}

/* iOS-style inline rows */
.patient-form-section .form-grid-narrow .form-row-inline {
  gap: 0;
  align-items: stretch;
  border-bottom: 0.5px solid #c6c6c8;
  padding: 0;
  width: 100%;
}

.patient-form-section .form-grid-narrow .form-row-inline:last-child {
  border-bottom: none;
}

.patient-form-section .form-grid-narrow .form-row-inline .form-field {
  border-bottom: none;
  padding: 11px 16px;
  border-right: 0.5px solid #c6c6c8;
  min-height: 44px;
}

.patient-form-section .form-grid-narrow .form-row-inline .form-field:last-child {
  border-right: none;
}

.patient-form-section .form-grid-narrow .form-row-inline .form-field label {
  width: auto;
  min-width: auto;
  margin-right: 8px;
}

/* Notes textarea - keep sticky note style but adapt to iOS group */
/* flex: 0 0 auto + align-self: stretch — позволяет JS autoResizeNotesTextarea растягивать высоту по содержимому */
.patient-form-section .form-grid-narrow .form-field .sticky-note-textarea {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: none;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 60px;
  font-size: 14px;
  color: #854d0e;
  box-shadow: none;
  flex: 0 0 auto;
  align-self: stretch;
}

.patient-form-section .form-grid-narrow .form-field .sticky-note-textarea:focus {
  box-shadow: none;
  background: linear-gradient(135deg, #fef9e7 0%, #fef3c7 100%);
}

/* Phone numbers inside iOS group */
.patient-form-section .form-grid-narrow .phone-numbers-container {
  flex: 1;
  min-width: 0;
}

.patient-form-section .phone-number-item {
  background: #f9f9f9;
  border: none;
  border-radius: 8px;
}

.patient-form-section .phone-number-item input[type="tel"] {
  border: none;
  background: transparent;
  padding: 8px 0;
}

.patient-form-section .phone-number-item input[type="tel"]:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

/* Custom select inside iOS group */
.patient-form-section .form-grid-narrow .form-field .custom-select {
  flex: 1;
  min-width: 0;
  width: auto;
}

.patient-form-section .form-grid-narrow .form-field .custom-select .select-trigger {
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
}

/* Accordion inside iOS groups */
.patient-form-section .accordion-container {
  max-width: none !important;
  margin-left: 0 !important;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  gap: 0;
}

.patient-form-section .accordion-item {
  border: none;
  border-radius: 0;
  border-bottom: 0.5px solid #c6c6c8;
}

.patient-form-section .accordion-item:last-child {
  border-bottom: none;
}

.patient-form-section .accordion-header {
  background: transparent;
  padding: 11px 16px;
  min-height: 44px;
}

.patient-form-section .accordion-header:hover {
  background: rgba(0, 0, 0, 0.03);
}

.patient-form-section .accordion-item.has-data {
  background: #f0f7ff;
  border-color: #c6c6c8;
}

.patient-form-section .accordion-item.has-data .accordion-header {
  background: transparent;
}

.patient-form-section .accordion-content .form-grid {
  gap: 0;
}

.patient-form-section .accordion-content .form-field {
  padding: 8px 0;
  border-bottom: 0.5px solid #e5e5ea;
}

.patient-form-section .accordion-content .form-field:last-child {
  border-bottom: none;
}

.patient-form-section .accordion-content .form-field input {
  border: none;
  border-bottom: 0.5px solid #e5e5ea;
  border-radius: 0;
  padding: 6px 0;
  background: transparent;
}

.patient-form-section .accordion-content .form-field input:focus {
  outline: none;
  box-shadow: none;
  border-bottom-color: #007aff;
}

/* Representative section iOS adaptation */
.patient-form-section .representative-section {
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 0;
  margin-top: 0;
  overflow: hidden;
}

.patient-form-section .representative-section .form-section-header {
  padding: 12px 16px;
  margin-bottom: 0;
  border-bottom: 0.5px solid #c6c6c8;
}

.patient-form-section .representative-section .form-section-title {
  color: #007aff;
  text-transform: none;
  font-size: 14px;
  font-weight: 600;
}

.patient-form-section .representative-section .form-section-title .section-icon {
  display: inline;
}

.patient-form-section .representative-section .form-grid-narrow {
  border-radius: 0;
}

/* Validation errors in iOS style */
.patient-form-section .form-field.error label {
  color: #ff3b30;
}

.patient-form-section .form-field.error input,
.patient-form-section .form-field.error textarea,
.patient-form-section .form-field.error select {
  border: none;
  background-color: rgba(255, 59, 48, 0.05);
}

/* Buttons inside iOS groups */
.patient-form-section .form-grid-narrow .button-secondary {
  background: transparent;
  border: none;
  color: #007aff;
  padding: 8px 0;
  font-size: 14px;
}

.patient-form-section .form-grid-narrow .button-secondary:hover {
  background: transparent;
  color: #0056b3;
}

/* Add representative button */
.patient-form-section #addRepresentativeBtn {
  margin-top: 8px;
  padding: 0 16px;
}

.patient-form-section #addRepresentativeBtn .button-secondary {
  color: #007aff;
  opacity: 1;
}

/* Complex fields that should stay vertical within iOS group */
.patient-form-section .form-grid-narrow .form-field:has(.phone-numbers-container) {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.patient-form-section .form-grid-narrow .form-field:has(.phone-numbers-container) label {
  width: auto;
  min-width: auto;
}

.patient-form-section .form-grid-narrow .form-field:has(.sticky-note-textarea) {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0; /* не сжимать — заметки должны растягиваться по содержимому */
}

.patient-form-section .form-grid-narrow .form-field:has(.sticky-note-textarea) label {
  width: auto;
  min-width: auto;
}

/* Позволяем form-grid-narrow с заметками не обрезать textarea (overflow: hidden мешает resize и авторастягиванию) */
.patient-form-section .form-grid-narrow:has(.sticky-note-textarea) {
  overflow: visible;
}

/* Позволяем form-grid-narrow с селектом "Источник" не обрезать выпадающий список */
.patient-form-section .form-grid-narrow:has(#sourceSelect) {
  overflow: visible;
}

/* Custom fields container */
.patient-form-section .form-grid-narrow .custom-fields-inline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.patient-form-section .form-grid-narrow .custom-fields-inline .form-field {
  border-bottom: 0.5px solid #c6c6c8;
}

.patient-form-section .form-grid-narrow .custom-fields-inline .form-field:last-child {
  border-bottom: none;
}

/* VIP checkbox row alignment fix */
.patient-form-section .form-grid-narrow .form-row-inline .form-field label input[type="checkbox"] {
  width: auto;
}

/* Messenger links container inside iOS group */
.patient-form-section .messenger-links-container {
  background: #f2f2f7 !important;
  border: none !important;
  border-radius: 8px !important;
}

/* Patient Appointments Sidebar */
.patient-appointments-section {
  width: 340px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  padding-left: 20px;
  min-height: 0;
  overflow: hidden;
}

.appointments-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

/* Appointments Tab Section */
.appointments-tab-section {
  padding: 0;
  width: 100%;
}

.patient-appointments-table-container {
  width: 100%;
  min-width: 100%;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
  padding-right: 4px;
}

.patient-appointments-table-container::-webkit-scrollbar {
  width: 6px;
}

.patient-appointments-table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.patient-appointments-table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.patient-appointments-table-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.appointments-table {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.appointments-table thead tr {
  background: #f8fafc;
}

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

/* Sidebar Tabs: Приемы / Дневники */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  width: 100%;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-tab:hover {
  color: #334155;
  background: rgba(255, 255, 255, 0.5);
}

.sidebar-tab.active {
  color: #0f172a;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-tab-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  background: #e2e8f0;
  color: #64748b;
}

.sidebar-tab.active .sidebar-tab-count {
  background: var(--brand-secondary);
  color: white;
}

/* Patient Diaries List */
.patient-diaries-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.patient-diaries-list::-webkit-scrollbar {
  width: 6px;
}

.patient-diaries-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.patient-diaries-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.patient-diaries-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Diary Detail Section */
.diary-detail-section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  z-index: 1100;  /* Must be higher than .custom-select (100) and .select-dropdown (1003) */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.diary-detail-section.visible {
  opacity: 1;
  visibility: visible;
}

.diary-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.diary-detail-header h3 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.diary-detail-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.diary-detail-info {
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.diary-info-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 8px;
}

.diary-info-row:last-child {
  margin-bottom: 0;
}

.diary-info-label {
  font-weight: 500;
  color: #64748b;
  min-width: 120px;
  font-size: 13px;
}

.diary-info-value {
  color: #1e293b;
  font-size: 14px;
}

.diary-detail-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.diary-detail-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  font-size: 14px;
}

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

.diary-field-label {
  font-weight: 500;
  color: #475569;
  background: #f8fafc;
  width: 220px;
  min-width: 220px;
}

.diary-field-value {
  color: #1e293b;
  white-space: pre-wrap;
  line-height: 1.5;
}

.diary-empty-message {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
  font-size: 14px;
}

.diary-section {
  margin-bottom: 24px;
}

.diary-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* Dental Formula Styles */
.dental-formula-grid {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  font-family: monospace;
  font-size: 13px;
}

.dental-jaw {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.dental-jaw-line {
  height: 2px;
  background: #cbd5e1;
  margin: 4px 0;
}

.dental-side {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 200px;
}

.dental-side.right {
  justify-content: flex-end;
}

.dental-side.left {
  justify-content: flex-start;
}

.dental-divider {
  color: #94a3b8;
  font-weight: bold;
  padding: 0 8px;
}

.dental-tooth {
  display: inline-block;
  padding: 4px 8px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.patient-appointments-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.patient-appointments-list::-webkit-scrollbar {
  width: 6px;
}

.patient-appointments-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.patient-appointments-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.patient-appointments-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Разделители групп приёмов */
.appointments-group-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.appointments-group-divider:first-child {
  margin-top: 0;
}

.group-divider-icon {
  font-size: 12px;
  line-height: 1;
}

.group-divider-label {
  flex: 1;
}

.group-divider-count {
  background: rgba(255, 255, 255, 0.6);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

/* Сегодня - акцентный цвет */
.group-today {
  background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

.group-today .group-divider-count {
  background: #3b82f6;
  color: white;
}

/* Будущие - мягкий зелёный */
.group-future {
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  color: #15803d;
  border: 1px solid #86efac;
}

.group-future .group-divider-count {
  background: #22c55e;
  color: white;
}

/* Прошедшие - нейтральный серый */
.group-past {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.group-past .group-divider-count {
  background: #94a3b8;
  color: white;
}

.appointment-list-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.appointment-list-clinic {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.appointment-list-notes {
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  line-height: 1.4;
}

/* Patient modal specific - wider */
#patientModal .modal-content {
  max-width: 80%;
}

/* Patient modal - separate scroll for appointments */
#patientModal .modal-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Селект "Источник" — высокий z-index, чтобы выпадающий список был поверх блоков ниже */
#patientModal #sourceSelect {
  z-index: 1100;
}
#patientModal #sourceSelect .select-dropdown {
  z-index: 1101;
}

/* ============================================
   TABS NAVIGATION
   ============================================ */
.tabs-navigation-wrapper {
  display: flex;
  align-items: stretch;
  position: relative;
  margin-bottom: 24px;
  width: 100%;
}

.tabs-scroll-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  background: var(--bg-primary);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  z-index: 2;
  flex-shrink: 0;
}

.tabs-scroll-arrow:hover {
  color: var(--brand-primary);
  background: var(--bg-highlight);
}

.tabs-scroll-arrow:active {
  transform: scale(0.95);
}

.tabs-scroll-arrow.hidden {
  opacity: 0.3;
  pointer-events: none;
}

.tabs-scroll-left {
  border-right: 1px solid var(--border-color);
  border-radius: 6px 0 0 6px;
}

.tabs-scroll-right {
  border-left: 1px solid var(--border-color);
  border-radius: 0 6px 6px 0;
}

.tabs-navigation-wrapper .tabs-navigation {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  scroll-behavior: smooth;
}

.tabs-navigation-wrapper .tabs-navigation::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.tabs-navigation {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  padding-bottom: 0;
  width: 100%; /* Занимаем всю доступную ширину */
}

.tabs-navigation-wrapper .tabs-navigation {
  margin-bottom: 0;
  border-bottom: 2px solid var(--border-color);
}

/* Стрелки скрываются когда скролл не нужен (через JS класс .no-scroll) */
.tabs-navigation-wrapper.no-scroll .tabs-scroll-arrow {
  display: none;
}

.tab-button {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
  bottom: -2px;
}

.tab-button:hover {
  color: var(--brand-primary);
  background: var(--bg-highlight);
  border-radius: 8px 8px 0 0;
}

.tab-button.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: block;
  width: 100%;
}

/* ============================================
   HEALTH QUESTIONNAIRE
   ============================================ */
.questionnaire-section {
  width: 100%;
}

.questionnaire-form {
  width: 100%;
}

.questionnaire-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.questionnaire-section-title {
  grid-column: 1 / -1;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 10px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
}

.questionnaire-section-title:first-child {
  margin-top: 0;
}

.questionnaire-form-grid .form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.questionnaire-form-grid .form-field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.questionnaire-form-grid .form-field input,
.questionnaire-form-grid .form-field textarea,
.questionnaire-form-grid .form-field select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  background: white;
}

.questionnaire-form-grid .form-field input:focus,
.questionnaire-form-grid .form-field textarea:focus,
.questionnaire-form-grid .form-field select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(55, 192, 116, 0.1);
}

.questionnaire-form-grid .form-field textarea {
  resize: vertical;
  min-height: 60px;
}

.questionnaire-form-grid .form-field.full-width {
  grid-column: 1 / -1;
}

.questionnaire-form-grid .button-primary {
  width: 100%;
  justify-content: center;
}

#questionnaireFieldsContainer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

#questionnaireFieldsContainer .form-field {
  margin-bottom: 0;
}

#questionnaireFieldsContainer h3.questionnaire-section-title {
  margin-top: 24px;
}

#questionnaireFieldsContainer h3.questionnaire-section-title:first-child {
  margin-top: 0;
}

/* Question field styling with colored borders */
.question-field {
  padding: 16px;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  transition: all 0.3s ease;
}

.question-field.question-unanswered {
  border-color: #e5e7eb;
  background: #ffffff;
}

.question-field.question-yes {
  border-color: #ef4444;
  background: #fef2f2;
}

.question-field.question-no {
  border-color: #10b981;
  background: #f0fdf4;
}

.question-field.question-unknown {
  border-color: #f59e0b;
  background: #fffbeb;
}

.question-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: block;
}

/* Radio button group styling */
.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 6px;
  border: 2px solid #e5e7eb;
  background: white;
  transition: all 0.2s ease;
  user-select: none;
}

.radio-option:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}

.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand-primary);
}

/* Цвета радио-кнопок в анкете здоровья */
.radio-option input[type="radio"][value="yes"] {
  accent-color: #ef4444;
}

.radio-option input[type="radio"][value="no"] {
  accent-color: #10b981;
}

.radio-option input[type="radio"][value="unknown"] {
  accent-color: #f59e0b;
}

.radio-option input[type="radio"]:checked + .radio-label {
  font-weight: 600;
}

/* Цвета текста при выбранной радио-кнопке */
.radio-option input[type="radio"][value="yes"]:checked + .radio-label {
  color: #ef4444;
}

.radio-option input[type="radio"][value="no"]:checked + .radio-label {
  color: #10b981;
}

.radio-option input[type="radio"][value="unknown"]:checked + .radio-label {
  color: #f59e0b;
}

.radio-label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  margin: 0;
}

.error-message {
  padding: 20px;
  text-align: center;
  color: var(--badge-danger);
  background: #fee2e2;
  border-radius: var(--radius-md);
  margin: 20px 0;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .patient-modal-layout {
    flex-direction: column;
    overflow-y: auto;
  }
  
  .patient-form-section {
    overflow-y: visible;
    flex-shrink: 0;
  }
  
  .patient-appointments-section {
    width: 100%;
    min-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 16px;
    max-height: 350px;
    overflow-y: auto;
  }
  
  .appointments-table {
    font-size: 13px;
  }
  
  .appointments-table th,
  .appointments-table td {
    padding: 10px 12px !important;
  }
  
  #patientModal .modal-content {
    max-width: 90%;
  }

  .tab-button {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  /* Balance tab responsive layout */
  #tab-balance > .balance-section > div[style*="display: flex"] {
    flex-direction: column !important;
  }
  
  #tab-balance .balance-header {
    width: 100%;
  }
}

/* Средние экраны - уменьшаем отступы вокруг модалки */
@media (max-width: 1400px) {
  .modal-backdrop {
    padding: 16px;
  }
  
  #patientModal .modal-content {
    max-width: 94%;
  }
}

@media (max-width: 1100px) {
  .modal-backdrop {
    padding: 12px;
  }
  
  #patientModal .modal-content {
    max-width: 96%;
  }
}

@media (max-width: 900px) {
  .modal-backdrop {
    padding: 10px;
  }
  
  #patientModal .modal-content {
    max-width: 98%;
  }
}

@media (max-width: 768px) {
  .modal-backdrop {
    padding: 8px;
  }
  
  #patientModal .modal-content {
    max-width: 100%;
    border-radius: 8px;
  }
  
  .modal-header {
    padding: 12px 16px;
  }
  
  .modal-body {
    padding: 12px 16px;
  }
}

/* Утилиты */
.hidden {
  display: none !important;
}

/* ========== PRICELIST PAGE (Redesigned) ========== */
.pricelist-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* --- Header --- */
.pricelist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 16px;
  flex-shrink: 0;
  gap: 20px;
}
.pricelist-header__left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.pricelist-header__left h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.pricelist-header__count {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}
.pricelist-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --- Search --- */
.pricelist-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 340px;
}
.pricelist-search__icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.pricelist-search input {
  width: 100%;
  padding: 9px 36px 9px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  transition: border-color .2s, box-shadow .2s;
}
.pricelist-search input:focus {
  outline: none;
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.12);
}
.pricelist-search input::placeholder {
  color: #94a3b8;
}
.pricelist-search__clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  display: flex;
  border-radius: 50%;
  transition: background .2s;
}
.pricelist-search__clear:hover {
  background: var(--bg-highlight);
  color: var(--text-secondary);
}

/* --- Layout --- */
.pricelist-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* --- Sidebar --- */
.pricelist-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pricelist-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-color);
}
.pricelist-sidebar__header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pricelist-sidebar__reorder-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  background: var(--brand-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .2s;
}
.pricelist-sidebar__reorder-btn:hover {
  opacity: 0.85;
}
.pricelist-sidebar__tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.pricelist-sidebar__loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}
.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--brand-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* --- Category tree items --- */
.pricelist-cat-item--all {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  margin-bottom: 4px;
}
.pricelist-cat-item--all:hover {
  background: var(--bg-highlight);
  color: var(--text-primary);
}
.pricelist-cat-item--all.active {
  background: rgba(47, 143, 237, 0.08);
  color: var(--brand-secondary);
  border-left-color: var(--brand-secondary);
  font-weight: 600;
}
.pricelist-cat-item--all .pricelist-cat-item__icon {
  flex-shrink: 0;
  opacity: 0.6;
}
.pricelist-cat-item--all.active .pricelist-cat-item__icon {
  opacity: 1;
}

.pricelist-cat-list {
  display: flex;
  flex-direction: column;
}

.pricelist-cat-item {
  display: flex;
  flex-direction: column;
}
.pricelist-cat-item__row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  min-height: 38px;
}
.pricelist-cat-item__row:hover {
  background: var(--bg-highlight);
}
.pricelist-cat-item.active > .pricelist-cat-item__row {
  background: rgba(47, 143, 237, 0.08);
  border-left-color: var(--brand-secondary);
}
.pricelist-cat-item.active > .pricelist-cat-item__row .pricelist-cat-item__name {
  color: var(--brand-secondary);
  font-weight: 600;
}

.pricelist-cat-item__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: transform .2s, background .15s;
  flex-shrink: 0;
}
.pricelist-cat-item__toggle:hover {
  background: rgba(0,0,0,.06);
}
.pricelist-cat-item__toggle.expanded {
  transform: rotate(90deg);
}
.pricelist-cat-item__no-toggle {
  width: 22px;
  flex-shrink: 0;
}

.pricelist-cat-item__drag-handle {
  display: flex;
  align-items: center;
  cursor: grab;
  color: #c8cdd7;
  padding: 2px;
  transition: color .15s;
  flex-shrink: 0;
}
.pricelist-cat-item__drag-handle:hover {
  color: var(--text-secondary);
}
.pricelist-cat-item__drag-handle:active {
  cursor: grabbing;
}

.pricelist-cat-item__name {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.pricelist-cat-item__name--muted {
  color: var(--text-tertiary, #999);
  font-style: italic;
}

.pricelist-cat-item__icon-slot {
  display: flex;
  align-items: center;
  padding: 2px;
  flex-shrink: 0;
  color: var(--text-tertiary, #999);
}

.pricelist-cat-item__edit-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}
.pricelist-cat-item__edit-btn:hover {
  background: var(--bg-soft-hover);
  color: var(--brand-secondary);
}
.pricelist-cat-item__row:hover .pricelist-cat-item__edit-btn,
.pricelist-cat-item.active > .pricelist-cat-item__row .pricelist-cat-item__edit-btn {
  display: flex;
}

.pricelist-sidebar__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px dashed #d0d5dd;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  margin-left: auto;
}
.pricelist-sidebar__add-btn:hover {
  border-color: var(--brand-secondary);
  background: rgba(47, 143, 237, 0.08);
  color: var(--brand-secondary);
}

.pricelist-cat-children {
  display: none;
  flex-direction: column;
  padding-left: 18px;
}
.pricelist-cat-children.expanded {
  display: flex;
}

/* --- Content area --- */
.pricelist-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
}

/* --- Breadcrumb bar --- */
.pricelist-breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  flex-shrink: 0;
  gap: 12px;
}
.pricelist-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  flex-wrap: wrap;
  min-width: 0;
}
.pricelist-btn--sm {
  padding: 6px 12px;
  font-size: 12px;
}
.pricelist-breadcrumb__item {
  color: var(--text-secondary);
}
.pricelist-breadcrumb__item.clickable {
  cursor: pointer;
  transition: color .15s;
}
.pricelist-breadcrumb__item.clickable:hover {
  color: var(--brand-secondary);
}
.pricelist-breadcrumb__item.active {
  color: var(--text-primary);
  font-weight: 600;
}
.pricelist-breadcrumb__sep {
  color: #c8cdd7;
  flex-shrink: 0;
}

/* --- Loading / Error / Empty states --- */
.pricelist-loading,
.pricelist-error,
.pricelist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--text-secondary);
  padding: 40px;
}
.pricelist-error svg {
  color: var(--badge-danger);
}
.pricelist-empty svg {
  color: #c8cdd7;
}

/* --- Table wrap --- */
.pricelist-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 28px;
}
.pricelist-table-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0;
}
.pricelist-table-actions__save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  background: var(--brand-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .2s;
}
.pricelist-table-actions__save:hover {
  opacity: 0.85;
}

/* --- Table --- */
.pricelist-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.pricelist-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg-highlight);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}
.pricelist-table__drag-col {
  width: 40px;
}
.pricelist-table__code-col {
  width: 140px;
}
.pricelist-table__bundle-count-col {
  width: 80px;
  text-align: center !important;
}
.pricelist-table__bundle-toggle-col {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}
.pricelist-table__name-col {
  /* flex */
}
.pricelist-table__price-col {
  width: 130px;
  text-align: right !important;
}
.pricelist-table__row {
  border-bottom: 1px solid var(--border-color);
  transition: background-color .15s;
}
.pricelist-table__row:last-child {
  border-bottom: none;
}
.pricelist-table__row:hover {
  background: var(--bg-highlight);
}
.pricelist-table__row td {
  padding: 12px 16px;
  font-size: var(--font-size-md);
  vertical-align: top;
}

/* Group rows */
.pricelist-table__group-row td {
  padding: 14px 16px 8px;
  background: rgba(47, 143, 237, 0.04);
  border-bottom: 1px solid var(--border-color);
}
.pricelist-table__group-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.pricelist-table__group-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 8px;
  background: var(--bg-highlight);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Cell content */
.pricelist-table__drag-handle {
  display: flex;
  align-items: center;
  cursor: grab;
  color: #c8cdd7;
  transition: color .15s;
}
.pricelist-table__drag-handle:hover {
  color: var(--text-secondary);
}
.pricelist-table__drag-handle:active {
  cursor: grabbing;
}
.pricelist-table__code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.pricelist-table__name-text {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.pricelist-table__name-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
}
.pricelist-table__price {
  font-weight: 700;
  color: var(--brand-primary);
  text-align: right;
  white-space: nowrap;
  font-size: 15px;
}

/* --- Sortable.js states --- */
.pricelist-sortable-ghost {
  opacity: 0.4;
  background: rgba(47, 143, 237, 0.08) !important;
}
.pricelist-sortable-chosen {
  background: rgba(47, 143, 237, 0.04) !important;
}
.pricelist-sortable-drag {
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  border-radius: var(--radius-sm);
}

/* --- Toast --- */
.pricelist-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: white;
  background: #1d2333;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 9999;
}
.pricelist-toast--success {
  background: var(--brand-primary);
}
.pricelist-toast--error {
  background: var(--badge-danger);
}
.pricelist-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* --- Sidebar tabs --- */
.pricelist-sidebar__tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  flex-shrink: 0;
}
.pricelist-sidebar__tab {
  flex: 1;
  padding: 11px 8px 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  text-align: center;
  white-space: nowrap;
}
.pricelist-sidebar__tab:hover {
  color: var(--text-primary);
}
.pricelist-sidebar__tab.active {
  color: var(--brand-secondary);
  border-bottom-color: var(--brand-secondary);
}
.pricelist-sidebar__tabs .pricelist-sidebar__reorder-btn {
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Toggle (checkbox label) --- */
.pricelist-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  user-select: none;
  white-space: nowrap;
}
.pricelist-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-secondary);
  cursor: pointer;
  margin: 0;
}
.pricelist-toggle__label {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Breadcrumb bar right area --- */
.pricelist-breadcrumb-bar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* --- Inactive row styling --- */
.pricelist-table__row--inactive {
  opacity: 0.5;
}
.pricelist-table__row--inactive:hover {
  opacity: 0.75;
}

/* --- Badges --- */
.pricelist-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pricelist-badge--inactive {
  background: #fee2e2;
  color: #dc2626;
}
.pricelist-badge--info {
  background: #dbeafe;
  color: #2563eb;
}
.pricelist-badge--bundle {
  background: rgba(47, 143, 237, 0.15);
  color: var(--brand-secondary);
  font-size: 12px;
  font-weight: 600;
  margin-left: 0;
  min-width: 24px;
  text-align: center;
  display: inline-block;
}

/* --- Bundle row --- */
.pricelist-table__row--bundle .pricelist-table__name-desc {
  max-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bundle toggle button */
.pricelist-bundle-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  margin-right: 6px;
  vertical-align: middle;
}
.pricelist-bundle-toggle:hover {
  background: var(--bg-highlight);
  color: var(--brand-secondary);
}
.pricelist-bundle-toggle svg {
  transition: transform 0.2s ease;
}
.pricelist-bundle-toggle.expanded svg {
  transform: rotate(90deg);
}

/* Bundle detail row (expandable) */
.pricelist-bundle-detail {
  background: var(--bg-highlight);
}
.pricelist-bundle-detail.hidden {
  display: none;
}
.pricelist-bundle-detail > td {
  padding: 0 16px 16px 16px;
}
.pricelist-bundle-detail__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}
.pricelist-bundle-detail__table thead tr {
  background: var(--bg-muted);
}
.pricelist-bundle-detail__table th {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.pricelist-bundle-detail__th-code {
  width: 120px;
}
.pricelist-bundle-detail__th-price {
  width: 100px;
  text-align: right !important;
}
.pricelist-bundle-detail__row td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.pricelist-bundle-detail__row:last-child td {
  border-bottom: none;
}
.pricelist-bundle-detail__code {
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}
.pricelist-bundle-detail__name {
  color: var(--text-primary);
}
.pricelist-bundle-detail__qty {
  color: var(--brand-secondary);
  font-weight: 600;
  margin-left: 4px;
}
.pricelist-bundle-detail__price {
  text-align: right;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* --- Responsive: narrow sidebar on small screens --- */
@media (max-width: 900px) {
  .pricelist-sidebar {
    width: 220px;
    min-width: 220px;
  }
  .pricelist-search {
    width: 240px;
  }
}
@media (max-width: 700px) {
  .pricelist-layout {
    flex-direction: column;
  }
  .pricelist-sidebar {
    width: 100%;
    min-width: auto;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .pricelist-header {
    flex-wrap: wrap;
  }
  .pricelist-search {
    width: 100%;
  }
}

/* --- Pricelist: Buttons --- */
.pricelist-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .2s, background .2s;
  white-space: nowrap;
}
.pricelist-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pricelist-btn--primary {
  color: white;
  background: var(--brand-secondary);
}
.pricelist-btn--primary:hover:not(:disabled) {
  opacity: 0.9;
}
.pricelist-btn--success {
  color: white;
  background: var(--brand-primary);
}
.pricelist-btn--success:hover:not(:disabled) {
  opacity: 0.9;
}
.pricelist-btn--secondary {
  color: var(--text-secondary);
  background: var(--bg-highlight);
}
.pricelist-btn--secondary:hover:not(:disabled) {
  background: var(--border-color);
}
.pricelist-btn--danger {
  color: white;
  background: var(--badge-danger);
}
.pricelist-btn--danger:hover:not(:disabled) {
  opacity: 0.9;
}

/* --- Row edit button --- */
.pricelist-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: #b8bfcc;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.pricelist-row-btn:hover {
  color: var(--brand-secondary);
  background: rgba(47, 143, 237, 0.08);
}
.pricelist-table__actions-col {
  width: 52px;
}
.pricelist-table__actions-cell {
  text-align: center;
  padding: 8px 4px !important;
}

/* --- Pricelist: Modal --- */
.pricelist-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: plFadeIn .15s ease;
}
@keyframes plFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.pricelist-modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  width: 640px;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: plSlideUp .2s ease;
}
@keyframes plSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.pricelist-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
}
.pricelist-modal__header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.pricelist-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 8px;
  transition: background .15s;
}
.pricelist-modal__close:hover {
  background: var(--bg-highlight);
}
.pricelist-modal__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.pricelist-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-color);
  gap: 12px;
}
.pricelist-modal__footer-left {
  display: flex;
  gap: 8px;
}
.pricelist-modal__footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.pricelist-modal--wide {
  width: 720px;
  max-height: 85vh;
}
.pricelist-modal--sm {
  width: 480px;
}

.pricelist-form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* --- Pricelist: Bundle Items (in modal) --- */
.pricelist-bundle-items {
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.pricelist-bundle-items__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-highlight);
  border-bottom: 1px solid var(--border-color);
}
.pricelist-bundle-items__header label {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
}
.pricelist-bundle-items__list {
  max-height: 250px;
  overflow-y: auto;
}
.pricelist-bundle-items__empty {
  padding: 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.pricelist-bundle-items__total {
  padding: 12px 16px;
  background: var(--bg-highlight);
  border-top: 1px solid var(--border-color);
  font-weight: 600;
  text-align: right;
}
.pricelist-bundle-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}
.pricelist-bundle-item:last-child {
  border-bottom: none;
}
.pricelist-bundle-item__name {
  flex: 1;
  font-size: 13px;
  min-width: 0;
}
.pricelist-bundle-item__name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pricelist-bundle-item__price {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}
.pricelist-bundle-item__qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pricelist-bundle-item__qty input {
  width: 50px;
  text-align: center;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}
.pricelist-bundle-item__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.pricelist-bundle-item__remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Service Picker for bundle */
.pricelist-search--modal {
  margin-bottom: 12px;
}

/* Picker layout with category tree */
.pricelist-picker-layout {
  display: flex;
  gap: 0;
  height: 450px;
  padding: 0 !important;
}

/* Sidebar with categories */
.pricelist-picker-sidebar {
  width: 220px;
  min-width: 180px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fafbfc;
}
.pricelist-picker-sidebar__header {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}
.pricelist-picker-sidebar__tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Picker category item */
.pricelist-picker-cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
  margin-bottom: 2px;
}
.pricelist-picker-cat-item:hover {
  background: var(--bg-highlight);
  color: var(--text-primary);
}
.pricelist-picker-cat-item.active {
  background: var(--brand-primary);
  color: white;
}
.pricelist-picker-cat-item.active svg {
  color: white;
}
.pricelist-picker-cat-item--all {
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.pricelist-picker-cat-item svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

/* Picker category with children */
.pricelist-picker-cat-group {
  margin-bottom: 4px;
}
.pricelist-picker-cat-group__header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.15s;
}
.pricelist-picker-cat-group__header:hover {
  background: var(--bg-highlight);
}
.pricelist-picker-cat-group__header.active {
  background: var(--brand-primary);
  color: white;
}
.pricelist-picker-cat-group__toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}
.pricelist-picker-cat-group__toggle.expanded {
  transform: rotate(90deg);
}
.pricelist-picker-cat-group__children {
  padding-left: 16px;
  display: none;
}
.pricelist-picker-cat-group__children.expanded {
  display: block;
}

/* Content area */
.pricelist-picker-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

/* Picker breadcrumb */
.pricelist-picker-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.pricelist-picker-breadcrumb__item {
  color: var(--text-tertiary);
}
.pricelist-picker-breadcrumb__item.active {
  color: var(--text-primary);
  font-weight: 500;
}
.pricelist-picker-breadcrumb__item.clickable {
  cursor: pointer;
  color: var(--brand-secondary);
}
.pricelist-picker-breadcrumb__item.clickable:hover {
  text-decoration: underline;
}
.pricelist-picker-breadcrumb__sep {
  color: var(--text-tertiary);
}

.pricelist-service-picker__list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}
.pricelist-service-picker__loading {
  padding: 24px;
  text-align: center;
  color: var(--text-tertiary);
}
.pricelist-service-picker__group-header {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-highlight);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
}
.pricelist-service-picker__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
.pricelist-service-picker__item:last-child {
  border-bottom: none;
}
.pricelist-service-picker__item:hover {
  background: var(--bg-highlight);
}
.pricelist-service-picker__item-name {
  flex: 1;
  font-size: 13px;
}
.pricelist-service-picker__item-price {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Responsive picker */
@media (max-width: 640px) {
  .pricelist-picker-layout {
    flex-direction: column;
    height: auto;
  }
  .pricelist-picker-sidebar {
    width: 100%;
    max-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .pricelist-picker-content {
    min-height: 300px;
  }
}

/* --- Pricelist: Change Log --- */
.pricelist-changelog__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}
.pricelist-changelog__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}
.pricelist-changelog__list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.pricelist-changelog__entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.pricelist-changelog__entry:last-child {
  border-bottom: none;
}
.pricelist-changelog__entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.pricelist-changelog__action {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 6px;
}
.pricelist-changelog__action--create {
  background: rgba(55, 192, 116, 0.15);
  color: #1e7a4a;
}
.pricelist-changelog__action--update {
  background: rgba(47, 143, 237, 0.15);
  color: #1a5a9e;
}
.pricelist-changelog__action--delete {
  background: rgba(255, 93, 93, 0.15);
  color: #c43d3d;
}
.pricelist-changelog__action--activate {
  background: rgba(255, 186, 90, 0.2);
  color: #b3782a;
}
.pricelist-changelog__action--reorder {
  background: rgba(108, 117, 125, 0.15);
  color: #5c6378;
}
.pricelist-changelog__date {
  font-size: 12px;
  color: var(--text-secondary);
}
.pricelist-changelog__desc {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.45;
}
.pricelist-changelog__changes {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.pricelist-changelog__change {
  margin-bottom: 4px;
}
.pricelist-changelog__change:last-child {
  margin-bottom: 0;
}
.pricelist-changelog__change-label {
  color: var(--text-secondary);
  font-weight: 500;
}
.pricelist-changelog__change-old {
  color: var(--badge-danger);
  text-decoration: line-through;
}
.pricelist-changelog__change-new {
  color: var(--brand-primary);
  font-weight: 500;
}
.pricelist-changelog__meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.pricelist-changelog__empty {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
}

/* --- Pricelist: Form --- */
.pricelist-form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.pricelist-form-row:last-child {
  margin-bottom: 0;
}
.pricelist-form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pricelist-form-group--full {
  flex: 1 0 100%;
}
.pricelist-form-group--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding-top: 22px;
}
.pricelist-form-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
}
.pricelist-form-group--checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-secondary);
  cursor: pointer;
}
.pricelist-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pricelist-form-group label .required {
  color: var(--badge-danger);
}
.pricelist-form-group input[type="text"],
.pricelist-form-group input[type="number"],
.pricelist-form-group textarea,
.pricelist-form-group select {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-family: inherit;
  background: white;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
.pricelist-form-group input:focus,
.pricelist-form-group textarea:focus,
.pricelist-form-group select:focus {
  outline: none;
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.12);
}
.pricelist-form-group textarea {
  resize: vertical;
  min-height: 40px;
}
.pricelist-form-group select {
  cursor: pointer;
}

/* --- Pricelist table actions bar --- */
.pricelist-table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 12px;
  gap: 12px;
}

/* ========== DOCTORS PAGE ========== */
.doctors-page {
  padding: 32px 40px;
  max-width: 100%;
  margin: 0;
}

.doctors-page .page-header {
  margin-bottom: 32px;
}

.doctors-page .page-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.doctors-container {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 24px;
}

.doctors-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.doctor-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.specialization-header {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--brand-primary);
}

.doctors-table {
  width: 100%;
  border-collapse: collapse;
}

.doctors-table thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-highlight);
  color: var(--text-secondary);
  font-size: var(--font-size-md);
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
}

.doctors-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

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

.doctors-table tbody td {
  padding: 16px;
  font-size: var(--font-size-md);
}

.doctor-name {
  font-weight: 600;
  color: var(--text-primary);
  width: 40%;
}

.doctor-phone {
  color: var(--text-secondary);
  width: 25%;
}

.doctor-email {
  color: var(--text-secondary);
  width: 35%;
}

.doctor-email a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.doctor-email a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.no-doctors {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

/* Адаптивность */
@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 240px 1fr;
  }
}

/* ========== SIDEBAR MOBILE SECTIONS (hidden on desktop) ========== */
.sidebar-mobile-header,
.sidebar-mobile-search,
.sidebar-mobile-footer {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    transform: translateX(-100%);
  }
  
  .sidebar.expanded {
    width: 300px;
    padding: 0;
    transform: translateX(0);
    z-index: 250;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .sidebar-overlay.visible {
    z-index: 210;
  }
  
  .sidebar-toggle {
    display: none;
  }

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

  /* Top bar: hide search, notifications, user card on mobile */
  .top-bar .global-search-wrapper,
  .top-bar .top-bar-right {
    display: none !important;
  }

  .top-bar {
    padding: 8px 16px;
  }

  /* --- Sidebar mobile header --- */
  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    flex-shrink: 0;
  }

  .sidebar-mobile-header .brand {
    font-size: 20px;
  }

  .sidebar-mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
  }

  .sidebar-mobile-close:hover {
    background-color: rgba(47, 143, 237, 0.08);
    color: var(--brand-secondary);
  }

  /* --- Sidebar mobile search --- */
  .sidebar-mobile-search {
    display: block;
    padding: 0 20px 12px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  .sidebar-search-box {
    position: relative;
    display: flex;
    align-items: center;
  }

  .sidebar-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    pointer-events: none;
  }

  .sidebar-search-input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255,255,255,0.6);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .sidebar-search-input:focus {
    outline: none;
    border-color: var(--brand-secondary);
    box-shadow: 0 0 0 3px rgba(47, 143, 237, 0.12);
  }

  .sidebar-search-input::placeholder {
    color: #94a3b8;
  }

  .sidebar-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  .sidebar-search-clear:hover {
    color: #64748b;
    background: #f1f5f9;
  }

  .sidebar-search-clear.hidden {
    display: none;
  }

  .sidebar-search-dropdown {
    position: absolute;
    top: calc(100% - 4px);
    left: 20px;
    right: 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 320px;
    overflow-y: auto;
  }

  .sidebar-search-dropdown.hidden {
    display: none;
  }

  .sidebar-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 8px;
    color: #64748b;
    font-size: 14px;
  }

  .sidebar-search-loading.hidden {
    display: none;
  }

  .sidebar-search-results {
    padding: 6px;
  }

  .sidebar-search-empty {
    padding: 24px;
    text-align: center;
  }

  .sidebar-search-empty.hidden {
    display: none;
  }

  .sidebar-search-empty-text {
    font-size: 14px;
    color: #94a3b8;
  }

  .sidebar-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
  }

  .sidebar-search-item:hover {
    background: #f1f5f9;
  }

  .sidebar-search-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #4338ca;
    flex-shrink: 0;
  }

  .sidebar-search-item-info {
    flex: 1;
    min-width: 0;
  }

  .sidebar-search-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-search-item-phone {
    font-size: 12px;
    color: #64748b;
  }

  /* --- Sidebar nav on mobile --- */
  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
  }

  .sidebar .sidebar-entry {
    padding: 10px 12px;
    border-radius: 10px;
    gap: 12px;
  }

  .sidebar .sidebar-text {
    opacity: 1;
    visibility: visible;
    font-size: 15px;
  }

  /* --- Sidebar mobile footer --- */
  .sidebar-mobile-footer {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 0 12px 16px;
  }

  .sidebar-mobile-divider {
    height: 1px;
    background: rgba(18, 27, 56, 0.08);
    margin: 8px 8px 12px;
  }

  .sidebar-mobile-notifications {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.15s;
    position: relative;
    text-align: left;
    width: 100%;
  }

  .sidebar-mobile-notifications:hover {
    background-color: rgba(47, 143, 237, 0.08);
  }

  .sidebar-mobile-notifications svg {
    flex-shrink: 0;
    color: var(--text-secondary);
  }

  .sidebar-mobile-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-mobile-badge.hidden {
    display: none;
  }

  .sidebar-mobile-user {
    padding: 12px;
    margin: 4px 0;
  }

  .sidebar-mobile-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-mobile-user-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
  }

  .sidebar-mobile-user-role {
    font-size: 13px;
    color: var(--text-secondary);
  }

  .sidebar-mobile-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.15s;
  }

  .sidebar-mobile-action:hover {
    background-color: rgba(47, 143, 237, 0.08);
  }

  .sidebar-mobile-action svg {
    flex-shrink: 0;
    color: var(--text-secondary);
  }

  .sidebar-mobile-logout {
    color: #e53e3e;
  }

  .sidebar-mobile-logout svg {
    color: #e53e3e;
  }

  .sidebar-mobile-logout:hover {
    background-color: rgba(229, 62, 62, 0.08);
  }

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

  .modal-footer {
    flex-direction: column;
  }

  .footer-left,
  .footer-right {
    width: 100%;
    justify-content: stretch;
  }

  .footer-left button,
  .footer-right button {
    flex: 1;
  }
}

/* ========== SCHEDULES PAGE ========== */
.schedule-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  color: var(--text-primary);
  min-width: 150px;
  cursor: pointer;
}

.date-input:focus {
  outline: none;
  border-color: var(--brand-secondary);
}

.select-field select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  color: var(--text-primary);
  min-width: 200px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235c6378' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.select-field select:focus {
  outline: none;
  border-color: var(--brand-secondary);
}

.schedule-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-x: auto;
}

.schedule-grid {
  display: flex;
  gap: 2px;
  min-width: fit-content;
  position: relative;
}

.schedule-time-column {
  display: grid;
  grid-template-rows: auto;
  grid-auto-rows: var(--schedule-row-height); /* 5 minutes slot height */
  min-width: var(--schedule-time-column-width);
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  align-items: stretch;
  border: 1px solid transparent;
  position: sticky;
  left: 0;
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.schedule-time-header {
  padding: 6px 10px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 40px;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  grid-row: 1;
}

.schedule-time-slot {
  padding: 2px 4px;
  font-size: calc(10px * var(--schedule-font-scale));
  color: var(--text-secondary);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  height: calc(var(--schedule-row-height) * 6); /* 30 minutes = 6 x 5-minute slots */
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* Schedule gap indicator (between adjacent doctor schedules) */
.schedule-gap-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c0c8d4;
  font-size: 12px;
  letter-spacing: 2px;
  user-select: none;
  pointer-events: none;
  border-top: 1px dashed #d8dfe8;
  border-bottom: 1px dashed #d8dfe8;
  background: linear-gradient(to bottom, rgba(230, 236, 242, 0.3), transparent, rgba(230, 236, 242, 0.3));
}

.schedule-shift-separator {
  min-height: 8px;
  height: auto;
  background: #e8f4f8;
  border-top: 1px solid #d4ecf4;
  border-bottom: 1px solid #d4ecf4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  z-index: 0;
}

/* ========== SCHEDULE CLOUDS (Doctor shift visual blocks) ========== */

.schedule-cloud {
  z-index: 0;
  border-radius: 8px;
  border: 2px solid;
  margin: 0;
  pointer-events: none;
  box-sizing: border-box;
}

.schedule-cloud-label {
  z-index: 5;
  pointer-events: auto;
  align-self: start;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: calc(9px * var(--schedule-font-scale, 1));
  font-weight: 600;
  color: white;
  padding: 1px 10px 2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--cloud-label-color);
  border-radius: 6px 6px 0 0;
  line-height: 1.4;
  max-width: calc(100% - 16px);
  opacity: 0.92;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
  height: fit-content;
  transform: translateY(-100%);
}

.schedule-cloud-label .schedule-cloud-print-btn {
  flex-shrink: 0;
  opacity: 1;
  color: white;
  margin-left: 4px;
}

.schedule-cloud-label .schedule-cloud-print-btn:hover {
  opacity: 1;
  color: white;
  background: rgba(255, 255, 255, 0.3);
}

.print-dropdown-item:hover {
  background: #f1f5f9;
}

.print-dropdown-item:active {
  background: #e2e8f0;
}

/* Inset schedule content so cloud border/background is visible on sides */
.schedule-slot-available,
.schedule-slot.appointment-slot,
.schedule-slot-remainder {
  margin-left: 6px;
  margin-right: 6px;
}

/* Make available slots semi-transparent to show cloud color through */
.schedule-slot-available.schedule-odd,
.schedule-slot-available.schedule-even {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(0, 0, 0, 0.06);
}

.schedule-slot-available:hover {
  background: rgba(224, 242, 254, 0.85);
  border-color: #3b82f6;
  border-style: solid;
}

/* ========== SHIFT SEPARATOR TOGGLE BUTTON ========== */

.shift-separator-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shift-separator-toggle-btn:hover {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0284c7;
}

.shift-separator-toggle-btn:hover svg {
  stroke: #0284c7;
}

.shift-separator-toggle-btn.active {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #38bdf8;
  color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

.shift-separator-toggle-btn.active svg {
  stroke: #0284c7;
}

/* Current time indicator */
.current-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.current-time-line {
  flex: 1;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.current-time-label {
  position: absolute;
  left: 0;
  background: #ef4444;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: calc(11px * var(--schedule-font-scale, 1));
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(-50%);
}

.current-time-dot {
  position: absolute;
  right: 0;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  transform: translate(50%, -50%);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Hover time indicator - показывает время при наведении мыши на сетку */
.hover-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 99;
  pointer-events: none;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  transform: translateY(-50%);
}

.hover-time-indicator.visible {
  opacity: 1;
}

.hover-time-line {
  flex: 1;
  height: 1px;
  background: #3b82f6;
  opacity: 0.6;
}

.hover-time-label {
  position: sticky;
  left: 0;
  background: #3b82f6;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: calc(11px * var(--schedule-font-scale, 1));
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(-50%);
  z-index: 11;
}

.schedule-room-column {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  grid-auto-rows: var(--schedule-row-height); /* 5 minutes slot height */
  min-width: var(--schedule-column-width);
  max-width: var(--schedule-column-width);
  width: var(--schedule-column-width);
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  align-items: stretch;
  overflow: hidden;
}

/* Force all children of room column into the same grid column (prevents side-by-side placement) */
.schedule-room-column > * {
  grid-column: 1;
}

.schedule-room-header {
  padding: 6px 10px 22px;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 40px;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: flex-start;
  grid-row: 1;
  align-self: start;
}

.schedule-room-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.sticky-room-headers-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 9;
}

.sticky-cloud-labels-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 8;
}

.sticky-cloud-label {
  position: absolute;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: calc(9px * var(--schedule-font-scale, 1));
  font-weight: 600;
  color: white;
  background: var(--cloud-label-color);
  border-radius: 0 0 6px 6px;
  line-height: 1.4;
  padding: 2px 10px;
  opacity: 0.95;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-room-header {
  position: absolute;
  z-index: 9;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(4px);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0 0 4px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  pointer-events: none;
}

.schedule-room-description {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

.print-schedule-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 3px;
  opacity: 0.4;
  transition: all 0.2s;
  vertical-align: middle;
  margin-left: 2px;
}

.print-schedule-btn:hover {
  opacity: 1;
  color: var(--brand-secondary);
  background: rgba(0, 0, 0, 0.05);
}

.schedule-slot {
  border-bottom: 1px solid var(--border-color);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
  z-index: 1;
}

.schedule-slot.empty {
  min-height: 20px;
  height: 100%;
}

.schedule-slot.empty:hover {
  background: var(--bg-highlight);
}

.schedule-slot.occupied {
  padding: 4px 6px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 4px;
  margin: 1px;
  box-shadow: var(--shadow-soft);
  align-content: start;
  min-height: 20px;
  font-size: calc(10px * var(--schedule-font-scale, 1));
}

.schedule-slot.occupied:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

/* Schedule background for appointments page (gray) */
.schedule-slot.schedule-background {
  padding: 4px 6px;
  background: #f1f5f9;
  color: #64748b;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 4px;
  margin: 1px;
  border: 1px solid #cbd5e1;
  min-height: 20px;
  font-size: calc(10px * var(--schedule-font-scale, 1));
  cursor: default;
}

.schedule-slot.schedule-background:hover {
  transform: none;
}

.schedule-slot.empty-no-schedule {
  min-height: 20px;
  height: 100%;
  background: transparent;
  cursor: not-allowed;
}

.schedule-empty-space {
  flex: 1;
  min-height: 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.schedule-empty-space:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Available slot for appointment creation */
.schedule-slot-available {
  min-height: 20px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  z-index: 1;
  position: relative;
}

/* Чередующиеся оттенки для расписаний (шахматная структура) */
.schedule-slot-available.schedule-odd {
  background: #eef2f5;
}

.schedule-slot-available.schedule-even {
  background: #f8fafc;
}

.schedule-slot-available:hover {
  background: #e0f2fe;
  border-color: #3b82f6;
  border-style: solid;
}

/* Кнопка для остатка частично занятого слота */
.schedule-slot-remainder {
  min-height: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 1;
  position: relative;
}

.schedule-slot-remainder:hover {
  background: #e0f2fe;
  border-color: #3b82f6;
  border-style: solid;
}

.remainder-plus {
  font-size: calc(14px * var(--schedule-font-scale, 1));
  font-weight: bold;
  color: #94a3b8;
  line-height: 1;
}

.schedule-slot-remainder:hover .remainder-plus {
  color: #3b82f6;
}

.appointment-slot {
  min-height: 10px;
}

.schedule-slot-doctor {
  font-size: calc(11px * var(--schedule-font-scale, 1));
  font-weight: 600;
  line-height: 1.2;
}

.schedule-slot-time {
  font-size: calc(10px * var(--schedule-font-scale, 1));
  opacity: 0.9;
  line-height: 1.2;
}

.schedule-slot-notes {
  font-size: calc(9px * var(--schedule-font-scale, 1));
  opacity: 0.8;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  line-height: 1.2;
}

/* Appointment Tooltip */
.appointment-tooltip {
  position: absolute;
  z-index: 1000;
  background: #1e293b;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  max-width: 280px;
  white-space: normal;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.appointment-tooltip.visible {
  opacity: 1;
}

.appointment-tooltip-patient {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: #f1f5f9;
}

.appointment-tooltip-time {
  color: #94a3b8;
  margin-bottom: 6px;
}

.appointment-tooltip-notes {
  display: block;
  text-align: left !important;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
}

.appointment-tooltip-patient-note {
  display: block;
  text-align: left !important;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
}

/* Appointment Card Notes in Grid */
.appointment-card-notes {
  font-size: calc(9px * var(--schedule-font-scale, 1));
  color: #64748b;
  line-height: 1.3;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Schedule Tooltip */
.schedule-tooltip {
  position: fixed;
  z-index: 10000;
  background: #1e293b;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.schedule-tooltip.visible {
  opacity: 1;
}

.schedule-tooltip-doctor {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: #f1f5f9;
}

.schedule-tooltip-time {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.schedule-tooltip-notes {
  font-size: 11px;
  border-top: 1px solid #475569;
  padding-top: 6px;
  color: #e2e8f0;
  word-break: break-word;
}

/* Doctor Specialization Tooltip */
.doctor-spec-tooltip {
  position: fixed;
  z-index: 10000;
  background: #1e293b;
  color: #f1f5f9;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  max-width: 220px;
  text-align: center;
  white-space: normal;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(4px);
}

.doctor-spec-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.doctor-spec-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1e293b;
}

.doctor-spec-tooltip.tooltip-above::before {
  top: auto;
  bottom: -6px;
  border-bottom-color: transparent;
  border-top-color: #1e293b;
}

/* Rooms Management */
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.room-item {
  padding: 12px 16px;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}

.room-item:hover {
  background: var(--bg-card);
  border-color: var(--brand-secondary);
  transform: translateX(4px);
}

.room-item-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.room-item-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.required {
  color: var(--badge-danger);
}

/* Custom Select for Doctors */
.custom-select {
  position: relative;
  width: 100%;
  z-index: 100;
}

/* Увеличиваем z-index когда селект активен */
.custom-select.is-open {
  z-index: 1005;
}

.custom-select.is-open .select-dropdown {
  z-index: 1006;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 42px;
}

.select-trigger:hover {
  border-color: var(--brand-secondary);
}

.select-placeholder {
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

.select-placeholder.selected {
  color: var(--text-primary);
}

/* Multi-select assistant chips */
.assistant-select-multiple .select-trigger {
  min-height: 40px;
  height: auto;
}

.assistant-select-multiple .select-placeholder {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.assistant-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.assistant-chip-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: #0369a1;
  opacity: 0.6;
}

.assistant-chip-remove:hover {
  opacity: 1;
}

.select-arrow {
  color: var(--text-secondary);
  font-size: 12px;
  transition: transform 0.2s;
}

.select-loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-loading-spinner .spinner {
  width: 18px;
  height: 18px;
  color: var(--brand-secondary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1003;
  max-height: 550px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.select-search {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-shrink: 0;
}

.select-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  outline: none;
  box-sizing: border-box;
}

.select-search input:focus {
  border-color: var(--brand-secondary);
}

.select-options {
  overflow-y: auto;
  max-height: 520px;
  flex: 1;
  min-height: 0;
}

.select-group-label {
  padding: 8px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-highlight);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.select-option {
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-bottom: 1px solid var(--border-color);
}

.select-option:last-child {
  border-bottom: none;
}

.select-option:hover {
  background: var(--bg-highlight);
}

.select-option.selected {
  background: var(--bg-highlight);
  border-left: 3px solid var(--brand-secondary);
}

.select-option.disabled {
  color: var(--text-secondary);
  cursor: not-allowed;
  text-align: center;
  padding: 20px;
}

#doctorFilterOptions .select-option {
  flex-direction: column;
  align-items: flex-start;
}

.select-option-main {
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.select-option-sub {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.3;
}

#specializationFilterOptions .select-option-main {
  padding-right: 10px;
}

/* Увеличиваем высоту выпадающего списка специальностей */
#specializationFilterDropdown {
  max-height: 600px;
}

#specializationFilterOptions {
  max-height: 550px;
}

/* Checkbox for room filter */
.select-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  margin-right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.select-checkbox.checkbox-checked {
  background: #3b82f6;
  border-color: #3b82f6;
}

.select-checkbox.checkbox-checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.select-option {
  display: flex;
  align-items: center;
}

/* ========== DOCTOR CARD MODAL ========== */
.doctor-row-clickable:hover {
  background-color: var(--bg-highlight);
}

.modal-content.modal-large {
  max-width: 1000px;
}

.doctor-info-section {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--bg-highlight);
  border-radius: var(--radius-md);
}

.doctor-info-section h3 {
  margin: 0 0 20px 0;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  font-weight: 600;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-item.full-width {
  grid-column: 1 / -1;
}

.info-item.full-width span {
  white-space: pre-wrap;
  line-height: 1.6;
}

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

.info-item span {
  font-size: var(--font-size-md);
  color: var(--text-primary);
  font-weight: 600;
}

.info-item a {
  color: var(--brand-secondary);
  text-decoration: none;
}

.info-item a:hover {
  text-decoration: underline;
}

.doctor-appointments-section h3 {
  margin: 0 0 16px 0;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  font-weight: 600;
}

.appointments-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.appointments-table thead {
  background: var(--bg-highlight);
}

.appointments-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.appointments-table tbody tr {
  border-bottom: 1px solid var(--border-color);
}

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

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

.appointments-table td {
  padding: 12px 16px;
  font-size: var(--font-size-md);
  color: var(--text-primary);
}

.time-range {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

.no-data {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

.error-message {
  text-align: center;
  padding: 40px;
  color: var(--badge-danger);
  font-size: var(--font-size-md);
}

.patient-link {
  color: var(--brand-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

.patient-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.appointment-date-link {
  color: var(--text-primary);
  text-decoration: none;
  display: block;
  transition: all 0.2s;
}

.appointment-date-link:hover {
  color: var(--brand-secondary);
}

.appointment-date-link:hover .time-range {
  color: var(--brand-secondary);
}

/* ========== EMPLOYEES PAGE STYLES ========== */
.employees-page {
  padding: 32px;
}

.employees-page .page-header {
  margin-bottom: 24px;
}

.employees-page .page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.employees-page .filters-section {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 24px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
}

.employees-page .filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.employees-page .filter-group > label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  white-space: nowrap;
}

.employees-page .filter-group select,
.employees-page .filter-group input[type="text"] {
  padding: 10px 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary, #1e293b);
  background: white;
  transition: border-color 0.2s;
  min-width: 160px;
}

.employees-page .filter-group select:focus,
.employees-page .filter-group input[type="text"]:focus {
  outline: none;
  border-color: var(--brand-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.employees-container {
  margin-top: 24px;
}

.employees-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.employee-group-section {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.group-header {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
}

.employee-role-section {
  margin-top: 24px;
}

.role-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

.employees-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.employees-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.employees-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

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

.employees-table tbody td {
  padding: 12px 16px;
  font-size: var(--font-size-md);
  color: var(--text-primary);
}

.employee-row-clickable {
  cursor: pointer;
}

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

.no-employees {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

/* Badge variants */
.badge-success {
  background-color: #10b981;
}

.badge-primary {
  background-color: #0284c7;
}

.badge-secondary {
  background-color: #6b7280;
}

.badge-warning {
  background-color: #f59e0b;
}

.badge-doctor {
  font-size: 16px;
  margin-left: 8px;
  display: inline-block;
  vertical-align: middle;
}

/* Employee Modal */
.employee-info-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

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

.employee-info-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--brand-primary);
  display: inline-block;
}

/* Employee Photo */
.employee-main-info-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.employee-photo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.employee-photo-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary, #f1f5f9);
    border: 2px solid var(--border-color, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.employee-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.employee-photo-placeholder {
    color: var(--text-tertiary, #94a3b8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.employee-photo-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-photo-upload,
.btn-photo-delete {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #64748b);
    transition: all 0.15s ease;
}

.btn-photo-upload:hover {
    background: var(--brand-primary, #3b82f6);
    color: #fff;
    border-color: var(--brand-primary, #3b82f6);
}

.btn-photo-delete {
    color: var(--danger, #ef4444);
    border-color: var(--danger, #ef4444);
}

.btn-photo-delete:hover {
    background: var(--danger, #ef4444);
    color: #fff;
}

/* Accordion для результатов приема */
.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accordion-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.accordion-item:hover {
  border-color: #cbd5e1;
}

.accordion-item.has-data {
  border-color: #3b82f6;
  background: #eff6ff;
}

.accordion-item.has-data .accordion-header {
  background: #dbeafe;
}

.accordion-item.has-data .accordion-header span {
  color: #1e40af;
  font-weight: 600;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: #f8fafc;
  transition: all 0.2s ease;
}

.accordion-header:hover {
  background: #f1f5f9;
}

.accordion-header span {
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
}

.accordion-arrow {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.accordion-item.active .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 16px;
}

.accordion-item.active .accordion-content {
  max-height: 2000px;
  padding: 16px;
  overflow-y: auto;
}

.accordion-content textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s ease;
}

.accordion-content textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.accordion-content textarea::placeholder {
  color: #94a3b8;
}

/* Обертка для textarea с кнопкой расширения */
.textarea-wrapper {
  position: relative;
}

.expand-textarea-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 1;
}

.expand-textarea-btn:hover {
  background: #f1f5f9;
  color: #3b82f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.expand-textarea-btn:active {
  transform: scale(0.95);
}

.expand-textarea-btn svg {
  width: 16px;
  height: 16px;
}

/* Модальное окно результатов на всю высоту */
.result-modal-fullheight {
  height: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  display: flex;
  flex-direction: column;
}

.result-modal-fullheight .modal-header {
  flex-shrink: 0;
}

.result-modal-fullheight .modal-footer {
  flex-shrink: 0;
}

.result-modal-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 20px;
  padding: 20px;
  max-height: 85vh;
  overflow: hidden;
}

/* ========== TEETH SELECTION ========== */
.teeth-selection-section {
  position: relative;
}

.teeth-type-switch {
  display: flex;
  background: white;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.teeth-type-btn {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.teeth-type-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.teeth-type-btn.active {
  background: #3b82f6;
  color: white;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

.teeth-intact-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.teeth-intact-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #475569;
}

.teeth-intact-btn.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #16a34a;
}

.teeth-intact-btn.active svg {
  stroke: #16a34a;
}

.teeth-quick-btn {
  padding: 8px 16px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.teeth-quick-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #1e293b;
}

.teeth-quick-btn.selected {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

.teeth-clear-btn {
  margin-left: auto;
  border-color: #fca5a5;
  color: #dc2626;
}

.teeth-clear-btn:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.teeth-diagram {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.teeth-diagram-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.teeth-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.teeth-row.upper-jaw {
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.teeth-row.lower-jaw {
  padding-top: 12px;
}

.teeth-side {
  display: flex;
  gap: 6px;
  align-items: center;
}

.teeth-divider {
  width: 2px;
  height: 40px;
  background: #cbd5e1;
  margin: 0 8px;
}

.tooth-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.tooth-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.tooth-btn.selected {
  background: #3b82f6;
  border-color: #2563eb;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.tooth-btn.selected:hover {
  background: #2563eb;
  border-color: #1d4ed8;
  transform: translateY(-2px);
}

.tooth-btn.highlighted {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1e40af;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2);
}

.tooth-btn.highlighted:hover {
  background: #bfdbfe;
  border-color: #3b82f6;
  transform: translateY(-2px);
}

/* Стили для зубной формулы */
.formula-tooth {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
}

.formula-tooth:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.formula-tooth.selected {
  background: #3b82f6;
  border-color: #2563eb;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.formula-tooth.selected:hover {
  background: #2563eb;
  border-color: #1d4ed8;
  transform: translateY(-2px);
}

/* Зубы с обозначениями */
.formula-tooth.has-notations {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 700;
}

.formula-tooth.has-notations:hover {
  background: #fde68a;
  border-color: #d97706;
  color: #78350f;
}

.formula-tooth.has-notations.selected {
  background: #f59e0b;
  border-color: #d97706;
  color: white;
}

.formula-tooth.has-notations.selected:hover {
  background: #d97706;
  border-color: #b45309;
}

/* Индикатор наличия обозначений */
.formula-tooth.has-notations::after {
  content: '●';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8px;
  color: #f59e0b;
}

.formula-tooth.has-notations.selected::after {
  color: white;
}

#selectedTeethDisplay {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.selected-teeth-placeholder {
  color: #94a3b8;
  font-style: italic;
}

.selected-tooth-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.selected-tooth-tag.special {
  background: #e0e7ff;
  color: #4338ca;
}

.selected-tooth-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: rgba(30, 64, 175, 0.2);
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.selected-tooth-remove:hover {
  background: rgba(30, 64, 175, 0.4);
}

/* ========== TEETH GROUP BLOCKS IN RIGHT PANEL ========== */
.teeth-group-block {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.teeth-group-block:hover {
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#teethEditingIndicator {
  transition: all 0.2s ease;
}

/* ========== TRANSACTIONS (BALANCE TAB) ========== */
.balance-section {
  padding: 8px 0 0 0;
}

.balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.balance-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.balance-label {
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.balance-amount {
  font-size: 36px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.balance-amount.positive {
  color: #10b981;
}

.balance-amount.negative {
  color: #ef4444;
}

/* Balance Statistics Cards */
.balance-stats-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.balance-stat-card {
  flex: 1;
  min-width: 180px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid;
}

.balance-stat-card.credits {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac;
}

.balance-stat-card.debits {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #fecaca;
}

.balance-stat-card.bonus-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
  min-width: 120px;
  flex: 0 0 auto;
}

.balance-stat-card.bonus-card .stat-header {
  color: #854d0e;
}

.balance-stat-card.bonus-card .stat-detail-value {
  color: #92400e;
}

/* Compact vertical layout for bonus card */
.balance-stat-card.compact-vertical {
  padding: 10px 12px;
}

.balance-stat-card.compact-vertical .stat-header {
  font-size: 11px;
  margin-bottom: 6px;
}

.balance-stat-card.compact-vertical .stat-icon {
  font-size: 13px;
}

.balance-stat-card.compact-vertical .stat-total {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
}

.balance-stat-card.compact-vertical .stat-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.balance-stat-card.compact-vertical .stat-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
}

.balance-stat-card.compact-vertical .stat-detail-label {
  opacity: 0.7;
  font-size: 9px;
}

.balance-stat-card.compact-vertical .stat-detail-value {
  font-weight: 600;
  font-size: 10px;
}

.balance-stat-card.total-balance-main {
  background: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 100%);
  border: 2px solid #3b82f6;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  flex: 0 0 auto;
  min-width: 240px;
}

.balance-stat-card.total-balance-main .stat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #075985;
}

.balance-stat-card.total-balance-main .stat-icon {
  font-size: 24px;
  font-weight: bold;
}

.balance-stat-card.total-balance-main .stat-total {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #0369a1;
}

.balance-stat-card.total-balance-main .stat-total.positive {
  color: #16a34a;
}

.balance-stat-card.total-balance-main .stat-total.negative {
  color: #dc2626;
}

.balance-stat-card.total-balance-main .stat-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.balance-stat-card.total-balance-main .stat-detail-item {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  font-size: 13px;
}

.balance-stat-card.total-balance-main .stat-detail-label {
  opacity: 0.7;
  font-weight: 500;
}

.balance-stat-card.total-balance-main .stat-detail-value {
  font-weight: 600;
  color: #64748b;
}

.balance-stat-card .stat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.balance-stat-card.credits .stat-header {
  color: #166534;
}

.balance-stat-card.debits .stat-header {
  color: #991b1b;
}

/* Compact cards */
.balance-stat-card.compact {
  padding: 10px 14px;
  flex: 1;
}

.balance-stat-card.compact .stat-header {
  font-size: 11px;
  margin-bottom: 4px;
}

.balance-stat-card.compact .stat-icon {
  font-size: 13px;
}

.balance-stat-card.compact .stat-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.balance-stat-card.compact .stat-total {
  font-size: 18px;
  margin-bottom: 0;
  min-width: 80px;
}

.balance-stat-card.compact .stat-details {
  gap: 2px;
  flex: 1;
}

.balance-stat-card.compact .stat-detail-item {
  font-size: 10px;
}

.balance-stat-card.compact .stat-detail-label {
  font-size: 10px;
}

.balance-stat-card.compact .stat-detail-value {
  font-size: 11px;
}

.balance-stat-card .stat-icon {
  font-size: 16px;
  font-weight: bold;
}

.balance-stat-card .stat-total {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.balance-stat-card.credits .stat-total {
  color: #16a34a;
}

.balance-stat-card.debits .stat-total {
  color: #dc2626;
}

.balance-stat-card .stat-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.balance-stat-card .stat-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.balance-stat-card .stat-detail-label {
  opacity: 0.8;
}

.balance-stat-card .stat-detail-value {
  font-weight: 600;
}

.balance-stat-card.credits .stat-detail-item.linked .stat-detail-value {
  color: #15803d;
}

.balance-stat-card.credits .stat-detail-item.free .stat-detail-value {
  color: #65a30d;
}

.balance-stat-card.debits .stat-detail-item.paid .stat-detail-value {
  color: #16a34a;
}

.balance-stat-card.debits .stat-detail-item.unpaid .stat-detail-value {
  color: #dc2626;
}

/* Balance Help Icon */
.balance-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0284c7;
  color: white;
  font-size: 11px;
  font-weight: bold;
  cursor: help;
  margin-left: 4px;
  transition: all 0.2s;
  position: relative;
}

.balance-help-icon:hover {
  background: #0369a1;
  transform: scale(1.1);
}

/* Тултип для balance-help-icon создаётся через JS (position: fixed),
   чтобы не обрезался overflow: hidden на .balance-sidebar */
.balance-help-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  white-space: normal;
  width: 220px;
  text-align: center;
  line-height: 1.4;
  z-index: 10000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.balance-help-tooltip.visible {
  opacity: 1;
}

.balance-help-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.9);
}

/* ===== TWO-COLUMN BALANCE LAYOUT ===== */

.patient-form-section:has(#tab-balance.active) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#tab-balance.active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#tab-balance .balance-section {
  padding: 0;
  flex: 1;
  min-height: 0;
}

.balance-two-col {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  height: 100%;
  overflow: hidden;
}

/* Левая колонка - сайдбар со статистикой */
.balance-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 8px;
  padding-bottom: 2px;
}

.balance-sidebar > * {
  flex-shrink: 0;
}

/* Правая колонка - транзакции */
.balance-two-col .balance-transactions {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.balance-two-col .balance-transactions .transactions-table-wrapper {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

/* Главный блок баланса */
.balance-main-block {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.balance-main-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.balance-main-value {
  font-size: 32px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
  white-space: nowrap;
}

.balance-main-value.positive { color: #16a34a; }
.balance-main-value.negative { color: #dc2626; }

/* Инлайн-блок бонусов внутри общего баланса */
.balance-bonus-inline {
  margin-top: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border: 1px solid #facc15;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.balance-bonus-inline:hover {
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
}

.balance-bonus-inline .bonus-inline-main {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
}

.balance-bonus-inline .bonus-inline-label {
  font-size: 13px;
  color: #854d0e;
  font-weight: 500;
}

.balance-bonus-inline .bonus-inline-value {
  font-size: 16px;
  font-weight: 700;
  color: #15803d;
  white-space: nowrap;
}

.balance-bonus-inline .expand-arrow {
  font-size: 10px;
  color: #92400e;
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.balance-bonus-inline.expanded .expand-arrow {
  transform: rotate(90deg);
}

.balance-bonus-inline .bonus-inline-sub {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  font-size: 10px;
  color: #78716c;
}

.balance-bonus-inline .bonus-inline-sub b {
  font-weight: 600;
  color: #57534e;
}

.balance-bonus-inline .bonus-sub-separator {
  color: #d6d3d1;
  font-size: 8px;
}

.balance-bonus-inline .stat-detail {
  width: 100%;
  margin-top: 8px;
  text-align: left;
  border-top: 1px dashed #facc15;
  padding-top: 8px;
}

/* Сетка статистики: пополнения и списания */
.balance-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.balance-stat-item {
  border-radius: 10px;
  padding: 12px;
}

.balance-stat-item.credits {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
}

.balance-stat-item.debits {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
}

.balance-stat-item .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.balance-stat-item.credits .stat-label { color: #166534; }
.balance-stat-item.debits .stat-label { color: #991b1b; }

.balance-stat-item .stat-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.balance-stat-item.credits .stat-value { color: #16a34a; }
.balance-stat-item.debits .stat-value { color: #dc2626; }

.balance-stat-item .stat-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
}

.balance-stat-item .stat-sub b { font-weight: 600; color: #374151; }
.balance-stat-item .stat-sub b.highlight { color: #16a34a; }
.balance-stat-item .stat-sub b.danger { color: #dc2626; }

/* Расширенный блок для реализации услуг - все цифры равнозначные */
.balance-stat-item.debits-extended .debits-values {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.balance-stat-item.debits-extended .debits-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance-stat-item.debits-extended .debits-label {
  font-size: 13px;
  color: #64748b;
}

.balance-stat-item.debits-extended .debits-value {
  font-size: 18px;
  font-weight: 700;
}

.balance-stat-item.debits-extended .debits-row.total .debits-value {
  color: #1e293b;
}

.balance-stat-item.debits-extended .debits-row.paid .debits-value {
  color: #16a34a;
}

.balance-stat-item.debits-extended .debits-row.unpaid .debits-value {
  color: #dc2626;
}

.balance-stat-item.debits-extended .debits-row.correction-note .debits-value {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  font-style: italic;
}

.stat-correction-note {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  margin-top: -2px;
  margin-bottom: 2px;
}

/* Раскрывающиеся блоки по типам */
.expandable {
  cursor: pointer;
}

.expand-arrow {
  font-size: 9px;
  opacity: 0.5;
  transition: transform 0.2s;
}

.stat-detail {
  margin-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 8px;
}

.stat-detail .detail-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-detail .detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 3px 0;
}

.stat-detail .detail-name {
  color: #475569;
}

.stat-detail .detail-amount {
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}

.stat-detail .detail-empty {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  padding: 4px 0;
}

/* Блок бонусов */
.balance-bonus-block {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border: 1px solid #facc15;
  border-radius: 10px;
  padding: 12px;
}

.balance-bonus-block .bonus-header {
  font-size: 11px;
  font-weight: 600;
  color: #854d0e;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.balance-bonus-block .bonus-value {
  font-size: 22px;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 6px;
}

.balance-bonus-block .bonus-sub {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #92400e;
}

.balance-bonus-block .bonus-sub b { font-weight: 600; }

/* Блок заметок */
.balance-notes-block {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  overflow: hidden;
}

.balance-notes-block .notes-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  transition: background 0.2s;
}

.balance-notes-block .notes-toggle:hover {
  background: #fef3c7;
}

.balance-notes-block .notes-arrow {
  font-size: 9px;
  transition: transform 0.2s;
}

.balance-notes-block .notes-arrow.open {
  transform: rotate(180deg);
}

.balance-notes-block .notes-saved {
  display: none;
  margin-left: auto;
  color: #10b981;
  font-size: 11px;
}

.balance-notes-block .notes-content {
  padding: 8px 10px;
  border-top: 1px solid #fcd34d;
}

.balance-notes-block .notes-content textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  background: rgba(255, 255, 255, 0.7);
  color: #78350f;
  line-height: 1.4;
}

.balance-notes-block .notes-content textarea:focus {
  outline: none;
  border-color: #f59e0b;
}

.balance-notes-block .notes-save-btn {
  margin-top: 6px;
  width: 100%;
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.balance-notes-block .notes-save-btn:hover {
  background: #d97706;
}

/* Кнопки действий */
.balance-actions {
  display: flex;
  gap: 8px;
}

.balance-actions .btn-action {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.balance-actions .btn-action.primary {
  flex: 1;
  background: var(--primary-color, #3b82f6);
  color: white;
}

.balance-actions .btn-action.primary:hover {
  background: var(--primary-hover, #2563eb);
}

.balance-actions .btn-group {
  display: flex;
  gap: 4px;
}

.balance-actions .btn-action.secondary {
  background: #f1f5f9;
  color: #475569;
  padding: 10px 12px;
}

.balance-actions .btn-action.secondary:hover {
  background: #e2e8f0;
}

/* Правая колонка - транзакции */
.balance-transactions {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.balance-transactions .transactions-header {
  display: none;
}

.balance-transactions .transactions-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.balance-transactions .transactions-table-wrapper {
  flex: 1;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* ===== END TWO-COLUMN BALANCE LAYOUT ===== */

/* Transactions Table */
.transactions-table-wrapper {
  max-height: 450px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.transactions-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 13px;
}

.transactions-table thead {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 10;
}

.transactions-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
}

.transactions-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.transactions-table tbody tr:hover {
  background: #f8fafc;
}

.transactions-table .tx-date {
  white-space: nowrap;
}

.transactions-table .tx-date .date {
  display: block;
  font-weight: 500;
}

.transactions-table .tx-date .time {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.transactions-table .tx-amount {
  font-weight: 600;
  white-space: nowrap;
}

.transactions-table .tx-amount.positive {
  color: #16a34a;
}

.transactions-table .tx-amount.negative {
  color: #dc2626;
}

.transactions-table .tx-realization,
.transactions-table .tx-payment,
.transactions-table .tx-created-by {
  color: var(--text-secondary);
  font-size: 12px;
}

.transactions-table .tx-realization-info {
  color: #0ea5e9;
  cursor: help;
}

.transactions-table .realization-tooltip {
  position: relative;
}

.transactions-table .tx-no-realization {
  color: #94a3b8;
  font-style: italic;
}

.transactions-table .tx-linked-transaction {
  color: #d97706;
  font-weight: 500;
  cursor: help;
}

.transactions-table .tx-has-refund {
  color: #dc2626;
  font-weight: 500;
  font-size: 12px;
}

.transactions-table .tx-clinic-sub {
  display: block;
  color: #94a3b8;
  font-size: 11px;
  margin-top: 2px;
}

/* Comment row - full width below transaction */
.transactions-table .transaction-comment-row {
  background: #f8fafc;
}

.transactions-table .transaction-comment-row:hover {
  background: #f1f5f9;
}

.transactions-table .tx-comment-full {
  padding: 8px 12px !important;
  color: #475569;
  font-size: 12.5px;
  font-style: italic;
  border-top: none !important;
  border-bottom: 1px solid #e2e8f0;
  border-left: 2px solid #94a3b8;
}

.transactions-table .tx-comment-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 600px;
  cursor: default;
  position: relative;
  line-height: 1.35;
}

.transactions-table .tx-comment-text:hover {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}

.transactions-table .tx-actions {
  white-space: nowrap;
  position: relative;
}

/* Transaction kebab menu button */
.tx-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 18px;
  color: #64748b;
  transition: background 0.15s;
  line-height: 1;
}

.tx-menu-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

.tx-menu-btn-small {
  font-size: 15px;
  padding: 2px 6px;
}

/* Transaction dropdown menu */
.tx-dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 190px;
  overflow: hidden;
  animation: dropdownFadeIn 0.15s ease-out;
}

.tx-menu-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  transition: background 0.15s;
  white-space: nowrap;
}

.tx-menu-item:hover {
  background: #f1f5f9;
}

.tx-menu-item:first-child {
  border-radius: 8px 8px 0 0;
}

.tx-menu-item:last-child {
  border-radius: 0 0 8px 8px;
}

.tx-menu-item:only-child {
  border-radius: 8px;
}

.tx-menu-item-disabled {
  color: #94a3b8;
  cursor: default;
  pointer-events: none;
}

/* Action buttons with text (legacy, kept for compatibility) */
.transactions-table .btn-tx-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 11px;
  border-radius: 4px;
  transition: all 0.2s;
  color: #475569;
  margin-right: 4px;
}

.transactions-table .btn-tx-action:last-child {
  margin-right: 0;
}

.transactions-table .btn-tx-action:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.transactions-table .btn-tx-action.btn-tx-sign {
  color: #2563eb;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.transactions-table .btn-tx-action.btn-tx-sign:hover {
  background: #dbeafe;
}

.transactions-table .btn-tx-action.btn-tx-small {
  padding: 2px 6px;
  font-size: 10px;
}

.transactions-table .tx-act-signed {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  color: #16a34a;
  font-weight: 500;
  font-size: 11px;
  background: #dcfce7;
  border-radius: 4px;
}

/* Keep old btn-action for backward compatibility */
.transactions-table .btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  transition: background 0.2s;
}

.transactions-table .btn-action:hover {
  background: #e2e8f0;
}

.transactions-table .btn-action.btn-sign {
  color: #2563eb;
}

.transactions-table .act-signed {
  color: #16a34a;
  font-weight: 600;
  font-size: 12px;
  margin-left: 4px;
}

.transactions-table .status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* Transaction Group Rows */
.transactions-table .transaction-group-header {
  background: #f1f5f9;
  cursor: pointer;
}

.transactions-table .transaction-group-header:hover {
  background: #e2e8f0;
}

.transactions-table .transaction-group-header .tx-group-info {
  font-weight: 500;
}

.transactions-table .transaction-group-header .expand-icon {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.transactions-table .transaction-group-item {
  background: #fafafa;
}

.transactions-table .transaction-group-item.hidden {
  display: none;
}

.transactions-table .transaction-group-item .tx-stage-title {
  padding-left: 20px;
}

.transactions-table .transaction-group-item .tx-stage-title a {
  text-decoration: none;
  font-size: 12px;
}

.transactions-table .transaction-group-item .tx-stage-title a:hover {
  text-decoration: underline;
}

/* Expandable single transactions with stages */
.transactions-table .transaction-row.expandable {
  cursor: pointer;
}

.transactions-table .transaction-row.expandable:hover {
  background: #f1f5f9;
}

.transactions-table .transaction-row .expand-icon {
  display: inline-block;
  font-size: 10px;
  color: var(--text-secondary);
  margin-right: 4px;
  transition: transform 0.2s;
}

.transactions-table .transaction-details {
  background: #fafafa;
}

.transactions-table .transaction-details.hidden {
  display: none;
}

.transactions-table .tx-details-cell {
  padding: 0 !important;
}

.transactions-table .tx-details-content {
  padding: 10px 16px 10px 40px;
  border-left: 3px solid #0ea5e9;
  background: linear-gradient(90deg, #f0f9ff 0%, #fafafa 100%);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.transactions-table .tx-details-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.transactions-table .tx-procedures-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transactions-table .tx-procedures-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.transactions-table .tx-procedures-list ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-primary);
}

.transactions-table .tx-procedures-list li {
  margin: 2px 0;
}

.transactions-table .tx-stage-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transactions-table .tx-stage-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.transactions-table .tx-stage-link {
  color: #0ea5e9;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.transactions-table .tx-stage-link:hover {
  text-decoration: underline;
}

.transactions-table .tx-plan-name {
  font-size: 11px;
  color: var(--text-secondary);
}

.transactions-table .tx-details-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.transactions-table .btn-action-text {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.transactions-table .btn-action-text:hover {
  background: #e2e8f0;
}

.transactions-table .btn-sign-text {
  color: #2563eb;
}

.transactions-table .act-signed-text {
  color: #16a34a;
  font-size: 12px;
  font-weight: 500;
}

/* ====== Кассовая дисциплина: аннулированные, сторно, возвраты ====== */

/* Аннулированные транзакции — серый фон, зачёркнутый текст */
.transactions-table .transaction-row.tx-voided {
  background: #f8fafc;
  opacity: 0.7;
}

.transactions-table .transaction-row.tx-voided td {
  text-decoration: line-through;
  color: #94a3b8;
}

.transactions-table .transaction-row.tx-voided .tx-amount {
  color: #94a3b8 !important;
}

.transactions-table .transaction-row.tx-voided .tx-status .status-badge {
  text-decoration: none;
}

.transactions-table .transaction-row.tx-voided .tx-actions {
  text-decoration: none;
}

.transactions-table .transaction-comment-row.tx-voided td {
  text-decoration: line-through;
  color: #94a3b8;
}

.transactions-table .tx-amount.voided {
  color: #94a3b8 !important;
}

/* Сторно-транзакции */
.transactions-table .transaction-row.tx-reversal {
  background: #f1f5f9;
}

/* Возвраты */
.transactions-table .transaction-row.tx-refund {
  background: #fffbeb;
}

/* Возвращённые транзакции (по ним оформлен возврат) */
.transactions-table .transaction-row.tx-refunded {
  background: #fffbeb;
  opacity: 0.55;
}

/* Коррекции */
.transactions-table .transaction-row.tx-correction {
  background: #eef2ff;
}

/* Бейджи типа операции */
.tx-op-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
  text-decoration: none !important;
  vertical-align: middle;
}

.tx-op-voided {
  background: #e2e8f0;
  color: #64748b;
}

.tx-op-reversal {
  background: #e2e8f0;
  color: #64748b;
}

.tx-op-refund {
  background: #fef3c7;
  color: #d97706;
}

.tx-op-correction {
  background: #e0e7ff;
  color: #4338ca;
}

.tx-correction-reason {
  font-size: 12px;
  color: #4338ca;
  font-style: italic;
}

/* Детали аннулирования */
.tx-void-details, .tx-reversal-link, .tx-refund-details {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.tx-void-label {
  font-weight: 600;
  color: #475569;
}

.tx-void-reason {
  margin-top: 4px;
}

/* Кнопка возврата */
.btn-tx-refund {
  background: #fef3c7 !important;
  color: #d97706 !important;
  border: 1px solid #fde68a !important;
}

.btn-tx-refund:hover {
  background: #fde68a !important;
}

/* Метка «Возврат оформлен» */
.tx-refund-done {
  font-size: 11px;
  color: #d97706;
  font-weight: 500;
}

/* Метка для voided */
.tx-voided-label {
  color: #94a3b8;
  font-size: 11px;
}

/* Аннулированные элементы внутри группы */
.transactions-table .tx-group-item-voided {
  background: #f8fafc;
  opacity: 0.7;
}

.transactions-table .tx-group-item-voided .tx-stage-title .tx-group-procedures {
  text-decoration: line-through;
  color: #94a3b8;
}

/* Группа, в которой все элементы аннулированы */
.transactions-table .tx-group-all-voided {
  background: #f8fafc;
  opacity: 0.7;
}

.transactions-table .tx-group-all-voided td {
  color: #94a3b8;
}

/* Loading indicator for transactions */
.transactions-table-wrapper .loading-state,
.transactions-table-wrapper .no-transactions {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

.transactions-table-wrapper .loading-more-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.transactions-table-wrapper .spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

#patientTreatmentPlansList {
  padding-right: 4px;
}

#labTestsList {
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

#patientDocumentsList {
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

#patientTasksList {
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

#commentsList {
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

.transaction-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s ease;
}

.transaction-item:hover {
  box-shadow: var(--shadow-soft);
  border-color: var(--brand-secondary);
}

.transaction-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.transaction-amount {
  font-size: 24px;
  font-weight: 700;
}

.transaction-amount.positive {
  color: #10b981;
}

.transaction-amount.negative {
  color: #ef4444;
}

.transaction-datetime {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.transaction-date {
  font-size: var(--font-size-md);
  color: var(--text-primary);
  font-weight: 500;
}

.transaction-time {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.transaction-comment {
  font-size: var(--font-size-md);
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 4px;
}

.transaction-author {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-style: italic;
}

.no-transactions {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
}

/* Transaction Groups */
.transaction-group {
  background: var(--bg-card);
  border: 2px solid #e0e7ff;
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.transaction-group:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  border-color: #c7d2fe;
}

.transaction-group-header {
  background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
  padding: 16px;
  border-bottom: 1px solid #e0e7ff;
}

.transaction-group-meta {
  margin-bottom: 12px;
}

.transaction-group-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #c7d2fe;
}

.transaction-group-stages {
  padding: 12px 16px;
  background: white;
}

.transaction-group-stage-item {
  padding: 12px;
  margin-bottom: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.transaction-group-stage-item:last-child {
  margin-bottom: 0;
}

.transaction-group-stage-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Standalone transactions (not in groups) */
.transaction-standalone {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.transaction-standalone:hover {
  box-shadow: var(--shadow-soft);
  border-color: var(--brand-secondary);
}

.transaction-standalone .transaction-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* Transaction Modal */
.modal-sm {
  max-width: 500px;
}

.form-vertical {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-vertical .form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-vertical label {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.form-vertical input[type="number"],
.form-vertical textarea {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-vertical input[type="number"]:focus,
.form-vertical textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(55, 192, 116, 0.1);
}

.form-vertical textarea {
  min-height: 100px;
  resize: vertical;
}

/* ========== NOTIFICATION SYSTEM ========== */
.notification-container {
  position: fixed;
  top: 120px;
  right: 20px;
  z-index: 10100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  min-width: 300px;
  max-width: 500px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: all;
  cursor: pointer;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.notification-message {
  flex: 1;
  font-size: var(--font-size-md);
  font-weight: 500;
  line-height: 1.4;
}

/* Success notification */
.notification-success {
  border-left: 4px solid #10b981;
}

.notification-success .notification-icon {
  background: #d1fae5;
  color: #059669;
}

.notification-success .notification-message {
  color: #065f46;
}

/* Error notification */
.notification-error {
  border-left: 4px solid #ef4444;
}

.notification-error .notification-icon {
  background: #fee2e2;
  color: #dc2626;
}

.notification-error .notification-message {
  color: #991b1b;
}

/* Warning notification */
.notification-warning {
  border-left: 4px solid #f59e0b;
}

.notification-warning .notification-icon {
  background: #fef3c7;
  color: #d97706;
}

.notification-warning .notification-message {
  color: #92400e;
}

/* Info notification */
.notification-info {
  border-left: 4px solid #3b82f6;
}

.notification-info .notification-icon {
  background: #dbeafe;
  color: #2563eb;
}

.notification-info .notification-message {
  color: #1e40af;
}

/* ========== QUICK PHRASES PANEL ========== */
#quickPhrasesPanel {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#quickPhrasesPanel::-webkit-scrollbar {
  width: 6px;
}

#quickPhrasesPanel::-webkit-scrollbar-track {
  background: transparent;
}

#quickPhrasesPanel::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}

#quickPhrasesPanel::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.quick-phrase-item {
  position: relative;
  overflow: hidden;
}

.quick-phrase-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #3b82f6;
  transform: scaleY(0);
  transition: transform 0.2s;
}

.quick-phrase-item:hover::before {
  transform: scaleY(1);
}

.quick-phrase-item:active {
  transform: scale(0.98);
}

/* ========== REPORTS STYLES ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead {
  background-color: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table td {
  padding: 14px 16px;
  color: #1e293b;
}

.form-control {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========== DYNAMIC PHONE NUMBERS ========== */
.phone-numbers-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phone-number-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e5e9f2;
}

.phone-number-item .remove-phone-btn {
  padding: 6px 10px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s;
}

.phone-number-item .remove-phone-btn:hover {
  background: #b91c1c;
}

.phone-number-item input[type="tel"] {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.phone-number-item input[type="tel"]:focus {
  outline: none;
  border-color: #37c074;
}

.phone-primary-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.phone-primary-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #37c074;
}

.phone-primary-checkbox .checkbox-label {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}

.btn-remove-phone {
  padding: 6px 10px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-remove-phone:hover {
  background: #fecaca;
}

/* Phone Warning Styles */
.phone-warning {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  margin: 8px 0;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.phone-warning-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.phone-warning-content {
  flex: 1;
  min-width: 0;
}

.phone-warning-title {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 4px;
}

.phone-warning-patients {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.phone-warning-patient-link {
  font-size: 13px;
  color: #b45309;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.phone-warning-patient-link:hover {
  color: #78350f;
  text-decoration: underline;
}

.phone-warning-stage {
  font-weight: 400;
  font-size: 12px;
  opacity: 0.8;
}

.phone-warning-hint {
  font-size: 11px;
  color: #78350f;
  opacity: 0.8;
}

.btn-add-phone {
  padding: 6px 10px;
  background: #dbeafe;
  color: #2563eb;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-add-phone:hover {
  background: #bfdbfe;
}

.button-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.button-sm .button-icon {
  font-size: 14px;
}

.button-xs {
  padding: 2px 6px;
  font-size: 11px;
  min-width: auto;
  line-height: 1.2;
}

.button-xs .button-icon {
  font-size: 11px;
}

/* Mini phone type badges for patient cards */
.phone-type-badge-mini {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  margin-left: 6px;
  background: #e0f2fe;
  color: #0369a1;
}

/* Age display for patient cards */
.patient-age {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  margin-left: auto;
  background: #f0fdf4;
  color: #166534;
  white-space: nowrap;
}

/* Age display inline in patient modal */
.age-display-inline {
  font-size: 12px;
  font-weight: 400;
  color: #94a3b8;
  margin-left: 4px;
}

.patient-info {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Document status indicator */
.document-status-indicator {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: #10b981;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

/* ========== DOCUMENTS STYLES ========== */
.documents-section {
  padding: 20px 0;
}

.document-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.document-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Status badges for documents */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-completed {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.status-signed {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.status-unsigned {
  background: #fef3c7;
  color: #92400e;
}

/* Animation for slideIn/slideOut */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

/* Month selection buttons */
.month-btn {
  min-width: 42px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: white;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.month-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.month-btn.selected {
  background: #3b82f6;
  border-color: #2563eb;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.month-btn.selected:hover {
  background: #2563eb;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

/* ========== HELPDESK FLOATING BUTTON ========== */
.helpdesk-float-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 999;
  border: none;
  font-size: 38px;
  font-weight: bold;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.helpdesk-float-button:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.helpdesk-float-button:active {
  transform: scale(0.95);
}

/* ========== HELPDESK MODAL ========== */
#helpdeskModal .modal-content {
  max-width: 600px;
}

.helpdesk-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.helpdesk-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.helpdesk-form label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.helpdesk-form textarea {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  min-height: 120px;
  resize: vertical;
  transition: all 0.2s ease;
}

.helpdesk-form textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(55, 192, 116, 0.1);
}

.helpdesk-drag-drop-area {
  padding: 24px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}

.helpdesk-drag-drop-area:hover {
  border-color: #37c074;
  background: #f0fdf4;
}

.helpdesk-files-list {
  margin-top: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
}

/* ========== BULK ACTIONS PANEL ========== */
.bulk-actions-panel {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== PLAN CHECKBOX ========== */
.plan-checkbox {
  transition: all 0.2s ease;
}

.plan-checkbox:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ========== PLAN ORDER MODAL ========== */
.plan-order-item {
  transition: all 0.2s ease;
}

.plan-order-item:hover {
  transform: translateX(4px);
}

.plan-order-item.dragging {
  opacity: 0.5;
}

.plan-order-item:active {
  cursor: grabbing;
}

/* ========== TREATMENT PLANS TABLE ========== */
.treatment-plans-table {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  border-collapse: separate;
  border-spacing: 0;
}

.treatment-plans-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 5;
}

.treatment-plans-table thead th:first-child {
  border-radius: 8px 0 0 0;
}

.treatment-plans-table thead th:last-child {
  border-radius: 0 8px 0 0;
}

.treatment-plans-table .plan-row:hover {
  background: #f8fafc;
}

.plan-dropdown-menu {
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.plan-menu-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  transition: background 0.15s;
  white-space: nowrap;
}

.plan-menu-item:hover {
  background: #f1f5f9;
}

.plan-menu-item:first-child {
  border-radius: 8px 8px 0 0;
}

.plan-menu-item:last-child {
  border-radius: 0 0 8px 8px;
}

.plan-menu-item:only-child {
  border-radius: 8px;
}

/* ========== STAGE (PROCEDURE) DROPDOWN MENU ========== */
.stage-dropdown-menu {
  animation: dropdownFadeIn 0.15s ease-out;
}

.stage-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: #334155;
  transition: background 0.15s;
  white-space: nowrap;
}

.stage-menu-item:hover {
  background: #f1f5f9;
}

.stage-menu-item:first-child {
  border-radius: 8px 8px 0 0;
}

.stage-menu-item:last-child {
  border-radius: 0 0 8px 8px;
}

.stage-menu-item:only-child {
  border-radius: 8px;
}

/* ========== PROCEDURES SELECTION MODAL ========== */
.add-procedure-button {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.add-procedure-button:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 4px 16px rgba(55, 192, 116, 0.45) !important;
}

.add-procedure-button:active {
  transform: translateY(0) scale(0.99);
}

/* Стили для модального окна процедур */
#proceduresSelectionModal .modal-content {
  animation: slideDownModal 0.3s ease-out;
}

@keyframes slideDownModal {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Стили для скроллбара в модальном окне */
#proceduresModalOptions::-webkit-scrollbar {
  width: 10px;
}

#proceduresModalOptions::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

#proceduresModalOptions::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

#proceduresModalOptions::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Стили для элементов процедур в модальном окне */
.service-item-modal {
  position: relative;
  overflow: visible;
}

.service-item-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, #37c074 0%, #2f8fed 100%);
  transform: scaleY(0);
  transition: transform 0.2s ease;
  border-radius: 8px 0 0 8px;
}

.service-item-modal:hover::before {
  transform: scaleY(1);
}

.category-header-modal,
.subcategory-item-modal {
  position: relative;
  overflow: hidden;
}

.category-header-modal::after,
.subcategory-item-modal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(55, 192, 116, 0.08), rgba(47, 143, 237, 0.05), transparent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.category-header-modal:hover::after,
.subcategory-item-modal:hover::after {
  transform: translateX(100%);
}

/* Анимация появления таблицы процедур */
#selectedProceduresTable {
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Стили для строк таблицы процедур */
#selectedProceduresBody tr {
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
}

#selectedProceduresBody tr:hover {
  background-color: #f8fafc;
}

#selectedProceduresBody tr:last-child {
  border-bottom: none;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  #proceduresSelectionModal .modal-content {
    max-width: 95vw;
    max-height: 90vh;
  }
  
  .add-procedure-button {
    font-size: 14px !important;
    padding: 14px !important;
  }
  
  .service-item-modal,
  .category-header-modal {
    padding: 12px !important;
  }
}

/* ========== DOCUMENTS: NEW IDS AND CONTRACT MODALS ========== */

/* Documents button group */
.documents-button-group {
  transition: all 0.2s ease;
}

.documents-button-group:hover {
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Limit dropdown height in contract modal */
#createContractModal .custom-select-dropdown {
  max-height: 250px !important;
  overflow-y: auto !important;
}

/* IDS Template Cards */
.ids-templates-grid {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.ids-templates-grid::-webkit-scrollbar {
  width: 8px;
}

.ids-templates-grid::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.ids-templates-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.ids-templates-grid::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.ids-template-card {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ids-template-card:active {
  transform: scale(0.98);
}

/* IDS Search input focus */
#idsSearchInput:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Spinner for loading states */
.spinner {
  border: 3px solid #f1f5f9;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== BUTTON LOADING STATE (opt-in via data-loading) ========== */
.button.is-loading,
button.is-loading,
a.is-loading {
  pointer-events: none;
  opacity: 0.8;
  cursor: wait;
  position: relative;
}

.button.is-loading .spinner-small,
button.is-loading .spinner-small,
a.is-loading .spinner-small {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

/* Responsive design for IDS modal */
@media (max-width: 1280px) {
  .ids-templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  }
}

@media (max-width: 768px) {
  .ids-templates-grid {
    grid-template-columns: 1fr !important;
  }
  
  .documents-button-group {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 8px 12px !important;
  }
  
  .documents-button-group .button {
    flex: 1 1 auto;
    min-width: 120px;
  }
}

/* ========== CANCELLED APPOINTMENTS TOGGLE ========== */

/* Кнопка переключения отмененных приемов */
.cancelled-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cancelled-toggle-btn:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.cancelled-toggle-btn:hover svg {
  stroke: #dc2626;
}

.cancelled-toggle-btn.active {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #f87171;
  color: #dc2626;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.15);
}

.cancelled-toggle-btn.active svg {
  stroke: #dc2626;
}

.cancelled-toggle-btn .cancelled-count {
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Анимация появления отмененных карточек */
@keyframes fadeInCancelled {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.cancelled-appointment-card {
  animation: fadeInCancelled 0.3s ease-out;
}

/* Overlay контейнер */
.cancelled-appointments-overlay {
  pointer-events: none;
}

/* ===== MESSENGER LINKS / КНОПКИ МЕССЕНДЖЕРОВ ===== */

/* Кнопки мессенджеров в карточках пациентов (канбан) */
.messenger-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  color: white;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.2s;
  margin-right: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.messenger-badge:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.messenger-badge:last-child {
  margin-right: 0;
}

.messenger-badge-telegram {
  background: #0088cc;
}

.messenger-badge-vk {
  background: #4a76a8;
}

.messenger-badge-whatsapp {
  background: #25d366;
}

.messenger-badge-viber {
  background: #665cac;
}

/* Контейнер кнопок мессенджеров в строке с иконкой */
.patient-messengers {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

/* Контейнер кнопок мессенджеров в модальном окне */
.messenger-links-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* Стили для inline кнопок мессенджеров (в appointments и др.) */
.messenger-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color 0.2s, transform 0.1s;
}

.messenger-btn:hover {
  transform: scale(1.02);
}

.messenger-btn svg {
  flex-shrink: 0;
}

/* ========== ARRIVAL/DEPARTURE BUTTONS ========== */
.arrival-btn,
.departure-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.1s;
  padding: 0;
  line-height: 1;
}

.arrival-btn {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #22c55e;
}

.arrival-btn:hover {
  background: #bbf7d0;
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

.departure-btn {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #ef4444;
}

.departure-btn:hover {
  background: #fecaca;
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Индикатор присутствия пациента */
.patient-inside-indicator {
  color: #22c55e;
  font-size: 8px;
  flex-shrink: 0;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== DIARIES TAB MOBILE STYLES ========== */

/* Мобильные стили для вкладки дневников лечения */
@media (max-width: 900px) {
  .diaries-tab-layout {
    flex-direction: column !important;
    height: auto !important;
    min-height: auto !important;
    gap: 12px !important;
  }
  
  .diaries-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding-right: 0 !important;
    padding-bottom: 12px !important;
    max-height: none !important;
  }
  
  .diaries-list-container {
    max-height: 280px !important;
    overflow-y: auto !important;
  }
  
  .diaries-content {
    min-height: 400px !important;
    padding: 0 !important;
  }
  
  #diariesFiltersPanel {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }
}

@media (max-width: 600px) {
  .diaries-tab-layout {
    gap: 8px !important;
  }
  
  .diaries-list-container {
    max-height: 200px !important;
  }
  
  /* Кнопки редактирования и печати */
  #diariesContentArea .button {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
  
  /* Заголовок дневника - вертикальное расположение (текст сверху, кнопки снизу) */
  .diary-header-mobile {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }
  
  /* Таблица данных дневника - вертикальная раскладка */
  #diariesContentArea table td {
    display: block !important;
    width: 100% !important;
    padding: 8px 12px !important;
  }
  
  #diariesContentArea table td:first-child {
    padding-bottom: 4px !important;
    border-bottom: none !important;
  }
  
  #diariesContentArea table tr {
    display: block !important;
    border-bottom: 1px solid #e2e8f0 !important;
    margin-bottom: 8px !important;
    padding-bottom: 8px !important;
  }
  
  /* Сетка изображений */
  #diariesContentArea [style*="grid-template-columns"] {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
  }
}

/* ============================================
   Payment History Modal Table
   ============================================ */
.ph-stage-header {
  font-weight: 600;
  font-size: 14px;
  color: #1e293b;
  padding: 14px 0 6px;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.ph-stage-header:first-child {
  border-top: none;
  padding-top: 8px;
}

.ph-stage-status {
  font-weight: 400;
  font-size: 12px;
}

.ph-stage-amounts {
  font-weight: 400;
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
}

.ph-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 6px;
}

.ph-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 500;
  font-size: 12px;
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.ph-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.ph-table td:nth-child(1),
.ph-table td:nth-child(2),
.ph-table td:nth-child(3) {
  white-space: nowrap;
}

.ph-table td:nth-child(4) {
  word-break: break-word;
  min-width: 120px;
}

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

.ph-table tr:hover td {
  background: #f8fafc;
}

.ph-no-payments {
  color: #94a3b8;
  font-size: 13px;
  padding: 8px 0 14px;
  font-style: italic;
}

.ph-total-row {
  text-align: right;
  font-size: 12px;
  color: #64748b;
  padding: 2px 0 10px;
}

.ph-summary-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  flex-wrap: wrap;
}

.ph-summary-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ph-summary-label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ph-summary-value {
  font-weight: 600;
  font-size: 14px;
  color: #1e293b;
}

.ph-summary-divider {
  width: 1px;
  height: 28px;
  background: #e2e8f0;
  flex-shrink: 0;
}

/* ========== INCIDENTS FILTERS ========== */

#incidentFiltersPanel .filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

#incidentFiltersPanel .filter-group {
  min-width: 0;
  width: auto;
}

#incidentFiltersPanel .filter-group select,
#incidentFiltersPanel .filter-group input[type="date"] {
  width: 140px;
}

#incidentFiltersPanel .filter-group .custom-select-wrapper {
  min-width: 220px;
}

#incidentFiltersPanel .filter-actions {
  margin-left: auto;
}

#incidentFiltersPanel .filter-group select,
#incidentFiltersPanel .filter-group input {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}

#incidentFiltersPanel .filter-group select:focus,
#incidentFiltersPanel .filter-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========== TASKS SECTION TABS ========== */

.tasks-section-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color, #e2e8f0);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.tasks-section-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.tasks-section-tab:hover {
  color: var(--text-primary, #1e293b);
}

.tasks-section-tab.active {
  color: var(--primary, #2563eb);
  border-bottom-color: var(--primary, #2563eb);
  font-weight: 600;
}

/* ========== INCIDENTS TABLE ========== */

.incidents-table-wrapper {
  overflow-x: auto;
  flex: 1;
}

.incidents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.incidents-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #64748b);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  white-space: nowrap;
  background: var(--bg-secondary, #f8fafc);
  position: sticky;
  top: 0;
  z-index: 1;
}

.incidents-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color, #f1f5f9);
  color: var(--text-primary, #1e293b);
  vertical-align: top;
}

.incident-row {
  cursor: pointer;
  transition: background 0.12s;
}

.incident-row:hover {
  background: var(--bg-hover, #f1f5f9);
}

.incident-col-date {
  min-width: 110px;
  white-space: nowrap;
}

.incident-col-status {
  min-width: 100px;
  white-space: nowrap;
}

.incident-col-desc {
  min-width: 200px;
  max-width: 320px;
}

.incident-col-resolution {
  min-width: 160px;
  max-width: 280px;
}

.incident-col-responsible {
  min-width: 120px;
  white-space: nowrap;
}

.incident-col-clinic {
  min-width: 120px;
  white-space: nowrap;
}

.incident-col-created {
  min-width: 100px;
  white-space: nowrap;
}

.incident-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.incident-status-active {
  background: #fef3c7;
  color: #92400e;
}

.incident-status-resolved {
  background: #d1fae5;
  color: #065f46;
}

/* Pagination */

.incidents-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 16px 0;
}

.pagination-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1e293b);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--bg-hover, #f1f5f9);
  border-color: var(--border-active, #cbd5e1);
}

.pagination-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
  font-weight: 600;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Empty state for incidents */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-tertiary, #94a3b8);
}

.empty-state p {
  font-size: 15px;
  margin: 0;
}

/* ========== RECLAMATIONS ========== */

#reclFiltersPanel .filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

#reclFiltersPanel .filter-group {
  min-width: 0;
  width: auto;
}

#reclFiltersPanel .filter-group select,
#reclFiltersPanel .filter-group input[type="date"],
#reclFiltersPanel .filter-group input[type="text"] {
  width: 140px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}

#reclFiltersPanel .filter-group select:focus,
#reclFiltersPanel .filter-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#reclFiltersPanel .filter-actions {
  margin-left: auto;
}

.recl-patient-search-wrap {
  position: relative;
  width: 100%;
}

.recl-patient-search-wrap input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.recl-patient-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
}

.recl-patient-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

.recl-patient-item:hover {
  background: #f1f5f9;
}

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

.recl-teeth-display {
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  transition: border-color 0.15s;
}

.recl-teeth-display:hover {
  border-color: #3b82f6;
}

.recl-teeth-placeholder {
  color: #94a3b8;
  font-size: 13px;
}

#reclTeethModal .teeth-diagram-container {
  min-width: 0;
}

#reclTeethModal .teeth-row {
  flex-wrap: nowrap;
}

#reclTeethModal .tooth-btn {
  min-width: 32px;
  height: 32px;
  font-size: 12px;
  padding: 0 2px;
}

.recl-appt-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.recl-appt-filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}

.recl-appt-filter-row input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
}

.recl-appt-filter-row input:focus {
  border-style: solid;
  border-color: #3b82f6;
  background: #fff;
}

.recl-appt-info {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  font-size: 13px;
  color: #1e293b;
  display: flex;
  gap: 16px;
  align-items: center;
}

.recl-appt-info .recl-info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 2px;
}

.recl-appt-info .recl-info-value {
  font-weight: 500;
  color: #0f172a;
}