:root {
    --primary: #2563eb; --primary-light: #eff6ff;
    --secondary: #c2410c; --secondary-light: #fff7ed;
    --tertiary: #7c3aed; --tertiary-light: #f5f3ff;
    --bg: #f8fafc; --card: #ffffff; --text: #1e293b; --muted: #64748b;
    --border: #e2e8f0; --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --radius: 8px; --green: #16a34a; --red: #dc2626;
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
.icon { display: inline-flex; align-items: center; justify-content: center; }
.icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }

header { background: var(--text); color: white; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
header h1 span { opacity: 0.6; font-weight: 400; font-size: 13px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.header-btn { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-family: var(--font); transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.header-btn:hover { background: rgba(255,255,255,0.2); }
.header-btn.active { background: rgba(255,255,255,0.3); }
.header-btn svg { width: 14px; height: 14px; }
.status { font-size: 11px; color: rgba(255,255,255,0.6); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; display: inline-block; }
.status-dot.offline { background: var(--red); }

.pipeline { background: var(--card); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pipe-step { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 16px; border-radius: var(--radius); background: var(--bg); transition: all 0.3s; min-width: 100px; }
.pipe-step .pipe-icon { color: var(--muted); }
.pipe-step .pipe-icon svg { width: 18px; height: 18px; }
.pipe-step .pipe-label { font-size: 11px; color: var(--muted); font-weight: 500; }
.pipe-step .pipe-time { font-size: 10px; color: var(--primary); font-weight: 600; display: none; }
.pipe-step.active { background: var(--primary-light); box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.pipe-step.active .pipe-label { color: var(--primary); }
.pipe-step.active .pipe-icon { color: var(--primary); }
.pipe-step.done { background: #f0fdf4; }
.pipe-step.done .pipe-label { color: var(--green); }
.pipe-step.done .pipe-icon { color: var(--green); }
.pipe-step.done .pipe-time { display: block; }
.pipe-arrow { color: var(--border); }
.pipe-arrow svg { width: 16px; height: 16px; }
.pipe-step.active .pipe-icon svg { animation: pipePulse 1s infinite; }
@keyframes pipePulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }

.dist-banner { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0.8); background: white; border-radius: 12px; padding: 24px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); z-index: 200; text-align: center; opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.dist-banner.show { opacity: 1; transform: translate(-50%,-50%) scale(1); pointer-events: auto; }
.dist-banner h2 { font-size: 20px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; justify-content: center; }
.dist-banner .cats { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 13px; color: var(--muted); }

.toolbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 8px 24px; display: flex; gap: 12px; align-items: center; }
.toolbar input { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: var(--font); outline: none; transition: border-color 0.2s; }
.toolbar input:focus { border-color: var(--primary); }
.toolbar input[type="date"] { width: 160px; }
.toolbar .search-wrap { position: relative; }
.toolbar .search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--muted); }
.toolbar .search-wrap input { padding-left: 32px; width: 220px; }
.toolbar-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.app { display: grid; grid-template-columns: 300px 1fr; gap: 0; min-height: calc(100vh - 180px); }

.sidebar { background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 24px 16px; gap: 16px; overflow-y: auto; }
#recordBtn { width: 112px; height: 112px; border-radius: 50%; border: none; background: var(--green); color: white; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 16px rgba(22,163,74,0.3); display: flex; align-items: center; justify-content: center; }
#recordBtn svg { width: 32px; height: 32px; }
#recordBtn:hover { transform: scale(1.04); }
#recordBtn.recording { background: var(--red); box-shadow: 0 4px 16px rgba(220,38,38,0.3); animation: pulse 1.5s infinite; }
#recordBtn.processing { background: #d97706; pointer-events: none; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.03)} }
.rec-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
#transcription { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-size: 13px; color: var(--muted); line-height: 1.5; min-height: 40px; width: 100%; text-align: center; font-style: italic; }
#waveCanvas { width: 100%; height: 40px; display: none; border-radius: var(--radius); }
#waveCanvas.active { display: block; }
.text-input-area { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.text-input-area textarea { width: 100%; height: 60px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; resize: none; font-family: var(--font); transition: border-color 0.2s; }
.text-input-area textarea:focus { border-color: var(--primary); outline: none; }
.text-input-area button { padding: 8px; border-radius: var(--radius); border: none; background: var(--primary); color: white; cursor: pointer; font-size: 12px; font-weight: 600; font-family: var(--font); display: flex; align-items: center; justify-content: center; gap: 6px; }
.text-input-area button svg { width: 14px; height: 14px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 4px 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 10px; color: var(--muted); transition: all 0.2s; font-family: var(--font); }
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.panels { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; padding: 16px; align-content: start; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.panel-header { padding: 12px 16px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel-header .panel-icon { width: 28px; height: 28px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.panel-header .panel-icon svg { width: 16px; height: 16px; }
.panel-header .count { margin-left: auto; background: var(--bg); color: var(--muted); font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.entries { padding: 8px; overflow-y: auto; flex: 1; }

#project .panel-header { color: var(--primary); }
#project .panel-icon { background: var(--primary-light); color: var(--primary); }
#personnel .panel-header { color: var(--secondary); }
#personnel .panel-icon { background: var(--secondary-light); color: var(--secondary); }
#admin .panel-header { color: var(--tertiary); }
#admin .panel-icon { background: var(--tertiary-light); color: var(--tertiary); }

.entry { padding: 12px; margin-bottom: 8px; border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow); animation: fadeIn 0.4s ease; position: relative; }
.entry:hover .entry-actions { opacity: 1; }
.entry-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.entry-actions button { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px; }
.entry-actions button svg { width: 14px; height: 14px; }
.entry-actions .entry-edit:hover { color: var(--primary); }
.entry-actions .entry-delete:hover { color: var(--red); }
.entry .headline { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.entry .detail { font-size: 12px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; }
.entry .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entry .timestamp { font-size: 10px; color: var(--muted); }
.entry .label { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; color: white; border-radius: 4px; font-size: 10px; font-weight: 500; }
.entry .label svg { width: 10px; height: 10px; }
.entry.urgent { background: #fef2f2; box-shadow: 0 0 0 1px rgba(220,38,38,0.15); }
.entry.urgent .headline { display: flex; align-items: center; gap: 4px; }
.entry.urgent .urgent-icon { color: var(--red); }
.entry.urgent .urgent-icon svg { width: 14px; height: 14px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
#project .entry { background: var(--primary-light); }
#personnel .entry { background: var(--secondary-light); }
#admin .entry { background: var(--tertiary-light); }
#project .label { background: var(--primary); }
#personnel .label { background: var(--secondary); }
#admin .label { background: var(--tertiary); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 12px; }
.empty .empty-icon { margin-bottom: 8px; opacity: 0.4; }
.empty .empty-icon svg { width: 24px; height: 24px; }

.stats-bar { background: var(--card); border-top: 1px solid var(--border); padding: 8px 24px; display: flex; gap: 24px; justify-content: center; font-size: 12px; color: var(--muted); }
.stat { display: flex; align-items: center; gap: 4px; }
.stat svg { width: 14px; height: 14px; }
.stat b { color: var(--text); }

.json-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; align-items: center; justify-content: center; }
.json-overlay.active { display: flex; }
.json-box { background: #1e293b; color: #e2e8f0; border-radius: var(--radius); padding: 20px; max-width: 600px; width: 90%; max-height: 70vh; overflow: auto; font-family: 'JetBrains Mono', monospace; font-size: 12px; white-space: pre-wrap; cursor: pointer; }
.json-box .json-title { color: #93c5fd; font-size: 14px; margin-bottom: 12px; font-family: var(--font); font-weight: 600; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: var(--radius); padding: 24px; max-width: 400px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h3 { margin-bottom: 8px; font-size: 15px; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; }
.modal-actions button { padding: 8px 20px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 13px; font-weight: 600; font-family: var(--font); }
.btn-cancel { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-confirm { background: var(--red); color: white; }
.btn-save { background: var(--primary); color: white; }
.edit-form { text-align: left; margin: 12px 0; }
.edit-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; margin-top: 12px; font-weight: 500; }
.edit-form textarea, .edit-form select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: var(--font); }
.edit-form textarea { height: 60px; resize: vertical; }
.edit-form select { height: 36px; }

.presentation-mode .toolbar { display: none; }
.presentation-mode .panel-header { font-size: 16px; }
.presentation-mode .entry .headline { font-size: 15px; }
.presentation-mode .entry .label { font-size: 12px; }
.presentation-mode .pipe-step { min-width: 130px; }
.presentation-mode .pipe-label { font-size: 13px !important; }
.presentation-mode .dist-banner h2 { font-size: 24px; }

@media (max-width: 1200px) { .panels { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { padding: 16px; flex-direction: row; flex-wrap: wrap; justify-content: center; min-height: auto; }
    #recordBtn { width: 80px; height: 80px; }
    #recordBtn svg { width: 24px; height: 24px; }
    .panels { padding: 8px; }
    .toolbar { flex-wrap: wrap; }
    .pipeline { flex-wrap: wrap; gap: 4px; }
    .header-actions { gap: 4px; }
}
