/* Theme variables */
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1b26;
    --bg-tertiary: #24253a;
    --bg-input: #1a1b26;
    --text-primary: #e1e2e8;
    --text-secondary: #a0a9b8;
    --text-muted: #6b7084;
    --border: #2a2b3d;
    --accent-green: #4ade80;
    --accent-blue: #60a5fa;
    --accent-red: #f87171;
    --accent-orange: #fb923c;
    --btn-start-bg: #22c55e;
    --btn-start-hover: #16a34a;
    --btn-hangup-bg: #374151;
    --btn-hangup-hover: #4b5563;
    --summary-bg: #1e293b;
    --summary-border: #3b82f6;
    --history-active: #1e293b;
    --history-hover: #1a1b26;
    --modal-bg: #1a1b26;
    --shadow: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --bg-input: #ffffff;
    --text-primary: #1a1b26;
    --text-secondary: #495057;
    --text-muted: #868e96;
    --border: #dee2e6;
    --accent-green: #16a34a;
    --accent-blue: #2563eb;
    --accent-red: #dc2626;
    --accent-orange: #ea580c;
    --btn-start-bg: #16a34a;
    --btn-start-hover: #15803d;
    --btn-hangup-bg: #d1d5db;
    --btn-hangup-hover: #9ca3af;
    --summary-bg: #eff6ff;
    --summary-border: #3b82f6;
    --history-active: #eff6ff;
    --history-hover: #f1f3f5;
    --modal-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.active {
    background: var(--accent-green);
    animation: pulse 2s infinite;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.user-balance {
    font-size: 13px;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    padding: 4px 10px;
    border-radius: 14px;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    text-decoration: none;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-auth {
    font-size: 13px;
    color: var(--accent-blue);
    text-decoration: none;
    padding: 5px 12px;
    border: 1px solid var(--accent-blue);
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-auth:hover {
    background: rgba(96, 165, 250, 0.1);
}

.ui-lang-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.ui-lang-select:hover {
    border-color: var(--text-muted);
}

.btn-settings {
    background: rgba(168, 162, 158, 0.1);
    border: 1px solid rgba(168, 162, 158, 0.3);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.btn-settings:hover {
    color: var(--text-primary);
    background: rgba(168, 162, 158, 0.2);
}

/* Main layout */
main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Resize handles */
.resize-handle {
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: var(--accent-blue);
}

/* Left panel */
.panel-left {
    width: 420px;
    min-width: 280px;
    max-width: 60vw;
    padding: 16px;
    background: var(--bg-secondary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.tab {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 1px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.cost-hint {
    font-size: 11px;
    color: var(--accent-orange);
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.task-input-wrap {
    position: relative;
}

.task-input-wrap textarea {
    width: 100%;
    padding-right: 36px;
}

.btn-voice-input {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 2px;
}

.btn-voice-input:hover {
    opacity: 1;
}

.btn-voice-input.recording {
    opacity: 1;
    color: var(--accent-red);
    animation: pulse 1s infinite;
}

.template-bar {
    display: flex;
    gap: 8px;
}

.template-bar select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.btn-template {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.btn-template:hover {
    background: var(--border);
}

.btn-template-delete:hover {
    color: var(--accent-red);
}

.btn-start {
    width: 100%;
    padding: 12px;
    min-height: 44px;
    background: var(--btn-start-bg);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-start:hover:not(:disabled) {
    background: var(--btn-start-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-start:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-hangup {
    width: 100%;
    padding: 12px;
    min-height: 44px;
    background: var(--btn-hangup-bg);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-hangup:hover:not(:disabled) {
    background: var(--btn-hangup-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-hangup:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn-hangup:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.listen-link {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
    padding: 4px;
    transition: color 0.2s;
}

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

/* Transcript panel */
.transcript-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.transcript-header h2 {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.transcript-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.translate-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.translate-toggle input {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.translate-label.translating::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.message-translation {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    padding-left: 142px;
    margin-top: -6px;
    animation: fadeIn 0.3s ease;
}

.call-duration {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 13px;
    color: var(--accent-green);
    font-weight: 600;
}

.call-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 600;
}

.call-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.call-status.live::before {
    background: var(--accent-green);
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.call-status.ended::before {
    background: var(--accent-blue);
}

.transcript-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 12px;
    line-height: 1.5;
    animation: slideIn 0.2s ease;
}

.message-time {
    color: var(--text-muted);
    font-size: 12px;
    font-family: "SF Mono", "Fira Code", monospace;
    white-space: nowrap;
    padding-top: 1px;
    min-width: 60px;
}

.message-speaker {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    padding-top: 1px;
    min-width: 70px;
}

.message-speaker.agent_a,
.message-speaker.caller {
    color: var(--accent-green);
}

.message-speaker.agent_b,
.message-speaker.receiver,
.message-speaker.phone {
    color: var(--accent-blue);
}

.message-speaker.you {
    color: var(--accent-orange);
}

.message-speaker.system {
    color: var(--text-muted);
    font-style: italic;
}

.message-text {
    color: var(--text-primary);
    font-size: 14px;
}

.message-text[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* Summary box */
/* Horizontal resize handle between transcript and summary */
.resize-handle-h {
    height: 5px;
    cursor: row-resize;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.resize-handle-h:hover,
.resize-handle-h.dragging {
    background: var(--accent-blue);
}

.summary-box {
    min-height: 60px;
    height: 180px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 14px 16px;
    margin: 0;
    background: var(--summary-bg);
    border-left: 3px solid var(--summary-border);
    border-radius: 0;
    animation: fadeIn 0.4s ease;
}

.summary-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--summary-border);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    background: var(--summary-bg);
    padding-bottom: 4px;
}

.summary-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* SMS fallback */
.sms-fallback {
    padding: 8px 0;
    animation: fadeIn 0.3s ease;
}

/* Chat input bar */
.chat-input-bar {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    animation: fadeIn 0.3s ease;
}

.chat-input-bar input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-bar input:focus {
    border-color: var(--accent-blue);
}

.btn-chat-send {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    min-width: 60px;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-chat-send:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Right panel - history */
.panel-right {
    width: 280px;
    min-width: 180px;
    max-width: 40vw;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-right h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, border-left-color 0.15s;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background: var(--history-hover);
    border-left-color: var(--accent-blue);
}

.history-item.active {
    background: var(--history-active);
    border-left-color: var(--accent-green);
}

.history-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-meta {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.badge-live {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--accent-green);
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 360px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: 0 20px 40px var(--shadow);
    animation: scaleIn 0.2s ease;
}

.modal-content .auth-form {
    gap: 14px;
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* Wide modal variant */
.modal-wide {
    width: 480px;
}

/* Modal sections */
.modal-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.modal-section-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.section-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 4px;
}

/* Modal tabs (profile) */
.modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.modal-tab {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

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

/* Profile tab content panels */
.prof-tab-content {
    display: none;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn 0.2s ease;
}

.prof-tab-content.active {
    display: flex;
}

/* Overview info rows */
.overview-info {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.overview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.overview-row:last-child {
    border-bottom: none;
}

.overview-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.overview-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Modal action buttons */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.modal-actions .btn-start {
    flex: 1;
}

.btn-secondary {
    flex: 1;
    padding: 10px;
    min-height: 40px;
    background: var(--btn-hangup-bg);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Danger section */
.danger-section {
    border-color: rgba(248, 113, 113, 0.25);
    background: rgba(248, 113, 113, 0.04);
}

.danger-header {
    color: var(--accent-red);
}

.danger-warning {
    font-size: 12px;
    color: var(--accent-red);
    opacity: 0.8;
    line-height: 1.4;
    margin-bottom: 4px;
}

.btn-danger {
    width: 100%;
    padding: 10px;
    min-height: 40px;
    background: rgba(248, 113, 113, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.5);
}

/* Account Summary in Profile */
.account-summary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}

.account-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.account-stat {
    text-align: center;
}

.account-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: "SF Mono", "Fira Code", monospace;
}

.account-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Section separator — between task fields and personal info */
.form-section-break {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* Form sections */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.section-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.required-mark {
    color: var(--accent-red);
    margin-left: 2px;
    font-weight: 700;
}

/* Advanced section (collapsed) */
.advanced-section {
    padding: 0;
    background: transparent;
    border: 1px dashed var(--border);
}

.advanced-section > summary {
    cursor: pointer;
    padding: 10px 12px;
    border-bottom: none;
    margin-bottom: 0;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.advanced-section > summary::before {
    content: "\25B6";
    font-size: 9px;
    transition: transform 0.2s;
}

.advanced-section[open] > summary::before {
    transform: rotate(90deg);
}

.advanced-section > summary::-webkit-details-marker {
    display: none;
}

.advanced-section[open] {
    padding: 0 12px 12px;
    background: var(--bg-tertiary);
    border-style: solid;
}

.advanced-section > .form-group {
    margin-top: 8px;
}

/* Call Progress Rail */
.progress-rail {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 4px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
}

.progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.progress-step::before {
    content: "";
    position: absolute;
    top: 6px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.progress-step:first-child::before {
    display: none;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--bg-tertiary);
    position: relative;
    z-index: 1;
    transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}

.step-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: color 0.3s;
}

.progress-step.done .step-dot {
    background: var(--accent-green);
}

.progress-step.done .step-label {
    color: var(--accent-green);
}

.progress-step.done::before {
    background: var(--accent-green);
}

.progress-step.active .step-dot {
    background: var(--accent-blue);
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.5);
    animation: pulse 1.5s infinite;
    transform: scale(1.2);
}

.progress-step.active .step-label {
    color: var(--accent-blue);
    font-weight: 700;
}

.progress-step.active::before {
    background: var(--accent-green);
}

.progress-step.error .step-dot {
    background: var(--accent-red);
}

.progress-step.error .step-label {
    color: var(--accent-red);
}

/* State-driven panel emphasis */
.panel-left.in-call .form-section {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
}

.panel-left.in-call .progress-rail {
    opacity: 1;
    pointer-events: auto;
}

.panel-left.in-call .btn-hangup,
.panel-left.in-call .listen-link {
    opacity: 1;
    pointer-events: auto;
}

.panel-left.in-call .btn-start {
    display: none;
}

/* Activity badges on transcript */
.activity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    animation: fadeIn 0.3s ease;
}

.activity-badge.speaking {
    background: rgba(74, 222, 128, 0.15);
    color: var(--accent-green);
}

.activity-badge.waiting {
    background: rgba(251, 146, 60, 0.15);
    color: var(--accent-orange);
}

.activity-badge.ivr {
    background: rgba(96, 165, 250, 0.15);
    color: var(--accent-blue);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    .resize-handle {
        display: none;
    }
    .panel-right {
        display: none;
    }
    .main-content {
        flex-direction: column;
    }
    .panel-left {
        width: 100%;
        min-width: unset;
        max-width: 100%;
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    body {
        font-size: 14px;
    }
    .panel-left {
        width: 100%;
        min-width: unset;
        padding: 12px;
    }
    .transcript-panel {
        display: none;
    }
    .header {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header h1 {
        font-size: 16px;
    }
    .tab-bar {
        flex-wrap: wrap;
        gap: 4px;
    }
    .tab-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .form-group label {
        font-size: 12px;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 44px;
    }
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    .btn-start,
    .btn-hangup {
        padding: 14px;
        font-size: 14px;
        min-height: 44px;
    }
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
        padding: 16px;
    }
    .history-item {
        padding: 8px;
        font-size: 12px;
    }
    .user-menu,
    .guest-menu {
        font-size: 12px;
    }
    .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    /* Stack form rows on mobile */
    .form-row {
        flex-direction: column;
        gap: 8px;
    }
    /* Show call rating on mobile */
    .rating-stars {
        font-size: 24px;
    }
}

/* Responsive - Small mobile */
@media (max-width: 380px) {
    .header h1 {
        font-size: 14px;
    }
    .tab-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Call rating stars */
.rating-stars {
    display: flex;
    gap: 4px;
    font-size: 28px;
    cursor: pointer;
}
.rating-stars span {
    color: var(--text-muted);
    transition: color 0.2s;
}
.rating-stars span.active,
.rating-stars span:hover {
    color: #fbbf24;
}

/* Share button */
.btn-share {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}
.btn-share:hover {
    opacity: 0.8;
}

/* Logout text button */
.btn-logout-text {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--accent-red);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.btn-logout-text:hover {
    color: var(--accent-red);
    background: rgba(248, 113, 113, 0.1);
}

.btn-profile-text {
    background: rgba(168, 162, 158, 0.1);
    border: 1px solid rgba(168, 162, 158, 0.3);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.btn-profile-text:hover {
    color: var(--text-primary);
    background: rgba(168, 162, 158, 0.2);
}

.btn-admin-text {
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.3);
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.btn-admin-text:hover {
    background: rgba(96, 165, 250, 0.2);
}

/* RTL support */
[dir="rtl"] main {
    direction: rtl;
}
[dir="rtl"] .panel-left,
[dir="rtl"] .panel-right {
    direction: rtl;
}
[dir="rtl"] .transcript-messages {
    direction: rtl;
}
[dir="rtl"] .msg-agent {
    text-align: right;
}
[dir="rtl"] .msg-user {
    text-align: left;
}
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
}
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="datetime-local"] {
    text-align: left;
    direction: ltr;
}
[dir="rtl"] .header-left {
    flex-direction: row-reverse;
}
[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}
[dir="rtl"] .user-menu {
    flex-direction: row-reverse;
}
[dir="rtl"] .template-bar {
    direction: rtl;
}
[dir="rtl"] .task-input-wrap {
    direction: rtl;
}
[dir="rtl"] .btn-voice-input {
    right: auto;
    left: 8px;
}
[dir="rtl"] .transcript-header {
    flex-direction: row-reverse;
}
[dir="rtl"] .summary-box {
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .history-item {
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .chat-input-bar {
    direction: rtl;
}
[dir="rtl"] .form-group label {
    text-align: right;
}
[dir="rtl"] .auth-card {
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .auth-header .ui-lang-select {
    right: auto;
    left: 40px;
}
[dir="rtl"] .code-footer {
    direction: rtl;
}

/* Story 7: Transcript speaker styling & fact chips */
.msg-agent_a, .msg-caller { border-left: 3px solid rgba(74, 222, 128, 0.3); padding-left: 10px; }
.msg-agent_b, .msg-receiver, .msg-phone { border-left: 3px solid rgba(96, 165, 250, 0.3); padding-left: 10px; }
.msg-you { border-left: 3px solid rgba(251, 146, 60, 0.3); padding-left: 10px; }
.msg-system { border-left: 3px solid rgba(156, 163, 175, 0.3); padding-left: 10px; font-style: italic; }
.msg-continuation .message-time, .msg-continuation .message-speaker { visibility: hidden; }
.msg-continuation { padding-top: 2px; }
.fact-chip { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; margin-left: 8px; font-weight: 600; vertical-align: middle; }
.fact-chip-price { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.fact-chip-hours { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.fact-chip-address { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.fact-chip-callback { background: rgba(251, 146, 60, 0.15); color: #fb923c; }

/* Story 8: Sticky call actions */
.call-actions-sticky {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    z-index: 10;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Story 9: History enhancements */
.history-summary { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-retry-hint { font-size: 11px; color: #f97316; font-weight: 600; margin-top: 3px; }
.history-facts { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
