/* ---- Design Tokens ---- */

:root {
    /* Light theme — matching landing page palette */
    --color-primary: #1a73e8;
    --color-primary-hover: #1557b0;
    --color-primary-light: rgba(26, 115, 232, 0.1);
    --color-primary-glow: rgba(26, 115, 232, 0.15);
    --color-secondary: #5F6368;
    --color-success: #0d9488;
    --color-success-light: rgba(13, 148, 136, 0.1);
    --color-danger: #dc2626;
    --color-danger-light: rgba(220, 38, 38, 0.08);
    --color-warning: #d97706;
    --color-warning-light: rgba(217, 119, 6, 0.08);
    --color-text: #121317;
    --color-text-muted: #5F6368;
    --color-text-light: #6A6A71;
    --color-bg: #ffffff;
    --color-bg-secondary: #F8F9FC;
    --color-bg-elevated: #ffffff;
    --color-bg-hover: rgba(183, 191, 217, 0.12);
    --color-border: rgba(183, 191, 217, 0.25);
    --color-border-light: rgba(183, 191, 217, 0.15);
    --color-border-active: rgba(26, 115, 232, 0.4);
    --color-surface: #F8F9FC;
    --radius-card: 12px;
    --radius-btn: 8px;
    --radius-input: 8px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(26, 115, 232, 0.1);
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --transition: 0.2s ease;
    --header-height: 60px;
    --sidebar-width: 280px;
}

/* ---- Reset ---- */

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

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--color-primary-glow);
    color: var(--color-text);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.22);
}

/* ---- Header ---- */

header {
    background: #ffffff;
    color: var(--color-text);
    height: var(--header-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--color-border);
    z-index: 10;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-btn);
    transition: background var(--transition), color var(--transition);
}

.sidebar-toggle:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
    display: flex;
    align-items: center;
}

.subtitle {
    display: none;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-doctor-name {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
}

/* ---- Medical Cross Icon ---- */

.med-cross {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
    margin-right: 0.5rem;
    vertical-align: middle;
    flex-shrink: 0;
}

.med-cross::before,
.med-cross::after {
    content: "";
    position: absolute;
    background: var(--color-primary);
    border-radius: 2px;
}

.med-cross::before {
    width: 6px;
    height: 18px;
    top: 1px;
    left: 7px;
}

.med-cross::after {
    width: 18px;
    height: 6px;
    top: 7px;
    left: 1px;
}

/* ---- App Layout ---- */

.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right-color: transparent;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-block {
    width: 100%;
    text-align: center;
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.85rem;
    outline: none;
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder {
    color: var(--color-text-light);
}

.search-input:focus {
    border-color: var(--color-border-active);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.session-card {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-btn);
    cursor: pointer;
    margin-bottom: 2px;
    transition: background var(--transition);
}

.session-card:hover {
    background: var(--color-bg-hover);
}

.session-card.active {
    background: var(--color-primary-light);
    border-left: 3px solid var(--color-primary);
}

.session-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.session-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-text);
}

.session-card-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-dict-btn {
    font-size: 0.82rem;
}

/* ---- Sidebar Overlay (mobile) ---- */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    z-index: 15;
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Badges ---- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-green {
    background: var(--color-success-light);
    color: var(--color-success);
}

