* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: #f5f5f5; color: #1a1a1a; }
#app { min-height: 100vh; }

#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-box { background: #fff; padding: 2rem; border-radius: 12px; max-width: 360px; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-box h1 { margin: 0 0 0.5rem; font-size: 1.25rem; color: #1a1a1a; }
.login-box .hint { color: #666; font-size: 0.875rem; margin: 0 0 1rem; }
.login-box input { display: block; width: 100%; padding: 0.6rem; margin-bottom: 0.75rem; border: 1px solid #ccc; border-radius: 6px; background: #fff; color: #1a1a1a; }
.login-box button { width: 100%; padding: 0.6rem; background: #2563eb; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-weight: 600; }
.login-box button:hover { background: #1d4ed8; }
.error { color: #dc2626; font-size: 0.875rem; margin-top: 0.5rem; }

.hidden { display: none !important; }

#messenger-screen { display: flex; height: 100vh; }
#thread-list { width: 320px; border-right: 1px solid #e5e7eb; display: flex; flex-direction: column; background: #fff; }
#templates-panel { width: 300px; border-left: 1px solid #e5e7eb; display: flex; flex-direction: column; background: #fff; overflow: hidden; }
#templates-panel h2 { margin: 0; padding: 1rem; font-size: 1rem; color: #1a1a1a; }
.templates-departure { margin: 0 1rem 0.5rem; padding: 0.4rem 0.5rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.85rem; }
#templates-list { flex: 1; overflow-y: auto; padding: 0.5rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.branch-item { display: flex; flex-direction: column; gap: 0.25rem; }
.branch-btn { width: 100%; padding: 0.55rem 0.75rem; text-align: left; background: #2563eb; border: none; border-radius: 8px; color: #fff; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.branch-btn:hover { background: #1d4ed8; }
.branch-body { padding: 0.35rem 0 0.5rem 0.5rem; border-left: 2px solid #93c5fd; margin-left: 0.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.template-item { display: flex; flex-direction: column; gap: 0.2rem; }
.template-btn { width: 100%; padding: 0.45rem 0.65rem; text-align: left; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 6px; color: #1a1a1a; cursor: pointer; font-size: 0.85rem; }
.template-btn:hover { background: #e5e7eb; }
.template-body { padding: 0.5rem 0; border-left: 3px solid #2563eb; padding-left: 0.5rem; }
.template-needs-summary-row { margin-bottom: 0.5rem; }
.template-summary-label { display: block; font-size: 0.8rem; color: #374151; margin-bottom: 0.25rem; }
.template-summary-input { width: 100%; padding: 0.4rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.85rem; resize: vertical; min-height: 60px; box-sizing: border-box; }
.template-rejection-input { min-height: 0; resize: none; }
.template-action-build { margin-bottom: 0.5rem; padding: 0.35rem 0.6rem; font-size: 0.8rem; background: #059669; border: none; border-radius: 6px; color: #fff; cursor: pointer; }
.template-action-build:hover { background: #047857; }
.template-body .template-preview { font-size: 0.8rem; color: #374151; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; margin-bottom: 0.5rem; }
.template-actions { display: flex; gap: 0.5rem; }
.template-action-insert, .template-action-send { padding: 0.35rem 0.6rem; font-size: 0.8rem; background: #2563eb; border: none; border-radius: 6px; color: #fff; cursor: pointer; }
.template-action-insert:hover, .template-action-send:hover { background: #1d4ed8; }
#thread-list h2 { margin: 0; padding: 1rem; font-size: 1rem; color: #1a1a1a; }
.channel-badge { margin-left: 0.5rem; display: inline-flex; align-items: center; }
.channel-logo { display: inline-block; object-fit: contain; vertical-align: middle; }
.channel-logo-header { height: 24px; width: auto; max-width: 28px; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0 0 0.5rem; }
.channel-badges-sidebar { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0; }
.new-chat-plus-btn { width: 28px; height: 28px; padding: 0; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #2563eb; font-size: 1.25rem; line-height: 1; cursor: pointer; font-weight: 600; flex-shrink: 0; }
.new-chat-plus-btn:hover { background: #eff6ff; border-color: #2563eb; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-overlay.hidden { display: none; }
.modal-box { background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); max-width: 360px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid #e5e7eb; }
.modal-header h3 { margin: 0; font-size: 1.1rem; color: #1a1a1a; }
.modal-close { width: 32px; height: 32px; padding: 0; border: none; background: transparent; color: #6b7280; font-size: 1.5rem; line-height: 1; cursor: pointer; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: #1a1a1a; }
.new-chat-box { padding: 1.25rem; }
.channel-with-dot { position: relative; display: inline-flex; align-items: center; gap: 0.2rem; }
.channel-logo-sidebar { height: 20px; width: auto; max-width: 22px; opacity: 0.85; }
.channel-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #9ca3af; cursor: help; }
.channel-status-dot-ok { background: #22c55e; }
.channel-status-dot-err { background: #ef4444; }
.channel-status-hint { margin: 0 0 0.5rem; padding: 0.25rem 0; font-size: 0.75rem; color: #6b7280; }
.channel-status-hint.channel-status-ok { color: #059669; }
.channel-status-hint.channel-status-warn { color: #d97706; cursor: help; }
#threads .channel-badge-inline { display: inline-flex; align-items: center; padding: 0.15rem 0.25rem; border-radius: 4px; background: #f3f4f6; }
#threads .channel-badge-inline .channel-logo { height: 16px; width: auto; max-width: 18px; }
.new-chat-label { display: block; font-size: 0.75rem; color: #6b7280; margin-bottom: 0.35rem; }
.new-chat-select { width: 100%; padding: 0.45rem 0.5rem; margin-bottom: 0.4rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.875rem; }
.new-chat-input { width: 100%; padding: 0.45rem 0.5rem; margin-bottom: 0.4rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.875rem; box-sizing: border-box; }
.new-chat-btn { width: 100%; padding: 0.5rem; background: #2563eb; border: none; border-radius: 6px; color: #fff; font-size: 0.875rem; cursor: pointer; font-weight: 600; }
.new-chat-btn:hover { background: #1d4ed8; }
.new-chat-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.new-chat-hint { margin: 0.35rem 0 0; font-size: 0.75rem; min-height: 1em; }
.new-chat-hint-ok { color: #059669; }
.new-chat-hint-err { color: #dc2626; }
.documents-step-desc { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.5rem; }
.documents-file-list { list-style: none; margin: 0 0 0.5rem; padding: 0; max-height: 120px; overflow-y: auto; }
.documents-file-item { display: flex; align-items: center; justify-content: space-between; padding: 0.3rem 0; font-size: 0.8rem; border-bottom: 1px solid #f3f4f6; }
.documents-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.documents-file-remove { padding: 0 0.35rem; border: none; background: #fee2e2; color: #dc2626; cursor: pointer; border-radius: 4px; font-size: 1rem; line-height: 1.2; }
.documents-file-remove:hover { background: #fecaca; }
.documents-step-actions { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
#threads { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#threads li { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e7eb; cursor: pointer; }
#threads li:hover { background: #f9fafb; }
#threads li.active { background: #eff6ff; border-left: 3px solid #2563eb; }
#threads .thread-name-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
#threads .thread-name { font-weight: 600; color: #1a1a1a; }
#threads .thread-id { font-size: 0.75rem; color: #6b7280; margin-top: 0.15rem; }
#threads .preview { font-size: 0.8rem; color: #9ca3af; margin-top: 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#no-threads { padding: 1rem; color: #6b7280; font-size: 0.875rem; }

#chat-panel { flex: 1; display: flex; flex-direction: column; background: #f5f5f5; }
#chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chat-header { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; background: #fff; }
.chat-header-names { display: flex; flex-direction: column; flex: 1; }
#chat-title { font-weight: 600; color: #1a1a1a; }
#chat-id { font-size: 0.75rem; color: #6b7280; margin-top: 0.1rem; }
#messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; background: #f5f5f5; }
.msg { max-width: 75%; padding: 0.5rem 0.75rem; border-radius: 12px; font-size: 0.9rem; }
.msg.tourist { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; color: #1a1a1a; }
.msg.manager { align-self: flex-end; background: #2563eb; color: #fff; }
.msg .meta { font-size: 0.7rem; color: #6b7280; margin-top: 0.25rem; }
.msg.manager .meta { color: rgba(255,255,255,0.85); }
#no-chat { padding: 2rem; color: #6b7280; text-align: center; }
#send-form { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid #e5e7eb; background: #fff; }
#message-input { flex: 1; padding: 0.5rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #1a1a1a; resize: none; min-height: 44px; max-height: 50vh; overflow-y: auto; }
#send-form button { padding: 0.5rem 1rem; background: #2563eb; border: none; border-radius: 8px; color: #fff; cursor: pointer; font-weight: 600; }
#send-form button:hover { background: #1d4ed8; }

.new-thread-box { padding: 0 1rem 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; border-bottom: 1px solid #e5e7eb; }
.new-thread-box input { flex: 1; min-width: 80px; padding: 0.5rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.9rem; }
.new-thread-box button { padding: 0.5rem 0.75rem; background: #2563eb; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 0.85rem; white-space: nowrap; }
.new-thread-box button:hover { background: #1d4ed8; }
.chat-toolbar { padding: 0.5rem 1rem; border-bottom: 1px solid #e5e7eb; background: #fff; display: flex; flex-direction: column; gap: 0.5rem; }
.chat-toolbar .toolbar-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.chat-toolbar .toolbar-input { padding: 0.4rem 0.5rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.85rem; min-width: 120px; }
.chat-toolbar .toolbar-input.optional { min-width: 100px; }
.chat-toolbar .toolbar-select { padding: 0.4rem 0.5rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1a1a1a; font-size: 0.85rem; min-width: 180px; }
.chat-toolbar button { padding: 0.4rem 0.75rem; background: #2563eb; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 0.85rem; }
.chat-toolbar button:hover { background: #1d4ed8; }
.chat-toolbar .context-label { font-size: 0.85rem; color: #6b7280; }
.bind-status { font-size: 0.8rem; margin-left: 0.5rem; }
.bind-status-none { color: #9ca3af; }
.bind-status-ok { color: #059669; }
.bind-status-loading { color: #2563eb; }
.bind-status-err { color: #dc2626; }
