:root {
  --navy: #0f1e30;
  --navy-light: #16293f;
  --red: #9e1b32;
  --red-dark: #7a1527;
  --blue: #2563eb;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2433;
  --muted: #6b7686;
  --border: #e3e7ed;
  --green: #16a34a;
  --amber: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-logo { height: 48px; margin-bottom: 20px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--muted); }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.login-error { color: var(--red); font-size: 13px; margin: -4px 0 14px; }

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

.sidebar {
  width: 250px;
  background: var(--navy);
  color: #cfd8e3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand img { height: 34px; }

.sidebar-nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  text-align: left;
  background: none;
  border: none;
  color: #a9b4c4;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-btn:hover { background: var(--navy-light); color: #fff; }
.nav-btn.active { background: var(--red); color: #fff; font-weight: 600; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.usage-block { margin-bottom: 14px; }
.usage-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #7c8aa0; margin-bottom: 6px; }
.progress-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); width: 0%; transition: width 0.3s; }
.usage-value { font-size: 12px; color: #cfd8e3; margin-top: 4px; }
.session-block { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: #8c98ab; }
.btn-link { background: none; border: none; color: #9fb3d9; cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; }

.main { flex: 1; padding: 28px 32px; min-width: 0; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.topbar h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); font-size: 13px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fde8e8; color: #b91c1c; }
.btn-danger:disabled, .btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: 12px; }

.tab-content { background: transparent; }

.filters-bar { display: flex; gap: 10px; margin-bottom: 14px; }
.filters-bar input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.table-wrap { background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.rec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rec-table th {
  text-align: left;
  background: #fafbfc;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.rec-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.rec-table tr:last-child td { border-bottom: none; }
.rec-transcript-cell { max-width: 320px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-novo { background: #dbeafe; color: #1d4ed8; }
.badge-processado { background: #dcfce7; color: #15803d; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-falhou { background: #fde8e8; color: #b91c1c; }

.row-actions { display: flex; gap: 6px; }
.icon-btn {
  border: none;
  background: #f1f3f6;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
}
.icon-btn.danger { background: #fde8e8; }

.card-block { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 18px; }
.mini-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.mini-card h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.mini-card .value { font-size: 20px; font-weight: 700; }

.form-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.form-row input, .form-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

table.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
table.simple-table th, table.simple-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }

.log-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-time { color: var(--muted); margin-right: 8px; }
.log-output { background: #0f1e30; color: #c7d2e0; padding: 14px; border-radius: 8px; font-size: 12px; max-height: 500px; overflow: auto; white-space: pre-wrap; }

.loading { text-align: center; color: var(--muted); padding: 30px; }
audio.rec-audio { width: 180px; height: 30px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .main { padding: 18px; }
}
