/* ===================================================================
   Tele-Market Guru — design tokens & shared component classes.
   Layered on top of Bootstrap 5. Refines, doesn't replace.
   ------------------------------------------------------------------- */

:root {
    --tmg-brand: #0F766E;
    --tmg-brand-hover: #115E59;
    --tmg-bg: #EEF1F5;
    --tmg-surface: #FFFFFF;
    --tmg-page-card-bg: #FFFFFF;
    --tmg-sidebar-bg: #1F2937;
    --tmg-sidebar-fg: #E5E7EB;
    --tmg-sidebar-active: #10B981;
    --tmg-border: #E5E7EB;
    --tmg-text: #111827;
    --tmg-text-muted: #6B7280;
    --tmg-success: #10B981;
    --tmg-warning: #F59E0B;
    --tmg-danger: #EF4444;
    --tmg-info: #3B82F6;
    --tmg-radius: 6px;
    --tmg-radius-lg: 12px;
    --tmg-shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
    --tmg-shadow-md: 0 4px 12px rgb(0 0 0 / .08);
    --tmg-shadow-card: 0 1px 3px rgb(15 23 42 / .04), 0 10px 25px rgb(15 23 42 / .05);
    --tmg-shadow-modal: 0 20px 50px -10px rgba(15, 23, 42, .35), 0 8px 16px -4px rgba(15, 23, 42, .15);
}

/* ========== Page card (wraps @Body inside the authenticated MainLayout) ========== */
.tmg-page-card {
    background: var(--tmg-page-card-bg);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius-lg);
    box-shadow: var(--tmg-shadow-card);
    padding: 24px 28px;
    /* 80% of the main content area, centred horizontally inside <main>. */
    width: 80%;
    margin: 24px auto;
    min-height: calc(100vh - 80px);
    /* Defensive: contain wide flex/grid descendants so they can't push the page-card
       (and the document body) past the viewport, producing a horizontal page scroll. */
    min-width: 0;
    max-width: calc(100% - 48px);
    overflow-x: hidden;
}

@media (max-width: 991px) {
    .tmg-page-card {
        width: auto;
        padding: 20px;
        margin: 16px 8px;
    }
}

/* ==================== BUTTON VARIANT GUIDE ====================
   Four variants in use across the app:

   1. .btn-primary           Primary CTA — saturated brand-accent
                             with white text. One per page, attached to
                             the dominant action: form submit, "Call now",
                             "Start campaign", "Save".
   2. .btn-outline-secondary Secondary action — outlined neutral. Used
                             for "Back", "Cancel", "Discard",
                             "Test connection", "Preview".
   3. .btn-outline-danger    Destructive — outlined red. Used for
                             "Delete", "Cancel campaign", "Hang up",
                             "Erase".
   4. .btn-link              Tertiary / link-as-button. Used for in-row
                             actions that aren't primary ("Edit",
                             "Re-queue", "Research").

   Status-state actions (Pause/Resume/Retry) keep their semantic
   Bootstrap colour (warning / success / outline-warning).
   ============================================================== */

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--tmg-text);
    background: var(--tmg-bg);
}

a, .btn-link {
    color: var(--tmg-brand);
}

a:hover, .btn-link:hover {
    color: var(--tmg-brand-hover);
}

.btn-primary {
    color: #fff;
    background-color: var(--tmg-brand);
    border-color: var(--tmg-brand);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--tmg-brand-hover);
    border-color: var(--tmg-brand-hover);
    color: #fff;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem rgba(15, 118, 110, 0.45);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ========== Page header ========== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--tmg-border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

.page-header h1,
.page-header .h1,
.page-header > div > .h3,
.page-header > div > .h2 {
    margin: 0;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--tmg-text);
}

