/* =========================
   Основные стили приложения
   static/css/app.css
   ========================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;

  --light: #f8fafc;
  --white: #ffffff;
  --dark: #0f172a;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --border-radius-sm: 8px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.14);

  --transition: all 0.2s ease;

  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-info: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* =========================
   База
   ========================= */

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: linear-gradient(135deg, #f5f7fa 0%, #f8f9fc 100%);
  color: var(--gray-900);
  min-height: 100vh;
}

img,
svg {
  vertical-align: middle;
}

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

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

/* =========================
   Типографика
   ========================= */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--gray-900);
}

h1 {
  font-size: 2rem;
  line-height: 1.08;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

small,
.text-muted {
  color: var(--gray-500) !important;
}

.number-cell {
  display: inline-block;
  min-width: 100px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 700;
  font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.number-cell-large {
  font-size: 1.25rem;
  font-weight: 800;
}

/* =========================
   Навбар
   ========================= */

.navbar {
  box-shadow: var(--shadow-md);
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff !important;
}

.navbar-nav .nav-link {
  font-size: 1rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92) !important;
  transition: var(--transition);
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  color: #fff !important;
  opacity: 1;
}

/* =========================
   Кнопки
   ========================= */

.btn {
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  transition: var(--transition);
  padding: 0.625rem 1.05rem;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  box-shadow: none;
}

.btn:hover,
.btn:focus {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--gradient-primary);
  border: none;
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  box-shadow: var(--shadow-md);
  color: #fff;
}

.btn-secondary {
  background-color: var(--secondary);
  border-color: var(--secondary);
}

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

.btn-success:hover,
.btn-success:focus {
  box-shadow: var(--shadow-md);
  color: #fff;
}

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

.btn-danger:hover,
.btn-danger:focus {
  box-shadow: var(--shadow-md);
  color: #fff;
}

.btn-outline-primary {
  border: 2px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
}

.btn-outline-danger {
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
  background: var(--danger);
  color: #fff;
}

.btn-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  padding-left: 0;
  padding-right: 0;
}

.btn-link:hover,
.btn-link:focus {
  text-decoration: underline;
  color: var(--primary-dark);
}

/* =========================
   Карточки / блоки
   ========================= */

.card {
  border: none;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  margin-bottom: 1.5rem;
  background: var(--white);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
  border-bottom: 1px solid var(--gray-200);
  padding: 1.1rem 1.35rem;
  font-weight: 700;
  font-size: 1rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.card-text {
  font-size: 0.95rem;
  color: var(--gray-600);
}

/* =========================
   Таблицы
   ========================= */

.table-container {
  overflow: auto;
  max-height: 600px;
  border-radius: var(--border-radius);
  background-color: var(--white);
}

.table,
.data-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th,
.data-table th {
  text-align: left;
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.9rem 0.75rem;
  border-bottom: 2px solid var(--gray-300);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--gray-700);
  white-space: nowrap;
}

.table td,
.data-table td {
  vertical-align: middle;
  padding: 0.9rem 0.75rem;
  border-bottom: 1px solid var(--gray-200);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover,
.data-table tr:hover {
  background-color: rgba(37, 99, 235, 0.04);
}

.table-bordered th,
.table-bordered td {
  border: 1px solid var(--gray-300);
}

.table-responsive {
  border-radius: var(--border-radius);
  overflow-x: auto;
}

.time-cell {
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
}

.patient-cell {
  font-weight: 600;
  color: var(--gray-900);
}

.amount {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--gray-900);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.amount.due {
  color: var(--danger);
}

/* =========================
   Формы
   ========================= */

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-control,
.form-select {
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  padding: 0.625rem 0.875rem;
  transition: var(--transition);
  border: 1px solid var(--gray-300);
  background-color: var(--white);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
  outline: none;
}

.form-control:hover,
.form-select:hover {
  border-color: var(--gray-400);
}

.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-label {
  font-size: 0.95rem;
  cursor: pointer;
}

/* =========================
   Модальные окна / пагинация / alert
   ========================= */

.modal-content {
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: none;
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--gray-200);
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
  padding: 1.15rem 1.35rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-footer {
  border-top: 1px solid var(--gray-200);
  padding: 1rem 1.35rem;
}

.pagination .page-link {
  font-size: 0.95rem;
  border-radius: var(--border-radius-sm);
  margin: 0 0.2rem;
  transition: var(--transition);
}

.pagination .page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
}

