/* ========== LAYOUT PRINCIPAL ========== */
.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-primary);
}

/* ========== LOGIN PAGE WRAPPER ========== */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--bg-primary);
  padding: 24px; /* Adiciona um padding para telas menores */
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px 20px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.sidebar-brand {
  display: grid;
  gap: 8px;
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-mark {
  color: var(--accent-primary);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(to bottom, #fff, #888);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(0, 229, 255, 0.06);
  border-color: rgba(0, 229, 255, 0.15);
  transform: translateX(2px);
}

.nav-item.active {
  color: var(--accent-primary);
  background: rgba(0, 229, 255, 0.1);
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: var(--shadow-glow-soft);
}

.sidebar-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 16px 4px;
  margin-top: 8px;
}

.nav-item:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.sidebar-logout {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 128, 147, 0.2);
  border-radius: var(--radius-md);
  color: #ffb0bc;
  background: rgba(255, 128, 147, 0.06);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.sidebar-logout:hover {
  background: rgba(255, 128, 147, 0.12);
  border-color: rgba(255, 128, 147, 0.35);
  transform: translateY(-1px);
}

/* ========== CONTEÚDO PRINCIPAL ========== */
.content-shell {
  margin-left: 250px;
  width: calc(100% - 250px);
  flex: 1;
  min-height: 100vh;
  padding: 60px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.content-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.module-outlet {
  display: grid;
  gap: 24px;
}

/* ========== CARDS PADRÃO ========== */
.module-card,
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all var(--transition-smooth);
}

.module-card:hover {
  border-color: var(--border-strong);
}

.module-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.module-eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: 700;
}

.module-title {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.module-copy {
  margin: 0;
  color: var(--text-muted);
  max-width: 72ch;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ========== STATUS CHIP ========== */
.status-chip {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 229, 255, 0.25);
  background: rgba(18, 24, 33, 0.7);
  color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0, 229, 255, 0.1);
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
}

/* ========== RESUMO FINANCEIRO (HIERARQUIA) ========== */
.cost-hero {
  display: grid;
  gap: 24px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.cost-hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: var(--accent-primary);
  background: rgba(0, 229, 255, 0.06);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(0, 229, 255, 0.1);
}

.cost-summary {
  display: grid;
  gap: 20px;
}

.cost-summary-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

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

/* Valor da Obra + Impostos */
.cost-metric-obra,
.cost-metric-tax {
  grid-column: span 3;
  min-height: 120px;
}

/* Custos Totais */
.cost-metric-total {
  grid-column: span 4;
  padding: 20px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.06), rgba(124, 92, 255, 0.04));
  border-color: rgba(0, 229, 255, 0.2);
}

/* LUCRO - DESTAQUE PRINCIPAL */
.cost-metric-profit {
  grid-column: span 8;
  min-height: 200px;
  padding: 28px;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.08) 0%, rgba(0, 229, 255, 0.02) 100%);
  border-color: rgba(0, 229, 255, 0.25);
  position: relative;
  overflow: hidden;
}

