:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2F4F8;
  --mesh-1: rgba(0, 122, 255, 0.14);
  --mesh-2: rgba(175, 82, 222, 0.11);
  --mesh-3: rgba(52, 199, 89, 0.08);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #FFFFFF;
  --surface-alt: rgba(120, 120, 128, 0.10);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-outline: rgba(15, 23, 42, 0.08);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  --text: #111827;
  --muted: #6B7280;
  --border: rgba(15, 23, 42, 0.09);
  --input-bg: rgba(255, 255, 255, 0.85);
  --ok: #16A34A;
  --ok-bg: rgba(22, 163, 74, 0.14);
  --warn: #D97706;
  --warn-bg: rgba(217, 119, 6, 0.14);
  --err: #DC2626;
  --err-bg: rgba(220, 38, 38, 0.13);
  --msg-ai-bg: rgba(0, 122, 255, 0.10);
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0D13;
  --mesh-1: rgba(10, 132, 255, 0.20);
  --mesh-2: rgba(191, 90, 242, 0.16);
  --mesh-3: rgba(48, 209, 88, 0.10);
  --surface: rgba(28, 31, 42, 0.68);
  --surface-solid: #181B24;
  --surface-alt: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-outline: rgba(255, 255, 255, 0.08);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 12px 36px rgba(0, 0, 0, 0.42);
  --text: #F3F4F6;
  --muted: #9CA3AF;
  --border: rgba(255, 255, 255, 0.11);
  --input-bg: rgba(17, 20, 28, 0.78);
  --ok: #34D399;
  --ok-bg: rgba(52, 211, 153, 0.16);
  --warn: #FBBF24;
  --warn-bg: rgba(251, 191, 36, 0.16);
  --err: #F87171;
  --err-bg: rgba(248, 113, 113, 0.16);
  --msg-ai-bg: rgba(255, 255, 255, 0.08);
}

/* Акцентные палитры */
:root,
[data-accent="ios"] {
  --primary: #007AFF;
  --primary-dark: #0062CC;
  --primary-soft: rgba(0, 122, 255, 0.14);
}
[data-theme="dark"][data-accent="ios"] {
  --primary: #0A84FF;
  --primary-dark: #0070E0;
  --primary-soft: rgba(10, 132, 255, 0.22);
}

[data-accent="rose"] {
  --primary: #B85D6E;
  --primary-dark: #9B4758;
  --primary-soft: rgba(184, 93, 110, 0.15);
  --mesh-1: rgba(184, 93, 110, 0.18);
  --mesh-2: rgba(244, 162, 97, 0.12);
}
[data-theme="dark"][data-accent="rose"] {
  --primary: #E07A8D;
  --primary-dark: #C86074;
  --primary-soft: rgba(224, 122, 141, 0.22);
  --mesh-1: rgba(224, 122, 141, 0.22);
  --mesh-2: rgba(191, 90, 242, 0.14);
}

[data-accent="emerald"] {
  --primary: #10B981;
  --primary-dark: #059669;
  --primary-soft: rgba(16, 185, 129, 0.15);
  --mesh-1: rgba(16, 185, 129, 0.16);
  --mesh-2: rgba(56, 189, 248, 0.13);
}
[data-theme="dark"][data-accent="emerald"] {
  --primary: #34D399;
  --primary-dark: #10B981;
  --primary-soft: rgba(52, 211, 153, 0.20);
  --mesh-1: rgba(52, 211, 153, 0.20);
}

[data-accent="violet"] {
  --primary: #7C3AED;
  --primary-dark: #6D28D9;
  --primary-soft: rgba(124, 58, 237, 0.15);
  --mesh-1: rgba(124, 58, 237, 0.16);
  --mesh-2: rgba(236, 72, 153, 0.12);
}
[data-theme="dark"][data-accent="violet"] {
  --primary: #A78BFA;
  --primary-dark: #8B5CF6;
  --primary-soft: rgba(167, 139, 250, 0.22);
  --mesh-1: rgba(167, 139, 250, 0.22);
}

* { box-sizing: border-box; }

html {
  background-color: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(at 10% 10%, var(--mesh-1) 0px, transparent 50%),
    radial-gradient(at 90% 15%, var(--mesh-2) 0px, transparent 48%),
    radial-gradient(at 50% 90%, var(--mesh-3) 0px, transparent 55%);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.83rem; }

/* Экраны авторизации */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  border-radius: 24px;
  padding: 26px 24px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 1.55rem; letter-spacing: -0.02em; }

