:root {
  color-scheme: dark;
  --bg: #0b0d14;
  --bg-gradient: radial-gradient(circle at top right, #1a1625, #0b0d14 50%);
  --panel: rgba(22, 26, 35, 0.65);
  --panel-2: rgba(32, 38, 50, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --accent: #ff7a1a;
  --accent-hover: #ff9142;
  --accent-gradient: linear-gradient(135deg, #ff7a1a 0%, #e65c00 100%);
  --accent-dim: rgba(255, 122, 26, 0.15);
  --ok: #3ecf6d;
  --warn: #f2b84b;
  --danger: #f2634b;
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(255, 122, 26, 0.2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Outfit', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.6s ease-out;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;

}

.login-card p.subtitle {
  color: var(--text-dim);
  margin: 0 0 32px;
  font-size: 0.95rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin: 16px 0 8px;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

input:focus, textarea:focus { 
  outline: none; 
  border-color: var(--accent); 
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
}

button.primary {
  background: var(--accent-gradient);
  color: #fff;
  padding: 12px 20px;
  width: 100%;
  margin-top: 32px;
  box-shadow: 0 4px 15px rgba(255, 122, 26, 0.3);
}

button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 122, 26, 0.4);
}

button.primary:active:not(:disabled) {
  transform: translateY(0);
}

button.primary:disabled { 
  opacity: 0.6; 
  cursor: default; 
  box-shadow: none;
}

.error-box {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(242, 99, 75, 0.1);
  border: 1px solid rgba(242, 99, 75, 0.3);
  color: #ffb3a3;
  font-size: 0.9rem;
}

/* ---------- Auth Tabs & Hints ---------- */
.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.admin-hint {
  margin-top: 28px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(255, 122, 26, 0.08);
  border: 1px solid rgba(255, 122, 26, 0.2);
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.admin-hint code {
  color: var(--accent);
  background: rgba(255, 122, 26, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}


/* ---------- app shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

header.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  position: sticky;
  top: 0;
}

header.topbar h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

header.topbar .user-box {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

header.topbar button.logout {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
}
header.topbar button.logout:hover { 
  background: rgba(255, 255, 255, 0.1); 
  border-color: var(--border-hover); 
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
  background: rgba(11, 13, 20, 0.4);
}

.sidebar input[type="search"] { 
  margin-bottom: 24px; 
  background: rgba(0, 0, 0, 0.3);
}

.brand-group {
  animation: slideIn 0.4s ease-out backwards;
}
.brand-group:nth-child(2) { animation-delay: 0.05s; }
.brand-group:nth-child(3) { animation-delay: 0.1s; }
.brand-group:nth-child(4) { animation-delay: 0.15s; }

.brand-group h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 24px 0 12px 4px;
  font-weight: 600;
}

.manual-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.manual-item:hover { 
  background: var(--panel); 
  border-color: var(--border);
}
.manual-item.active { 
  background: var(--accent-dim); 
  border-color: rgba(255, 122, 26, 0.3);
  color: #fff; 
  font-weight: 500;
}

.manual-item .badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 600;
}
.badge.ok { background: rgba(62,207,109,0.15); color: var(--ok); }
.badge.warn { background: rgba(242,184,75,0.15); color: var(--warn); }

main.content {
  padding: 32px 48px;
  overflow-y: auto;
  position: relative;
}

.empty-state {
  color: var(--text-dim);
  margin-top: 80px;
  text-align: center;
  font-size: 1.1rem;
  animation: fadeIn 0.5s ease;
}

.manual-header {
  animation: fadeIn 0.4s ease;
}
.manual-header h2 { 
  margin: 0 0 8px; 
  font-size: 2rem;
  font-weight: 700;
}
.manual-header .meta { 
  color: var(--text-dim); 
  font-size: 0.95rem; 
}

.tabs {
  display: flex;
  gap: 16px;
  margin: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.5s ease;
}
.tabs button {
  background: transparent;
  color: var(--text-dim);
  padding: 12px 4px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-size: 1rem;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { 
  color: var(--accent); 
  border-bottom: 2px solid var(--accent); 
}

.ask-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  animation: fadeIn 0.6s ease;
  width: 100%;
}

.ask-textarea-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 56px;
}

.ask-textarea-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.1);
}

.ask-row textarea {
  flex: 1;
  min-height: 40px;
  max-height: 200px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  outline: none;
  line-height: 1.5;
}

.ask-row textarea::placeholder {
  color: var(--text-dim);
}

.ask-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 8px;
  padding-bottom: 2px;
}

.btn-mic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-mic:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.ask-row button.primary {
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  font-weight: 600;
}

.notice {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  animation: fadeIn 0.4s ease;
}
.notice.warn { background: rgba(242,184,75,0.1); color: var(--warn); border: 1px solid rgba(242,184,75,0.3); }
.notice.info { background: rgba(255,122,26,0.1); color: var(--accent); border: 1px solid rgba(255,122,26,0.3); }

.answer-box {
  margin-top: 24px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.5s ease;
}

/* resposta renderizada como markdown */
.answer-box.md { white-space: normal; }
.answer-box.md > :first-child { margin-top: 0; }
.answer-box.md > :last-child { margin-bottom: 0; }

/* Primeiro paragrafo: resposta direta destacada */
.answer-box.md p.answer-lead {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  margin: 0 0 20px;
  padding: 14px 18px;
  background: rgba(255, 122, 26, 0.07);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
}

.answer-box.md h1, .answer-box.md h2, .answer-box.md h3, .answer-box.md h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 28px 0 10px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.answer-box.md p { margin: 12px 0; }
.answer-box.md ul, .answer-box.md ol { margin: 12px 0; padding-left: 24px; }
.answer-box.md li { margin: 6px 0; }
.answer-box.md strong { color: var(--accent); font-weight: 600; }
.answer-box.md table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  width: 100%;
  font-size: 0.95rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.answer-box.md th, .answer-box.md td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
}
.answer-box.md th:last-child, .answer-box.md td:last-child { border-right: none; }
.answer-box.md tr:last-child td { border-bottom: none; }
.answer-box.md th { 
  background: rgba(255, 255, 255, 0.05); 
  color: #fff; 
  font-weight: 600; 
}
.answer-box.md tr:nth-child(even) td { background: rgba(0, 0, 0, 0.15); }
.answer-box.md tr:hover td { background: rgba(255, 122, 26, 0.05); }

.answer-box.md blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--warn);
  background: rgba(242, 184, 75, 0.08);
  border-radius: 0 8px 8px 0;
}
.answer-box.md blockquote p { margin: 0; }
.answer-box.md blockquote strong { color: var(--warn); }
.answer-box.md code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid var(--border);
  color: #e5e7eb;
}

a.pdf-link {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 122, 26, 0.1);
  border: 1px solid rgba(255, 122, 26, 0.3);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.85em;
  font-weight: 600;
  margin: 0 4px;
}
a.pdf-link:hover {
  background: rgba(255, 122, 26, 0.2);
  border-color: rgba(255, 122, 26, 0.5);
  text-decoration: none;
}
a.pdf-link::after {
  content: "↗";
  margin-left: 4px;
  font-size: 1.1em;
}

