:root {
  --color-primary: #004C97;
  --color-primary-hover: #003a75;
  --color-call-active: #E30613;
  --color-bg: #F5F5F0;
  --color-surface: #ffffff;
  --color-border: #F0F0F0;
  --color-border-strong: #E0E0E0;
  --color-text-primary: #404040;
  --color-text-secondary: #808080;
  --color-text-muted: #B0B0B0;
  --color-chat-user: #e3f2fd;
  --color-chat-agent: #f1f8e9;
  --color-chat-error-bg: #ffebee;
  --color-chat-error-text: #c62828;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 50%;

  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.06);
  --shadow-button: 0 4px 16px rgba(0, 76, 151, 0.25);
  --shadow-button-active: 0 4px 16px rgba(227, 6, 19, 0.25);

  --transition-fast: 0.15s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: var(--color-text-primary);
}

.container {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
  max-height: 800px;
  position: relative;
}

.header {
  padding: var(--space-md) 20px;
  border-bottom: 1px solid var(--color-border);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.auth-info {
  font-size: 12px;
  color: var(--color-text-secondary);
  word-break: break-all;
  margin-top: var(--space-xs);
  text-align: center;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.server-dot.online {
  background: #34a853;
}

.server-dot.offline {
  background: #ea4335;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tab:hover {
  color: var(--color-text-primary);
}

#tabTextContent {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) 20px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chat .empty {
  color: var(--color-text-muted);
  text-align: center;
  margin: auto;
  font-size: 14px;
}

.msg {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  max-width: 85%;
  font-size: 14px;
  line-height: 1.4;
}

.msg.user {
  background: var(--color-chat-user);
  align-self: flex-end;
}

.msg.agent {
  background: var(--color-chat-agent);
  align-self: flex-start;
}

.msg.error {
  background: var(--color-chat-error-bg);
  align-self: center;
  color: var(--color-chat-error-text);
}

.msg .label {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.msg .label.user-label {
  color: #1565c0;
}

.msg .label.agent-label {
  color: #558b2f;
}

.controls-text {
  padding: var(--space-md) 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.controls-text input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}

.controls-text input:focus {
  border-color: var(--color-primary);
}

#tabVoiceContent {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: var(--space-lg);
}

.phone-number {
  font-size: 22px;
  font-weight: 500;
  color: var(--color-text-primary);
  letter-spacing: 1px;
}

.phone-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: -16px;
}

.session-info {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
  word-break: break-all;
  text-align: center;
  line-height: 1.4;
  max-width: 100%;
  padding: 0 10px;
}

.btn-call {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  position: relative;
}

.btn-call.idle {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-button);
}

.btn-call.idle:hover {
  box-shadow: 0 6px 24px rgba(0, 76, 151, 0.35);
  transform: scale(1.03);
}

.btn-call.active {
  background: var(--color-call-active);
  color: #fff;
  box-shadow: var(--shadow-button-active);
  animation: pulse 1.5s ease-in-out infinite;
}

.btn-call.active:hover {
  box-shadow: 0 6px 24px rgba(227, 6, 19, 0.35);
}

.btn-call:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
  box-shadow: none;
  color: var(--color-text-muted);
}

.btn-call svg {
  width: 36px;
  height: 36px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.voice-status {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  min-height: 18px;
  transition: all 0.2s;
}

.voice-status.error {
  color: var(--color-call-active);
}

.voice-status.connected {
  color: var(--color-primary);
}

.btn {
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-family);
  transition: all var(--transition-fast);
}

.btn-send {
  padding: 10px 20px;
  background: var(--color-primary);
  color: #fff;
}

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

.btn-send:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
}

.btn-new {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-new:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.auth-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: 40px;
  border-radius: var(--radius-md);
  text-align: center;
}

.auth-overlay.hidden {
  display: none;
}

.auth-overlay h2 {
  font-size: 20px;
  color: var(--color-text-primary);
  font-weight: 500;
}

.auth-overlay p {
  font-size: 14px;
  color: var(--color-text-secondary);
  max-width: 320px;
  line-height: 1.5;
}

.auth-overlay .error {
  color: var(--color-call-active);
  font-size: 14px;
}