.badge-blue {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-red {
    background: var(--color-danger-light);
    color: var(--color-danger);
    animation: badge-pulse 1.5s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ---- Main Content ---- */

main {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--color-bg);
}

/* ---- Cards ---- */

.card {
    background: var(--color-bg-elevated);
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

/* ---- Controls ---- */

.controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.55rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

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

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(26, 115, 232, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #EF4444;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: rgba(183, 191, 217, 0.4);
    color: var(--color-text);
}

.btn-danger-outline {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-danger-outline:hover:not(:disabled) {
    background: var(--color-danger-light);
}

/* ---- Form Elements ---- */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.text-input {
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    outline: none;
    max-width: 350px;
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.text-input::placeholder {
    color: var(--color-text-light);
}

.text-input:focus {
    border-color: var(--color-border-active);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

select.text-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235F6368' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select.text-input option {
    background: #ffffff;
    color: var(--color-text);
}

/* ---- Patient & Meta ---- */

.patient-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
}

.language-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 12px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    margin-left: 8px;
    letter-spacing: 0.02em;
}

.meta-text {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* ---- Status Indicator ---- */

.status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-recording .status-dot {
    background: var(--color-danger);
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.6);
    animation: pulse 1.2s ease-in-out infinite;
}

.status-recording {
    color: var(--color-danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Recording Interface ---- */

.recording-interface {
    text-align: center;
    padding: 2.5rem 1rem;
}

.mic-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--color-danger-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    animation: mic-pulse 1.5s ease-in-out infinite;
    border: 2px solid rgba(248, 113, 113, 0.2);
}

.mic-icon svg {
    width: 36px;
    height: 36px;
    stroke: var(--color-danger);
    fill: none;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.25); }
    50% { box-shadow: 0 0 0 20px rgba(248, 113, 113, 0); }
}

.recording-patient-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.recording-timer {
    font-size: 2.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    margin: 0.25rem 0 0.75rem;
    letter-spacing: 0.02em;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: var(--color-bg);
    border-radius: 20px;
    border: 1px solid var(--color-border);
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.connection-dot.green, .connection-dot.connected {
    background: var(--color-success);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}
.connection-dot.yellow { background: var(--color-warning); box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }
.connection-dot.red { background: var(--color-danger); box-shadow: 0 0 6px rgba(248, 113, 113, 0.5); }

/* ---- Welcome Screen ---- */

.welcome-screen {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--color-text-muted);
}

.welcome-tabs {
    display: flex;
    gap: 4px;
    background: var(--color-surface);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 1.5rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.welcome-tab:hover {
    color: var(--color-text);
    background: rgba(26, 115, 232, 0.06);
}

.welcome-tab.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.2);
}

.welcome-tab svg {
    flex-shrink: 0;
}

.welcome-tab-content {
    display: none;
}

.welcome-tab-content.active {
    display: block;
}

.transcribe-hero {
    padding: 3rem 1rem;
}

.welcome-icon {
    margin-bottom: 1.5rem;
}

.welcome-icon svg {
    width: 56px;
    height: 56px;
    stroke: var(--color-text-light);
}

.welcome-screen h2 {
    color: var(--color-text);
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    text-transform: none;
    letter-spacing: -0.01em;
    font-weight: 600;
}

.welcome-screen p {
    margin-bottom: 2rem;
    color: var(--color-text-muted);
}

#welcome-analytics-content {
    text-align: left;
}

#welcome-analytics-content .analytics-grid {
    margin-bottom: 1rem;
}

#welcome-analytics-content .card {
    margin-bottom: 1rem;
}

#welcome-analytics-content .analytics-two-col {
    margin-bottom: 1rem;
}

/* Patient Directory */
#welcome-patients-content {
    text-align: left;
}

.patient-directory-search {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color var(--transition);
}

.patient-directory-search:focus {
    border-color: var(--color-primary);
}

.patient-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.patient-card:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-hover);
}

.patient-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.patient-info {
    flex: 1;
    min-width: 0;
}

.patient-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.95rem;
}

.patient-meta {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.patient-diagnoses {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.patient-diagnoses .pill {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.patient-visits-badge {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: right;
    flex-shrink: 0;
}

.patient-visits-badge strong {
    display: block;
    font-size: 1.2rem;
    color: var(--color-text);
}

/* ---- Transcript Area ---- */

.transcript-area {
    max-height: 500px;
    min-height: 150px;
    overflow-y: auto;
    padding: 0.5rem 0;
    line-height: 1.7;
}

.placeholder {
    color: var(--color-text-light);
    font-style: italic;
    font-size: 0.9rem;
    padding: 2rem 0;
    text-align: center;
}

.utterance {
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.utterance.interim .utterance-text {
    color: var(--color-text);
}

.utterance.interim .utterance-text.live {
    color: var(--color-text-light);
}

.speaker-label {
    font-weight: 600;
    font-size: 0.78rem;
}

.utterance-text {
    color: var(--color-text);
}

.utterance-row {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* ---- Detail Layout ---- */

.detail-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1rem;
}

/* ---- Loading Spinner ---- */

.loading-container {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ---- Clinical Note ---- */

#detail-clinical-note {
    line-height: 1.7;
    font-size: 0.88rem;
}

#detail-clinical-note h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-top: 1.1rem;
    margin-bottom: 0.3rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--color-border);
}

#detail-clinical-note h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: 0.65rem;
    margin-bottom: 0.2rem;
}

#detail-clinical-note p {
    margin: 0.15rem 0;
    color: var(--color-text);
}

#detail-clinical-note li {
    margin: 0.1rem 0 0.1rem 1.2rem;
    color: var(--color-text);
}

#detail-clinical-note hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0.75rem 0;
}

