/* ═══════════════════════════════════════════════════════
   PRECISION LEDGER — Meu Posto v7
   Design: Enterprise Dark / Tech-Minimalist
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-app: #0a0b0e;
  --bg-panel: rgba(16, 18, 23, 0.6);
  --bg-surface: rgba(255, 255, 255, 0.03);
  --bg-surface-hover: rgba(255, 255, 255, 0.06);
  
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.2);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.15);
  
  --font-main: 'Bricolage Grotesque', sans-serif;
  --font-mono: 'Geist Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

/* ── Base ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Ambient Background ── */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  right: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--success);
  bottom: -100px;
  left: -100px;
}

.grain-overlay {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3%3Cfilter id='noiseFilter'%3%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3%3C/filter%3%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3%3C/svg%3");
  opacity: 0.03;
  pointer-events: none;
}

/* ── App Container ── */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  padding: 32px 40px;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: white;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text .brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-text .product {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-badge {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Layout ── */
.main-layout {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 32px;
  padding: 0 40px 40px;
  position: relative;
}

/* ── Cockpit Panel ── */
.cockpit-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  width: 380px;
  flex-shrink: 0;
  height: calc(100vh - 80px);
  position: sticky;
  top: 40px;
  z-index: 10;
}

.analysis-panel {
  flex: 1;
  min-width: 0;
}

.panel-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.scroll-area::-webkit-scrollbar {
  width: 4px;
}

.scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 10px;
}

.input-section {
  margin-bottom: 32px;
}

.section-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-btn.active {
  transform: rotate(180deg);
}

.input-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-stack.compact {
  gap: 12px;
}

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

.field-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-surface-hover);
}

.input-wrapper input {
  width: 100%;
  background: none;
  border: none;
  color: white;
  padding: 12px 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  outline: none;
}

.input-wrapper .unit,
.input-wrapper .prefix {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 8px;
}

.input-wrapper .prefix {
  margin-left: 0;
  margin-right: 8px;
}

/* ── Sliders ── */
.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

.range-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: right;
  color: var(--accent);
  margin-top: 4px;
}

.collapsible-panel {
  display: none;
}

.collapsible-panel.open {
  display: block;
}

.panel-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.reset-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.reset-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-bright);
}

/* ── Analysis Panel ── */
.analysis-panel {
  display: flex;
  flex-direction: column;
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Hero Card ── */
.hero-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(16, 185, 129, 0.05));
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  z-index: 0;
}

.hero-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.hero-value {
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  margin-bottom: 16px;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-delta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.delta-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.delta-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--success);
}

.hero-chart-mini {
  width: 100%;
}

.mini-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--accent), var(--success));
  box-shadow: 0 0 15px var(--accent-glow);
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-card.success .stat-value {
  color: var(--success);
}

/* ── Viz Card ── */
.visualization-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.comparison-viz {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.viz-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viz-info {
  display: flex;
  justify-content: space-between;
}

.viz-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.viz-amount {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
}

.viz-bar-track {
  height: 32px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.viz-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.viz-bar-fill.primary {
  background: linear-gradient(to right, var(--accent), #818cf8);
}

.viz-bar-fill.secondary {
  background: linear-gradient(to right, #475569, #94a3b8);
}

/* ── Ledger Table ── */
.ledger-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
}

.ledger-table {
  display: flex;
  flex-direction: column;
}

.ledger-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.ledger-row:last-child {
  border-bottom: none;
}

.ledger-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.ledger-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
}

.ledger-row.highlight {
  background: rgba(255, 255, 255, 0.02);
  margin: 0 -32px;
  padding: 14px 32px;
  border-top: 1px solid var(--border);
}

.ledger-row.credit .ledger-val {
  color: var(--success);
}

.ledger-row.total {
  margin-top: 12px;
  padding-top: 24px;
  border-top: 2px solid var(--border-bright);
}

.ledger-row.total .ledger-desc {
  font-weight: 700;
  color: white;
}

.ledger-row.total .ledger-val {
  font-size: 1.2rem;
  color: var(--accent);
}

/* ── Footer ── */
.app-footer {
  padding: 40px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: white;
}

.separator {
  opacity: 0.3;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  
  .cockpit-panel {
    position: relative;
    top: 0;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .app-header { padding: 20px; }
  .main-layout { padding: 0 20px 20px; }
  .hero-value { font-size: 2.5rem; }
  .stats-row { grid-template-columns: 1fr; }
  .footer-content { flex-direction: column; gap: 20px; text-align: center; }
}
