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

:root {
    --bg: #0c0e14;
    --surface: #151823;
    --surface-hover: #1e2233;
    --border: #252a3a;
    --text: #e4e4e7;
    --text-muted: #808899;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --accent: #f59e0b;
    --sidebar-w: 220px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== TOP BAR ===== */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; padding: 0.25rem; }
.nav-brand { font-size: 1.1rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.viewer-select { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.3rem 0.5rem; border-radius: 6px; font-size: 0.8rem; }
.nav-logout { color: var(--text-muted); text-decoration: none; font-size: 0.8rem; }
.nav-logout:hover { color: var(--text); }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 90;
}
.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-heading {
    padding: 0 1.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.sidebar-link {
    display: block;
    padding: 0.4rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}
.sidebar-link:hover { color: var(--text); background: var(--surface-hover); }
.sidebar-link.active { color: var(--primary); border-left-color: var(--primary); background: rgba(99,102,241,0.06); }
.sidebar-overlay { display: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    margin-top: 52px;
    max-width: 920px;
    padding: 2rem 2.5rem;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 0.75rem; color: var(--text); }
h3 { font-size: 1rem; font-weight: 500; margin-bottom: 0.4rem; }

.header-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.45rem 1rem;
    border: none; border-radius: 6px;
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer; text-decoration: none;
    transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success { background: var(--success); color: white; }
.btn-large { padding: 0.6rem 1.5rem; font-size: 0.95rem; }
.btn-cooldown { background: var(--accent); color: black; }
.btn-cooldown:hover { background: #fbbf24; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.6rem;
    transition: border-color 0.2s;
}
.card:hover { border-color: #353a4d; }
a.card-link { text-decoration: none; color: inherit; display: block; cursor: pointer; }
a.card-link:hover { border-color: var(--primary); }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.card-header h3 { font-size: 0.95rem; }
.card-meta { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.3rem; }
.card-preview { color: var(--text-muted); font-size: 0.85rem; line-height: 1.5; }

/* ===== BADGES ===== */
.badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 10px; font-weight: 500; }
.badge-live { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-live_server { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-upload_audio { background: rgba(245,158,11,0.15); color: var(--accent); }
.badge-upload_text { background: rgba(99,102,241,0.15); color: var(--primary); }
.badge-whatsapp { background: rgba(37,211,102,0.15); color: #25D366; }
.badge-severity-low { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-severity-mid { background: rgba(245,158,11,0.15); color: var(--accent); }
.badge-severity-high { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-manual { background: var(--surface-hover); color: var(--text-muted); }
.badge-analysis { background: rgba(99,102,241,0.1); color: var(--primary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[type="file"] { color: var(--text-muted); font-size: 0.85rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); }

.record-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.record-actions { display: flex; gap: 0.75rem; margin-bottom: 1rem; }

.help-text { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.3rem; }
.info-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; line-height: 1.5; }
.severity-display { text-align: center; font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }

.pattern-checkboxes { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--text); cursor: pointer; }
.checkbox-label input { accent-color: var(--primary); }

/* ===== STATUS ===== */
.status-indicator { padding: 0.4rem 0; font-size: 0.85rem; min-height: 1.25rem; }
.status-indicator.active { color: var(--success); }
.status-indicator.active::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-right: 0.5rem; animation: pulse 1.5s infinite; }
.status-indicator.stopped { color: var(--text-muted); }
.status-indicator.error { color: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== ALERT ===== */
.alert { padding: 0.6rem 0.75rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.85rem; }
.alert.error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* ===== TRANSCRIPT ===== */
.transcript-box {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem; min-height: 250px; max-height: 500px;
    overflow-y: auto; font-size: 0.9rem; white-space: pre-wrap; line-height: 1.7;
}
.transcript-text {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem; white-space: pre-wrap; font-family: inherit;
    font-size: 0.9rem; line-height: 1.7; max-height: 500px; overflow-y: auto;
}

/* ===== ANALYSIS ===== */
.analysis-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 0.75rem;
}
.analysis-text { white-space: pre-wrap; line-height: 1.7; font-size: 0.9rem; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.tab {
    padding: 0.6rem 1.25rem; background: none; border: none;
    color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
    border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.empty-state { text-align: center; padding: 3rem 2rem; color: var(--text-muted); }

/* ===== PATTERN TAGS ===== */
.pattern-tag {
    display: inline-block; padding: 0.1rem 0.5rem;
    background: rgba(99,102,241,0.1); color: var(--primary);
    border-radius: 10px; font-size: 0.7rem; margin-right: 0.25rem; text-decoration: none;
}
.pattern-tag:hover { background: rgba(99,102,241,0.2); }

/* ===== TRENDS ===== */
.trend-increasing { color: var(--danger); font-size: 0.8rem; }
.trend-decreasing { color: var(--success); font-size: 0.8rem; }
.trend-stable { color: var(--text-muted); font-size: 0.8rem; }

/* ===== LAYOUTS ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; text-align: center; }
.stat-number { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ===== DOC SECTIONS ===== */
.doc-section { margin-bottom: 1rem; }
.doc-section h3 { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.2rem; }

/* ===== SCORE DASHBOARD ===== */
.score-dashboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 0.5rem; }
.score-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.25rem; text-align: center;
}
.score-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 0.6rem; }
.score-value { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-top: 0.4rem; }
.score-desc { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }

.score-hearts { font-size: 1.5rem; letter-spacing: 0.1rem; }
.heart.full { color: #ef4444; }
.heart.half { color: #ef4444; opacity: 0.5; }
.heart.empty { color: var(--border); }
.mini-hearts { color: #ef4444; font-size: 0.75rem; }

.score-bars { display: flex; justify-content: center; gap: 3px; }
.bar { display: inline-block; width: 20px; height: 24px; border-radius: 3px; }
.bar.full { background: var(--primary); }
.bar.half { background: var(--primary); opacity: 0.5; }
.bar.empty { background: var(--border); }

.score-arrows { font-size: 1.25rem; letter-spacing: 0.1rem; }
.arrow.full { color: var(--success); }
.arrow.half { color: var(--success); opacity: 0.5; }
.arrow.empty { color: var(--border); }

/* ===== PERSPECTIVES ===== */
.perspective-toggle { display: flex; gap: 0.4rem; margin-top: 0.75rem; flex-wrap: wrap; }
.perspective-card { margin-top: 0.5rem; padding: 0.75rem 1rem; border-radius: 6px; background: var(--bg); }
.perspective-carlos { border-left: 3px solid var(--primary); }
.perspective-lisa { border-left: 3px solid var(--accent); }
.perspective-card h4 { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.05em; }
.perspective-text { white-space: pre-wrap; line-height: 1.6; font-size: 0.85rem; }

/* ===== ACTIONS ===== */
.action-filters { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.action-checkbox { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
.action-done-text { text-decoration: line-through; color: var(--text-muted); }

/* ===== PRIVATE NOTES ===== */
.note-card {
    background: var(--bg); border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0; padding: 0.6rem 0.75rem; margin-bottom: 0.4rem;
}

/* ===== CHART ===== */
.chart-container { position: relative; width: 100%; height: 350px; }

/* ===== COOLDOWN OVERLAY ===== */
.cooldown-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92); z-index: 1000;
    justify-content: center; align-items: center; padding: 1rem;
}
.cooldown-card {
    background: var(--surface); border: 2px solid var(--accent);
    border-radius: 12px; padding: 2rem; max-width: 560px; width: 100%; text-align: center;
}
.cooldown-card h2 { color: var(--accent); margin-bottom: 0.5rem; }
.cooldown-text { font-size: 1.05rem; line-height: 1.7; white-space: pre-wrap; text-align: left; margin: 1rem 0; }

/* ===== LIVE TRANSCRIPTION ===== */
.live-transcript-box {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.75rem; min-height: 300px; max-height: 550px; overflow-y: auto; margin-top: 0.75rem;
}
.live-line {
    padding: 0.3rem 0.6rem; margin: 0.15rem 0; border-radius: 4px;
    font-size: 0.9rem; line-height: 1.5;
    display: flex; align-items: center; gap: 0.4rem;
    transition: background 0.3s; border-left: 3px solid transparent;
}
.live-line.tone-red { background: rgba(239,68,68,0.1); border-left-color: #ef4444; color: #fca5a5; }
.live-line.tone-yellow { background: rgba(245,158,11,0.06); border-left-color: #f59e0b; }
.live-line.tone-green { background: rgba(34,197,94,0.08); border-left-color: #22c55e; color: #86efac; }
.live-line.tone-unclassified { background: transparent; border-left-color: var(--border); color: var(--text-muted); }
.line-text { flex: 1; }
.line-reason { color: var(--text-muted); cursor: help; font-size: 0.8rem; opacity: 0.5; }
.line-reason:hover { opacity: 1; }

.tone-red { color: #ef4444; }
.tone-yellow { color: #f59e0b; }
.tone-green { color: #22c55e; }

.live-legend { display: flex; gap: 1.25rem; margin-top: 0.75rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }
.tone-bg-green { background: #22c55e; }
.tone-bg-yellow { background: #f59e0b; }
.tone-bg-red { background: #ef4444; }
.tone-bg-unclassified { background: var(--border); }

.tone-summary { margin-top: 1rem; }
.tone-bar-container { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--border); margin-bottom: 0.4rem; }
.tone-bar { height: 100%; transition: width 0.5s ease; }
.tone-bar.green { background: #22c55e; }
.tone-bar.yellow { background: #f59e0b; }
.tone-bar.red { background: #ef4444; }
.tone-counts { font-size: 0.8rem; color: var(--text-muted); }

/* ===== LIVE TWO-COLUMN LAYOUT ===== */
.live-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; margin-top: 0.5rem; }
.live-left { min-width: 0; }
.live-right {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: 1rem; height: fit-content; position: sticky; top: 68px;
    max-height: calc(100vh - 80px); overflow-y: auto;
}
.live-right h3 { font-size: 0.85rem; margin-bottom: 0.25rem; }

.coach-feed { max-height: 400px; overflow-y: auto; }
.coach-empty { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 2rem 0; }

.coach-entry {
    padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
    border-radius: 6px; font-size: 0.82rem; line-height: 1.5;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.coach-red { background: rgba(239,68,68,0.08); border-left: 3px solid #ef4444; }
.coach-green { background: rgba(34,197,94,0.06); border-left: 3px solid #22c55e; }
.coach-info { background: rgba(99,102,241,0.06); border-left: 3px solid var(--primary); color: var(--text-muted); }

.coach-flag { font-size: 0.75rem; font-weight: 600; color: #ef4444; margin-bottom: 0.2rem; }
.coach-flag.coach-good { color: #22c55e; }
.coach-quote { font-style: italic; color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.coach-why { color: var(--text); margin-bottom: 0.25rem; }
.coach-tip { color: var(--accent); font-size: 0.8rem; }

.tone-analysis-panel { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.tone-mood { padding: 0.5rem; border-radius: 6px; font-size: 0.85rem; margin-bottom: 0.4rem; }
.tone-mood.tone-red { background: rgba(239,68,68,0.08); color: #fca5a5; }
.tone-mood.tone-green { background: rgba(34,197,94,0.06); color: #86efac; }
.tone-mood.tone-accent { background: rgba(245,158,11,0.06); color: var(--accent); }
.tone-pct { font-size: 0.75rem; color: var(--text-muted); }

/* ===== LOGIN ===== */
.login-container {
    max-width: 340px; margin: 18vh auto; padding: 2.5rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; text-align: center;
}
.login-container h1 { font-size: 1.75rem; color: var(--primary); margin-bottom: 0.2rem; }
.login-container .subtitle { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }
.login-container input { margin-bottom: 1rem; text-align: center; }
.login-container button { width: 100%; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,0.5); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .menu-toggle { display: block; }
    .main-content { margin-left: 0; padding: 1.5rem 1rem; }
    .record-controls { grid-template-columns: 1fr; }
    .header-row { flex-direction: column; }
    .two-col { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr; }
    .score-dashboard { grid-template-columns: 1fr; }
    .live-layout { grid-template-columns: 1fr; }
    .live-right { position: static; max-height: 300px; }
}

@media (min-width: 769px) {
    .menu-toggle { display: none; }
    .sidebar-overlay { display: none !important; }
}

/* Model badges */
.model-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.model-claude { background: #6366f133; color: #818cf8; border: 1px solid #6366f155; }
.model-local { background: #22c55e22; color: #4ade80; border: 1px solid #22c55e44; }

/* Analyze button group */
.analyze-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-local {
    background: #22c55e22; color: #4ade80; border: 1px solid #22c55e44;
    padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.btn-local:hover { background: #22c55e33; }
.btn-dual {
    background: linear-gradient(135deg, #6366f133, #22c55e22);
    color: var(--text); border: 1px solid #6366f155;
    padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.btn-dual:hover { background: linear-gradient(135deg, #6366f155, #22c55e44); }

/* Dual comparison grid */
.dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}
.dual-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    min-height: 200px;
}
.dual-col h3 { margin-bottom: 0.75rem; }
@media (max-width: 768px) {
    .dual-grid { grid-template-columns: 1fr; }
}