#detail-clinical-note br {
    display: block;
    content: "";
    margin-top: 0.15rem;
}

.error {
    color: var(--color-danger);
    font-weight: 500;
}

/* ---- Card Header Row ---- */

.card-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header-row h2 {
    margin-bottom: 0;
    margin-right: auto;
}

/* ---- Clinical Note Editor ---- */

.clinical-note-editor {
    width: 100%;
    min-height: 350px;
    padding: 1rem;
    border: 1px solid var(--color-border-active);
    border-radius: var(--radius-btn);
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    background: var(--color-bg);
    color: var(--color-text);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    margin-top: 0.75rem;
}

.clinical-note-editor:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* ---- SOAP Collapsible Sections ---- */

.soap-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.soap-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--color-primary);
    background: var(--color-bg-secondary);
    transition: background var(--transition);
    user-select: none;
}

.soap-section-header:hover {
    background: var(--color-bg-hover);
}

.soap-section-header .chevron {
    font-size: 0.7rem;
    transition: transform var(--transition);
    color: var(--color-text-light);
}

.soap-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.soap-section-body {
    padding: 0.75rem 1rem;
    background: var(--color-bg-elevated);
}

.soap-section.collapsed .soap-section-body {
    display: none;
}

/* ---- Structured Data ---- */

.data-group {
    margin-bottom: 0.85rem;
}

.data-group h4 {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

.data-group p {
    font-size: 0.85rem;
    color: var(--color-text);
}

/* ---- Pills / Tags ---- */

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
}

.pill-default {
    background: var(--color-bg-hover);
    color: var(--color-text-muted);
}

.pill-blue {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: 1px solid rgba(26, 115, 232, 0.15);
}

.pill-red {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.pill-orange {
    background: var(--color-warning-light);
    color: var(--color-warning);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.pill-green {
    background: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

/* ---- Editable Utterances ---- */

.utterance.editable {
    cursor: pointer;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    transition: background var(--transition);
}

.utterance.editable:hover {
    background: var(--color-bg-hover);
}

.utterance.corrected {
    background: var(--color-warning-light);
    border-left: 3px solid var(--color-warning);
    padding-left: 0.55rem;
}

.utterance.editing {
    background: var(--color-bg-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
}

.edit-container {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
}

.edit-original {
    font-size: 0.78rem;
    color: var(--color-text-light);
    font-style: italic;
}

.edit-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 2.2rem;
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.edit-input:focus {
    border-color: var(--color-border-active);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.edit-hint {
    font-size: 0.72rem;
    color: var(--color-text-light);
}

.edited-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-warning);
    background: var(--color-warning-light);
    padding: 0.05rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.undo-btn {
    background: none;
    border: none;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-left: 0.3rem;
    vertical-align: middle;
    transition: all var(--transition);
}

.undo-btn:hover {
    color: var(--color-danger);
    background: var(--color-danger-light);
}

/* ---- Stats ---- */

.stats-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-btn);
    border: 1px solid var(--color-border);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-good { color: var(--color-success); }
.stat-ok { color: var(--color-warning); }
.stat-low { color: var(--color-danger); }

/* ---- Auto-Corrected Utterances ---- */

.utterance.auto-corrected {
    background: var(--color-warning-light);
    border-left: 3px solid var(--color-warning);
    padding-left: 0.55rem;
    position: relative;
}

.auto-correct-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0.4rem;
    background: var(--color-bg-elevated);
    color: var(--color-text);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.72rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-elevated);
}

.auto-correct-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 1rem;
    border: 5px solid transparent;
    border-top-color: var(--color-bg-elevated);
}

.utterance.auto-corrected:hover .auto-correct-tooltip {
    display: block;
}

.auto-corrected-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-warning);
    background: var(--color-warning-light);
    padding: 0.05rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.auto-correct-actions {
    display: inline-flex;
    gap: 0.25rem;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.auto-correct-actions button {
    background: none;
    border: 1px solid var(--color-border);
    font-size: 0.65rem;
    cursor: pointer;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    color: var(--color-text-muted);
    transition: all var(--transition);
}

.auto-correct-actions button:hover {
    background: var(--color-bg-hover);
}

.auto-correct-actions .accept-btn:hover {
    background: var(--color-success-light);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--color-success);
}

.auto-correct-actions .undo-auto-btn:hover {
    background: var(--color-danger-light);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--color-danger);
}

/* ---- Auto-Correct Banner ---- */

.auto-correct-banner {
    background: var(--color-warning-light);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-btn);
    padding: 0.6rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-warning);
}

