﻿/* ── TEMA CLARO ──────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --primary:            #1565c0;
  --primary-dark:       #0d47a1;
  --primary-light:      #2979d4;
  --sidebar-bg:         #ffffff;
  --sidebar-border:     #e8e2d4;
  --sidebar-heading:    #111827;
  --sidebar-text:       #374151;
  --sidebar-active-bg:  rgba(21,101,192,.10);
  --sidebar-active-txt: #1565c0;
  --sidebar-hover-bg:   rgba(0,0,0,.04);
  --sidebar-hover-txt:  #111827;
  --sidebar-section:    #9ca3af;
  --bg:                 #faf8f4;
  --surface:            #ffffff;
  --text:               #1d1d1f;
  --text-muted:         #6e6e73;
  --border:             #e3ddd0;
  --danger:             #dc3545;
  --warning:            #d97706;
  --radius:             8px;
  --shadow:             0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:          0 4px 16px rgba(0,0,0,.10);
  --success:            #16a34a;
}

/* ── TEMA ESCURO ─────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;
  --primary:            #60a5fa;
  --primary-dark:       #3b82f6;
  --primary-light:      #93c5fd;
  --sidebar-bg:         #0f1117;
  --sidebar-border:     rgba(255,255,255,.07);
  --sidebar-heading:    #ffffff;
  --sidebar-text:       #c4d4e8;
  --sidebar-active-bg:  rgba(96,165,250,.18);
  --sidebar-active-txt: #60a5fa;
  --sidebar-hover-bg:   rgba(255,255,255,.06);
  --sidebar-hover-txt:  #ffffff;
  --sidebar-section:    #4a6480;
  --bg:                 #09090b;
  --surface:            #18181b;
  --text:               #f4f4f5;
  --text-muted:         #a1a1aa;
  --border:             #27272a;
  --shadow:             0 1px 4px rgba(0,0,0,.5);
  --shadow-md:          0 4px 20px rgba(0,0,0,.6);
  --success:            #22c55e;
}

/* ── Overrides escuro — elementos com cor hardcoded ─────────── */
[data-theme="dark"] .topbar {
  background: #111113;
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .topbar-title   { color: var(--text); }
[data-theme="dark"] .topbar-subtitle{ color: var(--text-muted); }

[data-theme="dark"] .card-metric,
[data-theme="dark"] .page-card,
[data-theme="dark"] .form-card,
[data-theme="dark"] .section-card,
[data-theme="dark"] .card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .card-metric .label { color: var(--text-muted); }
[data-theme="dark"] .card-metric .value { color: var(--text); }

[data-theme="dark"] .tabela thead th {
  background: #111113;
  color: var(--text-muted);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .tabela tbody tr     { background: var(--surface); }
[data-theme="dark"] .tabela tbody tr:hover { background: #1f1f23; }
[data-theme="dark"] .tabela td           { border-bottom-color: var(--border); color: var(--text); }

[data-theme="dark"] .filter-bar { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-control,
[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] textarea {
  background: #111113;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] select option { color: var(--text-muted); background: #111113; }

[data-theme="dark"] .btn-outline {
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .btn-secondary {
  background: #27272a;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .alerta-card             { background: #1c1500; border-color: #3d2e00; }
[data-theme="dark"] .alerta-card th          { background: #1c1500; color: #d4a820; }
[data-theme="dark"] .alerta-card td          { color: var(--text); border-color: #3d2e00; }

[data-theme="dark"] .modal               { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .modal-header        { border-bottom-color: var(--border); }
[data-theme="dark"] .modal-footer        { border-top-color: var(--border); }

[data-theme="dark"] .login-wrapper {
  background: linear-gradient(135deg, #1565c0 0%, #09090b 100%);
}

[data-theme="dark"] .notif-btn          { background: #111113; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .notif-dropdown     { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .notif-header       { background: #111113; border-color: var(--border); }
[data-theme="dark"] .notif-item         { border-color: var(--border); }
[data-theme="dark"] .notif-item:hover   { background: #1f1f23; }
[data-theme="dark"] .notif-unread       { background: rgba(96,165,250,.08); }
[data-theme="dark"] .notif-unread:hover { background: rgba(96,165,250,.14); }
[data-theme="dark"] .notif-item-title   { color: var(--text); }

[data-theme="dark"] .busca-global-input-wrap { background: #111113; border-color: var(--border); }
[data-theme="dark"] .busca-global-input-wrap:focus-within { background: #1a1a1e; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(96,165,250,.15); }
[data-theme="dark"] .busca-global-input     { background: transparent; color: var(--text); }
[data-theme="dark"] .busca-global-input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .busca-global-icon      { color: var(--text-muted); }
[data-theme="dark"] .busca-global-dropdown  { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .bg-item:hover,
[data-theme="dark"] .bg-active              { background: #1f1f23; }
[data-theme="dark"] .bg-label              { color: var(--text); }
[data-theme="dark"] .bg-sub               { color: var(--text-muted); }

/* Tabelas simples (sem .tabela) */
[data-theme="dark"] thead th               { background: #111113; color: var(--text-muted); border-bottom-color: var(--border); }
[data-theme="dark"] tbody tr               { background: var(--surface); }
[data-theme="dark"] tbody tr:hover         { background: #1f1f23; }
[data-theme="dark"] tbody td               { border-bottom-color: var(--border); color: var(--text); }

/* Notificações */
[data-theme="dark"] .notif-btn             { background: #111113; border-color: var(--border); }
[data-theme="dark"] .notif-btn:hover       { background: #1f1f23; color: var(--text); }
[data-theme="dark"] .notif-badge           { border-color: var(--surface); }

/* Botão outline hover */
[data-theme="dark"] .btn-outline:hover     { background: rgba(96,165,250,.08); border-color: var(--primary); color: var(--primary); }

/* Upload zone */
[data-theme="dark"] .upload-zone           { border-color: var(--border); background: #111113; color: var(--text); }
[data-theme="dark"] .upload-zone:hover     { border-color: var(--primary); background: rgba(96,165,250,.05); }

/* Profile chip */
[data-theme="dark"] .profile-chip          { background: rgba(255,255,255,.07); color: var(--text-muted); }

/* Busca global clear */
[data-theme="dark"] .busca-global-clear:hover { color: var(--text-muted); }

/* ── Botão de tema ──────────────────────────────────────────── */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .2s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1565c0 0%, #0a1929 100%);
  padding: 24px 16px;
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .icon {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-logo .icon svg { color: #fff; }

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 22px 16px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  text-align: center;
}

.sidebar-brand h2 {
  font-size: 13px;
  font-weight: 800;
  color: var(--sidebar-heading);
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1.2;
}

.sidebar-brand span {
  display: block;
  font-size: 10.5px;
  color: var(--sidebar-section);
  font-weight: 400;
  letter-spacing: .04em;
  margin-top: 3px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--sidebar-section);
  padding: 18px 20px 5px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0 8px 8px 0;
  margin-right: 8px;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-txt);
  text-decoration: none;
}
.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-txt);
  font-weight: 600;
  text-decoration: none;
}
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-nav a svg { flex-shrink: 0; opacity: .65; transition: opacity .15s; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--sidebar-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.sidebar-user-info .role {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sidebar-active-txt);
  background: var(--sidebar-active-bg);
  padding: 1px 7px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 2px;
  text-transform: capitalize;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--sidebar-text);
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  width: 100%;
  transition: background .15s, color .15s;
}

.btn-logout:hover {
  background: rgba(220,53,69,.1);
  color: #dc2626;
  text-decoration: none;
}

.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.page-body { padding: 28px; flex: 1; background: var(--bg); }

/* ── STAT CARDS ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card.orange { border-left-color: #f59e0b; }
.stat-card.blue   { border-left-color: #3b82f6; }
.stat-card.gray   { border-left-color: #9ca3af; }

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); }

/* ── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h3 { font-size: 15px; font-weight: 600; flex: 1; }

.card-body { padding: 20px; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,.18);
}

select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { filter: brightness(.92); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }
.btn-block   { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f9fbfa;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f4f2;
  font-size: 13.5px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fbfa; }

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.badge-pendente   { background: #fef3cd; color: #92400e; }
.badge-em_analise { background: #dbeafe; color: #1e40af; }
.badge-disponivel { background: #d1fae5; color: #065f46; }
.badge-arquivado  { background: #f3f4f6; color: #4b5563; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-danger  { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.alert-success { background: #f0fdf4; color: #065f46; border-color: #22c55e; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }

/* ── FILTERS ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.filter-bar .form-control { font-size: 13px; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h3 { font-size: 16px; font-weight: 700; flex: 1; }
.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.btn-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px; line-height: 1;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── UPLOAD AREA ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(21,101,192,.04);
}

.upload-zone p { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* ── PROFILE BADGE ───────────────────────────────────────── */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(21,101,192,.10);
  color: var(--primary-dark);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ── CODE inline ─────────────────────────────────────────── */
code {
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: .875em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}

/* ── EXAM CARD (paciente) ────────────────────────────────── */
.exam-cards { display: grid; gap: 12px; }

.exam-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .18s, transform .18s;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.exam-card-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: rgba(21,101,192,.10);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exam-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.exam-card-info { flex: 1; min-width: 0; }
.exam-card-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-card-info p  { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.exam-card-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

/* ── UTIL ────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ms-auto { margin-left: auto; }

/* Alias para labels com classe explícita */
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

/* ── MOBILE HAMBURGER + OVERLAY ──────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
}

.sidebar-toggle:hover { background: var(--border); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

.sidebar-overlay.open { display: block; }

/* ── PAGINAÇÃO ────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; flex-wrap: wrap;
  padding: 16px;
}
.pagination .btn { min-width: 36px; text-align: center; }
.pag-ellipsis { color: var(--text-muted); padding: 0 2px; line-height: 32px; }
.pag-info     { font-size: 12.5px; color: var(--text-muted); margin-left: 6px; }

/* ── TOASTS ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 8500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border-radius: 8px;
  padding: 13px 16px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.14);
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 260px; max-width: 360px;
  pointer-events: auto;
  transform: translateX(calc(100% + 28px));
  transition: transform .28s ease;
  position: relative; overflow: hidden;
}
.toast.show { transform: translateX(0); }
.toast-body { flex: 1; font-size: 13.5px; color: var(--text); line-height: 1.4; }
.toast-close {
  cursor: pointer; opacity: .45; background: none; border: none;
  padding: 0; font-size: 14px; line-height: 1; color: var(--text);
  flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
.toast-bar {
  position: absolute; bottom: 0; left: 0; height: 3px;
  animation: toast-shrink 4s linear forwards;
}
@keyframes toast-shrink { from { width: 100%; } to { width: 0; } }
.toast-success { border-left: 4px solid #16a34a; }
.toast-success svg, .toast-success .toast-bar { color: #16a34a; background: #16a34a; }
.toast-danger  { border-left: 4px solid var(--danger, #dc2626); }
.toast-danger  svg, .toast-danger  .toast-bar { color: #dc2626; background: #dc2626; }
.toast-warning { border-left: 4px solid #d97706; }
.toast-warning svg, .toast-warning .toast-bar { color: #d97706; background: #d97706; }
.toast-info    { border-left: 4px solid var(--primary); }
.toast-info    svg, .toast-info    .toast-bar { color: var(--primary); background: var(--primary); }

/* ── NOTIFICAÇÕES IN-APP ──────────────────────────────────── */
.notif-bell { position: relative; margin-left: auto; flex-shrink: 0; }
.notif-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border, #e5e7eb);
    background: #fff; color: var(--text-muted, #6b7280); cursor: pointer;
    position: relative; transition: background .15s, color .15s;
}
.notif-btn:hover { background: #f3f4f6; color: var(--text, #111827); }
.notif-badge {
    position: absolute; top: -5px; right: -5px;
    min-width: 17px; height: 17px; border-radius: 20px;
    background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; border: 2px solid #fff; pointer-events: none;
}
.notif-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 200;
    width: 320px; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
    overflow: hidden;
}
.notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.notif-header-title { font-size: 13px; font-weight: 700; color: var(--text, #111827); }
.notif-mark-all {
    font-size: 11.5px; color: var(--primary, #1565c0); background: none;
    border: none; cursor: pointer; padding: 0; font-weight: 500;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: #9ca3af; }
.notif-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background .1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-unread { background: #eff6ff; }
.notif-unread:hover { background: #dbeafe; }
[data-theme="dark"] .notif-unread { background: #1e3a5f; }
[data-theme="dark"] .notif-unread:hover { background: #1e40af33; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-item-text { font-size: 12px; color: var(--muted); margin-bottom: 4px; line-height: 1.45; }
.notif-item-time { font-size: 11px; color: var(--muted); }

/* ── BUSCA GLOBAL ─────────────────────────────────────────── */
.busca-global-wrap {
    position: relative;
    margin-left: auto;
    flex-shrink: 1;
    min-width: 0;
}
.busca-global-input-wrap {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0 10px;
    gap: 6px;
    height: 34px;
    transition: border-color .15s, box-shadow .15s;
    width: 220px;
    max-width: 220px;
}
.busca-global-input-wrap:focus-within {
    border-color: #1565c0;
    box-shadow: 0 0 0 3px rgba(21,101,192,.15);
    background: #fff;
    width: 280px;
    max-width: 280px;
}
.busca-global-icon { flex-shrink: 0; color: #9ca3af; }
.busca-global-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: #111827;
    width: 100%;
    min-width: 0;
}
.busca-global-input::placeholder { color: #9ca3af; }
.busca-global-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.busca-global-clear:hover { color: #374151; }

.busca-global-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 300;
    width: 360px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}
.bg-loading, .bg-empty {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}
.bg-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f3f4f6;
    transition: background .1s;
}
.bg-item:last-child { border-bottom: none; }
.bg-item:hover, .bg-active { background: #f9fafb !important; }
.bg-icone { flex-shrink: 0; display: flex; align-items: center; }
.bg-body { flex: 1; min-width: 0; }
.bg-label { display: block; font-size: 13px; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-sub { display: block; font-size: 11px; color: #9ca3af; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.bg-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #d1d5db; }
.bg-status { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 10px; white-space: nowrap; }

@media (max-width: 768px) {
    .busca-global-wrap { display: none; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar como drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }

  /* Layout */
  .main-content { margin-left: 0; }

  /* Hamburger visível */
  .sidebar-toggle { display: flex; }

  /* Topbar */
  .topbar { padding: 0 16px; flex-wrap: wrap; min-height: 56px; height: auto; gap: 8px; }

  /* Page body */
  .page-body { padding: 16px; }

  /* Cards */
  .card-body { padding: 16px; }
  .modal-overlay { padding: 12px; align-items: flex-start; padding-top: 40px; }
  .modal { max-width: 100%; max-height: calc(100vh - 80px); }
  .modal-body   { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Grids */
  .form-row   { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Filtros */
  .filter-bar { gap: 8px; }
  .filter-bar .form-group { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }

  /* Topbar — esconde botões secundários redundantes em mobile */
  .topbar-actions-hide { display: none !important; }
}

/* ── Spinner de carregamento de página ───────────────────────── */
@keyframes pg-spin {
  to { transform: rotate(360deg); }
}
.pg-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pg-spin .7s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════
   MELHORIAS VISUAIS — v20260701a
   ═══════════════════════════════════════════════════════════════ */

/* ── Transições globais suaves ──────────────────────────────── */
.btn           { transition: background .15s, color .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.form-control  { transition: border-color .15s, box-shadow .15s; }
.card          { transition: box-shadow .2s; }
.sidebar-item  { transition: background .12s, color .12s; }
.badge         { transition: opacity .15s; }

/* ── Modal com animação ─────────────────────────────────────── */
.modal-overlay {
  opacity: 0;
  transition: opacity .2s ease;
}
.modal-overlay.open {
  display: flex;
  opacity: 1;
}
.modal {
  transform: translateY(-16px) scale(.98);
  transition: transform .22s ease, opacity .22s ease;
  opacity: 0;
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── Botão com estado loading ───────────────────────────────── */
.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pg-spin .65s linear infinite;
}
.btn-outline.btn-loading::after {
  border-color: var(--border);
  border-top-color: var(--primary);
}

/* ── Zebra rows nas tabelas ─────────────────────────────────── */
table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface) 100%, var(--bg) 0%); }
[data-theme="dark"] table tbody tr:nth-child(even) { background: rgba(255,255,255,.025); }

/* ── Cabeçalho de tabela sticky ─────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table-wrapper table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* ── Focus ring acessível ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Input com erro ─────────────────────────────────────────── */
.form-control.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,53,69,.12);
}
.form-hint-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── Scrollbar personalizada ────────────────────────────────── */
::-webkit-scrollbar              { width: 8px; height: 8px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: var(--text-muted); }

/* ── Dark mode: badges ──────────────────────────────────────── */
[data-theme="dark"] .badge-pendente   { background: rgba(146,64,14,.25);  color: #fbbf24; }
[data-theme="dark"] .badge-em_analise { background: rgba(30,64,175,.25);  color: #93c5fd; }
[data-theme="dark"] .badge-disponivel { background: rgba(6,95,70,.3);     color: #6ee7b7; }
[data-theme="dark"] .badge-arquivado  { background: rgba(75,85,99,.25);   color: #9ca3af; }

/* ── Dark mode: alertas ─────────────────────────────────────── */
[data-theme="dark"] .alert-danger  { background: rgba(220,53,69,.15);  color: #fca5a5; border-color: #dc2626; }
[data-theme="dark"] .alert-success { background: rgba(22,163,74,.15);  color: #86efac; border-color: #16a34a; }
[data-theme="dark"] .alert-info    { background: rgba(59,130,246,.15); color: #93c5fd; border-color: #3b82f6; }

/* ── Dark mode: notificações ────────────────────────────────── */
[data-theme="dark"] .notif-btn             { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .notif-btn:hover       { background: var(--bg);      color: var(--text); }
[data-theme="dark"] .notif-badge           { border-color: var(--surface); }
[data-theme="dark"] .notif-dropdown        { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .notif-header          { background: var(--bg); border-color: var(--border); }
[data-theme="dark"] .notif-empty           { color: var(--text-muted); }

/* ── Dark mode: busca global ────────────────────────────────── */
[data-theme="dark"] .busca-global-input-wrap         { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .busca-global-input-wrap:focus-within { background: var(--bg); border-color: var(--primary); }
[data-theme="dark"] .busca-global-input              { color: var(--text); }
[data-theme="dark"] .busca-global-icon,
[data-theme="dark"] .busca-global-clear              { color: var(--text-muted); }
[data-theme="dark"] .busca-global-clear:hover        { color: var(--text); }
[data-theme="dark"] .busca-global-dropdown           { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .bg-item:hover,
[data-theme="dark"] .bg-active                       { background: var(--bg) !important; }
[data-theme="dark"] .bg-label                        { color: var(--text); }
[data-theme="dark"] .bg-sub,
[data-theme="dark"] .bg-cat                          { color: var(--text-muted); }
[data-theme="dark"] .bg-loading,
[data-theme="dark"] .bg-empty                        { color: var(--text-muted); }
[data-theme="dark"] .bg-item                         { border-color: var(--border); }

/* ── Status inline (badge clicável) ────────────────────────── */
.status-inline {
  position: relative;
  display: inline-flex;
}
.status-inline .badge {
  cursor: pointer;
  user-select: none;
}
.status-inline .badge:hover { opacity: .82; }
.status-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.14);
  min-width: 150px;
  overflow: hidden;
  display: none;
}
.status-popover.open { display: block; }
.status-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.status-popover-item:hover { background: var(--bg); }
.status-popover-item.current { font-weight: 700; pointer-events: none; opacity: .55; }
.status-popover-title {
  padding: 6px 12px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* ── Linha de tabela hover highlight ────────────────────────── */
table tbody tr { transition: background .1s; }
table tbody tr:hover { background: color-mix(in srgb, var(--primary) 6%, transparent) !important; }

/* ── Card hover elevation ───────────────────────────────────── */
.stat-card:hover { box-shadow: var(--shadow-md); }

/* ── Botão logout cor correta ───────────────────────────────── */
.btn-logout:hover { color: #ff8585; }

/* ── Topbar sticky aprimorada ───────────────────────────────── */
.topbar { backdrop-filter: blur(8px); }

/* ── Assinatura ASBOT ───────────────────────────────────────── */
.asbot-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  opacity: .7;
  letter-spacing: .02em;
  user-select: none;
}
.asbot-credit:hover { opacity: 1; }
.asbot-credit a { color: inherit; text-decoration: none; }
.asbot-credit a:hover { color: var(--primary); }
.asbot-credit svg { flex-shrink: 0; }
.asbot-credit .asbot-name {
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 11px;
}
.asbot-credit .asbot-sub {
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 9px;
  opacity: .75;
}

/* sidebar variant — texto adapta ao fundo */
.sidebar .asbot-credit {
  padding: 10px 20px 4px;
  justify-content: flex-start;
  color: var(--sidebar-text);
}
.sidebar .asbot-credit:hover { color: var(--sidebar-hover-txt); }

/* page-footer */
.page-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.page-footer .asbot-credit { opacity: 1; }

/* ── Empty state melhorado ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { opacity: .35; margin-bottom: 12px; }
.empty-state p   { font-size: 14px; margin-bottom: 16px; }
.empty-state .empty-cta { margin-top: 8px; }
