:host {
  /* Tokens de Cor - Enterprise Palette */
  --brand: #e33dcf;
  --brand-hover: #c92bb6;
  --brand-soft: rgba(227, 61, 207, 0.08);
  --brand-gradient: linear-gradient(135deg, #e33dcf 0%, #b0249d 100%);
  
  --blue: #030faa;
  --blue-soft: rgba(3, 15, 170, 0.06);
  
  --text-main: #0f172a;
  --text-sec: #64748b;
  --text-light: #94a3b8;
  
  --border: #e2e8f0;
  --surface: #ffffff;
  --bg-page: #f8fafc;
  
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  /* Elevation & Depth */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-elevated: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --focus-ring: 0 0 0 3px rgba(227, 61, 207, 0.2);

  display: block;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background: var(--bg-page);
}

.resumo-page {
  min-height: 100vh;
  padding-bottom: 80px;
}

.wrap { padding-top: 32px; }

.resumo-container {
  width: 100%;
  max-width: 1360px; /* Ligeiramente mais largo para dashboard */
  margin: 0 auto;
  padding: 0 24px;
  
  @media (max-width: 768px) { padding: 0 16px; }
}

/* Animações */
[data-animate] {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
:host(.animate-ready) [data-animate] {
  opacity: 0;
  transform: translateY(15px);
}
:host(.animate-ready) [data-animate].is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .wrap {
    padding-top: 12px;
  }

  :host(.animate-ready) [data-animate] {
    transform: translateY(8px);
  }
}

/* Header */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
  
  @media (max-width: 768px) {
    flex-direction: column;
    align-items: flex-start;
  }
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: white;
  border: 1px solid var(--border);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
  width: fit-content;
}

.flex-title {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.page-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-sec);
  max-width: 600px;
}

/* Status Indicators */
.status-wrapper {
  display: flex;
  gap: 12px;
}
.status {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  
  &.loading { background: #eff6ff; color: var(--blue); }
  &.error { background: #fef2f2; color: var(--danger); }
  &.success { background: #f0fdf4; color: var(--success); }
}
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Botões */
.btn-ghost {
  border: 1px solid var(--border);
  background: white;
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  
  &:hover:not(:disabled) {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
  }
  &:disabled { opacity: 0.6; cursor: wait; }
}

.btn-icon-text {
  @extend .btn-ghost;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(0,0,0,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  
  &:hover {
    background: rgba(0,0,0,0.06);
    color: var(--brand);
  }
}

.btn-mini {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-sec);
  
  &:hover {
    border-color: var(--brand);
    color: var(--brand);
  }
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  
  &:hover { color: var(--text-main); background: #f1f5f9; }
  &.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
  }
}

@media (max-width: 768px) {
  .tab-bar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    padding-bottom: 6px;
  }

  .tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* Hero Section */
.section-hero {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.hero-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  
  @media (max-width: 900px) {
    flex-direction: column;
    align-items: flex-start;
  }
}

.hero-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.hero-text p {
  margin: 0;
  color: var(--text-sec);
  font-size: 13px;
}

.hero-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 600px;
}

.kpi-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s;
  
  &:hover {
    border-color: #cbd5e1;
    background: white;
    box-shadow: var(--shadow-sm);
  }
  
  &.highlight {
    background: linear-gradient(to bottom right, #f8fafc, #fff);
    border-left: 3px solid var(--success);
  }
}

.kpi-lbl {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-sec);
  letter-spacing: 0.04em;
}

.kpi-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  font-feature-settings: "tnum";
}

.kpi-card.kpi-card--total-lines .kpi-val {
  font-size: 16px;
}

/* Grids */
.section-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.planos-charts .chart-card {
  grid-column: span 6;
  @media (max-width: 960px) { grid-column: span 12; }
}

.planos-charts .chart-card.full-span {
  grid-column: span 12;
}

.full-chart .chart-card {
  grid-column: span 12;
}

.chart-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chart-area {
  position: relative;
  height: 300px;
  width: 100%;
  margin-top: 16px;
}

.card-header-clean h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.card-header-clean p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-sec);
}

/* Details/Summary Sections */
.section-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
  
  &:hover { box-shadow: var(--shadow-elevated); }
}

summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: white;
  border-bottom: 1px solid transparent;
  transition: background 0.2s;
  
  &:hover { background: #fcfcfc; }
  &::-webkit-details-marker { display: none; }
}

details[open] summary {
  border-bottom-color: var(--border);
  background: #f8fafc;
}

