/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --black: #000000;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --gray-950: #0a0a0a;

    --bg: var(--gray-50);
    --bg-card: var(--white);
    --bg-input: var(--white);
    --border: var(--gray-200);
    --border-focus: var(--black);
    --text: var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-muted: var(--gray-400);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --transition: 0.15s ease;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== ICONS (Lucide inline SVG utility) ===== */
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    background: var(--white);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { border-color: var(--gray-400); background: var(--gray-50); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
}
.btn-primary:hover { background: var(--gray-800); border-color: var(--gray-800); }

.btn-danger {
    background: var(--white);
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fef2f2; border-color: #dc2626; }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { border-color: var(--black); color: var(--black); background: var(--gray-50); }

/* ===== INPUTS ===== */
.input, .textarea, .select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23737373' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.card-header .badge { margin-left: auto; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.badge-default { background: var(--gray-100); color: var(--gray-600); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-active { background: var(--gray-900); color: var(--white); }

/* ===== LAYOUT ===== */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--black);
    color: var(--white);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.topbar-brand span { font-weight: 400; color: var(--gray-400); margin-left: 6px; font-size: 13px; }
.topbar-spacer { flex: 1; }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--gray-300);
}
.topbar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
}
.topbar .btn-ghost { color: var(--gray-400); border: none; }
.topbar .btn-ghost:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.topbar-nav { display: flex; align-items: center; gap: 2px; }
.topbar-nav a {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.topbar-nav a:hover { color: var(--white); background: rgba(255,255,255,0.08); }
.topbar-nav a.active { color: var(--white); background: rgba(255,255,255,0.12); }

.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.page-header .spacer { flex: 1; }

/* ===== TABLE ===== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.td-name { font-weight: 600; }
.td-muted { color: var(--text-secondary); font-size: 13px; }
.td-actions { display: flex; gap: 4px; }

/* ===== STATS ROW ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.15s ease;
}
.modal-overlay.hidden { display: none !important; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0,0,0,0.12);
    animation: modal-in 0.2s ease;
}
.modal-lg { max-width: 720px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body { padding: 24px; overflow-y: auto; }
.modal-body iframe { width: 100%; height: 100%; min-height: 60vh; border: none; background: #fff; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    background: var(--black);
    color: var(--white);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
    max-width: 380px;
}
.toast.error { background: #dc2626; }
.toast.success { background: var(--black); }
.toast.removing { animation: toast-out 0.25s ease forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-mark {
    width: 48px;
    height: 48px;
    background: var(--black);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.login-logo h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .btn { width: 100%; justify-content: center; }
.login-error {
    font-size: 13px;
    color: #dc2626;
    text-align: center;
    min-height: 20px;
}

/* ===== RECORDING ===== */
.recording-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.recording-panel .timer {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    min-width: 72px;
}
.recording-panel .timer.active { color: #dc2626; }

.visualizer-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
    flex: 1;
    min-width: 100px;
}
.visualizer-bar .bar {
    width: 3px;
    background: var(--black);
    border-radius: 2px;
    transition: height 0.08s ease;
    opacity: 0.6;
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: #dc2626;
    border-radius: 50%;
    animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== CONTENT AREAS ===== */
.content-box {
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    min-height: 120px;
    max-height: 450px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}
.content-box::-webkit-scrollbar { width: 5px; }
.content-box::-webkit-scrollbar-track { background: transparent; }
.content-box::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.content-box .placeholder { color: var(--text-muted); font-style: italic; }

/* ===== SUMMARY CTA ===== */
.summary-view-cta {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.cta-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}
.cta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 6px;
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.cta-letter {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--black);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    flex-shrink: 0;
}

/* ===== SOAP SCROLLABLE MODAL ===== */
.soap-modal {
    max-width: 680px;
    max-height: 85vh;
}
.soap-scroll-body {
    padding: 0 !important;
    overflow-y: auto;
    scroll-behavior: smooth;
}
.soap-scroll-body::-webkit-scrollbar { width: 5px; }
.soap-scroll-body::-webkit-scrollbar-track { background: transparent; }
.soap-scroll-body::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.soap-section {
    border-bottom: 1px solid var(--gray-100);
}
.soap-section:last-child {
    border-bottom: none;
}

.soap-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 28px 0;
}

.soap-section-letter {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--black);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
}

.soap-section-header h3 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

.soap-section-body {
    padding: 12px 28px 20px 70px;
}

.soap-section-body p {
    font-size: 14px;
    line-height: 1.85;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}
.soap-section-body p strong {
    color: var(--text);
    font-weight: 700;
}
.soap-section-body p:last-child { margin-bottom: 0; }
.soap-section-body .soap-empty {
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .soap-section-body { padding: 10px 20px 18px 20px; }
    .soap-section-header { padding: 16px 20px 0; }
}

