/* Кабинет турагентства. Оформление — по образцу консоли ботов: те же переменные темы (shadcn, slate),
   карточки с тонкой границей, тёмно-синяя основная кнопка, пузыри сообщений трёх цветов. */
:root {
  --background: 0 0% 100%; --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%; --primary: 222.2 47.4% 11.2%; --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%; --muted: 210 40% 96.1%; --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%; --destructive: 0 84.2% 60.2%; --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%; --input: 214.3 31.8% 91.4%; --ring: 222.2 84% 4.9%;
  --success: 140 50% 70%; --success-foreground: 140 40% 25%;
  --warning: 30 80% 75%; --warning-foreground: 30 50% 20%;
  --input-highlight: 217 91% 95%; --input-highlight-border: 217 91% 60%;
  --send-button: 217 91% 60%; --send-button-hover: 217 91% 55%; --send-button-foreground: 0 0% 100%;
  --chat-user: 220 70% 95%; --chat-user-foreground: 220 40% 25%;
  --chat-operator: 25 85% 95%; --chat-operator-foreground: 25 45% 25%;
  --chat-assistant: 160 60% 95%; --chat-assistant-foreground: 160 40% 25%;
  --sidebar-background: 0 0% 98%; --sidebar-foreground: 240 5.3% 26.1%; --sidebar-accent: 240 4.8% 95.9%;
  --sidebar-primary: 240 5.9% 10%; --sidebar-border: 220 13% 91%;
  --radius: 0.5rem; --topbar: 4rem; --sidebar: 16rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: 222.2 84% 4.9%; --foreground: 210 40% 98%; --card: 222.2 84% 4.9%;
    --primary: 210 40% 98%; --primary-foreground: 222.2 47.4% 11.2%;
    --secondary: 217.2 32.6% 17.5%; --muted: 217.2 32.6% 17.5%; --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%; --destructive: 0 62.8% 40%; --destructive-foreground: 210 40% 98%;
    --border: 217.2 32.6% 17.5%; --input: 217.2 32.6% 17.5%; --ring: 212.7 26.8% 83.9%;
    --success: 140 45% 35%; --success-foreground: 140 60% 85%;
    --warning: 30 70% 45%; --warning-foreground: 30 85% 85%;
    --input-highlight: 217 91% 15%; --input-highlight-border: 217 91% 70%;
    --send-button: 217 91% 65%; --send-button-hover: 217 91% 70%; --send-button-foreground: 0 0% 0%;
    --chat-user: 220 50% 15%; --chat-user-foreground: 220 70% 85%;
    --chat-operator: 25 45% 15%; --chat-operator-foreground: 25 75% 85%;
    --chat-assistant: 160 40% 15%; --chat-assistant-foreground: 160 65% 85%;
    --sidebar-background: 240 5.9% 10%; --sidebar-foreground: 240 4.8% 95.9%; --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-primary: 224.3 76.3% 48%; --sidebar-border: 240 3.7% 15.9%;
  }
}

*, *::before, *::after { box-sizing: border-box; border-color: hsl(var(--border)); }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif,
       "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; line-height: 1.45; background: hsl(var(--background)); color: hsl(var(--foreground)); }
h1, h2, p, dl, dd, ul { margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: hsl(var(--muted)); padding: 2px 6px; border-radius: 4px; }
.icon { width: 16px; height: 16px; flex: none; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12px; }