.ref-list { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; animation: fadeIn 0.5s ease; }

.ref-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ref-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}
.ref-card.cited { border-color: rgba(255, 122, 26, 0.4); background: rgba(255, 122, 26, 0.02); }

.ref-card .ref-body { flex: 1; min-width: 0; }

.ref-thumb {
  flex: 0 0 120px;
  cursor: zoom-in;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s;
}
.ref-thumb img {
  display: block;
  width: 100%;
  height: auto;
}
.ref-thumb:hover { border-color: var(--accent); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  cursor: zoom-out;
  padding: 32px 16px;
  animation: fadeIn 0.2s ease-out;
}
.lightbox-inner { max-width: 1000px; width: 100%; }
.lightbox-bar {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 12px;
  text-align: center;
}
.lightbox img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.ref-card .ref-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ref-card .page-tag {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
}
.ref-card .snippet {
  font-size: 0.9rem;
  color: #d1d5db;
  line-height: 1.5;
}
.ref-card a.open-pdf {
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 122, 26, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ---------- Hamburger / Mobile Sidebar ---------- */
.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.07); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* ---------- Bottom tab bar (mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(11,13,20,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 8px 16px max(8px, env(safe-area-inset-bottom));
  flex-direction: row;
  gap: 8px;
}
.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 52px;
}
.bottom-nav-btn .bn-icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.bottom-nav-btn:hover { color: var(--text); }