/* Шапка Liquid Glass */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--glass-outline);
  box-shadow: var(--glass-highlight);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar-title {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
#header-user {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 115px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); }

/* Основной контент */
.main-content {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 14px calc(124px + env(safe-area-inset-bottom));
}

/* Плавающий док навигации Liquid Glass (Mobile) */
.bottom-nav {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  z-index: 30;
  background: var(--surface);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 12px 34px rgba(0, 0, 0, 0.14);
  border-radius: 26px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 6px;
}
.nav-item {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.63rem;
  font-weight: 500;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 18px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, transform 0.15s ease;
  flex: 1;
  min-width: 0;
}
.nav-item svg { width: 21px; height: 21px; flex-shrink: 0; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}
.nav-item:active { transform: scale(0.94); }

/* Адаптивный левый сайдбар на ПК / планшетах */
@media (min-width: 840px) {
  .app-shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: auto auto 1fr;
    min-height: 100vh;
  min-height: 100dvh;
  }
  .topbar {
    grid-column: 1 / -1;
  }
  #impersonation-banner {
    grid-column: 1 / -1;
  }
  .bottom-nav {
    position: sticky;
    top: 57px;
    left: auto;
    right: auto;
    bottom: auto;
    height: calc(100vh - 57px);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 4px;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--glass-outline);
    box-shadow: none;
    padding: 16px 12px;
  }
  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 11px 14px;
    font-size: 0.92rem;
    border-radius: 14px;
  }
  .main-content {
    width: 100%;
    padding: 22px 26px 40px;
  }
  .fab {
    bottom: 28px !important;
    right: 28px !important;
  }
}

/* Сетка и стеклянные карточки */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.card {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text);
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }

/* Формы и поля */
label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 5px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 82px; resize: vertical; }

/* iOS-тумблер вместо обычного чекбокса */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px !important;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.2s ease, border-color 0.2s ease;
  padding: 0;
  margin-right: 6px;
  flex-shrink: 0;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}
input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Кнопки */
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #FFF;
  box-shadow: 0 4px 14px var(--primary-soft);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 10px; }