/* ===== PHYSICAL EXAM CHECKLIST ===== */
.exam-checklist {
    margin: 16px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
}
.exam-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
}
.exam-header-icon {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}
.exam-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--gray-50);
    transition: background 0.15s ease;
}
.exam-row:last-child { border-bottom: none; }
.exam-row:hover { background: var(--gray-50); }

.exam-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.exam-noted .exam-indicator {
    background: #dcfce7;
    color: #15803d;
}
.exam-noted .exam-indicator svg { width: 11px; height: 11px; }
.exam-not-noted .exam-indicator {
    background: var(--gray-100);
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 800;
}

.exam-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.exam-system {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.exam-not-noted .exam-system {
    color: var(--text-muted);
}
.exam-finding {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.exam-finding.exam-na {
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
}

/* Exam inside modal — adjust spacing */
.soap-exam-body {
    padding: 8px 28px 16px 28px !important;
}
.soap-exam-body .exam-checklist {
    margin: 0;
}
.soap-exam-body .exam-header {
    display: none;
}

/* ===== AI CONSULTANT CHAT ===== */
.consultant-layout {
    display: flex;
    border-top: 1px solid var(--border);
    min-height: 360px;
}
.consultant-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
}
.consultant-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 8px;
    border-bottom: 1px solid var(--border);
}
.consultant-sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.consultant-new-btn {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.4;
}
.consultant-thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.consultant-thread-empty {
    margin: 12px 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.consultant-thread-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 6px;
    align-items: center;
    width: 100%;
    padding: 8px 8px 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s;
}
.consultant-thread-item:hover {
    background: var(--white);
    border-color: var(--border);
}
.consultant-thread-item.is-active {
    background: var(--white);
    border-color: var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.consultant-thread-title {
    grid-column: 1;
    grid-row: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.consultant-thread-meta {
    grid-column: 1;
    grid-row: 2;
    font-size: 10px;
    color: var(--text-muted);
}
.consultant-thread-delete {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.consultant-thread-item:hover .consultant-thread-delete,
.consultant-thread-item.is-active .consultant-thread-delete {
    opacity: 1;
}
.consultant-thread-delete:hover {
    background: var(--gray-100);
    color: var(--text);
}
.consultant-welcome.hidden {
    display: none;
}
.consultant-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
@media (max-width: 720px) {
    .consultant-layout {
        flex-direction: column;
        min-height: 0;
    }
    .consultant-sidebar {
        width: 100%;
        max-height: 140px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .consultant-thread-list {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
    }
    .consultant-thread-item {
        min-width: 140px;
        flex-shrink: 0;
    }
}
.consultant-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    max-height: 340px;
    min-height: 120px;
    overflow-y: auto;
    scroll-behavior: smooth;
}
.consultant-msg {
    display: flex;
    max-width: 85%;
}
.consultant-msg.assistant {
    align-self: flex-start;
}
.consultant-msg.user {
    align-self: flex-end;
}
.msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.consultant-msg.assistant .msg-bubble {
    background: var(--gray-50);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.consultant-msg.user .msg-bubble {
    background: var(--black);
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.msg-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-style: italic;
}
.msg-error {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca;
}
.consultant-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
}
.consultant-input-bar .btn-icon {
    flex-shrink: 0;
}
.consultant-input-bar .input {
    flex: 1;
    font-size: 13px;
}
.consultant-input-bar .btn {
    flex-shrink: 0;
    padding: 8px 12px;
}

.consultant-chat--enhanced .consultant-messages {
    min-height: 300px;
    max-height: min(56vh, 480px);
    background: linear-gradient(180deg, var(--gray-50) 0%, #fff 100%);
}
.consultant-chat--enhanced .consultant-msg.assistant .msg-bubble {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    white-space: normal;
}
.consultant-msg--streaming .msg-bubble { min-height: 2.5em; }
.consultant-chat--enhanced .consultant-msg.user .msg-bubble {
    background: var(--black);
    color: var(--white);
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.consultant-chat--enhanced .consultant-msg.user .consultant-user-text,
.consultant-chat--enhanced .consultant-msg.user .consultant-user-doc {
    color: var(--white);
}
.consultant-user-text { margin: 0 0 6px; color: inherit; }
.consultant-user-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.consultant-user-images img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid rgba(255,255,255,0.35); }
.consultant-user-docs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.consultant-user-doc { font-size: 11px; padding: 4px 8px; border-radius: 6px; background: rgba(255,255,255,0.18); color: var(--white); }
.consultant-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 0; border-top: 1px solid var(--border); background: var(--gray-50); }
.consultant-attach-item { position: relative; display: flex; flex-direction: column; gap: 4px; width: 72px; }
.consultant-attach-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.consultant-attach-item--doc { width: auto; min-width: 120px; max-width: 160px; flex-direction: row; align-items: center; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.consultant-attach-doc-ico { font-size: 10px; font-weight: 700; color: var(--text-muted); padding: 4px 6px; border-radius: 4px; background: var(--gray-100); }
.consultant-attach-name { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.consultant-attach-remove { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.consultant-composer {
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    padding: 12px 14px 14px;
    width: 100%;
    box-sizing: border-box;
}
.consultant-composer-row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}
.consultant-composer-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.consultant-composer-tools .btn-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    flex-shrink: 0;
}
.consultant-textarea {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    max-height: 128px;
    margin: 0;
    resize: none !important;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    box-sizing: border-box;
    display: block;
}
.consultant-textarea:focus {
    outline: none;
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}
.consultant-composer-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.consultant-composer .btn.consultant-send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.consultant-composer .btn.consultant-stop-btn {
    height: 42px;
    padding: 0 14px;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    flex-shrink: 0;
}
.consultant-composer-hint {
    display: block;
    width: 100%;
    margin: 10px 0 0;
    padding: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
    text-align: center;
}
.consultant-typing { display: inline-flex; align-items: center; gap: 4px; height: 18px; }
.consultant-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-400); animation: consultant-typing-bounce 1.1s ease-in-out infinite; }
.consultant-typing span:nth-child(2) { animation-delay: 0.15s; }
.consultant-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes consultant-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-4px); opacity: 1; }
}
@media (max-width: 768px) {
    .consultant-chat--enhanced .consultant-messages { max-height: min(50vh, 360px); }
    .consultant-user-images img { width: 72px; height: 72px; }
    .consultant-composer-row { flex-wrap: wrap; }
    .consultant-textarea { flex: 1 1 100%; min-width: 100%; order: 1; }
    .consultant-composer-actions { order: 2; }
    .consultant-composer-tools { order: 3; width: 100%; justify-content: flex-start; }
    .consultant-composer-hint { font-size: 10px; order: 4; }
}