.pagination .page-item.disabled .page-link {
  cursor: not-allowed;
  opacity: 0.6;
}

.alert {
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  border: none;
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}

.alert-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
}

.alert-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
}

.alert-info {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
}

.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* =========================
   Справочники
   ========================= */

#dictionaryModal .modal-dialog {
  max-width: 95vw;
  width: 95vw;
  margin: 1.75rem auto;
}

#dictionaryModal .modal-content {
  padding: 0;
  overflow-x: auto;
}

#dictionaryModal table {
  min-width: max-content;
}

.expenses-table-wrapper {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}

.expenses-table-wrapper table {
  min-width: 1100px;
}

.expenses-table-wrapper input.form-control-sm,
.expenses-table-wrapper select.form-select-sm {
  min-width: 110px;
}

/* =========================
   Dashboard
   ========================= */

.dashboard-container {
  padding: 0 0.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-left {
  flex: 1 1 auto;
  min-width: 240px;
}

.header-right {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
}

.dashboard-title {
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--gray-900);
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.03em;
  display: block;
}

.dashboard-subtitle {
  margin-top: 0.4rem;
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--gray-500);
}

.cash-widget {
  background: var(--gradient-primary);
  border-radius: var(--border-radius-xl);
  padding: 0.95rem 1.15rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
  min-width: 300px;
  max-width: 420px;
}

.cash-widget-content {
  display: flex;
  align-items: flex-start;
  gap: 0.95rem;
  color: #fff;
}

.cash-widget-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex: 0 0 46px;
}

.cash-widget-info {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  flex: 1;
  min-width: 0;
}

.cash-widget-label {
  font-size: 0.74rem;
  opacity: 0.94;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cash-widget-date {
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.cash-widget-status {
  font-size: 0.76rem;
}

.cash-widget-status .badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
}

.cash-widget-details {
  font-size: 0.82rem;
  opacity: 0.96;
  line-height: 1.35;
  font-weight: 500;
}

.cash-widget .btn {
  margin-top: 0.45rem;
  padding: 0.48rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 10px;
  align-self: flex-start;
}

.cash-widget .btn-outline-danger {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.cash-widget .btn-outline-danger:hover,
.cash-widget .btn-outline-danger:focus {
  background: rgba(255, 255, 255, 0.20);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.65);
}

.filter-card {
  background: #fff;
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 1rem;
}

.filter-form {
  margin: 0;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.filter-group {
  flex: 1 1 190px;
  min-width: 180px;
}

.filter-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.branch-badge {
  min-height: 42px;
  display: flex;
  align-items: center;
  background: var(--gray-100);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
}

.filter-actions {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 360px;
}

.filter-actions>.btn,
.action-buttons>.btn {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.filter-actions>.btn {
  min-width: 120px;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-buttons .btn {
  min-width: 185px;
}

.info-note {
  background: linear-gradient(135deg, #fff7db 0%, #fef3c7 100%);
  border-left: 4px solid #f59e0b;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #92400e;
  margin-bottom: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: #fff;
  border-radius: 18px;
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 148px;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card-icon {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: #fff;
  flex: 0 0 62px;
}

.stat-card-icon.revenue {
  background: var(--gradient-success);
}

.stat-card-icon.appointments {
  background: var(--gradient-info);
}

.stat-card-icon.operations {
  background: var(--gradient-warning);
}

.stat-card-icon.info {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.stat-card-content {
  flex: 1;
  min-width: 0;
}

.stat-card-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 0.55rem;
}

.stat-card-value {
  font-size: 2.35rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.02;
  letter-spacing: -0.03em;
  word-break: break-word;
}

.stat-card-trend {
  font-size: 0.82rem;
  color: var(--gray-400);
  margin-top: 0.35rem;
  font-weight: 500;
}

.stat-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.4rem;
  margin-top: 0.55rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--gray-500);
  font-weight: 600;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-card-note {
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.45;
}

.timeline-card,
.data-card {
  background: #fff;
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.timeline-card {
  margin-bottom: 1.25rem;
}

.timeline-header-section,
.data-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--gray-200);
}

.timeline-title,
.data-card-title {
  font-weight: 750;
  color: var(--gray-900);
  font-size: 1.08rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.timeline-range,
.date-badge {
  background: var(--gray-100);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--gray-600);
  font-weight: 600;
}

/* =========================
   Таймлайн расписания
   ========================= */

.timeline {
  width: 100%;
}

.timeline-header,
.timeline-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: center;
  gap: 8px;
}

.timeline-header .tl-grid {
  height: 40px;
}

.tl-col-label {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gray-700);
  padding: 0.45rem 0.5rem 0.45rem 0;
}

.tl-col-grid {
  position: relative;
  overflow-x: auto;
}

.tl-grid {
  position: relative;
  height: 24px;
}

.tl-grid-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.04) 0 100%);
  border-radius: 8px;
  z-index: 1;
}

