/* ============================================================
   Clinote - Main Stylesheet
   Clean clinical aesthetic: whites, blues, Plus Jakarta Sans
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --blue-900:  #0a1628;
    --blue-800:  #0f2246;
    --blue-700:  #163470;
    --blue-600:  #1d4ed8;
    --blue-500:  #2563eb;
    --blue-400:  #3b82f6;
    --blue-100:  #dbeafe;
    --blue-50:   #eff6ff;

    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;

    --white:     #ffffff;
    --red-600:   #dc2626;
    --red-100:   #fee2e2;
    --green-600: #16a34a;
    --green-100: #dcfce7;
    --amber-600: #d97706;
    --amber-100: #fef3c7;

    --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    --shadow-sm:  0 1px 3px rgba(15,34,85,0.08), 0 1px 2px rgba(15,34,85,0.04);
    --shadow-md:  0 4px 16px rgba(15,34,85,0.10), 0 2px 6px rgba(15,34,85,0.06);
    --shadow-lg:  0 12px 40px rgba(15,34,85,0.14);

    --nav-height: 64px;
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-body);
    background: var(--slate-50);
    color: var(--slate-900);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ─────────────────────────────────────────────────────────────── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    box-shadow: var(--shadow-sm);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: var(--blue-600);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
}

.brand-name {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--blue-900);
    letter-spacing: -0.03em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--slate-700);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.nav-link:hover {
    background: var(--slate-100);
    color: var(--blue-600);
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.nav-user-name {
    font-size: 0.875rem;
    color: var(--slate-500);
    font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--blue-600);
    color: var(--white);
    border-color: var(--blue-600);
}
.btn-primary:hover {
    background: var(--blue-700);
    border-color: var(--blue-700);
    color: var(--white);
}

.btn-outline {
    background: var(--white);
    color: var(--slate-700);
    border-color: var(--slate-300);
}
.btn-outline:hover {
    background: var(--slate-50);
    border-color: var(--slate-400);
    color: var(--slate-900);
}

.btn-danger {
    background: var(--red-600);
    color: var(--white);
    border-color: var(--red-600);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: var(--white); }

.btn-record {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
    padding: 12px 24px;
    font-size: 1rem;
}
.btn-record:hover { background: #b91c1c; }
.btn-record.recording { animation: pulse-red 1.5s infinite; }

.btn-stop {
    background: var(--slate-700);
    color: white;
    border-color: var(--slate-700);
    padding: 12px 24px;
    font-size: 1rem;
}
.btn-stop:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-full { width: 100%; justify-content: center; }
.btn-large { padding: 14px 24px; font-size: 1.05rem; }

.btn-sm { padding: 6px 14px; font-size: 0.825rem; }
.btn-xs { padding: 4px 10px; font-size: 0.775rem; }
.btn-icon { font-size: 1rem; line-height: 1; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}
.container-narrow { max-width: 760px; }

.page-main {
    padding: 36px 0 60px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.page-title {
    font-family: var(--font-body);
    font-size: 2rem;
    font-weight: 700;
    color: var(--blue-900);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--slate-500);
    margin-top: 4px;
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--slate-100);
}

.card-title {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--blue-900);
}

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-page {
    background: linear-gradient(135deg, var(--blue-50) 0%, var(--white) 60%);
}

.auth-container {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-xl);
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--blue-600);
    color: white;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo-text {
    font-family: var(--font-body);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--blue-900);
    letter-spacing: -0.03em;
}

.auth-title {
    font-family: var(--font-body);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--blue-900);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--slate-500);
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--slate-500);
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--slate-900);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--slate-500);
    margin-top: 6px;
    line-height: 1.5;
}

.optional {
    font-weight: 400;
    color: var(--slate-400);
    font-size: 0.8rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-error   { background: var(--red-100);   color: #7f1d1d; border-color: #fca5a5; }
.alert-success { background: var(--green-100); color: #14532d; border-color: #86efac; }
.alert-info    { background: var(--blue-50);   color: var(--blue-800); border-color: var(--blue-100); }
.alert-warning { background: var(--amber-100); color: #78350f; border-color: #fcd34d; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-format {
    background: var(--blue-100);
    color: var(--blue-800);
}

.badge-status { }
.badge-complete     { background: var(--green-100); color: #14532d; }
.badge-pending      { background: var(--slate-100); color: var(--slate-600); }
.badge-transcribing { background: var(--amber-100); color: #92400e; }
.badge-generating   { background: var(--blue-50);   color: var(--blue-700); }
.badge-error        { background: var(--red-100);   color: #7f1d1d; }

/* ── Stats row ───────────────────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-number {
    font-family: var(--font-body);
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--blue-600);
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -0.04em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--slate-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate-500);
    border-bottom: 2px solid var(--slate-200);
    background: var(--slate-50);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--slate-100);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-50); }

.td-title { font-weight: 500; color: var(--slate-900); max-width: 220px; }
.td-date  { color: var(--slate-500); white-space: nowrap; font-size: 0.8rem; }
.td-expires { color: var(--amber-600); }
.td-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--slate-500);
}

.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-body); font-size: 1.3rem; color: var(--slate-700); margin-bottom: 8px; }
.empty-state p  { margin-bottom: 20px; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 20px 0 4px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--slate-600);
    border: 1px solid var(--slate-200);
    background: var(--white);
    text-decoration: none;
    transition: all 0.15s;
}
.page-link:hover { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-200); text-decoration: none; }
.page-link.active { background: var(--blue-600); color: white; border-color: var(--blue-600); }

/* ── Step cards (new.php) ────────────────────────────────────────────────────── */
.step-card { position: relative; }

