* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --bg: #0b0d12;
    --surface: #12151d;
    --surface-2: #171b25;
    --border: #232838;
    --text: #e8eaf0;
    --text-dim: #8b93a7;
    --accent: #4f7cff;
    --accent-hover: #3a67f0;
    --good: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --radius: 10px;
}

html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1.05rem; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.tabs { display: flex; gap: 0.25rem; flex: 1; }
.tab-btn {
    background: transparent; border: none; color: var(--text-dim);
    padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 0.9rem; cursor: pointer;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.status-bar { display: flex; align-items: center; gap: 0.9rem; font-size: 0.8rem; color: var(--text-dim); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
#logout-link { color: var(--text-dim); text-decoration: none; border: 1px solid var(--border); padding: 0.25rem 0.7rem; border-radius: 6px; }
#logout-link:hover { color: var(--text); border-color: #3a4156; }

main { flex: 1; padding: 1.25rem; max-width: 1200px; margin: 0 auto; width: 100%; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap;
}
.card-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--text); margin: 0; }

.panel-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

/* ---------- inputs ---------- */
input[type="text"], input[type="password"], input[type="number"], select {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.9rem;
    width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.search-controls { display: flex; gap: 0.6rem; margin-bottom: 0.9rem; }
.search-controls input { flex: 1; }
.search-controls select { max-width: 220px; }

/* ---------- botões ---------- */
.btn {
    padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 0.85rem; cursor: pointer;
}
.btn:hover { border-color: #3a4156; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* ---------- resultados de busca ---------- */
.result-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 520px; overflow-y: auto; }
.result-item {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.7rem 0.85rem;
}
.result-item mark { background: #f59e0b40; color: #fbbf24; padding: 0 2px; border-radius: 3px; }
.result-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.35rem; flex-wrap: wrap; }
.result-text { font-size: 0.88rem; line-height: 1.4; margin-bottom: 0.5rem; }
.result-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.result-actions audio { height: 32px; max-width: 220px; }

.badge { font-size: 0.68rem; padding: 0.15rem 0.5rem; border-radius: 20px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-quiet { background: #f59e0b30; color: var(--warn); }
.badge-noisy { background: #f8717130; color: var(--bad); }

/* ---------- timeline ---------- */
.timeline { max-height: 520px; overflow-y: auto; }
.timeline h3 { font-size: 0.85rem; color: var(--text-dim); margin: 1rem 0 0.4rem; }
.timeline h3:first-child { margin-top: 0; }
.summary-item {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.6rem 0.85rem; margin-bottom: 0.5rem; font-size: 0.86rem; line-height: 1.4;
}
.summary-item .result-meta { margin-bottom: 0.3rem; }

/* ---------- câmeras ---------- */
.camera-list { display: flex; flex-direction: column; gap: 0.6rem; }
.camera-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.75rem 1rem; flex-wrap: wrap;
}
.camera-info { display: flex; flex-direction: column; gap: 0.2rem; }
.camera-name { font-weight: 600; font-size: 0.92rem; }
.camera-tech { font-size: 0.78rem; color: var(--text-dim); font-family: ui-monospace, monospace; }
.camera-actions { display: flex; gap: 0.4rem; align-items: center; }

.pill { font-size: 0.72rem; padding: 0.2rem 0.6rem; border-radius: 20px; font-weight: 600; }
.pill-active { background: #34d39930; color: var(--good); }
.pill-inactive { background: #8b93a730; color: var(--text-dim); }

.empty-hint { color: var(--text-dim); font-size: 0.85rem; padding: 1rem 0; text-align: center; }

/* ---------- modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 1.25rem 1.4rem;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

.form-row { margin-bottom: 0.8rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-row label { font-size: 0.78rem; color: var(--text-dim); }
.form-row-inline { flex-direction: row; align-items: center; }
.form-row-inline label { display: flex; align-items: center; gap: 0.4rem; color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.hint { font-weight: normal; opacity: 0.7; }
.form-error { color: var(--bad); font-size: 0.82rem; background: #f8717115; border: 1px solid #f8717140; border-radius: 6px; padding: 0.5rem 0.7rem; margin-bottom: 0.6rem; }

/* ---------- login ---------- */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 2rem; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 0.6rem;
}
.login-box h1 { font-size: 1.1rem; margin: 0 0 0.5rem; text-align: center; }
.login-box label { font-size: 0.85rem; color: var(--text-dim); }
.login-box button {
    margin-top: 0.5rem; padding: 0.6rem; border-radius: 8px; border: none;
    background: var(--accent); color: white; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.login-box button:hover { background: var(--accent-hover); }
.login-error { color: var(--bad); font-size: 0.85rem; margin: 0; }

@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: stretch; }
    .form-grid { grid-template-columns: 1fr; }
}