/* Markdown inside bubbles */
.msg-bubble ul {
    margin: 6px 0 2px 0;
    padding-left: 18px;
    list-style: disc;
}
.msg-bubble li {
    margin: 2px 0;
    line-height: 1.5;
}
.msg-bubble strong {
    font-weight: 700;
}
.msg-bubble em {
    font-style: italic;
}

/* ===== TWO COLUMN ===== */
.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===== GRID FORM ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

/* ===== SEARCH BAR ===== */
.search-bar {
    position: relative;
    max-width: 320px;
}
.search-bar .input {
    padding-left: 38px;
}
.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===== CHECKBOX ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--black);
    width: 16px;
    height: 16px;
}

/* ===== EMAIL FORM ===== */
.email-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.email-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.checkbox-group {
    display: flex;
    gap: 20px;
}

/* ===== SESSION PAGE LAYOUT ===== */
.session-header-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.session-pet-info h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.session-pet-info p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.session-pet-info .spacer { flex: 1; }

/* ===== LOADING ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--black);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    height: 14px;
    margin: 6px 0;
}
.skeleton.w-full { width: 100%; }
.skeleton.w-75 { width: 75%; }
.skeleton.w-50 { width: 50%; }
.skeleton.w-33 { width: 33%; }
.skeleton.h-lg { height: 20px; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-state {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px 0;
    justify-content: center;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ===== PRINT ===== */
@page { margin: 14mm; }

@media print {
    body { background: #fff; }
    .topbar, .btn, .toast-container, .modal-overlay { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .content-box { max-height: none; overflow: visible; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .columns { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .main-content { padding: 20px 16px; }
    .page-header h1 { font-size: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar-brand span { display: none; }
    .recording-panel { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .form-grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .email-actions { flex-wrap: wrap; }
}

/* ===== INLINE EDIT ===== */
.edit-container {
    border: 2px solid var(--black);
    border-radius: var(--radius);
    overflow: hidden;
    animation: edit-in 0.2s ease;
}
.edit-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--gray-900);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.edit-banner svg { width: 14px; height: 14px; opacity: 0.7; }
.edit-banner .edit-hint {
    margin-left: auto;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--gray-400);
    font-size: 12px;
}
.edit-textarea {
    width: 100%;
    min-height: 320px;
    padding: 18px 20px;
    border: none;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    background: var(--white);
    resize: vertical;
    outline: none;
    display: block;
}
.edit-textarea::placeholder { color: var(--text-muted); }
.edit-footer {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    gap: 10px;
}
.edit-footer .edit-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.edit-footer .edit-meta span { color: var(--text-secondary); font-weight: 600; }
.edit-footer .spacer { flex: 1; }
@keyframes edit-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hide the old actions bar — merged into footer */
.edit-actions { display: none !important; }

/* ===== META TAGS ===== */
.session-meta-tags {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--gray-100);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 100px;
    font-family: monospace;
    letter-spacing: 0.02em;
}
.meta-tag strong {
    color: var(--text);
    font-weight: 700;
}

/* ===== BTN LINK ===== */
.btn-link {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    text-decoration: none;
    transition: color var(--transition);
}
.btn-link:hover { color: var(--gray-600); }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