.btn-full { width: 100%; margin-top: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Сегментированные подвкладки (iOS Segmented Control) */
.seg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-btn {
  flex: 1;
  min-width: max-content;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.seg-btn.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Плавающая кнопка + (FAB) */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 28;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--primary);
  color: #FFF;
  box-shadow: 0 8px 24px var(--primary-soft), 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.fab:active { transform: scale(0.92); }

/* Списки */
.list-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.list-item:last-child { border-bottom: none; }

.service-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.service-item:last-child { border-bottom: none; }
.service-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.service-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Чаты (Telegram style) */
.chat-box {
  max-height: 390px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.92rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.msg-client { align-self: flex-start; background: var(--surface-solid); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg-ai { align-self: flex-end; background: var(--msg-ai-bg); border-bottom-right-radius: 5px; }
.msg-master { align-self: flex-end; background: var(--primary); color: #FFF; border-bottom-right-radius: 5px; }

/* Выбор темы и акцентов */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.theme-option {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.theme-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.accent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.accent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.accent-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.accent-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.error-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* Модалка / Bottom Sheet на мобильных */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 470px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border-radius: 22px;
  padding: 20px;
}
.modal-card h3 { margin-top: 0; }

@media (max-width: 640px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 24px 24px 0 0;
    padding: 14px 18px calc(22px + env(safe-area-inset-bottom));
    animation: sheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .modal-card::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    margin: 0 auto 12px;
  }
}
@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.tabs-inline { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

.card-btn {
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  position: relative;
  transition: transform 0.14s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  margin-bottom: 0;
}
.card-btn:hover {
  border-color: var(--primary);
}
.card-btn:active {
  transform: scale(0.97);
}
.card-btn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.card-btn-arrow {
  color: var(--muted);
  font-size: 1.05rem;
  opacity: 0.7;
}
.card-btn-wide {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
@media (min-width: 840px) {
  .card-btn-wide {
    grid-column: auto;
    display: block;
  }
}

/* Telegram-style Web Chat */
.tg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  overflow: hidden;
}
.tg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tg-chat-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
}
.tg-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tg-chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 430px;
  min-height: 260px;
  overflow-y: auto;
  padding: 12px 6px;
  margin: 8px 0;
  border-radius: 16px;
  background: var(--surface-alt);
}
.tg-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.tg-msg-row.in {
  align-self: flex-start;
  align-items: flex-start;
}
.tg-msg-row.out {
  align-self: flex-end;
  align-items: flex-end;
}
.tg-bubble {
  padding: 9px 12px;
  border-radius: 16px;
  font-size: 0.91rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.tg-msg-row.in .tg-bubble {
  background: var(--surface-solid);
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
}
.tg-msg-row.out .tg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.tg-msg-row.out.ai .tg-bubble {
  background: var(--msg-ai-bg);
  color: var(--text);
  border: 1px solid var(--glass-outline);
}
.tg-msg-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
  padding: 0 4px;
}
.tg-msg-img {
  display: block;
  max-width: 230px;
  max-height: 240px;
  border-radius: 12px;
  margin-bottom: 6px;
  object-fit: cover;
  cursor: pointer;
}
.tg-quick-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}
.tg-quick-bar::-webkit-scrollbar { display: none; }
.tg-quick-chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.tg-quick-chip.ai-chip {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.tg-quick-chip:active { transform: scale(0.95); }

.tg-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.tg-attach-preview img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.work-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.work-cal-head {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 0;
}
.work-cal-day {
  position: relative;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
  color: var(--text);
}
.work-cal-day:active { transform: scale(0.95); }
.work-cal-day.is-working {
  background: var(--surface-solid);
}
.work-cal-day.is-off {
  opacity: 0.52;
}
.work-cal-day.is-custom {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.work-cal-day.is-dayoff {
  border-color: var(--err);
  background: var(--err-bg);
  opacity: 0.95;
}
.work-cal-day.is-today {
  box-shadow: 0 0 0 2px var(--primary);
}
.work-cal-num {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}
.work-cal-sub {
  font-size: 9px;
  line-height: 1.1;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.work-cal-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.work-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.work-cal-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.work-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 8px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.work-cal-nav-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.work-cal-nav-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.sys-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.sys-metric-box {
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.sys-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
}
.sys-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.user-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 145px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.user-pill-btn:active { transform: scale(0.96); }
.user-pill-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #AF52DE);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-pill-caret {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

.dash-cluster {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.dash-gauge-card {
  padding: 8px 4px 10px;
  border-radius: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.dash-gauge-svg {
  width: 100%;
  max-width: 126px;
  height: auto;
  display: block;
}
.dash-gauge-title {
  font-size: 11px;
  font-weight: 700;
  margin-top: -2px;
  letter-spacing: 0.03em;
}
.dash-gauge-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.25;
}
.dash-footer-strip {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}

.list-item-clickable {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.list-item-clickable:hover {
  background: rgba(255, 255, 255, 0.03);
}
.appt-photo-section {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.appt-photo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.appt-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
}
.appt-photo-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.25);
}
.appt-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.appt-photo-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.appt-photo-del:hover {
  background: #ef4444;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}
.chip-btn:hover {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.45);
}
.chip-btn.active {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border-color: #3b82f6;
}
.promo-tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.promo-tpl-card {
  text-align: left;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.promo-tpl-card:hover {
  border-color: #3b82f6;
}
.promo-tpl-card:active {
  transform: scale(0.98);
}
.promo-tpl-title {
  font-size: 13px;
  font-weight: 700;
}
.promo-tpl-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.promo-adv {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.promo-adv summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.promo-adv[open] summary {
  margin-bottom: 8px;
  color: var(--text);
}


/* Master Community, Profiles & Portfolio */
.master-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
}
.master-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.master-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
}
.master-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.master-preview-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.master-preview-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-solid);
  cursor: pointer;
}
.profile-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-hero-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0;
}
.profile-stat-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
}
.profile-stat-val {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.profile-stat-lbl {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.portfolio-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-alt);
  cursor: pointer;
  border: 1px solid var(--border);
}
.portfolio-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.portfolio-tile-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
}

.badge-plus {
  background: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.badge-pro {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.42);
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 12%;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}
.slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.slot-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.slot-chip:hover, .slot-chip:active {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.onboarding-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  margin-top: 8px;
  cursor: pointer;
}
.client-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.client-meta-bar b {
  color: var(--text);
  font-weight: 600;
}
.client-pin-note {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text);
  font-size: 12.5px;
}

