:host {
  --brand: #E33DCF;
  --blue: #030FAA;
  --text: #111214;
  --muted: rgba(17, 18, 20, 0.65);

  --success-bg: rgba(25, 135, 84, 0.12);
  --success-text: #198754;
  --info-bg: rgba(3, 15, 170, 0.1);
  --info-text: #030FAA;
  --danger-bg: rgba(220, 53, 69, 0.12);
  --danger-text: #dc3545;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --shadow-card: 0 22px 46px rgba(17, 18, 20, 0.10);
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: 1px solid rgba(227, 61, 207, 0.16);

  display: block;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  box-sizing: border-box;
}

.historico-page {
  min-height: 100vh;
  padding: 0 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  overflow-y: auto;
  background:
    radial-gradient(900px 420px at 20% 10%, rgba(227, 61, 207, 0.14), transparent 60%),
    radial-gradient(820px 380px at 80% 30%, rgba(227, 61, 207, 0.08), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #f5f5f7 70%);

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.25);
  }
}

.page-blob {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(34px);
  opacity: 0.55;
  z-index: 0;
  background: radial-gradient(circle at 30% 30%, rgba(227,61,207,0.55), rgba(227,61,207,0.06));
  animation: floaty 10s ease-in-out infinite;
  &.blob-1 { width: 420px; height: 420px; top: -140px; left: -140px; }
  &.blob-2 { width: 520px; height: 520px; top: -220px; right: -240px; animation-duration: 12s; }
  &.blob-3 { width: 360px; height: 360px; bottom: -180px; left: 25%; animation-duration: 14s; }
  &.blob-4 { width: 520px; height: 520px; bottom: -260px; right: -260px; animation-duration: 16s; opacity: .45; }
}

@keyframes floaty {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, 10px) scale(1.03); }
  100% { transform: translate(0, 0) scale(1); }
}

.container-geral-responsive {
  width: 100%;
  max-width: 1400px !important;
  width: 98% !important;
  position: relative;
  z-index: 1;
  margin-top: 40px;
  margin-bottom: 200px;
}

.geral-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--glass-bg);
  border: var(--glass-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 80vh;
  &::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: calc(var(--radius-xl) - 1px);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.65);
    opacity: 0.75;
  }
}

.geral-header {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(17, 18, 20, 0.06);
  background: linear-gradient(180deg, rgba(227,61,207,0.06), rgba(255,255,255,0.2));
  flex-shrink: 0;
}

.header-row-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 16px;
    .title-badge { justify-self: center; margin-bottom: 8px; }
    .header-actions { justify-self: center; }
  }
}

.title-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(227, 61, 207, 0.22);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  i { color: var(--brand); }
}

.header-title {
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.title {
  font-size: 26px;
  font-weight: 950;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-top: 10px;
  margin-bottom: 0;
}

.subtitle {
  color: rgba(17, 18, 20, 0.65);
  font-weight: 700;
}

.header-actions {
  justify-self: end;
}

.btn-brand {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 900;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  &:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(227, 61, 207, 0.25); filter: brightness(1.05); }
}

.filters-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(17, 18, 20, 0.08);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 14px;
  box-shadow: 0 14px 28px rgba(17, 18, 20, 0.08);
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filters-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 14px;
  color: rgba(17, 18, 20, 0.82);
}

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

.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;

  label {
    font-size: 11px;
    font-weight: 800;
    color: rgba(17, 18, 20, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(227, 61, 207, 0.12);
  }
}

.filter-search {
  grid-column: span 2;
}

.filter-user {
  min-width: 0;
  width: 100%;

  input {
    width: 100%;
    max-width: 100%;
  }
}

