
/* ============================================================
   iOS 19 — Liquid Glass Design System  CRM Panel 2.0
   ============================================================ */

:root {
  --ios-accent:       #6b4e9e;
  --ios-accent-rgb:   107,78,158;
  --ios-accent2:      #9b72d4;
  --ios-bg:           #f0ecfa;
  --ios-glass:        rgba(255,255,255,0.72);
  --ios-glass-strong: rgba(255,255,255,0.88);
  --ios-blur:         blur(42px) saturate(220%) brightness(1.06);
  --ios-blur-sm:      blur(26px) saturate(200%) brightness(1.05);
  --ios-radius:       16px;
  --ios-radius-sm:    10px;
  --ios-radius-lg:    22px;
  --ios-radius-xl:    28px;
  --ios-shadow:       0 14px 44px rgba(107,78,158,0.20), 0 4px 14px rgba(0,0,0,0.10);
  --ios-shadow-sm:    0 4px 16px rgba(107,78,158,0.14), 0 1px 4px rgba(0,0,0,0.06);
  --ios-shadow-lg:    0 28px 70px rgba(0,0,0,0.24), 0 6px 20px rgba(107,78,158,0.16);
  --ios-border:       1px solid rgba(255,255,255,0.6);
  --ios-label:        #1c1c1e;
  --ios-label2:       #636366;
  --ios-sep:          rgba(60,60,67,0.18);
  --ios-font:         -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --ios-ease:         cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

*,*::before,*::after { box-sizing: border-box !important; }
html { -webkit-text-size-adjust: 100% !important; }

body {
  font-family: var(--ios-font) !important;
  background: var(--ios-bg) !important;
  color: var(--ios-label) !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

body::before {
  content: "" !important;
  position: fixed !important;
  inset: 0 !important;
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(180,140,255,0.28) 0%, transparent 55%),
    radial-gradient(ellipse 60% 80% at 85% 85%, rgba(120,180,255,0.20) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 50%, rgba(240,230,255,0.35) 0%, transparent 65%),
    linear-gradient(145deg,#ede6ff 0%,#f4eeff 45%,#eaf0ff 100%) !important;
  z-index: -1 !important;
  pointer-events: none !important;
}

::-webkit-scrollbar { width: 4px !important; height: 4px !important; }
::-webkit-scrollbar-track { background: transparent !important; }
::-webkit-scrollbar-thumb { background: rgba(107,78,158,0.3) !important; border-radius: 100px !important; }

/* --- NAV BAR --- */
.nav-bar {
  background: var(--ios-glass) !important;
  backdrop-filter: var(--ios-blur) !important;
  -webkit-backdrop-filter: var(--ios-blur) !important;
  border-radius: var(--ios-radius-lg) !important;
  border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm), inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(0,0,0,0.04) !important;
  padding: 6px 10px !important;
  margin-bottom: 10px !important;
  gap: 4px !important;
  position: sticky !important;
  top: 6px !important;
  z-index: 100 !important;
}

.nav-btn {
  background:
    radial-gradient(circle at 28% 22%, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0) 48%),
    rgba(255,255,255,0.22) !important;
  backdrop-filter: blur(28px) saturate(220%) brightness(1.08) !important;
  -webkit-backdrop-filter: blur(28px) saturate(220%) brightness(1.08) !important;
  border: 1px solid rgba(255,255,255,0.65) !important;
  border-radius: 100px !important;
  color: var(--ios-accent) !important;
  font-family: var(--ios-font) !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  padding: 5px 14px !important;
  letter-spacing: -0.15px !important;
  box-shadow:
    0 6px 16px rgba(107,78,158,0.16),
    0 1px 2px rgba(0,0,0,0.05),
    inset 0 1.5px 0 rgba(255,255,255,0.95),
    inset 0 -1.5px 3px rgba(107,78,158,0.10) !important;
  transition: all 0.2s var(--ios-ease) !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}