@media (max-width: 768px) {
  /* Header compacto */
  header.topbar {
    padding: 12px 16px;
    gap: 10px;
  }
  header.topbar h1 {
    font-size: 1rem;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  header.topbar .user-box {
    gap: 8px;
    flex-shrink: 0;
  }
  /* Ocultar textos secundários no mobile */
  #username-label { display: none; }
  .btn-secondary span.btn-text { display: none; }

  .hamburger-btn { display: flex; }

  /* Sidebar como drawer lateral */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 82vw;
    max-width: 320px;
    height: 100dvh;
    z-index: 50;
    border-right: 1px solid var(--border);
    border-bottom: none;
    max-height: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding-top: 20px;
    background: rgba(11, 13, 20, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .sidebar.open { left: 0; }
  .sidebar-close-btn {
    display: flex;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 1.1rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  main.content {
    padding: 20px 16px;
    padding-bottom: 88px; /* space for bottom nav */
    overflow-y: auto;
  }

  .manual-header h2 { font-size: 1.5rem; }

  .tabs { display: none; } /* substituído pela bottom nav */

  .bottom-nav { display: flex; }

  /* Ask row vertical */


  /* Ref cards vertical */
  .ref-card { flex-direction: column; }
  .ref-thumb { width: 100%; max-width: none; flex: none; }
  .ref-thumb img { max-height: 200px; object-fit: contain; }

  /* Modal fullscreen no mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-card {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 24px 20px;
  }

  /* Lightbox */
  .lightbox { padding: 16px 8px; }
  .lightbox-inner { max-width: 100%; }

  /* Filtro */
  .sidebar input[type="search"] { margin-bottom: 16px; }

  .answer-box { padding: 18px; }
}

/* ---------- Botões Adicionais & Links ---------- */
.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn-admin {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-admin:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  color: #93c5fd;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Modal Styles ---------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: #131722;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 8px;
}
.modal-close:hover { color: var(--text); }
.modal-desc {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  margin-bottom: 6px;
}

.form-status {
  margin-top: 12px;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 6px;
  display: none;
}
.form-status.loading { display: block; background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.form-status.success { display: block; background: rgba(62, 207, 109, 0.15); color: var(--ok); }
.form-status.error { display: block; background: rgba(242, 99, 75, 0.15); color: var(--danger); }

/* ---------- Admin Dashboard Styles ---------- */
.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-link {
  font-size: 0.9rem;
  color: var(--text-dim);
  text-decoration: none;
}
.back-link:hover { color: var(--accent); }

.admin-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-title {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  backdrop-filter: blur(10px);
}
.admin-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.admin-card .card-header h2 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
}

.badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}
.admin-table th, .admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.badge-status {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending { background: rgba(242, 184, 75, 0.15); color: var(--warn); }
.status-approved { background: rgba(62, 207, 109, 0.15); color: var(--ok); }
.status-rejected { background: rgba(242, 99, 75, 0.15); color: var(--danger); }

.btn-action {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-right: 6px;
}
.btn-action.approve { background: var(--ok); color: #000; font-weight: 600; }
.btn-action.reject { background: rgba(242, 99, 75, 0.2); color: var(--danger); border: 1px solid rgba(242, 99, 75, 0.4); }
.btn-action.delete { background: rgba(242, 99, 75, 0.15); color: var(--danger); }
.btn-action.view { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); text-decoration: none; display: inline-block; }
.btn-action:hover { opacity: 0.85; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.empty-text, .loading-text {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 16px 0;
}

/* ---------- Voice Input ---------- */
@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: 0.8; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes mic-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.btn-mic {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

.btn-mic:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: var(--text);
  transform: scale(1.05);
}

.btn-mic:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Estado: gravando */
.btn-mic.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
  animation: mic-glow 1.5s ease-in-out infinite;
}

.btn-mic.recording svg {
  animation: pulse-ring 1.5s ease-in-out infinite;
}

/* Feedback visual na caixa de texto quando está a ouvir */
.ask-textarea-wrap.is-listening textarea {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  background: var(--bg);
}

/* Tooltip de voz */
.voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  min-height: 22px;
  animation: fadeIn 0.3s ease;
  transition: opacity 0.3s;
}

.voice-status .voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f87171;
  flex-shrink: 0;
  animation: mic-glow 1s ease-in-out infinite;
}

.voice-status.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Wrapper do textarea + mic */
.ask-textarea-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Badge de não suportado */
.voice-unsupported {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 6px;
}

/* ---------- Plan Cards (login register + admin) ---------- */
.plan-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 8px;
}

.plan-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.plan-card:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.03);
}

.plan-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(255,122,26,0.12);
}

.plan-card input[type="radio"] {
  display: none;
}

.plan-radio-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.plan-card.selected .plan-radio-dot {
  border-color: var(--accent);
  background: var(--accent);
}
.plan-card.selected .plan-radio-dot::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}

.plan-card-body { flex: 1; }

.plan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.plan-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.plan-card-price {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.plan-card-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Seção de seleção de moto (plano proprietário) */
.plan-moto-select {
  margin-top: 12px;
  animation: fadeIn 0.3s ease;
}
.plan-moto-select label {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.plan-moto-select select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.plan-moto-select select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,122,26,0.2);
}

/* Banner de plano ativo no app */
.plan-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(255,122,26,0.25);
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
}
.plan-banner strong { color: var(--text); }

/* Select modal para proprietário escolher moto */
.select-manual-modal {
  text-align: center;
}
.select-manual-modal h2 { margin-bottom: 8px; }
.select-manual-modal .modal-desc { margin-bottom: 20px; }
.select-manual-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 20px;
}
.select-manual-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  background: rgba(0,0,0,0.1);
}
.select-manual-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.select-manual-item .moto-icon { font-size: 1.4rem; }
.select-manual-item .moto-info strong { display: block; font-size: 0.95rem; }
.select-manual-item .moto-info span { font-size: 0.8rem; color: var(--text-dim); }

/* Sidebar close btn (hidden on desktop) */
.sidebar-close-btn { display: none; }

/* Users table in admin */
.user-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.user-plan-badge.plan-owner {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}
.user-plan-badge.plan-mechanic {
  background: rgba(62,207,109,0.15);
  color: var(--ok);
}
.user-plan-badge.plan-none {
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
}

/* Admin plan cards */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.admin-plan-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
}
.admin-plan-card:hover { border-color: var(--border-hover); }
.admin-plan-card .plan-name {
  font-size: 1.1rem;
  font-weight: 700;
}
.admin-plan-card .plan-price {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}
.admin-plan-card .plan-price span {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
}
.admin-plan-card .plan-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  flex: 1;
}
.admin-plan-card .plan-actions {
  display: flex;
  gap: 8px;
}