.banner-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--color-warning);
    cursor: pointer;
    padding: 0 0.3rem;
    transition: color var(--transition);
}

.banner-close:hover {
    color: #F59E0B;
}

/* ---- Dictionary View ---- */

.dict-add-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.dict-add-form .text-input {
    max-width: 200px;
    flex: 1;
    min-width: 140px;
}

.dict-add-form select.text-input {
    max-width: 150px;
}

.dict-entries table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.dict-entries th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 0.6rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
}

.dict-entries td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.dict-entries tr:hover td {
    background: var(--color-bg-hover);
}

.dict-delete-btn {
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    transition: all var(--transition);
}

.dict-delete-btn:hover {
    color: var(--color-danger);
    background: var(--color-danger-light);
}

.category-pill {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.cat-medication { background: var(--color-primary-light); color: var(--color-primary); }
.cat-diagnosis { background: rgba(124, 58, 237, 0.08); color: #7c3aed; }
.cat-procedure { background: var(--color-success-light); color: var(--color-success); }
.cat-anatomy { background: var(--color-warning-light); color: var(--color-warning); }
.cat-name { background: var(--color-danger-light); color: var(--color-danger); }
.cat-other { background: var(--color-bg-hover); color: var(--color-text-muted); }

/* ---- Auth View ---- */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1rem;
    min-height: calc(100vh - var(--header-height));
}

.auth-card {
    background: var(--color-bg-elevated);
    border-radius: 16px;
    padding: 2.25rem 2.5rem;
    box-shadow: var(--shadow-elevated);
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: none;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

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

.auth-card .form-group {
    margin-bottom: 0.9rem;
}

.auth-card .text-input {
    max-width: 100%;
    width: 100%;
}

.auth-card .btn-block {
    margin-top: 0.75rem;
}

.auth-error {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: var(--radius-btn);
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.google-signin-wrapper {
    display: flex;
    justify-content: center;
    min-height: 44px;
    margin-bottom: 4px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 14px 0;
    color: var(--color-text-light);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--color-border);
}

.auth-divider span {
    padding: 0 12px;
}

.auth-switch {
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 1.25rem;
}

.auth-switch a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

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

/* ---- Toast Notifications ---- */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow-elevated);
    font-size: 0.875rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 380px;
    backdrop-filter: blur(8px);
}

.toast.visible {
    transform: translateX(0);
}

.toast-success { border-left: 3px solid var(--color-success); }
.toast-info { border-left: 3px solid var(--color-primary); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-error { border-left: 3px solid var(--color-danger); }

/* ---- Print Styles ---- */

@media print {
    header, .sidebar, .sidebar-overlay, .sidebar-toggle, .auto-correct-banner,
    #detail-stats, .toast-container, .controls-row .btn, #generate-btn,
    #copy-btn, #print-btn, #delete-btn, .auto-correct-actions, .undo-btn,
    .edited-badge, .auto-corrected-badge { display: none !important; }

    body { background: white; color: #1e293b; }
    .app-layout { display: block; }
    main { padding: 0; overflow: visible; }
    .detail-layout { display: block; }
    .card { box-shadow: none; border: none; padding: 0; margin-bottom: 1rem; background: white; }
    #detail-clinical-note { font-size: 12pt; line-height: 1.6; color: #1e293b; }
    .soap-section { border: none; }
    .soap-section-header { background: none; padding: 0.5rem 0; cursor: default; color: #1a56db; }
    .soap-section-body { background: white; }
    .soap-section.collapsed .soap-section-body { display: block; }
    .soap-section-header .chevron { display: none; }

    body::before {
        content: "MedSync Clinical Note";
        display: block;
        text-align: center;
        font-size: 16pt;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: #1a56db;
    }
}

/* ---- Consent Modal ---- */

.consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.consent-modal-card {
    background: var(--color-bg-elevated);
    border-radius: 16px;
    padding: 2rem 2rem 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-elevated);
    border: 1px solid var(--color-border);
    text-align: center;
}

.consent-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.consent-modal-card h2 {
    color: var(--color-text);
    margin-bottom: 0.4rem;
    font-size: 1.15rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: -0.01em;
}

.consent-modal-card > p {
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    line-height: 1.5;
}

.consent-terms-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.consent-term-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.consent-term-row svg {
    flex-shrink: 0;
}

.consent-modal-card .btn-block {
    font-size: 0.9rem;
    padding: 0.7rem;
    font-weight: 600;
}

.consent-footer {
    color: var(--color-text-light) !important;
    font-size: 0.72rem !important;
    margin-bottom: 0 !important;
    margin-top: 0.75rem;
    opacity: 0.7;
}

.consent-checkbox {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--color-primary);
}

/* ---- Privacy & Data View ---- */

.consent-description,
.audit-description {
    color: var(--color-text-muted);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.consent-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--color-border);
}

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