.nav-btn:hover {
  background:
    radial-gradient(circle at 28% 22%, rgba(255,255,255,0.75) 0%, rgba(255,255,255,0) 48%),
    rgba(255,255,255,0.34) !important;
  box-shadow: 0 9px 22px rgba(107,78,158,0.24), inset 0 1.5px 0 rgba(255,255,255,1), inset 0 -1.5px 3px rgba(107,78,158,0.12) !important;
  transform: translateY(-1.5px) !important;
}
.nav-btn:active { transform: translateY(0) scale(0.95) !important; box-shadow: 0 1px 4px rgba(107,78,158,0.18), inset 0 2px 5px rgba(107,78,158,0.20) !important; }

/* --- BUTTONS (liquid glass) --- */
.btn, button.btn {
  background:
    radial-gradient(circle at 30% 16%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(165deg, rgba(165,134,216,0.78) 0%, rgba(116,86,168,0.86) 50%, rgba(86,60,134,0.92) 100%) !important;
  backdrop-filter: blur(32px) saturate(220%) brightness(1.08) !important;
  -webkit-backdrop-filter: blur(32px) saturate(220%) brightness(1.08) !important;
  border-radius: 16px !important;
  border: 1.5px solid rgba(255,255,255,0.55) !important;
  font-family: var(--ios-font) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  letter-spacing: -0.2px !important;
  box-shadow:
    0 18px 40px rgba(107,78,158,0.34),
    0 6px 14px rgba(107,78,158,0.22),
    0 1px 3px rgba(0,0,0,0.10),
    inset 0 1.5px 1px rgba(255,255,255,0.7),
    inset 0 -5px 10px rgba(40,24,70,0.22) !important;
  transition: all 0.22s var(--ios-ease) !important;
}
.btn:hover {
  transform: translateY(-3px) !important;
  box-shadow:
    0 24px 50px rgba(107,78,158,0.42),
    0 8px 18px rgba(107,78,158,0.26),
    inset 0 1.5px 1px rgba(255,255,255,0.8),
    inset 0 -5px 10px rgba(40,24,70,0.22) !important;
}
.btn:active {
  transform: translateY(0) scale(0.965) !important;
  box-shadow:
    0 4px 12px rgba(107,78,158,0.28),
    inset 0 3px 8px rgba(40,24,70,0.32),
    inset 0 1px 1px rgba(255,255,255,0.45) !important;
}
.btn-master { background: radial-gradient(circle at 30% 16%, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(168,168,172,0.78) 0%, rgba(125,125,129,0.86) 50%, rgba(95,95,99,0.92) 100%) !important; box-shadow: 0 18px 40px rgba(99,99,102,0.30), 0 6px 14px rgba(99,99,102,0.18), inset 0 1.5px 1px rgba(255,255,255,0.65), inset 0 -5px 10px rgba(30,30,32,0.22) !important; }
.btn-danger,.btn-sdal-no { background: radial-gradient(circle at 30% 16%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(255,128,118,0.78) 0%, rgba(255,73,61,0.86) 50%, rgba(214,40,28,0.92) 100%) !important; border-radius: 16px !important; box-shadow: 0 18px 40px rgba(255,59,48,0.32), 0 6px 14px rgba(255,59,48,0.20), inset 0 1.5px 1px rgba(255,255,255,0.65), inset 0 -5px 10px rgba(110,16,8,0.22) !important; }
.btn-daily-report { background: radial-gradient(circle at 30% 16%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(255,179,102,0.78) 0%, rgba(255,124,0,0.86) 50%, rgba(214,90,0,0.92) 100%) !important; border-radius: 16px !important; box-shadow: 0 18px 40px rgba(255,111,0,0.32), 0 6px 14px rgba(255,111,0,0.20), inset 0 1.5px 1px rgba(255,255,255,0.65), inset 0 -5px 10px rgba(110,46,0,0.22) !important; }


/* --- FLAT BUTTONS INSIDE MODALS (убрана объёмность: без блика/многослойных теней/подъёма) --- */
.modal-content .btn, #ord-form-wrap .btn,
.modal-content button.btn, #ord-form-wrap button.btn {
  background: rgba(107,78,158,0.85) !important;
  border-radius: 14px !important;
  box-shadow: 0 2px 8px rgba(107,78,158,0.20) !important;
  transition: background 0.15s var(--ios-ease), box-shadow 0.15s var(--ios-ease) !important;
}
.modal-content .btn:hover, #ord-form-wrap .btn:hover,
.modal-content button.btn:hover, #ord-form-wrap button.btn:hover {
  transform: none !important;
  background: rgba(96,68,144,0.92) !important;
  box-shadow: 0 3px 10px rgba(107,78,158,0.26) !important;
}
.modal-content .btn:active, #ord-form-wrap .btn:active,
.modal-content button.btn:active, #ord-form-wrap button.btn:active {
  transform: scale(0.97) !important;
  box-shadow: 0 1px 4px rgba(107,78,158,0.22) !important;
}
.modal-content .btn-master, #ord-form-wrap .btn-master {
  background: rgba(120,120,124,0.85) !important;
  box-shadow: 0 2px 8px rgba(90,90,94,0.20) !important;
}
.modal-content .btn-danger, .modal-content .btn-sdal-no,
#ord-form-wrap .btn-danger, #ord-form-wrap .btn-sdal-no {
  background: rgba(255,59,48,0.85) !important;
  box-shadow: 0 2px 8px rgba(255,59,48,0.20) !important;
}
.modal-content .btn-daily-report, #ord-form-wrap .btn-daily-report {
  background: rgba(255,111,0,0.85) !important;
  box-shadow: 0 2px 8px rgba(255,111,0,0.20) !important;
}
.modal-content button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn),
#ord-form-wrap button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn) {
  box-shadow: 0 1px 4px rgba(0,0,0,0.12) !important;
}
.modal-content button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn):hover,
#ord-form-wrap button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn):hover {
  transform: none !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.16) !important;
}
.modal-content .copy-btn, #ord-form-wrap .copy-btn {
  box-shadow: 0 2px 8px rgba(23,162,184,0.24) !important;
}
.modal-content .copy-btn:hover, #ord-form-wrap .copy-btn:hover {
  transform: none !important;
  box-shadow: 0 3px 10px rgba(23,162,184,0.30) !important;
}
.modal-content .copy-btn:active, #ord-form-wrap .copy-btn:active {
  transform: scale(0.97) !important;
  box-shadow: 0 1px 4px rgba(23,162,184,0.26) !important;
}

