/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --bg:         #0f0f13;
  --surface:    #17171e;
  --surface2:   #1e1e28;
  --border:     rgba(255,255,255,0.06);
  --text:       #e8e8f0;
  --text-muted: #7c7c9a;
  --primary:    #6366f1;
  --primary-h:  #818cf8;
  --accent:     #8b5cf6;
  --red:        #ef4444;
  --green:      #22c55e;
  --blue:       #3b82f6;
  --yellow:     #f59e0b;
  --sidebar-w:  240px;
  --radius:     12px;
  --radius-sm:  8px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ─────────────────────────────────────────────────── */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }

.login-bg { position: fixed; inset: 0; z-index: 0; }
.bg-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .25; }
.orb1 { width: 500px; height: 500px; background: var(--primary); top: -100px; left: -100px; animation: float 8s ease-in-out infinite; }
.orb2 { width: 400px; height: 400px; background: var(--accent); bottom: -100px; right: -100px; animation: float 10s ease-in-out infinite reverse; }
.bg-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px); background-size: 40px 40px; }

@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-30px); } }

.login-container { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 20px; }

.glass { background: rgba(23,23,30,.8); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,.08); }

.login-card { border-radius: 20px; padding: 40px; }

.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.login-title { font-size: 1.4rem; font-weight: 700; }
.login-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.logo-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.logo-icon.small { width: 32px; height: 32px; }
.logo-icon.small svg { width: 22px; height: 22px; }

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; letter-spacing: .03em; text-transform: uppercase; }

.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.form-input { width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 12px 42px; color: var(--text); font-size: .9rem; font-family: inherit; transition: border-color .2s, box-shadow .2s; outline: none; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-input::placeholder { color: var(--text-muted); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; font-family: inherit; cursor: pointer; border: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99,102,241,.4); }
.btn-secondary { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,.1); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.15); }
.btn-success { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.25); }
.btn-success:hover { background: rgba(34,197,94,.25); }
.btn-full { width: 100%; justify-content: center; padding: 13px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 20px; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }

.login-footer { text-align: center; font-size: .75rem; color: var(--text-muted); margin-top: 28px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); min-height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }

.sidebar-header { padding: 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-brand { font-size: .95rem; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: .875rem; font-weight: 500; text-decoration: none; transition: all .2s; cursor: pointer; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.12); color: var(--primary-h); }
.nav-item.active svg { stroke: var(--primary-h); }

.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 999px; min-width: 20px; text-align: center; }
.nav-badge[data-count="0"] { display: none; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .7rem; color: var(--text-muted); }
.btn-logout { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; transition: color .2s, background .2s; }
.btn-logout:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── Main Content ──────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar { padding: 24px 28px 0; display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 1.4rem; font-weight: 700; }
.page-subtitle { display: block; font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

.sync-status { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Pages ─────────────────────────────────────────────────── */
.page { display: none; padding: 0 28px 28px; }
.page.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media(max-width: 1100px) { .cards-grid { grid-template-columns: repeat(2,1fr); } }

.metric-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.metric-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.metric-icon.red    { background: rgba(239,68,68,.1);    color: var(--red);    }
.metric-icon.purple { background: rgba(139,92,246,.1);   color: var(--accent); }
.metric-icon.blue   { background: rgba(59,130,246,.1);   color: var(--blue);   }
.metric-icon.green  { background: rgba(34,197,94,.1);    color: var(--green);  }

.metric-body { flex: 1; min-width: 0; }
.metric-label { display: block; font-size: .72rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.metric-value { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.metric-value.small { font-size: 1rem; font-weight: 600; }

.cards-row { display: flex; gap: 16px; margin-bottom: 20px; }
.flex-1 { flex: 1; }

.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 16px 20px; }

.badge-count { font-size: .75rem; color: var(--text-muted); background: var(--surface2); padding: 3px 10px; border-radius: 999px; }

/* ── Portador List ─────────────────────────────────────────── */
.portador-list { display: flex; flex-direction: column; gap: 10px; }
.portador-item { display: flex; align-items: center; gap: 12px; }
.portador-name { flex: 1; font-size: .85rem; }
.portador-bar-wrap { flex: 2; height: 6px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.portador-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .6s ease; }
.portador-val { font-size: .8rem; color: var(--text-muted); white-space: nowrap; width: 90px; text-align: right; }

/* ── Últimos Estornos ──────────────────────────────────────── */
.estorno-mini { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .83rem; }
.estorno-mini:last-child { border-bottom: none; }
.estorno-mini-left { display: flex; flex-direction: column; gap: 2px; }
.estorno-mini-name { font-weight: 500; }
.estorno-mini-sub { color: var(--text-muted); font-size: .76rem; }
.estorno-mini-val { font-weight: 600; color: var(--red); }

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-input { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px; color: var(--text); font-size: .85rem; font-family: inherit; outline: none; transition: border-color .2s; }
.filter-input:focus { border-color: var(--primary); }
.filter-input::placeholder { color: var(--text-muted); }
.toolbar-actions { display: flex; gap: 8px; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.data-table th { padding: 12px 16px; text-align: left; font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.02); }

.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .73rem; font-weight: 600; }
.tag-red    { background: rgba(239,68,68,.12); color: #fca5a5; }
.tag-yellow { background: rgba(245,158,11,.12); color: #fcd34d; }
.tag-gray   { background: rgba(255,255,255,.06); color: var(--text-muted); }

.empty-state { text-align: center; color: var(--text-muted); padding: 48px 20px !important; font-size: .9rem; }

.table-footer { padding: 14px 20px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text-muted); }

/* ── Skeletons ─────────────────────────────────────────────── */
.skeleton-row { height: 44px; background: linear-gradient(90deg, var(--surface2) 25%, rgba(255,255,255,.04) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); margin-bottom: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Scan Overlay ──────────────────────────────────────────── */
.scan-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.scan-card { padding: 40px; border-radius: 20px; text-align: center; max-width: 360px; }
.scan-card h3 { margin: 16px 0 8px; font-size: 1.1rem; }
.scan-card p { color: var(--text-muted); font-size: .9rem; }

/* ── Bulk Actions Bar ──────────────────────────────────────── */
.bulk-actions-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 46, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  z-index: 100;
  backdrop-filter: blur(12px);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
  from { transform: translate(-50%, 100px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.bulk-info {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cdd6f4;
  white-space: nowrap;
}

.bulk-buttons {
  display: flex;
  gap: 8px;
}