.step-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--blue-600);
    margin-bottom: 20px;
}

.step-num {
    width: 24px;
    height: 24px;
    background: var(--blue-600);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Audio tabs ──────────────────────────────────────────────────────────────── */
.audio-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--slate-200);
    padding-bottom: 0;
}

.audio-tab {
    padding: 9px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--slate-500);
    transition: all 0.15s;
}
.audio-tab:hover { color: var(--blue-600); }
.audio-tab.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }

/* ── Recorder UI ─────────────────────────────────────────────────────────────── */
.recorder-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 8px 0;
}

.waveform-container {
    width: 100%;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 80px;
}

#waveform { display: block; width: 100%; height: 80px; }

.recorder-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.rec-timer {
    font-family: var(--font-body);
    font-size: 2rem;
    color: var(--red-600);
    letter-spacing: 0.05em;
}

.rec-status {
    font-size: 0.85rem;
    color: var(--slate-500);
    min-height: 20px;
    text-align: center;
}

.record-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}
.btn-record.recording .record-dot {
    animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Upload zone ─────────────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--slate-50);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--blue-500);
    background: var(--blue-50);
}

.upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-text { font-weight: 600; color: var(--slate-700); margin-bottom: 4px; }
.upload-hint { font-size: 0.8rem; color: var(--slate-500); margin-bottom: 16px; }

.upload-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--green-100);
    border: 1px solid #86efac;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: #14532d;
}
.file-icon { font-size: 1.2rem; }

/* ── Template options ────────────────────────────────────────────────────────── */
.template-options { margin-top: 8px; }

.template-option-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
}

.tmpl-tab {
    padding: 6px 14px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--slate-600);
    transition: all 0.15s;
}
.tmpl-tab.active { background: var(--blue-600); color: white; border-color: var(--blue-600); }

.file-name-display {
    font-size: 0.825rem;
    color: var(--slate-500);
    margin-left: 10px;
}

/* ── Generate section ────────────────────────────────────────────────────────── */
.generate-hint {
    font-size: 0.875rem;
    color: var(--slate-500);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* ── Progress overlay ────────────────────────────────────────────────────────── */
#progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,34,85,0.55);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 48px 56px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.progress-spinner {
    width: 52px;
    height: 52px;
    border: 4px solid var(--blue-100);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

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

.progress-card h3 {
    font-family: var(--font-body);
    font-size: 1.4rem;
    color: var(--blue-900);
    margin-bottom: 8px;
}

.progress-card p {
    color: var(--slate-500);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.progress-bar-wrap {
    background: var(--slate-100);
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-500), var(--blue-400));
    border-radius: 100px;
    transition: width 0.4s ease;
}

/* ── View page ───────────────────────────────────────────────────────────────── */
.view-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .view-grid { grid-template-columns: 3fr 2fr; }
}

.notes-card { }

.notes-content {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--slate-800);
}

