:root {
  --bg: #f3f6fb;
  --ink: #102340;
  --muted: #5f738f;
  --line: #d8e2ef;
  --card: #ffffff;
  --primary: #0b4f8a;
  --primary-2: #0f6a9f;
  --danger: #b3313d;
  --ok: #0f7349;
  --warn: #a05a00;
  --shadow: 0 10px 30px rgba(9, 37, 71, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 420px at 95% -20%, #d9ecff 0%, transparent 70%),
    radial-gradient(900px 300px at -10% 0%, #d8fff5 0%, transparent 65%),
    var(--bg);
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(160deg, #0f2f57 0%, #134674 100%);
  color: #f6fbff;
  padding: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #17b386, #2bd1a0);
  color: #083228;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand h1 {
  margin: 0;
  font: 700 1.05rem/1 "Manrope", sans-serif;
}

.brand p {
  margin: 3px 0 0;
  font-size: 0.74rem;
  color: #b7d5f0;
}

.year-badge {
  display: inline-block;
  margin: 10px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: #d7ebff;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.side-nav-link {
  text-decoration: none;
  color: #d0e5f9;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.side-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.side-nav-link.active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.36);
  color: #ffffff;
}

.side-block {
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 14px;
}

.side-block h2 {
  margin: 0 0 10px;
  font: 700 0.82rem/1 "Manrope", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c9e1f8;
}

.top-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-list li {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px;
}

.top-list b {
  display: block;
  font-size: 0.8rem;
  color: #f1f8ff;
}

.top-list span {
  display: block;
  margin-top: 3px;
  font-size: 0.73rem;
  color: #a7c8e7;
}

.side-muted {
  margin: 0;
  font-size: 0.8rem;
  color: #c1d8ed;
  line-height: 1.5;
}

.main {
  padding: 24px 28px 28px;
}

.hero {
  background: linear-gradient(135deg, #ffffff 0%, #ecf4ff 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--primary);
  font-weight: 700;
}

.hero h2 {
  margin: 7px 0 6px;
  font: 800 1.5rem/1.2 "Manrope", sans-serif;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sync-status {
  font-size: 0.76rem;
  color: #2e4f73;
  background: #eef5ff;
  border: 1px solid #d4e1f3;
  border-radius: 999px;
  padding: 4px 10px;
}

.sync-log-wrap {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sync-log-head {
  padding: 10px 12px;
  border-bottom: 1px solid #e6edf8;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #f8fbff;
}

.sync-log-head strong {
  font-size: 0.8rem;
  color: #2b4669;
}

.sync-log-head span {
  font-size: 0.76rem;
  color: #60758f;
}

.sync-log {
  margin: 0;
  padding: 10px 12px;
  min-height: 64px;
  max-height: 170px;
  overflow: auto;
  background: #0f223b;
  color: #d4e6ff;
  font: 0.74rem/1.45 "IBM Plex Sans", sans-serif;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  animation: slideUp 0.45s ease both;
}

.kpi-card span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
}

.kpi-card strong {
  display: block;
  margin-top: 6px;
  font: 800 1.45rem/1 "Manrope", sans-serif;
  color: var(--ink);
}

.kpi-critical {
  background: linear-gradient(135deg, #fff1f3, #ffe3e8);
  border-color: #f3bcc7;
}

.kpi-critical strong {
  color: var(--danger);
}

.overview {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.overview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f5f9ff;
}

.overview-head h3 {
  margin: 0;
  font: 700 0.95rem/1 "Manrope", sans-serif;
  color: #1a365a;
}

.overview-filters {
  display: flex;
  gap: 8px;
}

.overview-filters input,
.overview-filters select {
  height: 34px;
  border: 1px solid #ccd8e8;
  border-radius: 9px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.overview-table-wrap {
  overflow: auto;
  max-height: 260px;
}

.overview-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

.overview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4fd;
  color: #1f3d61;
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: left;
  padding: 8px 10px;
}

.overview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e8eef7;
  font-size: 0.8rem;
}

.filters {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  grid-template-columns: 1.7fr 1fr 0.8fr 0.75fr 0.75fr auto;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.wide {
  min-width: 240px;
}

.field label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input,
.field select {
  border: 1px solid #ccd8e8;
  border-radius: 10px;
  height: 38px;
  padding: 0 11px;
  font-size: 0.9rem;
  color: var(--ink);
  background: #fff;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(20, 111, 177, 0.12);
}

.field.actions {
  align-self: end;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.btn-primary,
.btn-ghost {
  border: 0;
  border-radius: 10px;
  height: 38px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f7fbff;
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-ghost {
  background: #eef4fb;
  color: var(--ink);
  border: 1px solid #d4deec;
}

.btn-ghost:hover {
  background: #e4edf8;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.config-hero {
  align-items: center;
}

.config-panel {
  overflow: visible;
}

.config-form-wrap {
  padding: 14px;
}

.config-grid {
  display: grid;
  grid-template-columns: 0.6fr 1.8fr 1fr auto;
  gap: 10px;
}

.status-msg {
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 10px;
  font-size: 0.84rem;
}

.status-success {
  background: #eaf8ef;
  border-color: #cae9d5;
  color: #186f49;
}

.status-error {
  background: #ffecef;
  border-color: #ffc8d1;
  color: #8e2f3d;
}

.table-tools {
  flex-wrap: wrap;
}

.config-table {
  min-width: 760px;
}

.action-buttons {
  display: inline-flex;
  gap: 6px;
}

.btn-small {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.btn-danger {
  background: #fff1f4;
  border-color: #ffc8d2;
  color: #a13747;
}

.text-right {
  text-align: right;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: #f5f9ff;
}

.tab {
  border: 0;
  background: transparent;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  color: #5b6f88;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.table-wrap {
  overflow: auto;
  max-height: 66vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

thead th {
  position: sticky;
  top: 0;
  background: #edf4fd;
  color: #243b59;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8eef7;
  font-size: 0.84rem;
  vertical-align: top;
}

tbody tr:nth-child(odd) {
  background: #fcfdff;
}

.row-critico {
  background: #fff2f4 !important;
}

.company {
  font-weight: 700;
  color: #102a45;
}

.cnpj {
  display: block;
  margin-top: 2px;
  color: #6e8098;
  font-size: 0.75rem;
}

.body-preview {
  color: #304862;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.71rem;
  font-weight: 700;
}

.badge-ok {
  background: #e4f8ef;
  color: var(--ok);
}

.badge-warn {
  background: #fff1dd;
  color: var(--warn);
}

.badge-alert {
  background: #fde6ea;
  color: var(--danger);
}

.badge-critico {
  background: #ffe7ec;
  color: var(--danger);
}

.badge-view {
  background: #e7f0ff;
  color: #214c87;
}

.clickable {
  cursor: pointer;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: #6a7f98;
}

.hidden {
  display: none;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fafcff;
}

.pager span {
  color: #60758f;
  font-size: 0.82rem;
}

.pager button {
  margin-left: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 24, 44, 0.58);
}

.modal-content {
  position: relative;
  margin: 40px auto;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(5, 22, 42, 0.34);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font: 700 1rem/1 "Manrope", sans-serif;
}

.modal-meta {
  padding: 10px 12px;
  border-bottom: 1px solid #e5edf8;
  color: #44627f;
  font-size: 0.82rem;
}

.modal-body {
  margin: 0;
  padding: 14px 12px 18px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.5;
  font: 0.9rem/1.5 "IBM Plex Sans", sans-serif;
  color: #1c3552;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1360px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .main {
    padding: 16px;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .hero {
    flex-direction: column;
  }

  .hero-actions {
    align-items: stretch;
    width: 100%;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .field.actions {
    justify-content: flex-start;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    width: 100%;
    justify-content: flex-end;
  }
}