:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #65708a;
  --border: #dfe5ef;
  --primary: #2448ff;
  --primary-light: #eef2ff;
  --danger: #b42318;
  --danger-light: #fef3f2;
  --success: #027a48;
  --success-light: #ecfdf3;
  --warning: #b54708;
  --warning-light: #fffaeb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar / Header ────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Logo circular azul + VMA */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-circle {
  width: 36px;
  height: 36px;
  background: #0A4D8F;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-check {
  color: white;
  font-size: 18px;
  font-weight: bold;
}
.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #0F2942;
  letter-spacing: -0.5px;
}

/* Centro: Título e navegação */
.topbar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #0F2942;
}
.topbar-nav {
  display: flex;
  gap: 4px;
}
.nav-link {
  padding: 4px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary); color: white; }

/* Direita: Status badge + Usuário */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.status-badge {
  font-size: 12px;
  font-weight: 700;
  color: #027A48;
  background: #ECFDF3;
  padding: 6px 12px;
  border-radius: 8px;
}
.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-company { font-size: 11px; color: var(--muted); }

/* ── Container ──────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

/* ── Cards / Panels ─────────────────────────────────────────── */
.auth-card, .panel, .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
}
.auth-card {
  max-width: 460px;
  margin: 48px auto;
  padding: 28px;
}
.panel { padding: 20px; overflow-x: auto; margin-bottom: 18px; }
.panel-warning { border-left: 4px solid #f59e0b; }
.panel-danger { border-left: 4px solid #ef4444; }

/* ── Page Head ──────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 22px; }
.page-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 14px; }
input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 6px;
  font-size: 14px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-secondary { background: var(--primary-light); color: #28314a; }
.btn-secondary:hover { background: #dde4ff; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-download { background: #e0e7ff; color: var(--primary); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }
.muted { color: var(--muted); }

/* ── Stats Grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stats-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { padding: 20px; transition: transform 0.1s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-card-green { border-left: 4px solid #16a34a; }
.stat-card-yellow { border-left: 4px solid #f59e0b; }
.stat-card-red { border-left: 4px solid #ef4444; }
.stat-label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 13px; }
.stat-value { font-size: 32px; font-weight: 700; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-muted { background: #f1f5f9; color: #94a3b8; }
.badge-type { background: #f0f0ff; color: #4338ca; text-transform: capitalize; }
.badge-obsolete { background: #6b7280; color: white; }
.badge-client { background: #dbeafe; color: #1e40af; font-size: 9px; margin-left: 6px; }

/* ── Dots (status indicators) ────────────────────────────────── */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}
.dot-green { background: #16a34a; }
.dot-yellow { background: #f59e0b; }
.dot-red { background: #ef4444; }
.dot-gray { background: #cbd5e1; }
.dot-obsolete { background: #6b7280; }

/* ── Document Legend + Filter Buttons ───────────────────────────── */
.doc-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.doc-count { margin-left: auto; font-weight: 600; color: var(--text); font-size: 12px; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-btn.active .dot { outline: 2px solid rgba(255,255,255,0.5); }

.filter-btn.filter-green.active  { background: #16a34a; border-color: #16a34a; }
.filter-btn.filter-yellow.active { background: #d97706; border-color: #d97706; }
.filter-btn.filter-red.active    { background: #dc2626; border-color: #dc2626; }
.filter-btn.filter-gray.active   { background: #64748b; border-color: #64748b; }

.filter-btn.filter-green:hover  { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.filter-btn.filter-yellow:hover { border-color: #d97706; color: #d97706; background: #fffbeb; }
.filter-btn.filter-red:hover    { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.filter-btn.filter-gray:hover   { border-color: #64748b; color: #64748b; background: #f8fafc; }
.filter-btn.filter-obsolete:hover { border-color: #6b7280; color: #6b7280; background: #f3f4f6; }

.filter-btn.filter-obsolete.active { background: #6b7280; border-color: #6b7280; }

tr.row-obsolete { background: #f3f4f6; opacity: 0.7; }
tr.row-obsolete td { text-decoration: line-through; color: #6b7280; }
tr.row-obsolete .badge-type { text-decoration: none; }
tr.row-obsolete .badge-client { text-decoration: none; }

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(0,0,0,0.08);
  font-size: 11px;
  font-weight: 700;
}
.filter-btn.active .filter-count { background: rgba(255,255,255,0.25); }

/* ── Tables ──────────────────────────────────────────────────── */
.search-row { display: flex; gap: 12px; margin-bottom: 16px; }
.search-row input { margin-top: 0; flex: 1; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.3px;
}
td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
tr:hover { background: #f8fafc; }
tr.row-expired { background: #fef2f2; }
tr.row-expiring { background: #fffbeb; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px !important; }

/* ── Detail Grid ─────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}
.detail-full { grid-column: 1 / -1; }
.detail-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; font-weight: 600; }
.detail-value { font-size: 14px; font-weight: 500; }

/* ── Footer ──────────────────────────────────────────────────── */
.portal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-logo {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid, .stats-grid-4, .detail-grid { grid-template-columns: 1fr; }
  .page-head, .search-row { flex-direction: column; align-items: flex-start; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .topbar-nav { margin-left: 0; }
  .page-head-left, .page-head-actions { flex-wrap: wrap; }
}
