:root {
  --cabesp-blue: #002b53;
  --cabesp-blue-soft: #0d416f;
  --surface: #ffffff;
  --page-bg: #f4f6f8;
  --text-strong: #27272a;
  --text-muted: #70737a;
  --line: #e6e9ee;
  --shadow: 0 14px 28px rgba(0, 23, 44, 0.12), 0 3px 7px rgba(0, 23, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  color: var(--text-strong);
  background: var(--page-bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.main-panel {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 28px;
}

.top-tabs {
  max-width: 1120px;
  display: flex;
  align-items: flex-end;
  overflow-x: auto;
  border-bottom: 2px solid #4fc3b6;
}

.tab-button {
  min-width: 204px;
  min-height: 72px;
  padding: 0 28px;
  border: 0;
  border-radius: 22px 22px 0 0;
  color: var(--cabesp-blue);
  background: #ffffff;
  box-shadow: 0 -2px 18px rgba(0, 23, 44, 0.06);
  font: inherit;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: 0;
  cursor: pointer;
}

.tab-button.is-active {
  color: #ffffff;
  background: #4fc3b6;
}

.tab-button:focus {
  outline: 3px solid rgba(79, 195, 182, 0.38);
  outline-offset: -3px;
}

.tab-panel[hidden] {
  display: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 18px;
  max-width: 1120px;
}

.metric-card {
  min-height: 206px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 20px;
  border: 1px solid rgba(0, 43, 83, 0.06);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.metric-card h2 {
  margin: 0;
  color: var(--cabesp-blue);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 600;
  letter-spacing: 0;
}

.metric-value {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(1.95rem, 3vw, 2.65rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: 0;
}

.metric-detail {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

.metric-detail strong {
  color: var(--text-strong);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0;
}

.table-panel {
  max-width: 1120px;
  overflow: hidden;
  border: 1px solid rgba(0, 43, 83, 0.08);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.table-header h2 {
  margin: 0 0 6px;
  color: var(--cabesp-blue);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.table-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.table-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.table-pagination button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(0, 43, 83, 0.16);
  border-radius: 8px;
  color: var(--cabesp-blue);
  background: #f8fafc;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.table-pagination button:disabled {
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.72;
}

.table-scroll {
  max-height: calc(100vh - 340px);
  min-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
}

.table-panel table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.table-panel th,
.table-panel td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table-panel th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0;
  color: var(--cabesp-blue);
  background: #f8fafc;
  font-size: 0.78rem;
  font-weight: 700;
}

.sort-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  text-align: inherit;
  cursor: pointer;
}

.sort-button::after {
  content: "↕";
  flex: 0 0 auto;
  color: #8b98a8;
  font-size: 0.74rem;
}

.sort-button[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--cabesp-blue);
}

.sort-button[aria-sort="descending"]::after {
  content: "↓";
  color: var(--cabesp-blue);
}

.sort-button:focus {
  outline: 3px solid rgba(0, 43, 83, 0.18);
  outline-offset: -3px;
}

.table-panel td {
  color: var(--text-strong);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
}

.table-panel tbody tr:hover {
  background: #f8fbfd;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus {
  outline: 3px solid rgba(0, 43, 83, 0.18);
  outline-offset: -3px;
}

.table-panel th:nth-child(1),
.table-panel td:nth-child(1) {
  width: 18%;
}

.table-panel th:nth-child(2),
.table-panel td:nth-child(2) {
  width: 11%;
}

.table-panel th:nth-child(3),
.table-panel td:nth-child(3) {
  width: 10%;
}

.table-panel th:nth-child(4),
.table-panel td:nth-child(4) {
  width: 31%;
}

.table-panel th:nth-child(5),
.table-panel td:nth-child(5) {
  width: 14%;
}

.table-panel th:nth-child(6),
.table-panel td:nth-child(6),
.table-panel th:nth-child(7),
.table-panel td:nth-child(7) {
  width: 8%;
  text-align: right;
}

.overview-table th:nth-child(1),
.overview-table td:nth-child(1) {
  width: 17%;
}

.overview-table th:nth-child(2),
.overview-table td:nth-child(2) {
  width: 20%;
}

.overview-table th:nth-child(3),
.overview-table td:nth-child(3) {
  width: 9%;
}

.overview-table th:nth-child(4),
.overview-table td:nth-child(4) {
  width: 28%;
}

.overview-table th:nth-child(5),
.overview-table td:nth-child(5) {
  width: 12%;
}

.overview-table th:nth-child(6),
.overview-table td:nth-child(6),
.overview-table th:nth-child(7),
.overview-table td:nth-child(7) {
  width: 7%;
  text-align: right;
}

.table-panel .empty-table-row td {
  height: 160px;
  color: var(--text-muted);
  text-align: center;
  vertical-align: middle;
}

.side-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding: 34px 26px;
  background: var(--cabesp-blue);
  color: #ffffff;
}

.logo-stack {
  display: grid;
  gap: 26px;
  justify-items: center;
}

.logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.logo-horuss {
  width: 190px;
  height: auto;
}

.client-logo-box {
  width: 190px;
  min-height: 86px;
  display: grid;
  place-items: center;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #ffffff;
}

.logo-cabesp {
  width: 145px;
  height: auto;
}

.filters {
  display: grid;
  gap: 20px;
}

.filter-field {
  display: grid;
  gap: 9px;
}

.filter-field span {
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.86rem;
  font-weight: 600;
}

.filter-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 42px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  appearance: none;
  color: #ffffff;
  background:
    linear-gradient(45deg, transparent 50%, #ffffff 50%) right 18px center / 7px 7px no-repeat,
    linear-gradient(135deg, #ffffff 50%, transparent 50%) right 13px center / 7px 7px no-repeat,
    var(--cabesp-blue-soft);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  color: #ffffff;
  background: var(--cabesp-blue-soft);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
}

.filter-field input::placeholder {
  color: rgba(255, 255, 255, 0.64);
}

.combobox {
  position: relative;
}

.combobox-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 20;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 26px rgba(0, 23, 44, 0.22);
}

.combobox-options.is-open {
  display: block;
}

.combobox-option {
  width: 100%;
  min-height: 38px;
  display: block;
  padding: 9px 12px;
  border: 0;
  color: var(--text-strong);
  background: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.combobox-option:hover,
.combobox-option:focus {
  outline: 0;
  background: #edf5fb;
}

.filter-field select:focus,
.filter-field input:focus {
  outline: 3px solid rgba(255, 255, 255, 0.24);
  outline-offset: 2px;
}

.filter-field option {
  color: var(--text-strong);
  background: #ffffff;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 16, 31, 0.42);
}

.detail-overlay[hidden] {
  display: none;
}

.detail-card {
  position: fixed;
  top: 24px;
  left: 50%;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 43, 83, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 52px rgba(0, 23, 44, 0.28);
  transform: translateX(-50%);
}

.detail-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  cursor: move;
  user-select: none;
}

.detail-card-header p {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.detail-card-header h2 {
  margin: 0;
  color: var(--cabesp-blue);
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.2;
}

.detail-card-header button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 43, 83, 0.16);
  border-radius: 8px;
  color: var(--cabesp-blue);
  background: #ffffff;
  font-size: 1.12rem;
  line-height: 1;
  cursor: pointer;
}

.detail-content {
  display: grid;
  gap: 10px;
  padding: 12px 16px 16px;
  overflow: auto;
}

.detail-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.detail-stat {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.detail-stat span,
.detail-section-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.detail-stat strong {
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.18;
}

.detail-stat em {
  color: var(--text-muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 650;
}

.detail-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
}

.detail-section {
  display: grid;
  gap: 4px;
}

.detail-section.full-width {
  grid-column: 1 / -1;
}

.detail-text {
  margin: 0;
  color: var(--text-strong);
  font-size: 0.82rem;
  font-weight: 550;
  line-height: 1.32;
}

.detail-items-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 0;
}

.detail-items-title h3 {
  margin: 0;
  color: var(--cabesp-blue);
  font-size: 0.94rem;
  font-weight: 750;
}

.detail-items-title span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.guide-items-scroll {
  max-height: calc(100vh - 360px);
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.guide-items-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

.guide-items-table th,
.guide-items-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.guide-items-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--cabesp-blue);
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 750;
}

.guide-items-table td {
  color: var(--text-strong);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.28;
}

.guide-items-table th:nth-child(1),
.guide-items-table td:nth-child(1) {
  width: 11%;
}

.guide-items-table th:nth-child(2),
.guide-items-table td:nth-child(2) {
  width: 39%;
}

.guide-items-table th:nth-child(3),
.guide-items-table td:nth-child(3),
.guide-items-table th:nth-child(4),
.guide-items-table td:nth-child(4),
.guide-items-table th:nth-child(5),
.guide-items-table td:nth-child(5) {
  width: 11%;
  text-align: right;
}

.guide-items-table th:nth-child(6),
.guide-items-table td:nth-child(6) {
  width: 17%;
}

.guide-item-row.is-denied {
  background: #fff7f7;
}

.guide-item-row.is-reference {
  background: #edf5fb;
}

.guide-item-row.is-selected {
  background: #fff8e8;
  box-shadow: inset 4px 0 0 #d99b24;
}

.guide-item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.guide-item-badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--cabesp-blue);
  background: #e8f2fa;
  font-size: 0.66rem;
  font-weight: 750;
}

.guide-item-badge.denied {
  color: #8a1f1f;
  background: #fde8e8;
}

.guide-item-badge.selected {
  color: #7c4a00;
  background: #fff0c7;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 292px minmax(0, 1fr);
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .tab-button {
    min-width: 188px;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .side-panel {
    min-height: auto;
    gap: 26px;
    padding: 24px 18px;
  }

  .logo-stack {
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 16px;
  }

  .logo-horuss,
  .client-logo-box {
    width: min(100%, 170px);
  }

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

  .main-panel {
    padding: 18px;
  }

  .top-tabs {
    max-width: none;
  }

  .tab-button {
    min-width: 174px;
    min-height: 58px;
    padding: 0 18px;
    border-radius: 16px 16px 0 0;
    font-size: 0.92rem;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .metric-card {
    min-height: 176px;
  }

  .table-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-scroll {
    max-height: none;
  }

  .detail-card {
    top: 14px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 28px);
  }

  .detail-summary-grid,
  .detail-rule-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .logo-stack,
  .filters {
    grid-template-columns: 1fr;
  }
}