.summary-content h4 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}
.summary-content span {
  font-size: 13px;
  color: var(--text-sec);
}
.summary-icon {
  color: var(--text-sec);
  transition: transform 0.3s ease;
}
details[open] .summary-icon { transform: rotate(180deg); }

/* Tabelas e Listas */
.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
  background: white;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 8px;
  width: 300px;
  max-width: 100%;
  border: 1px solid transparent;
  transition: all 0.2s;
  
  &:focus-within {
    background: white;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-soft);
  }
  
  input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 13px;
  }
  i { color: var(--text-sec); }
}

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

.select-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: 8px;
  
  select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 24px 4px 8px;
    font-size: 12px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 6px center / 10px;
    appearance: none;
    cursor: pointer;
    
    &:hover { border-color: var(--text-light); }
    &:focus { outline: none; border-color: var(--brand); }
  }
}

.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* Listas Agrupadas */
.macrophony-row, .grouped-row {
  display: grid;
  grid-template-columns: 40px minmax(200px, 1.5fr) 2fr auto;
  gap: 16px;
  padding: 16px 24px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: white;
  transition: background 0.1s;
  cursor: pointer;
  
  &:hover { background: #f8fafc; }
  
  @media (max-width: 768px) {
    grid-template-columns: 40px 1fr;
    gap: 8px;
  }
}

.macrophony-row .group-actions,
.grouped-row .group-actions {
  grid-column: -1;
  justify-self: end;
}

.group-toggle {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  
  &:hover { border-color: var(--brand); color: var(--brand); }
}

.group-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.group-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.group-metrics {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  
  @media (max-width: 768px) {
    grid-column: 2;
    justify-content: flex-start;
    margin-top: 8px;
  }
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  
  @media (max-width: 768px) { align-items: flex-start; }
}

.metric .lbl {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.05em;
}
.metric strong {
  font-size: 14px;
  color: var(--text-main);
}

.badge-tag {
  background: #f1f5f9;
  color: var(--text-main);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  
  &.secondary { background: white; border-color: var(--border); color: var(--text-sec); }
}

/* Tabelas Internas */
.macrophony-details, .grouped-details {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.table-wrap {
  overflow-x: auto;
  
  &.is-nested { padding: 16px 24px; }
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  
  &.compact td, &.compact th { padding: 8px 12px; }
  
  th {
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-sec);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  td {
    text-align: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    transition: background 0.1s;
  }
  
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: white; }
  
  /* Auxiliares */
  .text-right { text-align: center; }
  .text-center { text-align: center; }
  .num-font { font-family: 'Roboto Mono', monospace; font-size: 12px; }
  .font-bold { font-weight: 700; }
  .text-brand { color: var(--brand); }
  .text-success { color: var(--success); }
  .text-danger { color: var(--danger); }
}

.diff-row td { background: #fff5f9; }

/* Footers */
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: white;
  border-top: 1px solid var(--border);
  
  @media (max-width: 600px) {
    flex-direction: column;
    gap: 12px;
  }
}

.table-count {
  font-size: 12px;
  color: var(--text-sec);
}

.pagination {
  display: flex;
  gap: 4px;
}

.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  
  &:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
  &.active { background: var(--brand); color: white; border-color: var(--brand); }
  &:disabled { opacity: 0.5; cursor: default; }
}

/* Resumo Bars (Totais) */
.macrophony-summary, .grouped-summary-bar {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.summary-item, .sum-col {
  display: flex;
  flex-direction: column;
  
  span { font-size: 11px; text-transform: uppercase; color: var(--text-sec); font-weight: 700; }
  strong { font-size: 16px; color: var(--text-main); }
  
  &.highlight strong { color: var(--brand); }
}

/* Modais */
.macrophony-modal, .grouped-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.macrophony-backdrop, .grouped-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
}

.macrophony-card, .grouped-card {
  background: white;
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  z-index: 101;
  overflow: hidden;
  animation: modalUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.detail-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: white;
  
  h4 { margin: 0; font-size: 18px; font-weight: 700; }
  .detail-super { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-sec); font-weight: 700; margin-bottom: 4px; }
}

.macrophony-modal-body, .grouped-modal-body {
  overflow-y: auto;
  padding: 0; 
}

/* Utils */
.hide-mobile {
  @media (max-width: 600px) { display: none; }
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-sec);
  
  i { font-size: 32px; margin-bottom: 12px; display: block; opacity: 0.5; }
  p { margin: 0; font-size: 14px; }
}