.cost-metric-profit::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 150%;
  background: radial-gradient(ellipse, rgba(0, 229, 255, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.cost-metric-profit.is-positive {
  background: linear-gradient(180deg, rgba(94, 240, 166, 0.08) 0%, rgba(94, 240, 166, 0.02) 100%);
  border-color: rgba(94, 240, 166, 0.25);
}

.cost-metric-profit.is-negative {
  background: linear-gradient(180deg, rgba(255, 128, 147, 0.08) 0%, rgba(255, 128, 147, 0.02) 100%);
  border-color: rgba(255, 128, 147, 0.25);
}

/* Margem */
.cost-metric-margin {
  grid-column: span 4;
  min-height: 200px;
  padding: 28px;
}

.cost-metric {
  display: grid;
  gap: 10px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.cost-metric:hover {
  border-color: rgba(0, 229, 255, 0.15);
  background: rgba(0, 229, 255, 0.02);
}

.cost-metric span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.cost-metric strong {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.cost-summary-value {
  display: inline-flex;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  transition: transform 200ms ease, text-shadow 200ms ease, color 200ms ease;
}

.cost-summary-value.is-updating {
  transform: translateY(-2px) scale(1.02);
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.2);
}

.cost-summary-value-obra {
  font-size: 1.5rem;
  color: var(--text-primary);
}

.cost-summary-value-subtle {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.cost-summary-value-total {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  color: var(--text-primary);
}

.cost-summary-value-profit {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.06em;
  color: var(--accent-primary);
}

.cost-summary-value-profit.is-positive {
  color: var(--accent-success);
  text-shadow: 0 0 32px rgba(94, 240, 166, 0.3);
}

.cost-summary-value-profit.is-negative {
  color: var(--accent-danger);
  text-shadow: 0 0 32px rgba(255, 128, 147, 0.3);
}

.cost-summary-value-margin {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  font-weight: 800;
  color: var(--text-primary);
}

/* ========== CUSTOS HUB ========== */
.cost-hub-shell {
  display: grid;
  gap: 24px;
}

.cost-hub-hero {
  display: grid;
  gap: 12px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.cost-hub-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  margin-top: 12px;
}

.cost-hub-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 32px;
  background: linear-gradient(180deg, var(--bg-surface-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.cost-hub-card:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--border-strong);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
  background: var(--bg-surface-hover);
}

.cost-hub-card-media {
  width: 56px;
  height: 56px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  transition: transform var(--transition-fast);
}

.cost-hub-card:hover:not(:disabled) .cost-hub-card-media {
  transform: scale(1.1);
  border-color: var(--accent-primary);
}

.cost-hub-card strong {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.cost-hub-card p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.cost-hub-card-cta {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.cost-hub-card:hover:not(:disabled) .cost-hub-card-cta {
  opacity: 1;
}

.cost-hub-card-coming {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-surface);
  border-style: dashed;
}

.cost-hub-coming-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 4px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ========== BUDGET ========== */
.budget-layout {
  display: grid;
  gap: 24px;
}

.budget-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.budget-hero-label {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.budget-hero-value {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.3);
}

.budget-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr 0.9fr;
}

/* ========== TABELAS ========== */
.cost-table,
.budget-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.cost-table th,
.cost-table td,
.budget-table th,
.budget-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.cost-table th,
.budget-table th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.01);
}

.cost-table tbody tr,
.budget-table tbody tr {
  transition: background var(--transition-fast);
}

.cost-table tbody tr:hover,
.budget-table tbody tr:hover {
  background: rgba(0, 229, 255, 0.03);
}

.cost-table td output,
.budget-table td:last-child {
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ========== FORMULÁRIOS ========== */
.cost-field,
.field {
  display: grid;
  gap: 8px;
}

.cost-field span,
.field label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cost-field input,
.cost-field select,
.field input {
  width: 100%;
  padding: 12px 14px;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(138, 147, 166, 0.2);
  border-radius: var(--radius-md);
  outline: none;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.cost-field input:focus,
.cost-field select:focus,
.field input:focus {
  border-color: rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15), var(--shadow-glow-soft);
  transform: translateY(-1px);
  background: var(--bg-surface-hover);
}

/* ========== BOTÕES ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
  box-shadow: var(--shadow-glow-soft);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border: none;
  color: var(--bg-primary);
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 8px 32px rgba(0, 229, 255, 0.35);
}

.btn-ghost {
  border-color: var(--border-default);
  background: rgba(255, 255, 255, 0.02);
}

.btn-ghost:hover {
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: var(--shadow-glow-soft);
  background: rgba(0, 229, 255, 0.04);
}

/* ========== FEEDBACK ========== */
.cost-feedback {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 229, 255, 0.2);
  background: rgba(0, 229, 255, 0.04);
}

.feedback-success {
  border-color: rgba(94, 240, 166, 0.3);
  background: rgba(94, 240, 166, 0.06);
  box-shadow: 0 0 0 1px rgba(94, 240, 166, 0.1);
}

.feedback-error {
  border-color: rgba(255, 128, 147, 0.3);
  background: rgba(255, 128, 147, 0.06);
  box-shadow: 0 0 0 1px rgba(255, 128, 147, 0.1);
}

/* ========== ANIMAÇÕES ========== */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cost-summary-value.is-updating {
  animation: countUp 0.3s var(--transition-smooth);
}

/* ========== RESPONSIVO ========== */
@media (max-width: 1040px) {
  .cost-summary-grid {
    grid-template-columns: 1fr;
  }
  
  .cost-metric-obra,
  .cost-metric-tax,
  .cost-metric-total,
  .cost-metric-profit,
  .cost-metric-margin {
    grid-column: 1 / -1;
  }
  
  .budget-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 16px;
    gap: 12px;
  }
  
  .sidebar-brand {
    padding-bottom: 0;
    border-bottom: 0;
    border-right: 1px solid var(--border-subtle);
    padding-right: 16px;
  }
  
  .sidebar-nav {
    flex: 1;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  .sidebar-logout {
    margin-top: 0;
  }
  
  .content-shell {
    margin-left: 0;
    padding: 24px 16px 32px;
  }
  
  .cost-hub-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== PRINT ========== */
@media print {
  .sidebar,
  .auth-screen,
  .sidebar-logout {
    display: none !important;
  }
  
  .content-shell {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  
  .module-card,
  .panel,
  .cost-hero,
  .budget-hero {
    box-shadow: none !important;
    border-color: #d9d9d9 !important;
    background: #ffffff !important;
    color: #111111 !important;
  }
}