/* --- RAW BUTTONS (без класса .btn — мелкие "+", корзина, копировать и т.п.) --- */
button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn) {
  border-radius: 8px !important;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.20),
    0 1.5px 3px rgba(0,0,0,0.14),
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -2px 5px rgba(0,0,0,0.22) !important;
  transition: all 0.16s var(--ios-ease) !important;
}
button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn):hover {
  transform: translateY(-1px) !important;
  filter: brightness(1.10) saturate(1.12) !important;
  box-shadow:
    0 8px 18px rgba(0,0,0,0.24),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -2px 5px rgba(0,0,0,0.22) !important;
}
button:not(.btn):not(.nav-btn):not(.tab):not(.copy-btn):active {
  transform: translateY(0) scale(0.94) !important;
  filter: brightness(0.88) !important;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.38) !important;
}

/* --- INPUTS --- */
input[type=text],input[type=number],input[type=date],input[type=tel],
input[type=email],input[type=search],select,textarea {
  background: rgba(118,118,128,0.10) !important;
  border: 1.5px solid rgba(118,118,128,0.20) !important;
  border-radius: 10px !important;
  font-family: var(--ios-font) !important;
  color: var(--ios-label) !important;
  transition: all 0.18s var(--ios-ease) !important;
  outline: none !important;
}
input:focus,select:focus,textarea:focus {
  background: rgba(118,118,128,0.14) !important;
  border-color: rgba(107,78,158,0.5) !important;
  box-shadow: 0 0 0 3px rgba(107,78,158,0.18) !important;
}