.consent-toggle-label {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    cursor: pointer;
    font-size: 0.88rem;
}

.consent-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.audit-log {
    max-height: 400px;
    overflow-y: auto;
}

.audit-entry {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.audit-entry:last-child {
    border-bottom: none;
}

.audit-time {
    color: var(--color-text-muted);
    min-width: 130px;
    font-size: 0.78rem;
}

.audit-action {
    font-size: 0.72rem;
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.badge-create, .badge-login { background: var(--color-success-light); color: var(--color-success); }
.badge-read { background: var(--color-primary-light); color: var(--color-primary); }
.badge-update { background: var(--color-warning-light); color: var(--color-warning); }
.badge-delete, .badge-login_failed { background: var(--color-danger-light); color: var(--color-danger); }
.badge-export { background: rgba(124, 58, 237, 0.08); color: #7c3aed; }
.badge-logout { background: var(--color-bg-hover); color: var(--color-text-muted); }
.badge-consent_granted { background: var(--color-success-light); color: var(--color-success); }
.badge-consent_revoked { background: var(--color-warning-light); color: var(--color-warning); }

.audit-resource {
    color: var(--color-text);
    font-weight: 500;
}

.audit-detail {
    color: var(--color-text-muted);
    font-size: 0.78rem;
}

/* ---- Analytics Dashboard ---- */

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    text-align: center;
}

.stat-card .stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
    margin-bottom: 0.3rem;
}

.stat-card .stat-card-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.stat-card.accent-success .stat-card-value { color: var(--color-success); }
.stat-card.accent-warning .stat-card-value { color: var(--color-warning); }
.stat-card.accent-danger .stat-card-value { color: var(--color-danger); }

.analytics-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
}

.bar-label {
    min-width: 120px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text);
    font-weight: 500;
}

.bar-track {
    flex: 1;
    height: 22px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--color-primary);
    transition: width 0.6s ease;
    min-width: 2px;
}

.bar-fill.fill-success { background: var(--color-success); }
.bar-fill.fill-warning { background: var(--color-warning); }

.bar-count {
    min-width: 28px;
    text-align: right;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 140px;
    padding: 0.5rem 0;
}

.daily-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.daily-bar {
    width: 100%;
    min-height: 2px;
    background: var(--color-primary);
    border-radius: 3px 3px 0 0;
    transition: height 0.4s ease;
}

.daily-bar:hover { background: var(--color-primary-hover); }

.daily-bar-label {
    font-size: 0.6rem;
    color: var(--color-text-light);
    margin-top: 4px;
}

.daily-bar-empty {
    width: 100%;
    min-height: 2px;
    background: var(--color-border);
    border-radius: 3px;
}

/* ---- Patient Visit History ---- */

.history-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.history-summary-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.history-summary-group h4 {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.patient-timeline {
    position: relative;
    padding-left: 20px;
}

.patient-timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.timeline-entry {
    position: relative;
    padding: 0.6rem 0 0.6rem 1rem;
    cursor: pointer;
    border-radius: var(--radius-btn);
    transition: background var(--transition);
}

.timeline-entry:hover { background: var(--color-bg-hover); }

.timeline-entry::before {
    content: "";
    position: absolute;
    left: -19px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    border: 2px solid var(--color-primary);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.15rem;
}

.timeline-complaint {
    font-size: 0.85rem;
    color: var(--color-text);
    font-weight: 500;
}

.timeline-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.3rem;
}

/* ---- Template Badge ---- */

.template-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.08);
    color: #7c3aed;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100vh - var(--header-height));
        z-index: 20;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    main {
        padding: 0.75rem;
    }

    .card {
        padding: 1rem;
        border-radius: 10px;
    }

    .recording-interface {
        padding: 1.5rem 0.5rem;
    }

    .recording-timer {
        font-size: 1.75rem;
    }

    .dict-add-form {
        flex-direction: column;
    }

    .dict-add-form .text-input,
    .dict-add-form select.text-input {
        max-width: 100%;
    }

    .auth-card {
        padding: 1.75rem 1.5rem;
    }

    .analytics-two-col {
        grid-template-columns: 1fr;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
