:root {
  --sidebar-bg: #10263c;
  --sidebar-bg-light: #16324d;
  --accent: #14919b;
  --accent-dark: #0e6e77;
  --green: #1f9d63;
  --green-bg: #e3f7ec;
  --orange: #d97a1f;
  --orange-bg: #fdefdf;
  --bg: #eef3f2;
  --card-bg: #ffffff;
  --text-dark: #16232f;
  --text-muted: #6b7a86;
  --border: #e2e8ec;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-dark);
  font-family: Arial, Helvetica, sans-serif;
}

a { text-decoration: none; color: inherit; }

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

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: #d7e2ea;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-center { justify-content: center; border-bottom: none; margin-bottom: 6px; }

.brand-badge {
  width: 38px; height: 38px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 14px;
  flex-shrink: 0;
}

.brand-title { color: #fff; font-weight: bold; font-size: 15px; line-height: 1.2; }
.brand-subtitle { color: #8ea3b3; font-size: 10px; letter-spacing: 0.06em; }

.nav-label {
  color: #6f8496;
  font-size: 10px;
  letter-spacing: 0.08em;
  margin: 14px 6px 6px;
}

.nav-section { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #b9c8d3;
  font-size: 13.5px;
  transition: background 0.15s ease;
}

.nav-item:hover { background: rgba(255,255,255,0.06); }

.nav-item.active {
  background: rgba(20,145,155,0.18);
  color: #fff;
  font-weight: bold;
}

.nav-index {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px;
  flex-shrink: 0;
}

.nav-item.active .nav-index { background: var(--accent); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: #6f8496;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-right: 6px;
}
.sidebar-footer .muted { color: #4c5e6c; }
.app-version-mobile { display: none; }

/* ---------------- Main / topbar ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
}

.crumb { font-size: 10.5px; letter-spacing: 0.08em; color: var(--text-muted); font-weight: bold; }
.crumb-title { font-size: 14px; color: var(--text-dark); font-weight: bold; margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.pill-count {
  background: #eef3f2; color: var(--text-muted);
  font-size: 11px; font-weight: bold;
  padding: 6px 12px; border-radius: 999px;
}

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

.user-info { line-height: 1.2; margin-right: 4px; }
.user-name { font-size: 12.5px; font-weight: bold; }
.user-handle { font-size: 11px; color: var(--text-muted); }

.content { padding: 26px 28px 60px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 9px;
  font-size: 13px; font-weight: bold;
  cursor: pointer; border: none;
  white-space: nowrap;
}
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-dark); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: #fdecec; color: #b3261e; }
.btn-danger:hover { background: #f8d3d1; }
.btn-block { width: 100%; padding: 12px; font-size: 14px; }

/* ---------------- Page head ---------------- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 14px;
  margin-bottom: 20px;
}
.eyebrow { font-size: 11px; letter-spacing: 0.08em; color: var(--accent); font-weight: bold; }
.page-head h1 { font-size: 26px; margin: 4px 0 4px; }
.page-desc { color: var(--text-muted); font-size: 13.5px; margin: 0; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- Filter bar ---------------- */
.filter-bar {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 20px;
  display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.filter-field label { color: var(--text-muted); font-weight: bold; }
.filter-field input, .filter-field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; min-width: 130px;
}
.filter-busca input { min-width: 200px; }

.audit-filter-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 20px;
}
.audit-filters {
  display: grid; grid-template-columns: 1.1fr 1fr 1fr 150px 150px auto;
  gap: 12px; align-items: end;
}
.audit-filter-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- Stat cards ---------------- */
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  box-shadow: 0 1px 3px rgba(20,40,60,0.06);
  position: relative;
  overflow: hidden;
}
.border-teal { border-left-color: var(--accent); }
.border-green { border-left-color: var(--green); }
.border-orange { border-left-color: var(--orange); }
.stat-card-filter {
  --filter-color: var(--accent);
  color: inherit; cursor: pointer; display: block; text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card-filter.border-green { --filter-color: var(--green); }
.stat-card-filter.border-orange { --filter-color: var(--orange); }
.stat-card-filter:hover { transform: translateY(-2px); box-shadow: 0 5px 14px rgba(20,40,60,0.12); }
.stat-card-filter:focus-visible {
  outline: 3px solid var(--filter-color); outline-offset: 3px;
}
.stat-card-filter.is-active {
  box-shadow: 0 0 0 2px var(--filter-color), 0 4px 12px rgba(20,40,60,0.1);
}

.stat-ghost {
  position: absolute; right: 14px; top: 6px;
  font-size: 46px; font-weight: bold; color: #eef1f3;
  line-height: 1; z-index: 0; user-select: none;
}
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: bold; position: relative; z-index: 1; }
.stat-value { font-size: 26px; font-weight: bold; margin-top: 6px; position: relative; z-index: 1; }
.stat-note { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; position: relative; z-index: 1; }

/* ---------------- Progress card ---------------- */
.progress-card {
  background: var(--card-bg); border-radius: 14px; padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(20,40,60,0.06);
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.progress-title { font-weight: bold; font-size: 13.5px; }
.progress-sub { font-size: 12px; color: var(--text-muted); }
.progress-track {
  flex: 1; min-width: 160px; height: 9px; background: #e6edec; border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-pct { font-weight: bold; font-size: 13.5px; min-width: 40px; text-align: right; }

/* ---------------- Table card ---------------- */
.table-card {
  background: var(--card-bg); border-radius: 14px;
  box-shadow: 0 1px 3px rgba(20,40,60,0.06);
  border: 2px solid transparent;
  padding: 18px 20px 8px; margin-bottom: 22px;
}
.table-card.table-filter-teal { border-color: var(--accent); }
.table-card.table-filter-green { border-color: var(--green); }
.table-card.table-filter-orange { border-color: var(--orange); }
.table-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.table-title { font-weight: bold; font-size: 15px; }
.table-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 900px; }
.data-table thead th {
  text-align: left; text-transform: uppercase; font-size: 10.5px;
  letter-spacing: 0.04em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); padding: 10px 10px;
}
.data-table thead th.sortable-column { padding: 0; }
.table-sort-link {
  color: inherit; display: inline-flex; align-items: center; gap: 4px;
  min-height: 38px; padding: 10px 8px; white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.table-sort-link:hover { color: var(--accent); background: #f0fafb; }
.table-sort-link:focus-visible {
  color: var(--accent); background: #e9f7f8; outline: 2px solid var(--accent);
  outline-offset: -2px; border-radius: 5px;
}
.sortable-column.is-active .table-sort-link { color: var(--accent); font-weight: 800; }
.sort-indicator {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 4px; font-size: 12px;
  line-height: 1; color: #82959f; background: #edf2f3;
}
.sortable-column.is-active .sort-indicator { color: #fff; background: var(--accent); }
.data-table tbody td { padding: 12px 8px; border-bottom: 1px solid #f0f3f4; vertical-align: middle; }
.cell-strong { font-weight: bold; }
.cell-muted { font-size: 11px; color: var(--text-muted); }
.cell-actions { display: flex; gap: 6px; }
.empty-row { text-align: center; color: var(--text-muted); padding: 26px !important; }

.badge {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  font-size: 10.5px; font-weight: bold; letter-spacing: 0.03em;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

/* ---------------- Auditoria ---------------- */
.audit-table { min-width: 1580px; table-layout: fixed; }
.audit-table th:nth-child(1) { width: 170px; }
.audit-table th:nth-child(2) { width: 240px; }
.audit-table th:nth-child(3) { width: 145px; }
.audit-table th:nth-child(4) { width: 165px; }
.audit-table th:nth-child(5) { width: 210px; }
.audit-table th:nth-child(6), .audit-table th:nth-child(7) { width: 310px; }
.audit-when { white-space: nowrap; }
.audit-method { margin-top: 5px; }
.audit-agent { font-size: 10.5px; color: var(--text-muted); margin-top: 5px; max-width: 160px; }
.audit-agent summary { cursor: pointer; font-weight: bold; }
.audit-agent[open] { overflow-wrap: anywhere; }
.audit-action { display: inline-block; }
.audit-action-login_sucesso, .audit-action-criou, .audit-action-ativou {
  background: var(--green-bg); color: var(--green);
}
.audit-action-alterou, .audit-action-redefiniu_senha,
.audit-action-solicitou_recuperacao, .audit-action-exportou, .audit-action-imprimiu {
  background: #e7f4f7; color: var(--accent-dark);
}
.audit-action-excluiu, .audit-action-desativou, .audit-action-login_falha {
  background: #fdecec; color: #b3261e;
}
.audit-action-logout { background: #edf1f3; color: var(--text-muted); }
.audit-action-logout_inatividade { background: #fff2d8; color: #8a5a00; }
.audit-values { margin: 0; display: flex; flex-direction: column; gap: 7px; }
.audit-values > div {
  border-left: 3px solid #d8e0e5; padding: 4px 7px; background: #f8fafb;
  border-radius: 0 6px 6px 0;
}
.audit-values-new > div { border-left-color: var(--accent); background: #f1fbfb; }
.audit-values dt { color: var(--text-muted); font-size: 10px; font-weight: bold; text-transform: uppercase; }
.audit-values dd { margin: 2px 0 0; color: var(--text-dark); font-size: 11.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.audit-new-value { display: grid; gap: 8px; }
.audit-value-card {
  overflow: hidden; border: 1px solid #d7eaed; border-radius: 9px;
  background: linear-gradient(145deg, #f7fcfc 0%, #eef9fa 100%);
  box-shadow: 0 1px 2px rgba(16, 38, 60, 0.05);
}
.audit-value-card-head {
  display: flex; align-items: center; gap: 6px; padding: 7px 9px;
  color: var(--accent-dark); font-size: 10px; font-weight: bold;
  letter-spacing: 0.045em; text-transform: uppercase;
}
.audit-value-card-head > span {
  width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--accent);
}
.audit-value-primary {
  padding: 0 9px 9px; color: var(--text-dark); font-size: 12px;
  font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; white-space: pre-wrap;
}
.audit-value-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px; padding: 1px; background: #dcecef;
}
.audit-value-detail { min-width: 0; padding: 7px 8px; background: rgba(255, 255, 255, 0.94); }
.audit-value-detail:last-child:nth-child(odd) { grid-column: 1 / -1; }
.audit-value-detail span {
  display: block; margin-bottom: 2px; color: var(--text-muted); font-size: 9px;
  font-weight: bold; letter-spacing: 0.035em; text-transform: uppercase;
}
.audit-value-detail strong {
  display: block; color: var(--text-dark); font-size: 11px; line-height: 1.25;
  overflow-wrap: anywhere;
}
.audit-value-metric {
  display: flex; align-items: baseline; gap: 6px; padding: 9px 11px;
  border: 1px solid #cce7e9; border-radius: 9px; background: #eaf8f8;
}
.audit-value-metric strong { color: var(--accent-dark); font-size: 20px; line-height: 1; }
.audit-value-metric span { color: var(--text-muted); font-size: 10px; font-weight: bold; text-transform: uppercase; }

@media (max-width: 520px) {
  .audit-value-grid { grid-template-columns: 1fr; }
}

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; padding: 14px 0; flex-wrap: wrap; }
.page-link {
  padding: 6px 11px; border-radius: 7px; font-size: 12.5px;
  border: 1px solid var(--border); color: var(--text-dark);
}
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------------- Forms ---------------- */
.form-card {
  background: var(--card-bg); border-radius: 14px; padding: 22px;
  box-shadow: 0 1px 3px rgba(20,40,60,0.06);
  margin-bottom: 22px;
}
.form-card-narrow { max-width: 420px; }
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: bold; color: var(--text-dark); }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px;
  font-family: inherit;
}
.field-hint { font-size: 11px; color: var(--text-muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; width: 120px; }
.inline-email-form input { width: 220px; }
.inline-display { display: inline; }
.new-user-title { margin-bottom: 14px; }

/* ---------------- Flash messages ---------------- */
.flash { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; font-size: 13px; font-weight: bold; }
.flash-erro { background: #fdecec; color: #b3261e; }
.flash-sucesso { background: var(--green-bg); color: var(--green); }
.session-timeout-warning {
  position: fixed; right: 22px; bottom: 22px; z-index: 1000;
  display: flex; align-items: center; gap: 11px; max-width: 360px;
  padding: 13px 15px; border: 1px solid #efcf8b; border-radius: 12px;
  background: #fff9eb; color: #6f4b00; box-shadow: 0 12px 32px rgba(16, 38, 60, 0.18);
}
.session-timeout-warning[hidden] { display: none; }
.session-timeout-warning strong { display: block; margin-bottom: 2px; font-size: 12.5px; }
.session-timeout-warning div > span { display: block; font-size: 11.5px; line-height: 1.35; }
.session-timeout-icon {
  width: 20px; height: 20px; flex: 0 0 20px; border: 2px solid #b77a00;
  border-radius: 50%; position: relative;
}
.session-timeout-icon::before,
.session-timeout-icon::after {
  content: ""; position: absolute; left: 8px; top: 4px;
  width: 2px; height: 6px; border-radius: 2px; background: #b77a00;
  transform-origin: bottom center;
}
.session-timeout-icon::after { transform: rotate(125deg); }

/* ---------------- Login page ---------------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg), #1c3d54);
}
.login-card {
  background: #fff; border-radius: 18px; padding: 36px 34px;
  width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-title { font-size: 20px; margin: 18px 0 2px; text-align: center; }
.login-subtitle { font-size: 12.5px; color: var(--text-muted); text-align: center; margin: 0 0 18px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 12px; font-weight: bold; margin-top: 8px; }
.login-form input {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px;
}
.login-form .btn { margin-top: 16px; }
.login-links { display: flex; justify-content: flex-end; margin-top: 8px; font-size: 12.5px; }
.login-links-center { justify-content: center; }
.login-links a { color: var(--teal); font-weight: bold; text-decoration: none; }
.login-links a:hover { text-decoration: underline; }

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
  .cards-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .audit-filters { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .cards-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .app-version-mobile { display: block; color: var(--text-muted); font-size: 10px; margin-top: 2px; }
  .audit-filters { grid-template-columns: 1fr; }
  .audit-filter-actions { justify-content: stretch; }
  .audit-filter-actions .btn { flex: 1; }
  .topbar { padding: 14px 18px; align-items: flex-start; flex-direction: column; gap: 12px; }
  .topbar-right { width: 100%; gap: 8px; flex-wrap: wrap; }
  .topbar-right .pill-count:empty { display: none; }
  .topbar-right .user-info { margin-right: auto; }
  .topbar-right .btn { padding: 7px 10px; }
  .session-timeout-warning { right: 14px; bottom: 14px; left: 14px; max-width: none; }
}