/* Windows 98 Classic Theme */
[data-theme="win98"] {
  color-scheme: light;
  --bg: #008080;
  --mesh-1: transparent;
  --mesh-2: transparent;
  --mesh-3: transparent;
  --surface: #c0c0c0;
  --surface-solid: #c0c0c0;
  --surface-alt: #dfdfdf;
  --glass-border: #ffffff;
  --glass-outline: #000000;
  --glass-highlight: inset 1px 1px 0 #ffffff;
  --glass-shadow: none;
  --text: #000000;
  --muted: #404040;
  --border: #808080;
  --input-bg: #ffffff;
  --primary: #000080;
  --primary-dark: #000060;
  --primary-soft: #d4d0c8;
  --ok: #008000;
  --ok-bg: #d4f8d4;
  --warn: #806000;
  --warn-bg: #fff4c2;
  --err: #a00000;
  --err-bg: #ffd8d8;
  --msg-ai-bg: #efefef;
  --radius: 0px;
}
[data-theme="win98"] body {
  font-family: "Tahoma", "MS Sans Serif", "Segoe UI", sans-serif;
  background-image: none !important;
  background-color: #008080 !important;
}
[data-theme="win98"] .topbar {
  background: linear-gradient(90deg, #000080 0%, #1084d0 100%) !important;
  color: #ffffff !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom: 2px solid #404040 !important;
  box-shadow: inset 0 1px 0 #84a8ff !important;
}
[data-theme="win98"] .topbar .badge {
  background: #c0c0c0 !important;
  color: #000000 !important;
  border-radius: 0 !important;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #404040;
  border-bottom: 1px solid #404040;
}
[data-theme="win98"] .user-pill-btn {
  background: #c0c0c0 !important;
  color: #000000 !important;
  border-radius: 0 !important;
  border-top: 2px solid #ffffff !important;
  border-left: 2px solid #ffffff !important;
  border-right: 2px solid #404040 !important;
  border-bottom: 2px solid #404040 !important;
}
[data-theme="win98"] .card,
[data-theme="win98"] .auth-card,
[data-theme="win98"] .modal-card,
[data-theme="win98"] .bottom-nav {
  background: #c0c0c0 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-radius: 0 !important;
  border-top: 2px solid #ffffff !important;
  border-left: 2px solid #ffffff !important;
  border-right: 2px solid #404040 !important;
  border-bottom: 2px solid #404040 !important;
  box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf, 2px 2px 0 rgba(0, 0, 0, 0.35) !important;
}
[data-theme="win98"] .card-btn:hover {
  transform: none;
}
[data-theme="win98"] .btn,
[data-theme="win98"] .theme-option,
[data-theme="win98"] .accent-chip,
[data-theme="win98"] .slot-chip,
[data-theme="win98"] .chip-btn,
[data-theme="win98"] .seg-btn {
  border-radius: 0 !important;
  background: #c0c0c0 !important;
  color: #000000 !important;
  border-top: 2px solid #ffffff !important;
  border-left: 2px solid #ffffff !important;
  border-right: 2px solid #404040 !important;
  border-bottom: 2px solid #404040 !important;
  box-shadow: inset -1px -1px 0 #808080 !important;
}
[data-theme="win98"] .btn-primary,
[data-theme="win98"] .theme-option.active,
[data-theme="win98"] .chip-btn.active,
[data-theme="win98"] .seg-btn.active {
  background: #000080 !important;
  color: #ffffff !important;
}
[data-theme="win98"] .btn-danger {
  background: #a00000 !important;
  color: #ffffff !important;
}
[data-theme="win98"] .btn:active,
[data-theme="win98"] .nav-item.active {
  border-top: 2px solid #404040 !important;
  border-left: 2px solid #404040 !important;
  border-right: 2px solid #ffffff !important;
  border-bottom: 2px solid #ffffff !important;
  background: #dfdfdf !important;
  color: #000080 !important;
}
[data-theme="win98"] .nav-item {
  border-radius: 0 !important;
  color: #000000;
}
[data-theme="win98"] input,
[data-theme="win98"] select,
[data-theme="win98"] textarea,
[data-theme="win98"] .tg-chat-box {
  border-radius: 0 !important;
  background: #ffffff !important;
  color: #000000 !important;
  border-top: 2px solid #404040 !important;
  border-left: 2px solid #404040 !important;
  border-right: 2px solid #ffffff !important;
  border-bottom: 2px solid #ffffff !important;
  box-shadow: inset 1px 1px 0 #808080 !important;
}
[data-theme="win98"] .badge,
[data-theme="win98"] .toast,
[data-theme="win98"] .onboarding-step,
[data-theme="win98"] .client-pin-note,
[data-theme="win98"] .master-card {
  border-radius: 0 !important;
}
[data-theme="win98"] .fab {
  border-radius: 0 !important;
  background: #c0c0c0 !important;
  color: #000080 !important;
  border-top: 2px solid #ffffff !important;
  border-left: 2px solid #ffffff !important;
  border-right: 2px solid #404040 !important;
  border-bottom: 2px solid #404040 !important;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4) !important;
}