.search-group {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  background: #fff;
  border: 1px solid rgba(17, 18, 20, 0.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;

  &:focus-within {
    border-color: var(--brand);
    box-shadow: 0 4px 12px rgba(227, 61, 207, 0.15);
    transform: translateY(-1px);
  }

  .input-group-text {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: rgba(17, 18, 20, 0.5);
    padding-left: 14px;
    padding-right: 8px;
    display: flex;
    align-items: center;
  }

  .form-control {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: none;
    background: transparent;
    height: 40px;
    padding: 0 8px;
    font-size: 0.9rem;
    color: var(--text);
    box-shadow: none;

    &::placeholder { color: rgba(17, 18, 20, 0.4); font-weight: 500; }
    &:focus { outline: none; }
  }

  .btn-clear {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: rgba(17, 18, 20, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    cursor: pointer;
    transition: color 0.2s ease;

    &:hover { color: #dc3545; }
  }
}

.btn-primary,
.btn-ghost {
  height: 38px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(3, 15, 170, 0.18);
}

.btn-ghost {
  background: #fff;
  color: rgba(17, 18, 20, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.select-wrapper { position: relative; display: inline-block; min-width: 90px; }

.select-glass {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(17, 18, 20, 0.12);
  border-radius: 10px;
  color: var(--blue);
  font-weight: 800;
}

.geral-body {
  padding: 0;
  background: transparent;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  height: 100%;
}

.table-modern {
  width: 100%;
  min-width: 1200px !important;
  border-collapse: separate;
  border-spacing: 0;

  thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid rgba(227, 61, 207, 0.15);
    padding: 12px;
    color: rgba(17, 18, 20, 0.7);
    font-size: 0.8rem;
    font-weight: 950;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    text-align: center;
  }

  tbody tr {
    transition: background-color 0.2s;
    border-bottom: 1px solid rgba(17,18,20,0.05);

    &:hover {
      background-color: rgba(227, 61, 207, 0.05);
    }

    td { border-bottom: 1px solid rgba(17,18,20,0.04); }
  }

  td {
    padding: 12px;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
    color: var(--text);
    text-align: center;
  }
}

.table-modern th:nth-child(5),
.table-modern td:nth-child(5) {
  text-align: center;
  min-width: 240px;
}

.table-modern th:nth-child(2),
.table-modern td:nth-child(2) {
  min-width: 260px;
}

.table-row-item.expanded {
  background: rgba(227, 61, 207, 0.06);
}

.td-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.empty-group {
  background: rgba(255,255,255,0.7);
  border: 1px dashed rgba(17,18,20,0.12);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  font-weight: 800;
  color: var(--muted);
  margin: 16px;
}

.user-cell {
  display: grid;
  gap: 2px;
  justify-items: center;
}

.user-name {
  font-weight: 800;
  color: var(--text);
}

.user-email {
  color: rgba(17, 18, 20, 0.55);
  font-size: 0.75rem;
}

.entity-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.entity-label {
  font-weight: 700;
  color: var(--text);
  text-align: center;
  max-width: 300px;
}

.entity-id {
  display: block;
  font-size: 0.75rem;
  color: rgba(17, 18, 20, 0.5);
  word-break: break-all;
}

.expand-btn {
  border: none;
  background: rgba(3, 15, 170, 0.08);
  color: var(--blue);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  &:hover { transform: translateY(-1px); background: rgba(227, 61, 207, 0.12); color: var(--brand); }
}

.badge-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-create {
  background: var(--success-bg);
  color: var(--success-text);
}

.action-update {
  background: var(--info-bg);
  color: var(--info-text);
}

.action-delete {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.action-default {
  background: rgba(17,18,20,0.08);
  color: rgba(17,18,20,0.7);
}

.details-row td {
  background: rgba(255, 255, 255, 0.95);
  padding: 0 12px 16px;
  white-space: normal;
  overflow: visible;
}

.details-panel {
  border-radius: 16px;
  border: 1px solid rgba(17, 18, 20, 0.08);
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.details-section {
  display: grid;
  gap: 12px;
}

.section-title {
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.changes-list {
  display: grid;
  gap: 10px;
}

.change-item {
  border: 1px solid rgba(17, 18, 20, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 6px;
}

.change-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.change-field {
  font-weight: 800;
  color: var(--text);
}

.change-type {
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.change-added { background: var(--success-bg); color: var(--success-text); }
.change-removed { background: var(--danger-bg); color: var(--danger-text); }
.change-modified { background: var(--info-bg); color: var(--info-text); }

.change-values {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: rgba(17, 18, 20, 0.7);
}

.change-values .old {
  color: rgba(17, 18, 20, 0.6);
}

.change-values .new {
  color: var(--text);
  font-weight: 700;
}

.empty-state {
  background: rgba(17, 18, 20, 0.04);
  border: 1px dashed rgba(17, 18, 20, 0.1);
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
  color: rgba(17, 18, 20, 0.6);
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.tech-item {
  display: grid;
  gap: 4px;
}

.tech-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: rgba(17, 18, 20, 0.55);
}

.tech-value {
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.geral-footer {
  padding: 12px 20px 18px;
  border-top: 1px solid rgba(17,18,20,0.06);
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 12px;
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-modern .page-link {
  color: var(--blue);
  font-weight: 900;
  border-radius: 10px;
  border: 1px solid rgba(17,18,20,0.1);
  background: rgba(255,255,255,0.6);
  margin: 0 2px;
  &:hover { transform: translateY(-1px); border-color: var(--brand); color: var(--brand); }
}

.pagination-modern .page-item.active .page-link {
  background-color: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.text-brand { color: var(--brand) !important; }

@media (max-width: 1100px) {
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .filters-grid { grid-template-columns: 1fr; }
  .search-group { width: 100%; max-width: 100%; }
  .entity-cell {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .entity-label { flex: 1 1 auto; min-width: 0; text-align: center; }
  .expand-btn { align-self: center; flex-shrink: 0; }
}

@media (max-width: 768px) {
  .historico-page {
    padding: 0 8px;
  }

  .container-geral-responsive {
    width: calc(100vw - 16px) !important;
    margin-top: 18px;
    margin-bottom: 28px;
  }

  .page-blob {
    opacity: 0.28;
    filter: blur(40px);

    &.blob-1,
    &.blob-2,
    &.blob-3,
    &.blob-4 {
      width: 240px;
      height: 240px;
    }
  }

  .geral-card {
    min-height: auto;
    border-radius: 16px;
  }

  .geral-header {
    padding: 12px;
  }

  .title {
    font-size: 22px;
    margin-top: 0;
    line-height: 1.15;
  }

  .subtitle {
    font-size: 12px;
    text-align: center;
    line-height: 1.35;
  }

  .header-actions {
    width: 100%;
    justify-self: stretch;
    display: flex;
  }

  .header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .filters-card {
    padding: 12px;
    gap: 12px;
    border-radius: 14px;
  }

  .filters-head {
    align-items: stretch;
  }

  .filters-title {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .filters-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .filters-actions .btn-primary,
  .filters-actions .btn-ghost {
    width: 100%;
    justify-content: center;
    min-width: 0;
    padding: 0 10px;
  }

  .filters-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .filter-search {
    grid-column: span 1;
  }

  .filter-field {
    min-width: 0;
  }

  .filter-field input {
    width: 100%;
    min-width: 0;
    font-size: 13px;
  }

  .filter-field app-select,
  .filter-field .select-glass {
    width: 100%;
    min-width: 0;
    display: block;
  }

  .search-group {
    max-width: 100%;
    min-width: 0;
    min-height: 40px;
    align-items: center;
  }

  .search-group .form-control {
    min-width: 0;
    height: 40px;
    padding: 0;
    font-size: 16px;
    line-height: 1.2;
  }

  .search-group .input-group-text,
  .search-group .btn-clear {
    height: 40px;
    min-height: 40px;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: center;
    line-height: 1;
  }

  .search-group .input-group-text {
    padding-left: 10px;
    padding-right: 6px;
  }

  .search-group .btn-clear {
    padding-left: 8px;
    padding-right: 10px;
  }

  .geral-body {
    min-width: 0;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .table-modern {
    min-width: 860px !important;
  }

  .table-modern thead th,
  .table-modern td {
    padding: 10px 8px;
    font-size: 0.78rem;
  }

  .table-modern th:nth-child(2),
  .table-modern td:nth-child(2) {
    min-width: 190px;
  }

  .table-modern th:nth-child(5),
  .table-modern td:nth-child(5) {
    min-width: 210px;
  }

  .td-clip {
    max-width: 180px;
  }

  .entity-cell {
    justify-content: center;
    gap: 6px;
  }

  .entity-label {
    min-width: 0;
    flex: 1 1 auto;
    text-align: center;
  }

  .details-row td {
    padding: 0 8px 12px;
  }

  .details-panel {
    padding: 10px;
    gap: 10px;
    border-radius: 14px;
    max-width: 640px;
    margin: 0 auto;
  }

  .section-title {
    font-size: 0.82rem;
    flex-wrap: wrap;
    line-height: 1.25;
  }

  .change-item {
    padding: 8px 10px;
  }

  .change-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .change-field {
    min-width: 0;
    overflow-wrap: break-word;
  }

  .change-values {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    line-height: 1.2;
  }

  .change-values i {
    transform: none;
    font-size: 0.7rem;
    flex-shrink: 0;
  }

  .change-values .old,
  .change-values .new {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .tech-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tech-value {
    font-size: 13px;
  }

  .alert.alert-danger {
    margin: 12px !important;
    display: grid;
    gap: 8px;
  }

  .alert.alert-danger .btn {
    margin-left: 0 !important;
    width: 100%;
  }

  .geral-footer {
    padding: 12px;
    gap: 10px;
  }

  .footer-meta {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .footer-meta > .small {
    text-align: center;
  }

  .page-size {
    width: 100%;
    justify-content: space-between;
  }

  .select-wrapper {
    min-width: 110px;
  }

  .geral-footer nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pagination-modern {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    justify-content: center;
    padding-bottom: 2px;
  }

  .pagination-modern .page-link {
    white-space: nowrap;
    font-size: 12px;
    padding: 0.35rem 0.6rem;
  }
}

@media (max-width: 480px) {
  .title-badge {
    font-size: 12px;
    padding: 6px 10px;
    gap: 8px;
  }

  .title {
    font-size: 20px;
  }

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

  .btn-primary,
  .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .table-modern {
    min-width: 760px !important;
  }

  .td-clip {
    max-width: 140px;
  }

  .table-modern th:nth-child(2),
  .table-modern td:nth-child(2) {
    min-width: 170px;
  }

  .table-modern th:nth-child(5),
  .table-modern td:nth-child(5) {
    min-width: 180px;
  }

  .details-panel {
    max-width: 520px;
    padding: 8px;
    gap: 8px;
  }

  .change-item {
    padding: 7px 8px;
  }

  .change-values {
    font-size: 0.72rem;
    gap: 5px;
  }

  .entity-cell {
    gap: 6px;
  }

  .expand-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
}