/* --- TABLE --- */
table { border-collapse: separate !important; border-spacing: 0 3px !important; font-family: var(--ios-font) !important; }
thead tr th {
  background: rgba(255,255,255,0.85) !important;
  border-bottom: 1px solid var(--ios-sep) !important;
  font-weight: 600 !important; font-size: 11px !important;
  letter-spacing: 0.4px !important; text-transform: uppercase !important;
  color: var(--ios-label2) !important; padding: 8px 10px !important;
}
tbody tr {
  background: var(--row-bg, rgba(255,255,255,0.85)) !important;
  transition: all 0.15s var(--ios-ease) !important;
}
tbody tr:hover { background: color-mix(in srgb, var(--row-bg, rgba(255,255,255,0.60)) 75%, white 25%) !important; box-shadow: var(--ios-shadow-sm) !important; transform: scale(1.001) !important; cursor: pointer !important; }
tbody tr { height: 40px !important; }
tbody tr td { height: 40px !important; max-height: 40px !important; overflow: hidden !important; white-space: nowrap !important; text-overflow: ellipsis !important; padding: 2px 10px !important; line-height: 1.2 !important; font-size: 13.5px !important; border-bottom: 1px solid rgba(0,0,0,0.04) !important; }
tbody tr td:first-child { border-radius: 10px 0 0 10px !important; }
tbody tr td:last-child  { border-radius: 0 10px 10px 0 !important; }
#ordersTable thead th:nth-child(7) { width: 132px !important; max-width: 132px !important; }
#ordersTable tbody tr td:nth-child(7) { width: 132px !important; max-width: 132px !important; }

/* --- TABLE CONTAINER --- */
.table-container,[class*="table-wrap"] {
  background: var(--ios-glass) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius-lg) !important;
  border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow) !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
}