.tl-grid-ticks {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.tl-grid-ticks .tl-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(15, 23, 42, 0.10);
}

.tl-grid-labels {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  font-size: 12px;
  color: var(--gray-500);
  pointer-events: none;
  z-index: 3;
}

.timeline-header .tl-col-grid {
  padding-top: 18px;
}

.tl-label {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.tl-label.first {
  transform: none;
  left: 0 !important;
}

.tl-label.last {
  transform: translateX(-100%);
}

.tl-track {
  position: relative;
  height: 28px;
  background: rgba(15, 23, 42, 0.03);
  border-radius: 8px;
  min-width: 720px;
}

.tl-shift {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: rgba(37, 99, 235, 0.14);
  border-radius: 6px;
}

.tl-appt {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 6px;
  display: block;
  cursor: pointer;
  outline: 1px solid rgba(15, 23, 42, 0.05);
  transition: filter 0.2s ease;
}

.tl-appt:hover {
  filter: brightness(1.05);
}

.tl-appt.status-booked {
  background: rgba(37, 99, 235, 0.68);
}

.tl-appt.status-done {
  background: rgba(5, 150, 105, 0.74);
}

.tl-appt.status-cancelled {
  background: rgba(220, 38, 38, 0.72);
}

.tl-appt.status-no_show {
  background: rgba(245, 158, 11, 0.74);
}

/* =========================
   Статусы / бейджи
   ========================= */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-booked {
  background: #e2e8f0;
  color: #475569;
}

.status-done {
  background: #d1fae5;
  color: #065f46;
}

.status-no_show {
  background: #fed7aa;
  color: #92400e;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.status-paid {
  background: #d1fae5;
  color: #065f46;
}

.status-pending {
  background: #ffedd5;
  color: #9a3412;
}

.visit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem 0.55rem;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.45rem;
}

/* =========================
   Кнопки действий в таблицах
   ========================= */

.action-buttons-cell {
  white-space: nowrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-width: 38px;
  height: 38px;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--gray-700);
  margin: 0 0.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  vertical-align: middle;
}

.btn-action i {
  font-size: 1rem;
  line-height: 1;
}

.btn-action .action-text {
  display: inline-block;
}

