:root {
  --portal-bg: #f5f7fb;
  --portal-text: #1f2335;
  --portal-card-bg: #ffffff;
  --portal-border: rgba(31, 35, 53, 0.08);
  --portal-accent: #0063f7;
  --portal-accent-soft: rgba(0, 99, 247, 0.1);
  --portal-radius-md: 16px;
  --portal-radius-lg: 22px;
  --portal-shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.08);
  --portal-shadow-lg: 0 26px 70px rgba(15, 23, 42, 0.16);
  --portal-header-blur: blur(22px);
  --portal-font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --portal-bg: #0e111a;
  --portal-text: #f5f7fb;
  --portal-card-bg: #161b2d;
  --portal-border: rgba(245, 247, 251, 0.08);
  --portal-accent: #00b4ff;
  --portal-accent-soft: rgba(0, 180, 255, 0.12);
  --portal-shadow-sm: 0 14px 32px rgba(0, 0, 0, 0.3);
  --portal-shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.48);
}

.portal-body {
  min-height: 100vh;
  background: var(--portal-bg);
  color: var(--portal-text);
  font-family: var(--portal-font-family);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--portal-mobile-nav-height, 0px));
}

.portal-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  position: sticky;
  top: 0;
  z-index: 1040;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: color-mix(in srgb, var(--portal-card-bg) 88%, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--portal-header-blur);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.07);
}

.portal-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.portal-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-header__inline {
  color: rgba(31, 35, 53, 0.6);
}

[data-theme="dark"] .portal-header__inline {
  color: rgba(245, 247, 251, 0.65);
}

.portal-brand strong {
  font-size: 1rem;
}

.portal-brand small {
  font-size: 0.75rem;
}

.portal-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--portal-accent), rgba(0, 0, 0, 0.35));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 20px rgba(0, 0, 0, 0.1);
}

.portal-nav {
  position: sticky;
  top: 72px;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: color-mix(in srgb, var(--portal-card-bg) 92%, transparent);
  border-bottom: 1px solid var(--portal-border);
  backdrop-filter: blur(18px);
}

.portal-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  color: var(--portal-text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.portal-nav__link:hover {
  background: var(--portal-accent-soft);
  color: var(--portal-accent);
}

.portal-nav__link.is-active {
  background: var(--portal-accent-soft);
  color: var(--portal-accent);
  font-weight: 600;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.portal-nav-mobile {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 0.5rem clamp(1rem, 4vw, 2rem);
  padding-bottom: calc(env(safe-area-inset-bottom) + 0.75rem);
  background: color-mix(in srgb, var(--portal-card-bg) 95%, transparent);
  border-top: 1px solid var(--portal-border);
  backdrop-filter: blur(24px);
  box-shadow: 0 -20px 40px rgba(15, 23, 42, 0.14);
  z-index: 1040;
}

.portal-nav-mobile__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  text-decoration: none;
  color: rgba(31, 35, 53, 0.65);
  background: transparent;
  border: none;
}

.portal-nav-mobile__item i {
  font-size: 1.2rem;
}

.portal-nav-mobile__item.is-active {
  color: var(--portal-accent);
}

.portal-main {
  flex: 1 1 auto;
  padding: 2.5rem clamp(1.25rem, 5vw, 2.5rem) 3.5rem;
}

.portal-footer {
  border-top: 1px solid var(--portal-border);
  background: rgba(0, 0, 0, 0.02);
}

.portal-login-container {
  padding-top: 4rem;
}

.portal-card {
  background: var(--portal-card-bg);
  border-radius: var(--portal-radius-lg);
  border: 1px solid var(--portal-border);
  box-shadow: var(--portal-shadow-sm);
}

.portal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.portal-stat {
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 140px;
  box-shadow: var(--portal-shadow-sm);
}

.portal-stat__label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(31, 35, 53, 0.6);
}

[data-theme="dark"] .portal-stat__label {
  color: rgba(245, 247, 251, 0.6);
}

.portal-stat__value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--portal-text);
}

.portal-stat__value--muted {
  color: rgba(31, 35, 53, 0.65);
}

[data-theme="dark"] .portal-stat__value--muted {
  color: rgba(245, 247, 251, 0.65);
}

