:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text: #e7e9ea;
  --text-muted: #8b98a5;
  --border: #2f3336;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding: 1.5rem;
}

.hidden {
  display: none !important;
}

/* Auth */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid var(--border);
}

.auth-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

#auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#auth-tabs .tab {
  flex: 1;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

#auth-tabs .tab.active {
  background: var(--accent);
  border-color: var(--accent);
}

.auth-form input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

.auth-form button {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.auth-form button:hover {
  background: var(--accent-hover);
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Main */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.card h3, .card h4 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.full-width {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.row select {
  flex: 1;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.textarea-wrap textarea {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.btn-primary {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-card);
}

.btn-danger {
  padding: 0.5rem 1rem;
  background: var(--danger);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
}

#calls-list, #templates-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.call-item, .template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.call-item:hover, .template-item:hover {
  cursor: pointer;
  border-color: var(--accent);
}

/* Call screen — layout Cursor-style */
#call-status {
  font-weight: 500;
  font-size: 0.8rem;
}

.bot-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.bot-status.ok {
  color: var(--success);
}
.bot-status.error {
  color: var(--danger);
}

#call-timer {
  font-variant-numeric: tabular-nums;
}

.layout-divider {
  background: var(--border);
  flex-shrink: 0;
  user-select: none;
}
.layout-divider:hover {
  background: var(--accent);
}

.left-column {
  width: var(--left-panel-width, 280px);
  min-width: 80px;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
}

.left-tabs {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.left-tab {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.left-tab:hover {
  color: var(--text);
}
.left-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.left-tab-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  padding: 0.5rem;
}
.left-tab-content.hidden {
  display: none !important;
}

.goal-panel {
  flex-shrink: 0;
  min-height: 40px;
  max-height: 150px;
  height: var(--goal-height, 60px);
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.goal-panel .call-goal-edit.hidden {
  display: none;
}

.goal-panel.editing {
  height: auto;
  min-height: 120px;
  overflow: visible;
}

.goal-panel h4 {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.call-goal-display {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.call-goal-display:hover {
  color: var(--accent);
}

.call-goal-edit {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.call-goal-edit textarea {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  resize: none;
  flex: 1;
  min-height: 50px;
  max-height: 80px;
}

.call-goal-edit .btn-secondary {
  flex-shrink: 0;
}

.goal-resize-handle {
  height: 6px;
  cursor: ns-resize;
  flex-shrink: 0;
}

.participants-status {
  font-size: 0.7rem;
  margin-bottom: 0.25rem;
}

.btn-clear-all {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.participant-state-problem {
  color: var(--warning) !important;
}

.behavioral-error {
  color: var(--warning);
  list-style-type: disc;
}

.behavioral-quote {
  font-size: 0.85em;
  color: var(--text-muted);
}

#call-screen {
  padding: 0;
  height: 100vh;
}

.call-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.call-main {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
}


/* Центральная панель — подсказки во весь экран */
.hints-column {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hints-block {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hints-block h4 {
  margin: 0 0 0.25rem;
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* Правая зона: чат + status badge */
.call-right-area {
  width: var(--chat-panel-width, 280px);
  min-width: 200px;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
}

.call-chat-panel {
  flex: 1;
  min-height: 80px;
  max-height: var(--chat-panel-height, 280px);
  height: var(--chat-panel-height, 280px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.call-chat-panel.chat-panel-collapsed {
  display: none !important;
}

.chat-resize-handle {
  height: 6px;
  cursor: row-resize;
  flex-shrink: 0;
}

.call-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.status-badge-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 1rem;
}
.status-badge-btn:hover {
  color: var(--accent);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}


.scroll-container {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.previous-topic-fixed {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
  padding: 0.4rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.chat-resize-handle {
  height: 6px;
  background: var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
}

.chat-resize-handle:hover {
  background: var(--accent);
}

.call-chat-panel h4 {
  margin: 0 0 0.5rem;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.chat-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.resize-handle {
  width: 6px;
  cursor: col-resize;
  flex-shrink: 0;
}

#live-transcript {
  font-size: 0.9rem;
  line-height: 1.5;
}

.participant-item {
  padding: 0.25rem 0;
  font-size: 0.75rem;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.participant-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.participant-check input {
  margin: 0;
}

#participants-list {
  font-size: 0.75rem;
  line-height: 1.3;
}

.utterance {
  margin-bottom: 0.5rem;
}

.utterance .utterance-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.utterance .speaker {
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.5rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.hint-time {
  font-weight: normal;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.utterance.partial {
  opacity: 0.7;
}

/* П.3.4, П.3.5 — уменьшенный шрифт подсказок, карточки */
#hints-content {
  font-size: 0.8rem;
}

.hint-section {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.hint-section h5 {
  margin: 0 0 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hint-section ul {
  margin: 0;
  padding-left: 1rem;
}

#analyzing {
  color: var(--text-muted);
  font-style: italic;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.chat-input input {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.chat-msg {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
}

.chat-msg.assistant {
  border-left: 3px solid var(--accent);
}

.participant-item {
  border-bottom: 1px solid var(--border);
}

.participant-item:last-child {
  border-bottom: none;
}

.chat-input .btn-danger {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.recommendation-item {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.recommendation-item .ts {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.recording-modal {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
}

.recording-modal p {
  margin-bottom: 1rem;
}