.btn-action:hover,
.btn-action:focus {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-action.btn-view {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.btn-action.btn-view:hover,
.btn-action.btn-view:focus {
  background: #dbeafe;
  color: #1e3a8a;
}

.btn-action.btn-edit {
  color: #b45309;
  background: #fff7ed;
  border-color: #fed7aa;
}

.btn-action.btn-edit:hover,
.btn-action.btn-edit:focus {
  background: #ffedd5;
  color: #92400e;
}

.btn-action.btn-payment {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.btn-action.btn-payment:hover,
.btn-action.btn-payment:focus {
  background: #d1fae5;
  color: #065f46;
}

.btn-action.btn-visit {
  color: #6d28d9;
  background: #f5f3ff;
  border-color: #ddd6fe;
}

.btn-action.btn-visit:hover,
.btn-action.btn-visit:focus {
  background: #ede9fe;
  color: #5b21b6;
}

.btn-action.disabled,
.btn-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--gray-400);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* =========================
   Прочее
   ========================= */

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* =========================
   Адаптив
   ========================= */

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  .navbar-brand {
    font-size: 1.25rem;
  }

  .btn {
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-right {
    margin-left: 0;
    width: 100%;
  }

  .dashboard-title {
    font-size: 1.9rem;
  }

  .dashboard-subtitle {
    font-size: 0.9rem;
  }

  .cash-widget {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .cash-widget-date {
    font-size: 1.08rem;
  }

  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    min-width: 0;
  }

  .filter-actions {
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
    flex: 1 1 auto;
  }

  .action-buttons {
    flex-direction: column;
    width: 100%;
  }

  .filter-actions>.btn,
  .action-buttons>.btn {
    width: 100%;
  }

  .stat-card {
    min-height: auto;
    padding: 1.15rem 1.2rem;
  }

  .stat-card-value {
    font-size: 2rem;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .timeline-header-section,
  .data-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
  }

  .timeline-header,
  .timeline-row {
    grid-template-columns: 180px 1fr;
  }

  .tl-track {
    min-width: 640px;
  }

  .table th,
  .table td,
  .data-table th,
  .data-table td {
    font-size: 0.85rem;
    padding: 0.6rem;
  }

  .action-buttons-cell {
    white-space: normal;
  }

  .btn-action {
    height: 34px;
    min-width: 34px;
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .btn-action .action-text {
    display: none;
  }
}

/* ===== CASH WIDGET SAFE OVERRIDE ===== */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.header-left {
  flex: 1 1 420px;
  min-width: 320px;
}

.header-right {
  flex: 0 0 520px;
  max-width: 520px;
  width: 100%;
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
}

.cash-widget {
  width: 100%;
  max-width: 520px;
  min-width: 0;
  background: var(--gradient-primary);
  border-radius: 22px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.cash-widget-content {
  display: flex;
  align-items: flex-start;
  gap: 0.95rem;
  color: #fff;
}

.cash-widget-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex: 0 0 52px;
}

.cash-widget-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.cash-widget-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 0.9rem;
  align-items: start;
}

.cash-widget-head {
  min-width: 0;
}

.cash-widget-label {
  font-size: 0.78rem;
  opacity: 0.94;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.12rem;
}

.cash-widget-date {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.cash-widget-status {
  margin-bottom: 0.35rem;
}

.cash-widget-status .badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
}

.cash-widget-details {
  font-size: 0.88rem;
  opacity: 0.96;
  line-height: 1.35;
  font-weight: 500;
}

.cash-widget-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.cash-metric {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
}

.cash-metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
  margin-bottom: 0.2rem;
}

.cash-metric-value {
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
  white-space: nowrap;
}

.cash-metric-value.current {
  font-size: 1.1rem;
}

.cash-widget-actions {
  display: flex;
  justify-content: flex-start;
}

.cash-widget .btn {
  margin-top: 0;
  padding: 0.5rem 0.95rem;
  font-size: 0.82rem;
  border-radius: 10px;
  align-self: flex-start;
}

.cash-widget .btn-outline-danger {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.42);
}

.cash-widget .btn-outline-danger:hover,
.cash-widget .btn-outline-danger:focus {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.68);
}