.portal-highlight {
  background: var(--portal-accent-soft);
  border-radius: var(--portal-radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-highlight__label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.portal-highlight__value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--portal-text);
}

.portal-highlight--empty {
  flex-direction: row;
  align-items: center;
  gap: 1.25rem;
}

.portal-highlight--empty i {
  font-size: 2rem;
  color: rgba(31, 35, 53, 0.35);
}

[data-theme="dark"] .portal-highlight--empty i {
  color: rgba(245, 247, 251, 0.35);
}

.portal-invoice-list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(31, 35, 53, 0.08);
}

.portal-invoice-list__item:last-child {
  border-bottom: none;
}

[data-theme="dark"] .portal-invoice-list__item {
  border-bottom-color: rgba(245, 247, 251, 0.08);
}

.portal-diagnostics__item {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: rgba(31, 35, 53, 0.75);
}

[data-theme="dark"] .portal-diagnostics__item {
  color: rgba(245, 247, 251, 0.75);
}

.portal-diagnostics__item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--portal-accent);
  position: absolute;
  left: 0;
  top: 0.45rem;
}

.portal-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-quick-action {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  border: 1px dashed var(--portal-border);
  border-radius: var(--portal-radius-md);
  background: transparent;
  color: var(--portal-text);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.portal-quick-action i {
  font-size: 1.5rem;
  color: var(--portal-accent);
}

.portal-quick-action strong {
  display: block;
  font-size: 1rem;
}

.portal-quick-action small {
  color: rgba(31, 35, 53, 0.6);
}

[data-theme="dark"] .portal-quick-action small {
  color: rgba(245, 247, 251, 0.6);
}

.portal-quick-action:hover {
  border-style: solid;
  border-color: var(--portal-accent);
  background: var(--portal-accent-soft);
  transform: translateY(-1px);
}

.portal-quick-action:disabled,
.portal-quick-action[disabled] {
  cursor: not-allowed;
  opacity: 0.85;
}

.portal-announcements {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-announcement {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--portal-radius-md);
  border: 1px solid var(--portal-border);
  background: rgba(0, 0, 0, 0.015);
  box-shadow: var(--portal-shadow-sm);
}

[data-theme="dark"] .portal-announcement {
  background: rgba(255, 255, 255, 0.03);
}

.portal-announcement__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 1.3rem;
}

.portal-announcement__title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.portal-panel {
  background: var(--portal-card-bg);
  border-radius: var(--portal-radius-lg);
  border: 1px solid var(--portal-border);
  padding: 1.5rem;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--portal-shadow-sm);
}

.portal-table table {
  background: var(--portal-card-bg);
  border-radius: var(--portal-radius-lg);
  overflow: hidden;
}

.portal-table thead {
  background: rgba(0, 0, 0, 0.02);
}

.portal-empty {
  background: rgba(0, 0, 0, 0.02);
  border: 1px dashed var(--portal-border);
  border-radius: 24px;
}

.portal-panel__header {
  margin-bottom: 1rem;
}

.portal-panel__body {
  flex: 1 1 auto;
}

.portal-placeholder {
  background: var(--portal-accent-soft);
  border-radius: var(--portal-radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  color: var(--portal-accent);
  font-weight: 600;
}

.portal-placeholder i {
  font-size: 1.5rem;
}

.skeleton {
  position: relative;
  color: transparent !important;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.05));
  background-size: 200% 100%;
  animation: portal-skeleton-shimmer 1.2s linear infinite;
  border-radius: 6px;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
}

.skeleton::selection {
  background: transparent;
}

.skeleton--text {
  min-height: 1em;
  display: inline-flex;
  align-items: center;
}

@keyframes portal-skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.portal-checklist {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.portal-checklist li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.5rem;
}

.portal-checklist li::before {
  position: absolute;
  left: 0;
  top: 0.2rem;
  font-family: "bootstrap-icons";
}

.portal-checklist li.done::before {
  content: "\f26e";
  color: var(--portal-accent);
}

.portal-checklist li.pending::before {
  content: "\f287";
  color: rgba(31, 35, 53, 0.5);
}