.page-header .page-header-subtitle {
    color: var(--tmg-text-muted);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* ========== Card ========== */
.tmg-card {
    background: var(--tmg-surface);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius);
    box-shadow: var(--tmg-shadow-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.tmg-card > h2:first-child,
.tmg-card > .tmg-card-title:first-child {
    margin-top: 0;
}

/* ========== Table ========== */
.tmg-table {
    vertical-align: middle;
}

.tmg-table > thead > tr > th {
    background: #f8f9fa;
    border-bottom: 2px solid var(--tmg-border);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--tmg-text-muted);
    text-transform: none;
}

.tmg-table > tbody > tr > td {
    border-bottom: 1px solid var(--tmg-border);
}

.tmg-table .num,
.tmg-table th.num,
.tmg-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tmg-row-clickable {
    cursor: pointer;
}
.tmg-row-clickable:hover {
    background: rgba(15, 118, 110, 0.04);
}

/* ========== Empty state ========== */
.tmg-empty {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--tmg-surface);
    border: 1px dashed var(--tmg-border);
    border-radius: var(--tmg-radius);
    color: var(--tmg-text-muted);
}

.tmg-empty .tmg-empty-icon {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.tmg-empty .tmg-empty-title {
    font-weight: 600;
    color: var(--tmg-text);
    margin-bottom: 0.25rem;
}

/* ========== Metric ========== */
.tmg-metric {
    background: var(--tmg-surface);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius);
    padding: 0.75rem 1rem;
    height: 100%;
}

.tmg-metric-label {
    color: var(--tmg-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 0.25rem;
}

.tmg-metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--tmg-text);
}

.tmg-metric-detail {
    color: var(--tmg-text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ========== NavMenu section heading (visible in MainLayout sidebar) ========== */
.nav-section-heading {
    color: rgba(229, 231, 235, 0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 22px 4px;
    font-weight: 600;
}

/* ========== Modal ========== */
body.tmg-modal-open {
    overflow: hidden;
}

.tmg-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1050;
}

.tmg-modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2.5rem 1rem;
    overflow-y: auto;
}

.tmg-modal-dialog {
    position: relative;
    background: var(--tmg-surface);
    border-radius: var(--tmg-radius-lg);
    box-shadow: var(--tmg-shadow-modal);
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Brand-accent strip across the top of the modal. */
.tmg-modal-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--tmg-brand);
    border-top-left-radius: var(--tmg-radius-lg);
    border-top-right-radius: var(--tmg-radius-lg);
    z-index: 1;
}

.tmg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 18px 24px;
    border-bottom: 1px solid var(--tmg-border);
}

.tmg-modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--tmg-text);
}

.tmg-modal-position {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    background: #F1F5F9;
    color: var(--tmg-text-muted);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}

.tmg-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* Tint metric tiles inside the modal so they read as a subtle group, not as
   white-on-white. */
.tmg-modal-body .tmg-metric {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
}

.tmg-modal-footer {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 16px 24px;
    border-top: 1px solid var(--tmg-border);
    background: #F8FAFC;
    border-bottom-left-radius: var(--tmg-radius-lg);
    border-bottom-right-radius: var(--tmg-radius-lg);
}

/* ========== Public layout (anon-only pages: Home, About, auth) ========== */
.tmg-public-shell {
    min-height: 100vh;
    background: var(--tmg-bg);
    display: flex;
    flex-direction: column;
}

.tmg-public-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--tmg-border);
    background: var(--tmg-surface);
}

.tmg-public-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--tmg-text);
    font-weight: 600;
    text-decoration: none;
    font-size: 1.05rem;
}

.tmg-public-brand:hover {
    color: var(--tmg-brand);
}

.tmg-public-main {
    flex: 1;
    padding: 32px 24px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* ========== Auth card (centred 420px panel for Login/Register) ========== */
.tmg-auth-card {
    max-width: 420px;
    margin: 24px auto;
    background: var(--tmg-surface);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius-lg);
    box-shadow: var(--tmg-shadow-md);
    padding: 32px;
}

.tmg-auth-title {
    margin: 0 0 1.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--tmg-text);
}

.tmg-auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--tmg-text-muted);
    font-size: 0.8rem;
    margin: 1rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tmg-auth-divider::before,
.tmg-auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--tmg-border);
}

.tmg-auth-divider span {
    padding: 0 0.75rem;
}

.tmg-auth-links {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.875rem;
}

.tmg-auth-links a {
    color: var(--tmg-brand);
    text-decoration: none;
}