@media (max-width: 1100px) {
  .header-right {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .cash-widget {
    max-width: 100%;
  }

  .cash-widget-top {
    grid-template-columns: 1fr;
  }

  .cash-widget-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left,
  .header-right {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    margin-left: 0;
  }

  .cash-widget {
    max-width: 100%;
    width: 100%;
    padding: 1rem;
  }

  .cash-widget-top {
    grid-template-columns: 1fr;
  }

  .cash-widget-metrics {
    grid-template-columns: 1fr;
  }
}

/* ===== DASHBOARD COMPACT TUNING ===== */

/* шапка */
.dashboard-header {
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.header-left {
  flex: 1 1 420px;
  min-width: 320px;
}

.header-right {
  flex: 0 0 500px;
  max-width: 500px;
  width: 100%;
}

.dashboard-title {
  font-size: 2.05rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
}

.dashboard-subtitle {
  margin-top: 0.2rem;
  font-size: 0.92rem;
  color: var(--gray-500);
}

/* касса */
.cash-widget {
  max-width: 500px;
  padding: 0.85rem 1rem;
  border-radius: 20px;
}

.cash-widget-content {
  gap: 0.8rem;
}

.cash-widget-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  font-size: 1.2rem;
}

.cash-widget-main {
  gap: 0.55rem;
}

.cash-widget-top {
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 0.75rem;
}

.cash-widget-label {
  font-size: 0.72rem;
  margin-bottom: 0.08rem;
}

.cash-widget-date {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.cash-widget-status {
  margin-bottom: 0.25rem;
}

.cash-widget-status .badge {
  font-size: 0.72rem;
  padding: 0.32rem 0.6rem;
}

.cash-widget-details {
  font-size: 0.8rem;
  line-height: 1.28;
}

.cash-widget-metrics {
  gap: 0.45rem;
}

.cash-metric {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
}

.cash-metric-label {
  font-size: 0.64rem;
  margin-bottom: 0.12rem;
}

.cash-metric-value {
  font-size: 0.92rem;
  line-height: 1.1;
}

.cash-metric-value.current {
  font-size: 1rem;
}

.cash-widget-actions {
  margin-top: 0.05rem;
}

.cash-widget .btn {
  padding: 0.42rem 0.82rem;
  font-size: 0.76rem;
  border-radius: 9px;
}

/* фильтр чуть ближе к шапке */
.filter-card {
  margin-top: 0;
  margin-bottom: 1rem;
  padding: 1.1rem 1.25rem;
}

/* карточки метрик */
.stats-grid {
  gap: 1rem;
}

.stat-card {
  min-height: 132px;
  padding: 1.15rem 1.25rem;
  border-radius: 16px;
}

.stat-card-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  font-size: 1.45rem;
  border-radius: 12px;
}

.stat-card-label {
  font-size: 0.76rem;
  margin-bottom: 0.4rem;
}

.stat-card-value {
  font-size: 1.95rem;
  line-height: 1.02;
}

.stat-card-trend {
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

.stat-card-stats {
  gap: 0.7rem 1rem;
  margin-top: 0.35rem;
}

.stat-label {
  font-size: 0.74rem;
}

.stat-value {
  font-size: 1.1rem;
}

/* мобильная адаптация */
@media (max-width: 1100px) {
  .dashboard-header {
    align-items: flex-start;
  }

  .header-right {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .cash-widget {
    max-width: 100%;
  }

  .cash-widget-top {
    grid-template-columns: 1fr;
  }

  .cash-widget-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard-header {
    margin-bottom: 0.9rem;
  }

  .dashboard-title {
    font-size: 1.8rem;
  }

  .dashboard-subtitle {
    font-size: 0.88rem;
  }

  .cash-widget {
    padding: 0.9rem;
  }

  .cash-widget-metrics {
    grid-template-columns: 1fr;
  }

  .stat-card-value {
    font-size: 1.7rem;
  }

  .stat-value {
    font-size: 1rem;
  }
}