.notes-content h1,
.notes-content h2,
.notes-content h3 {
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--blue-900);
    margin: 1.2em 0 0.4em;
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.notes-content h1 { font-size: 1.2rem; }
.notes-content h2 { font-size: 1.05rem; border-bottom: 1px solid var(--slate-200); padding-bottom: 4px; }
.notes-content h3 { font-size: 0.95rem; }

.notes-content p  { margin: 0 0 0.75em; }

.notes-content strong { font-weight: 600; color: var(--slate-900); }
.notes-content em     { font-style: italic; }

.notes-content ul,
.notes-content ol {
    margin: 0.5em 0 0.75em 1.4em;
    padding: 0;
}
.notes-content li { margin-bottom: 0.25em; }

.notes-content code {
    font-family: monospace;
    font-size: 0.85em;
    background: var(--slate-100);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--slate-700);
}

.notes-content hr {
    border: none;
    border-top: 1px solid var(--slate-200);
    margin: 1.2em 0;
}

.transcript-content {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--slate-600);
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.processing-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--blue-800);
}

.processing-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--blue-100);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.privacy-notice {
    text-align: center;
    font-size: 0.8rem;
    color: var(--slate-400);
    margin-top: 24px;
    padding: 12px;
    border-top: 1px solid var(--slate-200);
}

/* ── Templates page ──────────────────────────────────────────────────────────── */
.two-col-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 800px) {
    .two-col-layout { grid-template-columns: 1fr 1fr; }
}

.template-list { display: flex; flex-direction: column; gap: 12px; }

.template-item {
    padding: 16px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--slate-50);
    transition: border-color 0.15s;
}
.template-item:hover { border-color: var(--blue-200); }

.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.template-date { font-size: 0.775rem; color: var(--slate-400); }

.template-preview {
    font-size: 0.8rem;
    color: var(--slate-500);
    margin-bottom: 10px;
    line-height: 1.5;
}

.template-actions { display: flex; gap: 6px; }

.upload-btn { cursor: pointer; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15,34,85,0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--slate-200);
    flex-shrink: 0;
}

.modal-header h3 { font-family: var(--font-body); color: var(--blue-900); }

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--slate-400);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.modal-close:hover { background: var(--slate-100); color: var(--slate-700); }

.modal-pre {
    padding: 24px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--slate-700);
    white-space: pre-wrap;
}

/* ── Site footer ─────────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--blue-900);
    color: var(--blue-100);
    padding: 56px 0 0;
    margin-top: auto;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 48px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin-bottom: 16px;
}
.footer-logo:hover { text-decoration: none; }

.footer-logo-icon {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: white;
    flex-shrink: 0;
}

.footer-logo-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.03em;
}

.footer-tagline {
    font-size: 0.85rem;
    color: var(--blue-100);
    line-height: 1.7;
    margin-bottom: 16px;
    opacity: 0.8;
    max-width: 280px;
}

.footer-contact a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.85rem;
    color: var(--blue-100);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.footer-contact a:hover {
    opacity: 1;
    text-decoration: none;
}

.footer-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: white;
    opacity: 0.5;
    margin-bottom: 14px;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    font-size: 0.875rem;
    color: var(--blue-100);
    text-decoration: none;
    opacity: 0.75;
    transition: opacity 0.15s;
    line-height: 1.4;
}
.footer-links a:hover {
    opacity: 1;
    text-decoration: none;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 20px 24px;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-legal {
    font-size: 0.78rem;
    color: var(--blue-100);
    opacity: 0.5;
    margin: 0;
}

.footer-privacy-note {
    font-size: 0.78rem;
    color: var(--blue-100);
    opacity: 0.6;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 900px) {
    .footer-inner {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
    .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
    .footer-inner { grid-template-columns: 1fr; gap: 24px; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── Print styles ────────────────────────────────────────────────────────────── */
@media print {
    .site-nav, .header-actions, .privacy-notice, .transcript-card { display: none !important; }
    .notes-card { border: none; box-shadow: none; padding: 0; }
    body { background: white; }
}

/* ── Prevent horizontal overflow globally ────────────────────────────────────── */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* ── Mobile hamburger nav ────────────────────────────────────────────────────── */
.nav-auth-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-left: auto;
    padding: 0;
    flex-shrink: 0;
}

.nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--slate-700);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
    transform-origin: center;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Slide-in drawer */
.nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-drawer.open { transform: translateX(0); }

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 34, 85, 0.45);
    z-index: 499;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
}
.nav-overlay.open { opacity: 1; pointer-events: all; }