/* --- MODAL --- */
#ord-wrap,.modal {
  backdrop-filter: blur(6px) brightness(0.95) !important;
  -webkit-backdrop-filter: blur(6px) brightness(0.95) !important;
  background: rgba(0,0,0,0.25) !important;
}
#ord-form-wrap,.modal-content {
  background: rgba(245,242,255,0.94) !important;
  backdrop-filter: blur(40px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(200%) !important;
  border-radius: 14px !important;
  border: var(--ios-border) !important;
  position: relative !important;
  /* macOS-style window shadow: much softer/larger and more diffuse than a card shadow */
  box-shadow:
    0 1px 1px rgba(0,0,0,0.06),
    0 40px 90px rgba(20,10,40,0.34),
    0 12px 28px rgba(20,10,40,0.18),
    inset 0 1px 0 rgba(255,255,255,0.9) !important;
}
@media(max-width:768px){ #ord-form-wrap,.modal-content { border-radius: var(--ios-radius-xl) !important; } }

/* --- macOS TRAFFIC LIGHTS (window controls) ---
   Добавлены вручную в заголовки модалок, которые уже проверены (main.html
   #orderModal, settings.html #directorSalaryModal) — не блочный CSS-трюк на
   все .modal-content разом, чтобы не наложиться на разметку в других файлах. */
.mac-traffic { display: flex !important; gap: 8px !important; margin-bottom: 12px !important; }
.mac-traffic span {
  width: 12px !important; height: 12px !important; border-radius: 50% !important;
  display: inline-block !important;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.12) !important;
}
.mac-traffic span:nth-child(1) { background: linear-gradient(160deg,#ff6a5f,#e0443e) !important; }
.mac-traffic span:nth-child(2) { background: linear-gradient(160deg,#ffc130,#dea123) !important; }
.mac-traffic span:nth-child(3) { background: linear-gradient(160deg,#29d64a,#1aad35) !important; }

/* --- CHIPS, PILLS, BADGES --- */
.chip {
  border-radius: 100px !important; font-size: 12.5px !important; font-weight: 500 !important;
  padding: 3px 10px !important; border: 1px solid rgba(255,255,255,0.55) !important;
  background: rgba(255,255,255,0.55) !important;
  backdrop-filter: blur(16px) saturate(200%) !important; -webkit-backdrop-filter: blur(16px) saturate(200%) !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.7) !important;
}
.free-pill {
  border-radius: 100px !important; font-weight: 700 !important;
  box-shadow: 0 8px 20px rgba(40,167,69,0.32), 0 2px 5px rgba(0,0,0,0.10), inset 0 1.5px 1px rgba(255,255,255,0.5), inset 0 -2px 5px rgba(15,80,25,0.20) !important;
}
.warning-badge {
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(255,210,90,0.88) 0%, rgba(255,193,7,0.92) 100%) !important;
  backdrop-filter: blur(14px) saturate(200%) !important; -webkit-backdrop-filter: blur(14px) saturate(200%) !important;
  border: 1px solid rgba(255,255,255,0.6) !important;
  border-radius: 100px !important;
  box-shadow: 0 8px 18px rgba(255,193,7,0.38), 0 2px 5px rgba(0,0,0,0.10), inset 0 1.5px 1px rgba(255,255,255,0.65), inset 0 -2px 5px rgba(140,100,0,0.22) !important;
  color: #4a3500 !important;
}
.copy-btn {
  background: radial-gradient(circle at 30% 16%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(98,200,222,0.80) 0%, rgba(23,162,184,0.88) 50%, rgba(15,128,146,0.94) 100%) !important;
  backdrop-filter: blur(28px) saturate(220%) brightness(1.06) !important; -webkit-backdrop-filter: blur(28px) saturate(220%) brightness(1.06) !important;
  border-radius: 12px !important;
  border: 1.5px solid rgba(255,255,255,0.55) !important;
  color: #fff !important;
  box-shadow:
    0 14px 30px rgba(23,162,184,0.34),
    0 3px 8px rgba(0,0,0,0.12),
    inset 0 1.5px 1px rgba(255,255,255,0.6),
    inset 0 -4px 8px rgba(0,55,65,0.24) !important;
  transition: all 0.2s var(--ios-ease) !important;
}
.copy-btn:hover { transform: translateY(-2px) !important; box-shadow: 0 18px 38px rgba(23,162,184,0.42), inset 0 1.5px 1px rgba(255,255,255,0.7), inset 0 -4px 8px rgba(0,55,65,0.24) !important; }
.copy-btn:active { transform: translateY(0) scale(0.96) !important; box-shadow: inset 0 4px 10px rgba(0,55,65,0.40) !important; }

/* --- TABS --- */
.tab {
  border-radius: 100px !important; font-family: var(--ios-font) !important;
  font-weight: 500 !important; font-size: 13.5px !important;
  letter-spacing: -0.15px !important; transition: all 0.18s var(--ios-ease) !important;
  border: 1px solid rgba(107,78,158,0.15) !important;
}
.tab.active {
  background: radial-gradient(circle at 30% 16%, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0) 45%), linear-gradient(165deg, rgba(165,134,216,0.85) 0%, rgba(107,78,158,0.92) 100%) !important;
  backdrop-filter: blur(20px) saturate(200%) !important; -webkit-backdrop-filter: blur(20px) saturate(200%) !important;
  color: white !important;
  box-shadow: 0 10px 24px rgba(107,78,158,0.36), inset 0 1.5px 1px rgba(255,255,255,0.6), inset 0 -3px 6px rgba(40,24,70,0.20) !important;
  border-color: transparent !important;
}

/* --- ANY CARD-LIKE BLOCK (master-card, stats-card, city-group-card, etc.) --- */
/* :not([style*="background"]) — не трогаем карточки с собственным инлайновым фоном (градиенты типа БАЛАНС КАССЫ) */
[class*="-card"]:not(button):not([style*="background"]) {
  background: var(--ios-glass-strong) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius-lg) !important;
  border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow) !important;
  transition: all 0.22s var(--ios-ease) !important;
}
[class*="-card"]:not(button) { border-radius: var(--ios-radius-lg) !important; transition: all 0.22s var(--ios-ease) !important; }
[class*="-card"]:not(button):hover { transform: translateY(-3px) !important; box-shadow: var(--ios-shadow-lg) !important; }

/* --- GLASS PANELS --- */
.header,.stats-block {
  background: var(--ios-glass) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius-lg) !important;
  border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm), inset 0 1px 0 rgba(255,255,255,0.9) !important;
  margin-bottom: 10px !important;
}
.filters {
  background: var(--ios-glass) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius) !important; border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm) !important; padding: 10px 12px !important; margin-bottom: 10px !important;
}
.balance-card:not([style*="gradient"]) {
  background: var(--ios-glass-strong) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius) !important; border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm) !important; transition: all 0.18s var(--ios-ease) !important;
}
.balance-card[style*="gradient"] {
  border-radius: var(--ios-radius) !important;
  box-shadow: var(--ios-shadow) !important; transition: all 0.18s var(--ios-ease) !important;
}
.month-card:not(.income):not(.expense) {
  background: var(--ios-glass-strong) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius) !important; border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm) !important; transition: all 0.18s var(--ios-ease) !important;
}
.month-card.income { background: linear-gradient(135deg,#28a745,#20c997) !important; border-radius: var(--ios-radius) !important; box-shadow: var(--ios-shadow-sm) !important; }
.month-card.expense { background: linear-gradient(135deg,#dc3545,#e83e8c) !important; border-radius: var(--ios-radius) !important; box-shadow: var(--ios-shadow-sm) !important; }
.month-card.income h4,.month-card.income .value,.month-card.income .count { color: white !important; }
.month-card.expense h4,.month-card.expense .value,.month-card.expense .count { color: white !important; }
.balance-card:hover,.month-card:hover { box-shadow: var(--ios-shadow) !important; transform: translateY(-2px) !important; }
.month-nav {
  background: var(--ios-glass) !important;
  backdrop-filter: var(--ios-blur-sm) !important; -webkit-backdrop-filter: var(--ios-blur-sm) !important;
  border-radius: var(--ios-radius-lg) !important; border: var(--ios-border) !important;
  box-shadow: var(--ios-shadow-sm) !important; margin-bottom: 10px !important;
}

/* --- LIGHTBOX --- */
#_ordLb {
  backdrop-filter: blur(20px) brightness(0.5) !important;
  -webkit-backdrop-filter: blur(20px) brightness(0.5) !important;
  background: rgba(0,0,0,0.6) !important;
}
#_ordLbImg { border-radius: 16px !important; box-shadow: 0 24px 80px rgba(0,0,0,0.5) !important; }

/* --- NOTIFICATION --- */
#ios-notif { border-radius: 24px !important; backdrop-filter: blur(32px) saturate(180%) !important; -webkit-backdrop-filter: blur(32px) saturate(180%) !important; }

@media(max-width:768px){
  body { padding: 6px !important; }
  .nav-bar { top: 4px !important; z-index: 200 !important; }
  #ord-form-wrap,.modal-content { border-radius: 28px 28px 0 0 !important; padding-bottom: 32px !important; }
}

/* ============================================================
   PERF-LITE — облегчённый режим для слабых компьютеров.
   Класс html.perf-lite ставится инлайн-скриптом в <head> (core/utils.py)
   ДО первой отрисовки — по navigator.hardwareConcurrency<=4 и системным
   настройкам macOS "Уменьшить прозрачность"/"Уменьшить движение"
   (Safari отдаёт их через prefers-reduced-transparency/prefers-reduced-motion).
   Самый дорогой эффект в этой теме — backdrop-filter:blur на десятках
   элементов одновременно (перерисовка/композитинг на слабом GPU в Safari).
   В lite-режиме blur убирается полностью (фон остаётся полупрозрачным
   плоским — не "сломанным", просто без размытия), многослойные тени
   упрощены до одной лёгкой, и box-shadow при hover не меняется (оставлен
   только дешёвый transform для отклика). */
html.perf-lite .nav-bar,
html.perf-lite .nav-btn,
html.perf-lite .btn, html.perf-lite button.btn,
html.perf-lite .table-container, html.perf-lite [class*="table-wrap"],
html.perf-lite #ord-wrap, html.perf-lite .modal,
html.perf-lite #ord-form-wrap, html.perf-lite .modal-content,
html.perf-lite .chip,
html.perf-lite .warning-badge,
html.perf-lite .copy-btn,
html.perf-lite .tab.active,
html.perf-lite [class*="-card"]:not(button):not([style*="background"]),
html.perf-lite .header, html.perf-lite .stats-block,
html.perf-lite .filters,
html.perf-lite .balance-card:not([style*="gradient"]),
html.perf-lite .month-card:not(.income):not(.expense),
html.perf-lite .month-nav,
html.perf-lite #_ordLb,
html.perf-lite #ios-notif {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.perf-lite .btn, html.perf-lite button.btn {
  box-shadow: 0 3px 8px rgba(107,78,158,0.28), inset 0 1px 0 rgba(255,255,255,0.5) !important;
}
html.perf-lite .btn:hover, html.perf-lite button.btn:hover {
  box-shadow: 0 3px 8px rgba(107,78,158,0.28), inset 0 1px 0 rgba(255,255,255,0.5) !important;
}
html.perf-lite #ord-form-wrap, html.perf-lite .modal-content {
  box-shadow: 0 8px 24px rgba(20,10,40,0.28) !important;
}
html.perf-lite .nav-bar {
  box-shadow: 0 2px 8px rgba(107,78,158,0.14) !important;
}
html.perf-lite [class*="-card"]:not(button):hover,
html.perf-lite .balance-card:hover, html.perf-lite .month-card:hover {
  box-shadow: var(--ios-shadow-sm) !important;
}
html.perf-lite .copy-btn, html.perf-lite .copy-btn:hover {
  box-shadow: 0 3px 8px rgba(23,162,184,0.30), inset 0 1px 0 rgba(255,255,255,0.4) !important;
}
html.perf-lite .nav-btn, html.perf-lite .nav-btn:hover {
  box-shadow: 0 2px 6px rgba(107,78,158,0.20), inset 0 1px 0 rgba(255,255,255,0.6) !important;
  transform: none !important;
}

/* ============================================================
   DARK MODE — глобальная инверсия (data-theme="dark" на <html>)
   Красит АБСОЛЮТНО ВСЁ разом (все страницы, все белые карточки,
   все пастельные плашки статусов — с сохранением контраста текста,
   т.к. invert() сохраняет пары "тёмный текст на светлом" ↔ наоборот).
   Карта и медиа исключены двойным инвертом (см. ниже).
   ============================================================ */
html[data-theme="dark"] {
  --ios-accent:       #9d81e6 !important;
  --ios-accent-rgb:   157,129,230 !important;
  --ios-accent2:      #b491ee !important;
  --ios-bg:           #e8dcf7 !important;
  background: #1f1729 !important;
}
html[data-theme="dark"] body {
  filter: invert(1) hue-rotate(180deg) brightness(1.08) saturate(1.25) !important;
  min-height: 100vh !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(107,78,158,0.3) !important; }

/* Единый фирменный фон вместо "чёрного" по всей панели в тёмной теме.
   body сам инвертируется (см. выше), поэтому реальную картинку кладём в
   отдельный слой (body::after) со встречным фильтром, который гасит invert
   родителя — картинка показывается натуральными цветами. Старый декоративный
   body::before (светлый градиент, тоже ловит invert) в тёмной теме прячем,
   чтобы не накладывался. background-attachment:fixed — картинка одна на
   весь viewport, поэтому подложки модалок (см. ниже) выглядят её продолжением. */
html[data-theme="dark"] body::before { display: none !important; }
html[data-theme="dark"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url('/static/dark-bg.jpg?v=3');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  filter: saturate(0.8) brightness(0.9259) hue-rotate(180deg) invert(1) !important;
  pointer-events: none;
}

/* --- Исключения: карту, фото и уже-тёмные по дизайну блоки НЕ трогаем ---
   (двойной invert = обратно оригинал, применяется ко всему поддереву).
   Сюда же — цветные плашки статус/вид/профиль/график: у них уже подобрана
   пара "пастельный фон + тёмный читаемый текст", инверсия им не нужна. */
html[data-theme="dark"] img,
html[data-theme="dark"] video,
html[data-theme="dark"] canvas,
html[data-theme="dark"] iframe,
html[data-theme="dark"] #ymap,
html[data-theme="dark"] #orderMapDiv,
html[data-theme="dark"] .theme-switch,
html[data-theme="dark"] #ios-notif,
html[data-theme="dark"] #_histMod,
html[data-theme="dark"] #_ordLb,
html[data-theme="dark"] .status-cell,
html[data-theme="dark"] .type-cell,
html[data-theme="dark"] .profile-cell,
html[data-theme="dark"] .call-cell,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .shift-morning,
html[data-theme="dark"] .shift-day,
html[data-theme="dark"] .shift-evening,
html[data-theme="dark"] .shift-full,
html[data-theme="dark"] .shift-off,
html[data-theme="dark"] .legend-color,
html[data-theme="dark"] .lc {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* Строки таблицы без своего --row-bg — прозрачные, сливаются с фоном.
   Ячейки с собственным цветом (status/type/profile/call-cell) не задеты. */
html[data-theme="dark"] tbody tr { background: var(--row-bg, rgba(255,255,255,0.16)) !important; }
html[data-theme="dark"] tbody tr:hover { background: var(--row-bg, rgba(255,255,255,0.24)) !important; }

/* .table-container и th раньше были white/#f8f9fa — после invert превращались
   в сплошной чёрный прямоугольник поверх картинки фона (body::after), из-за
   чего сама картинка не была видна за таблицей. Делаем их прозрачными —
   строки (правило выше) продолжают давать лёгкую подсветку/разделение. */
html[data-theme="dark"] .table-container { background: transparent !important; }
html[data-theme="dark"] th { background: transparent !important; }

/* Подложки модалок по всей панели в тёмной теме — вместо чёрного (или
   белого после invert от rgba(0,0,0,x)) показываем фирменную картинку
   /static/dark-bg.jpg тем же приёмом встречного фильтра, что и body::after
   выше. background-attachment:fixed — картинка совпадает с фоном страницы,
   выглядит одним целым, а не отдельной плашкой. Список общих селекторов
   модалок панели: .modal (main.html/cash.html), .modal-overlay
   (calls.html/city_report.html), #_histMod (история звонков — общий кусок,
   скопирован в access/calls/cash/grm/interviews.html), #directorSalaryModal
   (settings.html). Прочие точечные модалки (#salaryModal, #intStatsModal,
   #ordFrameModal, #srcModal и т.п.) этим правилом НЕ покрыты. */
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-overlay,
html[data-theme="dark"] #_histMod,
html[data-theme="dark"] #directorSalaryModal { background: transparent !important; }
html[data-theme="dark"] .modal::before,
html[data-theme="dark"] .modal-overlay::before,
html[data-theme="dark"] #_histMod::before,
html[data-theme="dark"] #directorSalaryModal::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url('/static/dark-bg.jpg?v=3');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  filter: saturate(0.8) brightness(0.9259) hue-rotate(180deg) invert(1) !important;
}

/* Карточка «История клиента» в модалке заявки — фон заменён на ту же
   фирменную картинку (та же техника встречного фильтра), рамки и цвета
   шрифтов внутри карточки не трогаем — они остаются под общей invert-темой. */
html[data-theme="dark"] #orderModal .client-history {
  background: transparent !important;
  position: relative !important;
  z-index: 0;
}
html[data-theme="dark"] #orderModal .client-history::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: url('/static/dark-bg.jpg?v=3');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  filter: saturate(0.8) brightness(0.9259) hue-rotate(180deg) invert(1) !important;
}