.tmg-auth-links a:hover {
    text-decoration: underline;
}

/* ========== Public Home hero ========== */
.tmg-hero {
    text-align: center;
    padding: 48px 16px 32px;
}

.tmg-hero-mark {
    margin-bottom: 12px;
}

.tmg-hero-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--tmg-text);
}

.tmg-hero-tagline {
    color: var(--tmg-text-muted);
    font-size: 1.05rem;
    margin: 0 0 24px;
}

.tmg-hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.tmg-feature-row {
    margin-top: 16px;
}

.tmg-feature-icon {
    font-size: 1.5rem;
    color: var(--tmg-brand);
    display: block;
    margin-bottom: 8px;
}

/* ========== About page brand strip ========== */
.tmg-about-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.tmg-about-brand h1 {
    font-size: 1.6rem;
    font-weight: 600;
}

/* ========== Status badges (unified palette) ==========
   Used by Components/Shared/StatusBadge.razor. Single font-weight,
   single size, padded 2px 8px, fully-rounded pill. */
.badge.tmg-status {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 9999px;
    line-height: 1.25;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge.tmg-status-pending { background: rgba(245, 158, 11, 0.15); color: #92400e; }
.badge.tmg-status-queued  { background: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.badge.tmg-status-calling { background: rgba(99, 102, 241, 0.15); color: #4338ca; }
.badge.tmg-status-done    { background: rgba(16, 185, 129, 0.15); color: #047857; }
.badge.tmg-status-failed  { background: rgba(239, 68, 68, 0.15);  color: #b91c1c; }
.badge.tmg-status-skipped { background: rgba(100, 116, 139, 0.15); color: #475569; }
.badge.tmg-status-noanswer { background: rgba(100, 116, 139, 0.15); color: #475569; }
.badge.tmg-status-optout  { background: rgba(249, 115, 22, 0.15); color: #c2410c; }
.badge.tmg-status-info    { background: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.badge.tmg-status-neutral { background: rgba(100, 116, 139, 0.15); color: #475569; }

/* Pulsing dot for in-flight Calling state. */
.badge.tmg-status-calling::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6366f1;
    animation: tmg-pulse 1.4s ease-in-out infinite;
}

@keyframes tmg-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* ==================== Wave 3 — per-page polish ==================== */

/* Constrains main-column text on detail pages so transcript / notes
   don't stretch across a wide monitor. */
.tmg-readable {
    max-width: 880px;
}

/* Smaller, all-caps section heading used inside long pages (Settings,
   Detail tabs) where the H2 size is too loud for what's really a
   navigation label. */
.tmg-section-heading {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--tmg-text-muted);
    margin: 24px 0 12px;
}

/* Validation message styling: red, small, with an icon prefix. */
.tmg-validation-error {
    color: var(--tmg-danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.tmg-validation-error::before {
    content: '\f33a'; /* bi-exclamation-circle */
    font-family: 'bootstrap-icons';
    margin-right: 4px;
}

/* Forms with a sticky right-side action rail. */
.tmg-form {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 32px;
}

.tmg-form-rail {
    position: sticky;
    top: 24px;
    align-self: start;
    padding: 16px;
    background: var(--tmg-surface);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius);
}

.tmg-form-rail .btn {
    width: 100%;
}

.tmg-form-rail .tmg-form-rail-hint {
    color: var(--tmg-text-muted);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

@media (max-width: 991px) {
    .tmg-form { grid-template-columns: 1fr; }
    .tmg-form-rail { position: static; }
}

/* Avatar with initials, brand-accent background. 32px round. */
.tmg-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    background: var(--tmg-brand);
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Recent-calls / training-sessions / dashboard list rows: avatar + line. */
.tmg-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tmg-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--tmg-border);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.tmg-list-item:hover {
    background: rgba(15, 118, 110, 0.04);
}

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

.tmg-list-item .tmg-list-main {
    flex: 1 1 auto;
    min-width: 0;
}

.tmg-list-item .tmg-list-title {
    color: var(--tmg-text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.tmg-list-item .tmg-list-trailing {
    color: var(--tmg-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Calls-per-day mini bar chart on the dashboard. */
.tmg-bar-row {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    justify-content: center;
    padding: 12px 8px 4px;
}

.tmg-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.tmg-bar {
    width: 24px;
    border-radius: 4px 4px 0 0;
    background: var(--tmg-brand);
    min-height: 2px;
    transition: height 0.2s;
}

.tmg-bar.tmg-bar-empty {
    background: #E5E7EB;
    height: 4px;
}

.tmg-bar-count {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--tmg-text);
}

.tmg-bar-label {
    font-size: 0.7rem;
    color: var(--tmg-text-muted);
}

/* Sticky toolbar above list pages (search + filters). */
.tmg-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--tmg-surface);
    border: 1px solid var(--tmg-border);
    border-radius: var(--tmg-radius);
    padding: 12px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tmg-toolbar .tmg-toolbar-spacer {
    flex: 1 1 auto;
}

/* Truncated long names with ellipsis. */
.tmg-truncate {
    display: inline-block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Transcript bubbles — tighter look with asymmetric border radius. */
.tmg-transcript {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tmg-bubble {
    padding: 8px 12px;
    max-width: 75%;
    line-height: 1.4;
    word-wrap: break-word;
}

.tmg-bubble-agent {
    align-self: flex-start;
    background: #F3F4F6;
    color: #111827;
    border-radius: 14px 14px 14px 4px;
}

.tmg-bubble-user {
    align-self: flex-end;
    background: var(--tmg-brand);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

.tmg-bubble-speaker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.tmg-bubble-agent .tmg-bubble-speaker {
    color: var(--tmg-text-muted);
}

.tmg-bubble-user .tmg-bubble-speaker {
    color: rgba(255, 255, 255, 0.75);
}

/* Keyboard hint chips inside modals. */
kbd.tmg-kbd,
.tmg-kbd {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: var(--tmg-text-muted);
    background: #F3F4F6;
    border: 1px solid var(--tmg-border);
    border-radius: 4px;
    line-height: 1.2;
    vertical-align: baseline;
}

/* Training scenario card: coloured stripe at the top. */
.tmg-scenario-card {
    position: relative;
    overflow: hidden;
}

.tmg-scenario-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.tmg-scenario-card.tmg-difficulty-easy::before   { background: var(--tmg-success); }
.tmg-scenario-card.tmg-difficulty-medium::before { background: var(--tmg-warning); }
.tmg-scenario-card.tmg-difficulty-hard::before   { background: var(--tmg-danger);  }

/* ========== Settings tabbed layout ========== */
.tmg-settings-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tmg-settings-header {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.tmg-settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 16px 0 24px;
    border-bottom: 1px solid var(--tmg-border);
    overflow-x: auto;
}

.tmg-settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--tmg-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.tmg-settings-tab:hover {
    color: var(--tmg-text);
    border-bottom-color: var(--tmg-border);
}

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

.tmg-settings-tab i {
    font-size: 0.95rem;
    opacity: 0.85;
}

.tmg-settings-tab-ext {
    font-size: 0.75rem;
    opacity: 0.6;
}

.tmg-settings-tab-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.tmg-settings-tab-head h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--tmg-text);
}

.tmg-settings-tab-sub {
    margin: 0;
    color: var(--tmg-text-muted);
    font-size: 0.9rem;
    max-width: 720px;
}

.tmg-settings-tab-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tmg-settings-body {
    min-height: 200px;
}

/* ========== Polish wave 6 ==========
   Tightened typography, consistent form field height, muted nav-tabs,
   role-pill neutral palette, public header refinements. */

/* Form fields uniformly 40px so buttons next to inputs line up. */
.form-control, .form-select {
    min-height: 40px;
}
.form-control-sm, .form-select-sm {
    min-height: 32px;
}

/* In auth-card form-floating fields, hide the placeholder until focused so the
   label can sit at the input's left edge without colliding with the placeholder.
   The default Bootstrap floating-label depends on a placeholder being present
   (any value), but the visible placeholder isn't useful here. */
.tmg-auth-card .form-floating > .form-control:not(:focus):placeholder-shown::placeholder {
    color: transparent;
}
.tmg-auth-card .form-floating > .form-control:focus::placeholder {
    color: var(--bs-secondary-color);
    text-align: start;
}

/* Inactive nav-tab links should be muted, not bright Bootstrap blue. */
.nav-tabs .nav-link {
    color: var(--tmg-text-muted);
    font-weight: 500;
}
.nav-tabs .nav-link:hover {
    color: var(--tmg-text);
    border-color: transparent;
}
.nav-tabs .nav-link.active {
    color: var(--tmg-text);
    font-weight: 600;
    border-bottom-color: var(--tmg-surface);
}

/* `(not set)` placeholder styled as muted italic, not pink monospace. */
.tmg-not-set {
    color: var(--tmg-text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

/* Phone-number rendering: muted mono, no pink. Used to replace inline <code> for E.164. */
.tmg-phone {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--tmg-text);
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

/* Override Bootstrap inline-code reddening when the code element is just decorative for env-var
   references inside settings copy. Keep it monospace but neutral colour. */
.tmg-settings-tab-sub code,
.tmg-settings-body p code {
    color: var(--tmg-text);
    background: var(--tmg-bg);
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* List rows (recent calls / sessions) — taller, more breathing room, larger avatars. */
.tmg-list-item {
    padding: 12px 12px;
    min-height: 56px;
}

.tmg-list-item .tmg-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    font-size: 0.8rem;
}

/* Numeric table column helper — already defined in .tmg-table; reinforce as a
   standalone utility so non-tmg-tables benefit. */
.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Public header — give the wordmark + right-side links a real layout. */
.tmg-public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.tmg-public-header-nav {
    display: flex;
    gap: 18px;
    align-items: center;
}
.tmg-public-header-nav a {
    color: var(--tmg-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.tmg-public-header-nav a:hover {
    color: var(--tmg-brand);
}
.tmg-public-header-nav .btn {
    padding: 6px 14px;
}

/* Buttons inside in-row table actions should be uniform btn-sm height. */
.tmg-table td .btn,
.tmg-table tbody .btn {
    padding-top: 4px;
    padding-bottom: 4px;
    font-size: 0.8125rem;
    line-height: 1.4;
}

/* Inline bar chart in admin views — pure CSS, no JS library. */
.tmg-inline-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tmg-inline-bar {
    position: relative;
    height: 18px;
    background: #F3F4F6;
    border-radius: 3px;
    overflow: hidden;
}

.tmg-inline-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tmg-brand) 0%, var(--tmg-brand-hover) 100%);
}

.tmg-inline-bar-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.75rem;
    color: var(--tmg-text);
}

/* ---- Calling modal: notes split + objection-handling tab ---- */
.tmg-modal-tabs {
    margin-bottom: 16px;
}

.tmg-modal-tabs .nav-link {
    color: var(--tmg-text);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 12px;
    font-weight: 500;
}

.tmg-modal-tabs .nav-link.active {
    color: var(--tmg-brand);
    border-bottom-color: var(--tmg-brand);
    background: transparent;
}

.tmg-notes-history {
    background: #F8FAFC;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 10px 12px;
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
}

.tmg-objection-highlight {
    border-left: 4px solid var(--tmg-brand) !important;
    animation: tmg-objection-pulse 1.4s ease-out 0s 2;
}

@keyframes tmg-objection-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45); }
    70%  { box-shadow: 0 0 0 10px rgba(15, 118, 110, 0); }
    100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0); }
}

/* ---------- Available balance pill (Phase 4 billing) ---------------- */
.tmg-balance-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    line-height: 1.4;
    border: 1px solid transparent;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
}

.tmg-balance-ok {
    background: rgba(20, 83, 45, 0.85);
    color: #d1fae5;
    border-color: rgba(34, 197, 94, 0.4);
}

.tmg-balance-low {
    background: rgba(120, 53, 15, 0.85);
    color: #fef3c7;
    border-color: rgba(245, 158, 11, 0.45);
}

.tmg-balance-empty {
    background: rgba(127, 29, 29, 0.85);
    color: #fee2e2;
    border-color: rgba(248, 113, 113, 0.5);
}