.portal-pix__status {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.portal-pix__status strong {
  font-variant-numeric: tabular-nums;
}

.portal-pix__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.portal-pix__qr img {
  max-width: 220px;
  box-shadow: var(--portal-shadow-sm);
}

.portal-usage-chart {
  position: relative;
  width: 100%;
  min-height: 200px;
}

.portal-usage-chart canvas {
  width: 100%;
  height: 200px;
  display: block;
}

.portal-usage-summary {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.portal-usage-summary div {
  min-width: 140px;
}

.portal-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(31, 35, 53, 0.08);
  font-size: 0.87rem;
  font-weight: 600;
}

[data-theme="dark"] .portal-status-chip {
  background: rgba(245, 247, 251, 0.08);
}

.portal-status-chip__indicator {
  display: inline-flex;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
  background: rgba(31, 35, 53, 0.35);
  box-shadow: 0 0 0 4px rgba(31, 35, 53, 0.08);
}

[data-theme="dark"] .portal-status-chip__indicator {
  background: rgba(245, 247, 251, 0.45);
  box-shadow: 0 0 0 4px rgba(245, 247, 251, 0.08);
}

.portal-status-chip__indicator[data-status="success"] {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.24);
}

.portal-status-chip__indicator[data-status="warning"] {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.portal-status-chip__indicator[data-status="danger"] {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
}

.portal-status-chip__indicator[data-status="offline"] {
  background: rgba(31, 35, 53, 0.45);
}

.portal-status-chip--success {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
}

.portal-status-chip--warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
}

.portal-status-chip--danger {
  background: rgba(239, 68, 68, 0.12);
  color: #7f1d1d;
}

[data-theme="dark"] .portal-status-chip--success {
  color: #bbf7d0;
}

[data-theme="dark"] .portal-status-chip--warning {
  color: #fde68a;
}

[data-theme="dark"] .portal-status-chip--danger {
  color: #fecaca;
}

.portal-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-timeline__item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px dashed var(--portal-border);
}

.portal-timeline__item:last-child {
  border-bottom: none;
}

.portal-timeline__indicator {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--portal-accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--portal-accent);
}

.portal-timeline__item--success .portal-timeline__indicator {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.portal-timeline__item--danger .portal-timeline__indicator {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.portal-timeline__item--warning .portal-timeline__indicator {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.portal-timeline__item--primary .portal-timeline__indicator {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.portal-filters {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr auto;
  align-items: end;
  background: var(--portal-card-bg);
  border-radius: var(--portal-radius-md);
  border: 1px solid var(--portal-border);
  padding: 1rem;
  box-shadow: var(--portal-shadow-sm);
}

.portal-filters__group {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.portal-filters__search .input-group-text {
  background: transparent;
  border-right: none;
}

.portal-filters__search .form-control {
  border-left: none;
  padding-left: 0.25rem;
}

.portal-invoice-group {
  margin-bottom: 2rem;
}

.portal-invoice-group:last-of-type {
  margin-bottom: 0;
}

.portal-invoice-row--match {
  background: rgba(0, 99, 247, 0.05);
}

[data-theme="dark"] .portal-invoice-row--match {
  background: rgba(0, 180, 255, 0.1);
}

.portal-invoice-row--dim {
  opacity: 0.6;
}

.portal-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

.portal-theme-toggle i {
  font-size: 1rem;
}

.portal-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--portal-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.portal-avatar__label {
  font-weight: 600;
  margin-left: 0.5rem;
}

.portal-user-menu .dropdown-menu {
  border-radius: var(--portal-radius-md);
  border: 1px solid var(--portal-border);
  box-shadow: var(--portal-shadow-lg);
}

.portal-notify {
  position: relative;
}

.portal-notify__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  border-radius: 999px;
  background: var(--portal-accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--portal-card-bg);
}

.portal-toast {
  box-shadow: var(--portal-shadow-lg);
}

@media (max-width: 1024px) {
  .portal-nav {
    top: 66px;
  }
}

@media (max-width: 768px) {
  .portal-main {
    padding: 1.5rem 1rem 2.5rem;
  }

  .portal-nav {
    flex-wrap: wrap;
    gap: 0.25rem;
    top: 60px;
  }

  .portal-stats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .portal-quick-action {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .portal-announcement {
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-announcement__icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .portal-nav-mobile {
    display: flex;
  }

  .portal-header__inline {
    display: none !important;
  }

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