/* --- ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ (macOS/iOS style switch) --- */
.theme-switch {
  -webkit-appearance: none !important; appearance: none !important;
  position: relative !important;
  width: 46px !important; height: 26px !important;
  border-radius: 100px !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  background: rgba(120,120,128,0.20) !important;
  box-shadow: inset 0 1.5px 3px rgba(0,0,0,0.14) !important;
  transition: background 0.25s var(--ios-ease) !important;
}
.theme-switch.is-dark {
  background: linear-gradient(165deg, rgba(165,134,216,0.95) 0%, rgba(107,78,158,1) 100%) !important;
  box-shadow: inset 0 1.5px 3px rgba(40,24,70,0.35) !important;
}
.theme-switch .theme-switch-thumb {
  position: absolute !important;
  top: 2px !important; left: 2px !important;
  width: 22px !important; height: 22px !important;
  border-radius: 50% !important;
  background: #fff !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.28), 0 0 0 0.5px rgba(0,0,0,0.04) !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  transition: transform 0.28s var(--ios-ease) !important;
  color: #f5a623 !important;
}
.theme-switch.is-dark .theme-switch-thumb { transform: translateX(20px) !important; color: #6b4e9e !important; }
.theme-switch .theme-switch-thumb svg { width: 13px !important; height: 13px !important; position: absolute !important; }
.theme-switch .icon-moon { opacity: 0 !important; transform: scale(0.5) rotate(-40deg) !important; transition: all 0.28s var(--ios-ease) !important; }
.theme-switch .icon-sun { opacity: 1 !important; transform: scale(1) rotate(0deg) !important; transition: all 0.28s var(--ios-ease) !important; }
.theme-switch.is-dark .icon-sun { opacity: 0 !important; transform: scale(0.5) rotate(40deg) !important; }
.theme-switch.is-dark .icon-moon { opacity: 1 !important; transform: scale(1) rotate(0deg) !important; }

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