.nav-drawer-inner {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--blue-50);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.nav-drawer-icon {
    width: 38px;
    height: 38px;
    background: var(--blue-600);
    color: white;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-drawer-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--blue-900);
}

.nav-drawer-role {
    font-size: 0.775rem;
    color: var(--slate-500);
    margin-top: 1px;
}

.nav-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    color: var(--slate-700);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.nav-drawer-link:hover {
    background: var(--slate-100);
    color: var(--blue-600);
    text-decoration: none;
}

.nav-drawer-link-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }

.nav-drawer-link-danger { color: var(--red-600); }
.nav-drawer-link-danger:hover { background: var(--red-100); color: var(--red-600); }

.nav-drawer-divider {
    height: 1px;
    background: var(--slate-200);
    margin: 8px 0;
}

/* ── Responsive breakpoints ──────────────────────────────────────────────────── */

/* Tablet and below: show hamburger, hide desktop nav */
@media (max-width: 768px) {
    .nav-links-desktop,
    .nav-user-desktop { display: none !important; }

    .nav-hamburger { display: flex; }

    .nav-inner { gap: 12px; }

    /* Tighter page padding */
    .container { padding: 0 16px; }

    .page-main { padding: 24px 0 48px; }

    .page-title { font-size: 1.6rem; }

    .page-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .page-header > .btn,
    .page-header > a.btn {
        align-self: flex-start;
    }

    /* Cards */
    .card { padding: 18px 16px; }
    .card-header { flex-wrap: wrap; gap: 8px; }

    /* Auth card */
    .auth-card { padding: 28px 20px; }

    /* Stats row: 2 columns on tablet */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 18px 14px; }
    .stat-number { font-size: 2rem; }

    /* Table: make it scroll horizontally within its container */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 560px; }
    .td-title { max-width: 140px; }

    /* Dashboard action buttons in table */
    .td-actions { flex-wrap: nowrap; gap: 4px; }

    /* Step cards */
    .step-card { padding: 18px 16px; }

    /* Recorder */
    .recorder-controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .btn-record, .btn-stop, .btn-play-back { justify-content: center; width: 100%; }
    .waveform-container { height: 60px; }
    #waveform { height: 60px; }

    /* Upload zone */
    .upload-zone { padding: 32px 16px; }

    /* Header actions */
    .header-actions { width: 100%; justify-content: flex-start; gap: 6px; }
    .header-actions .btn { flex: 1; justify-content: center; min-width: 0; }

    /* Progress card */
    .progress-card { padding: 36px 28px; }
}

/* Mobile phones */
@media (max-width: 480px) {
    /* 1-column stats */
    .stats-row { grid-template-columns: 1fr 1fr; }

    /* Reduce page title further */
    .page-title { font-size: 1.4rem; }

    /* Auth */
    .auth-card { padding: 24px 16px; border-radius: var(--radius-lg); }
    .auth-title { font-size: 1.5rem; }

    /* Badges in table - shorten */
    .badge { font-size: 0.7rem; padding: 2px 7px; }

    /* Table date columns hidden on tiny screens */
    .td-expires { display: none; }

    /* Buttons full width in forms */
    .btn-full { font-size: 1rem; padding: 13px 18px; }

    /* New consultation options */
    .audio-tabs { gap: 0; }
    .audio-tab { flex: 1; text-align: center; padding: 9px 8px; font-size: 0.825rem; }

    /* Template tabs */
    .template-option-tabs { flex-direction: column; gap: 6px; }
    .tmpl-tab { text-align: center; }

    /* View page */
    .processing-banner { flex-direction: column; gap: 10px; text-align: center; }

    /* Modal */
    .modal { padding: 12px; align-items: flex-end; }
    .modal-box { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90vh; }
}

/* ── Admin panel ─────────────────────────────────────────────────────────────── */
.admin-topbar {
    background: var(--blue-900);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    padding: 0 4px;
}

.admin-topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 16px;
    height: 48px;
}

.admin-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
    opacity: 0.9;
}

.admin-nav-links {
    display: flex;
    gap: 4px;
}

.admin-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.admin-nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}
.admin-nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.admin-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--slate-400);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--blue-900);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--slate-400);
}

.admin-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 800px) {
    .admin-two-col { grid-template-columns: 1fr; }
    .admin-topbar-inner { height: auto; padding: 10px 16px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .admin-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