/* ---------- каркас ---------- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 50; display: flex; align-items: center; gap: 12px; padding: 0 16px;
          border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--background) / 0.92); backdrop-filter: blur(8px); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 6px; cursor: pointer; }
.icon-btn:hover { background: hsl(var(--accent)); }
.brand { display: inline-flex; text-decoration: none; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px;
              background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-mark-lg { width: 56px; height: 56px; margin: 0 auto 12px; }
.brand-mark-lg .icon { width: 28px; height: 28px; }
.topbar-title { font-size: 18px; font-weight: 600; line-height: 1.2; }
.topbar-agency { margin-left: 10px; font-size: 14px; font-weight: 400; color: hsl(var(--muted-foreground)); }
.sidebar { position: fixed; inset: var(--topbar) auto 0 0; width: var(--sidebar); z-index: 40; display: flex; flex-direction: column;
           background: hsl(var(--sidebar-background)); color: hsl(var(--sidebar-foreground)); border-right: 1px solid hsl(var(--sidebar-border)); }
.nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.nav-label { padding: 4px 12px; font-size: 12px; color: hsl(var(--sidebar-foreground) / 0.6); }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px; border-radius: 8px; font-weight: 500;
            text-decoration: none; color: hsl(var(--sidebar-foreground)); }
.nav-item .icon { width: 20px; height: 20px; }
.nav-item:hover { background: hsl(var(--sidebar-accent) / 0.6); }
.nav-item.is-active { background: hsl(var(--sidebar-accent)); border-right: 2px solid hsl(var(--sidebar-primary)); }
.nav-button { width: 100%; border: 0; background: none; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.sidebar-foot { padding: 12px; border-top: 1px solid hsl(var(--sidebar-border)); display: flex; flex-direction: column; gap: 4px; }
.who { padding: 4px 12px 8px; }
.who-name { font-weight: 600; }
.who-role { font-size: 12px; color: hsl(var(--sidebar-foreground) / 0.65); }
.version { padding: 6px 12px 0; font-size: 11px; color: hsl(var(--sidebar-foreground) / 0.5); }
.content { margin: var(--topbar) 0 0 var(--sidebar); min-height: calc(100vh - var(--topbar)); padding: 24px; }
.content-flush { padding: 0; }
.nav-toggle:checked ~ .sidebar { display: none; }
.nav-toggle:checked ~ .content { margin-left: 0; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.page { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head .icon { width: 24px; height: 24px; }
.page-title { font-size: 20px; font-weight: 600; }
.page-title-lg { font-size: 28px; font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack > .card:last-child { max-width: 32rem; }

/* ---------- общие элементы ---------- */
.card { border: 1px solid hsl(var(--border)); border-radius: 8px; background: hsl(var(--card)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.card-narrow { width: 100%; max-width: 28rem; margin: 0 auto; }
.card-head { padding: 24px 24px 0; display: flex; flex-direction: column; gap: 6px; }
.card-head-center { text-align: center; }
.card-title { font-size: 22px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.card-subtitle { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.card-body { padding: 24px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 500; line-height: 1; }
.hint { font-size: 12px; color: hsl(var(--muted-foreground)); }
.input, .select, .textarea { width: 100%; border: 1px solid hsl(var(--input)); border-radius: 6px; background: hsl(var(--background)); color: inherit;
                             font: inherit; padding: 8px 12px; }
.input, .select { height: 40px; }
.select-sm { height: 36px; width: auto; padding: 4px 8px; }
.textarea { min-height: 80px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible, .btn:focus-visible, .switch:focus-visible, .chat-card:focus-visible, .tab:focus-visible {
  outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 6px; border: 1px solid transparent;
       font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none; background: none; color: inherit; }
.btn-sm { height: 36px; padding: 0 12px; }
.btn-block { width: 100%; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-outline { border-color: hsl(var(--input)); background: hsl(var(--background)); }
.btn-outline:hover, .btn-ghost:hover { background: hsl(var(--accent)); }
.btn-send { background: hsl(var(--send-button)); color: hsl(var(--send-button-foreground)); font-weight: 600; padding: 0 24px;
            box-shadow: 0 4px 10px rgb(0 0 0 / 0.12); }
.btn-send:hover { background: hsl(var(--send-button-hover)); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid transparent; padding: 2px 10px; font-size: 12px; font-weight: 600;
         line-height: 1.4; text-decoration: none; white-space: nowrap; }
.badge-default, .badge-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.badge-outline { border-color: hsl(var(--border)); }
.badge-success { background: hsl(var(--success)); color: hsl(var(--success-foreground)); }
.badge-danger { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.badge-staff { background: hsl(var(--warning)); color: hsl(var(--warning-foreground)); }
.badge-tg { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-max { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.flash { border: 1px solid hsl(var(--border)); border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; }
.flash-ok { background: hsl(var(--success) / 0.25); border-color: hsl(var(--success)); }
.flash-error { background: hsl(var(--destructive) / 0.1); border-color: hsl(var(--destructive) / 0.4); color: hsl(var(--destructive)); }
.content-flush > .flash { margin: 12px 24px 0; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; text-align: center; }
.empty h2 { font-size: 18px; font-weight: 500; }
.empty-mark { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 999px; background: hsl(var(--muted)); }
.empty-mark .icon { width: 28px; height: 28px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { height: 44px; padding: 0 16px; text-align: left; font-weight: 500; color: hsl(var(--muted-foreground)); border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 260px; }
.tabs { display: inline-flex; align-self: flex-start; gap: 4px; padding: 4px; border-radius: 6px; background: hsl(var(--muted)); }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 4px; font-weight: 500; text-decoration: none; color: hsl(var(--muted-foreground)); }
.tab.is-active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* ---------- чаты: панель и список ---------- */
.toolbar { border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.search { position: relative; flex: 1 1 280px; max-width: 28rem; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: hsl(var(--muted-foreground)); }
.search .input { padding-left: 38px; }
.switches { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 8px 16px; border-radius: 8px; border: 1px solid hsl(var(--border) / 0.6);
            background: hsl(var(--muted) / 0.5); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-decoration: none; border-radius: 6px; }
.switch-track { display: inline-flex; align-items: center; width: 44px; height: 24px; padding: 2px; border-radius: 999px; background: hsl(var(--input)); transition: background .15s; }
.switch-thumb { width: 20px; height: 20px; border-radius: 999px; background: hsl(var(--background)); box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform .15s; }
.switch.is-on .switch-track { background: hsl(var(--primary)); }
.switch.is-on .switch-thumb { transform: translateX(20px); }
.toolbar-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: hsl(var(--muted-foreground)); font-size: 13px; }
.list { padding: 24px; display: grid; gap: 16px; }
.chat-card { display: flex; align-items: flex-start; gap: 16px; padding: 20px 24px; border: 1px solid hsl(var(--border) / 0.7); border-radius: 8px; background: hsl(var(--card));
             box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); text-decoration: none; transition: box-shadow .2s, border-color .2s; }
.chat-card:hover { box-shadow: 0 10px 20px -8px rgb(0 0 0 / 0.18); border-color: hsl(var(--primary) / 0.3); }
.chat-card.is-waiting { border-color: hsl(var(--destructive) / 0.45); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: none; border-radius: 999px; font-weight: 600;
          background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); border: 2px solid hsl(var(--primary) / 0.2); }
.avatar-sm { width: 40px; height: 40px; border: 0; background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.chat-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.chat-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.chat-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.chat-id { color: hsl(var(--muted-foreground)); font-size: 12px; }
.chat-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: hsl(var(--muted-foreground)); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.meta-item .icon { width: 14px; height: 14px; }
.meta-note { color: hsl(var(--foreground) / 0.8); }
.meta-note .icon { color: hsl(var(--warning-foreground)); }
.chat-last { color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-last b { font-weight: 600; color: hsl(var(--foreground) / 0.75); }

/* ---------- карточка диалога ---------- */
.content-chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar)); min-height: 0; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid hsl(var(--border));
             background: hsl(var(--card)); }
.chat-head-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.chat-head-right { display: flex; align-items: center; gap: 10px; }
.chat-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.chat-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.chat-col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid hsl(var(--border)); }
.passports summary { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.notes-form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.feed { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; background: hsl(var(--muted) / 0.25); }
.day-sep { display: flex; justify-content: center; }
.day-sep span { font-size: 12px; color: hsl(var(--muted-foreground)); background: hsl(var(--background)); border: 1px solid hsl(var(--border)); border-radius: 999px; padding: 2px 12px; }
.msg { display: flex; }
.msg-client { justify-content: flex-start; }
.msg-bot, .msg-staff { justify-content: flex-end; }
.bubble { max-width: 70%; border-radius: 12px; padding: 12px 16px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); display: flex; flex-direction: column; gap: 10px; }
.bubble-client { background: hsl(var(--chat-user)); color: hsl(var(--chat-user-foreground)); margin-right: 48px; }
.bubble-staff { background: hsl(var(--chat-operator)); color: hsl(var(--chat-operator-foreground)); margin-left: 48px; }
.bubble-bot { background: hsl(var(--chat-assistant)); color: hsl(var(--chat-assistant-foreground)); margin-left: 48px; }
.bubble-text { line-height: 1.6; overflow-wrap: anywhere; }
.bubble-text a { text-decoration: underline; }
.bubble-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; font-size: 12px; opacity: 0.7; }
.pill { background: rgb(255 255 255 / 0.35); border-radius: 999px; padding: 3px 8px; font-weight: 500; white-space: nowrap; }
.pill-warn { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.feed-more, .feed-note { display: flex; justify-content: center; gap: 6px; font-size: 13px; color: hsl(var(--muted-foreground)); }
.reply { border-top: 2px solid hsl(var(--input-highlight-border)); background: hsl(var(--input-highlight) / 0.7); padding: 12px 24px 14px; display: flex; flex-direction: column; gap: 8px; }
.reply-off { color: hsl(var(--muted-foreground)); }
.reply-hint { font-size: 12px; color: hsl(var(--muted-foreground)); }
.reply-row { display: flex; align-items: flex-end; gap: 12px; }
.reply-input { min-height: 44px; max-height: 220px; border: 2px solid hsl(var(--input-highlight-border)); background: hsl(var(--background)); }
.passports { border-top: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 10px 24px; }
.passports form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 8px; }
.passports-text { padding: 10px 12px; border-radius: 8px; background: hsl(var(--muted) / 0.6); max-width: 60ch; }
.side { overflow-y: auto; background: hsl(var(--card)); }
.side-block { padding: 18px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; flex-direction: column; gap: 12px; }
.side-title { font-size: 15px; font-weight: 600; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.doc { display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.doc img, .doc-file { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid hsl(var(--border)); background: hsl(var(--muted)); }
.doc-file { display: flex; align-items: center; justify-content: center; }
.doc-file .icon { width: 32px; height: 32px; }
.doc-meta { font-size: 11px; color: hsl(var(--muted-foreground)); }

/* ---------- запросы ---------- */
.request-list { display: grid; gap: 16px; }
.request { border: 1px solid hsl(var(--border)); border-radius: 8px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; background: hsl(var(--card)); }
.request-submitted { border-left: 3px solid hsl(var(--primary)); }
.request-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.request-title { font-weight: 600; font-size: 15px; }
.request-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; }
.request-facts dt { color: hsl(var(--muted-foreground)); }
.client-words { overflow-wrap: anywhere; }
.tour-lines { list-style: none; padding: 10px 12px; border-radius: 8px; background: hsl(var(--muted) / 0.5); display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.request-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.request-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.issued { border-color: hsl(var(--success)); background: hsl(var(--success) / 0.15); }
.issued-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin-bottom: 10px; }
.issued-facts dt { color: hsl(var(--muted-foreground)); }

/* ---------- узкие экраны ---------- */
@media (max-width: 1100px) {
  .chat-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .content-chat { height: auto; min-height: calc(100vh - var(--topbar)); }
  .chat-col { border-right: 0; }
  .feed { max-height: 70vh; }
}
@media (max-width: 860px) {
  .sidebar { display: none; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); }
  .content { margin-left: 0; padding: 16px; }
  .content-flush { padding: 0; }
  .nav-toggle:checked ~ .sidebar { display: flex; }
  .topbar-agency { display: none; }
  .bubble { max-width: 88%; }
  .bubble-client { margin-right: 12px; }
  .bubble-staff, .bubble-bot { margin-left: 12px; }
  .toolbar, .list { padding: 14px 16px; }
}
