/* ==========================================================================
   SIMULADOR DE AMORTIZAÇÃO - DESIGN SYSTEM & STYLES (Cloudflare Pages Ready)
   ========================================================================== */

:root {
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #0a2cff;
  --primary-900: #0524dd;

  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-card: #131b2e;
  --bg-card-subtle: #1c263d;
  --bg-input: #17223b;
  --border-color: #273553;
  --border-focus: #60a5fa;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-page);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   HEADER & NAVBAR
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}
[data-theme="dark"] .site-header {
  background-color: rgba(19, 27, 46, 0.85);
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}
.brand-link:hover {
  text-decoration: none;
}
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-800), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 10px rgba(10, 44, 255, 0.3);
}
.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-title span.highlight {
  background: linear-gradient(120deg, var(--primary-600), var(--success-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.api-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--success-50);
  color: var(--success-700);
  border: 1px solid var(--success-100);
}
[data-theme="dark"] .api-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success-500);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
  color: white;
  box-shadow: 0 4px 12px rgba(10, 44, 255, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  box-shadow: 0 6px 16px rgba(10, 44, 255, 0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-600), var(--success-700));
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--bg-card-subtle);
  border-color: var(--text-muted);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-main);
}
.btn-ghost:hover {
  background-color: var(--bg-card-subtle);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger-600);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}
.btn-danger-ghost:hover {
  background-color: var(--danger-50);
}
[data-theme="dark"] .btn-danger-ghost:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   CONTAINER & LAYOUT
   ========================================================================== */
.main-wrapper {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Page Intro Header */
.page-hero {
  text-align: center;
  padding: 0.75rem 0 1rem;
}
.hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}
.hero-title span {
  color: var(--primary-600);
}
.hero-desc {
  max-width: 780px;
  margin: 0 auto;
  font-size: 0.975rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Cards & Panels */
.card-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card-panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}
.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}
.panel-title svg {
  color: var(--primary-600);
}

/* ==========================================================================
   FORM & INPUTS
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  align-items: end;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.input-label span.req {
  color: var(--danger-500);
}

.input-control {
  width: 100%;
  padding: 0.65rem 0.875rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
  font-size: 0.95rem;
}
.input-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-with-select {
  display: flex;
  gap: 0.375rem;
}
.input-with-select .input-control {
  flex: 1;
}
.input-with-select select {
  width: 110px;
}

.form-actions-bar {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}
.privacy-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.privacy-note svg {
  color: var(--success-500);
}

/* ==========================================================================
   PLANO DE AMORTIZAÇÃO (ACTION BUTTONS & LIST)
   ========================================================================== */
.plan-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.plans-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.plan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  transition: var(--transition);
}
.plan-item:hover {
  background-color: var(--bg-card-subtle);
  border-color: var(--primary-200);
  transform: translateX(2px);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.plan-badge-term {
  background-color: #dbeafe;
  color: #1e40af;
}
.plan-badge-installment {
  background-color: #e0e7ff;
  color: #3730a3;
}
.plan-badge-fee {
  background-color: #fef3c7;
  color: #92400e;
}
.plan-badge-correction {
  background-color: #fce7f3;
  color: #9d174d;
}

.plan-desc {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-main);
  flex: 1;
}
.plan-val {
  font-weight: 700;
  color: var(--primary-600);
  background: rgba(37, 99, 235, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.plan-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.empty-plans-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   CONQUISTA & HERO STATS BANNER
   ========================================================================== */
.hero-achievement {
  background: linear-gradient(135deg, #091a7a 0%, #0a2cff 50%, #0284c7 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: 0 12px 30px rgba(10, 44, 255, 0.3);
  position: relative;
  overflow: hidden;
}
.hero-achievement::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.achievement-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.achievement-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.achievement-title-area {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}
.achievement-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.achievement-headline {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.achievement-sub {
  font-size: 0.925rem;
  opacity: 0.9;
}

.achievement-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.stat-pill {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.stat-pill-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}
.stat-pill-val {
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 0.25rem;
}
.stat-pill-val.green {
  color: #34d399;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.progress-bar-bg {
  width: 100%;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  opacity: 0.85;
}

/* ==========================================================================
   COMPARISON CARDS
   ========================================================================== */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.compare-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.compare-card.featured {
  border-color: var(--success-500);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.15);
}

.compare-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.compare-header.standard {
  background-color: var(--bg-card-subtle);
}
.compare-header.accelerated {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(37, 99, 235, 0.1));
}

.compare-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.compare-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  flex: 1;
}

.compare-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.925rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px dashed var(--border-color);
}
.compare-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.compare-row .lbl {
  color: var(--text-muted);
}
.compare-row .val {
  font-weight: 600;
  color: var(--text-main);
}
.compare-row.total {
  font-size: 1.05rem;
  padding-top: 0.35rem;
}
.compare-row.total .val {
  font-weight: 800;
  color: var(--primary-600);
}
.compare-card.featured .compare-row.total .val {
  color: var(--success-600);
}

/* ==========================================================================
   CHARTS (ZERO-DEPENDENCY SVG CHARTS)
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.775rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.svg-chart-container {
  width: 100%;
  height: 230px;
  position: relative;
}
.svg-chart-container svg.balance-chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Donut Chart Fix */
.donut-chart-container {
  width: 100%;
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.donut-content-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.donut-visual-box {
  position: relative;
  width: 140px;
  height: 140px;
  min-width: 140px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.donut-visual-box svg.donut-svg {
  width: 140px !important;
  height: 140px !important;
  max-width: 140px !important;
  max-height: 140px !important;
  display: block;
}

.donut-center-badge {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.donut-center-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.donut-legend-box {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
  min-width: 190px;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.donut-legend-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.donut-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.donut-legend-values {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  text-align: right;
  white-space: nowrap;
}

.donut-val {
  font-size: 0.82rem;
  color: var(--text-main);
}

.donut-pct {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(148, 163, 184, 0.15);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .donut-content-layout {
    flex-direction: column;
    gap: 1rem;
  }
  .donut-legend-box {
    width: 100%;
    min-width: 0;
  }
}

/* SVG Chart Tooltips */
.chart-tooltip {
  position: absolute;
  background-color: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  pointer-events: none;
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   DETAILED TABLE & PAGINATION
   ========================================================================== */
.table-tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-nav {
  display: flex;
  gap: 0.35rem;
  background-color: var(--bg-card-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary-600);
  box-shadow: var(--shadow-sm);
}

.table-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.search-input {
  max-width: 200px;
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
}

.table-responsive-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  text-align: right;
  white-space: nowrap;
}
.data-table th, .data-table td {
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid var(--border-color);
}
.data-table th {
  background-color: var(--bg-card-subtle);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.725rem;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
}
.data-table th:first-child, .data-table td:first-child {
  text-align: center;
}
.data-table th:nth-child(2), .data-table td:nth-child(2) {
  text-align: center;
}
.data-table tbody tr:hover {
  background-color: var(--bg-card-subtle);
}
.data-table tbody tr.has-extra-amort {
  background-color: rgba(16, 185, 129, 0.06);
}
.data-table .extra-val {
  color: var(--success-600);
  font-weight: 700;
}

.pagination-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0.25rem 0;
  flex-wrap: wrap;
  font-size: 0.825rem;
  color: var(--text-muted);
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ==========================================================================
   ACCORDION & EDUCATIONAL SECTION
   ========================================================================== */
.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background-color: var(--bg-card);
}
.accordion-summary {
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  list-style: none;
  transition: var(--transition);
}
.accordion-summary::-webkit-details-marker {
  display: none;
}
.accordion-summary:hover {
  background-color: var(--bg-card-subtle);
}
.accordion-icon {
  transition: transform 0.2s ease;
}
details[open] .accordion-icon {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--text-main);
}
.diagram-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 1rem auto;
  display: block;
  border: 1px solid var(--border-color);
}

/* SAC vs Price Comparison Table */
.edu-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}
.edu-table th, .edu-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  text-align: left;
}
.edu-table th {
  background-color: var(--bg-card-subtle);
  font-weight: 700;
}

/* ==========================================================================
   MODALS & BACKDROPS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-card-subtle);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Radio Cards in Modals */
.radio-cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.radio-card-label {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.radio-card-label input[type="radio"] {
  display: none;
}
.radio-card-label.selected {
  border-color: var(--primary-600);
  background-color: rgba(37, 99, 235, 0.08);
  color: var(--primary-600);
}

/* Scenarios List in Manager Modal */
.scenarios-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-height: 280px;
  overflow-y: auto;
}
.scenario-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  transition: var(--transition);
}
.scenario-item:hover {
  background-color: var(--bg-card-subtle);
}
.scenario-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.scenario-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background-color: #0f172a;
  color: white;
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  animation: slideToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}
.toast.success {
  border-left: 4px solid var(--success-500);
}
.toast.info {
  border-left: 4px solid var(--primary-500);
}
.toast.error {
  border-left: 4px solid var(--danger-500);
}
@keyframes slideToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   LOADING SPINNER & OVERLAY
   ========================================================================== */
.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   PRINT STYLESHEET
   ========================================================================== */
@media print {
  body {
    background-color: white !important;
    color: black !important;
  }
  .site-header, .page-hero, .form-actions-bar, .plan-actions-group,
  .plan-item-actions, .table-filter-bar, .pagination-footer, .btn,
  .accordion-summary, .modal-overlay, .toast-container {
    display: none !important;
  }
  .card-panel {
    border: none !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
  }
  .hero-achievement {
    background: #0a2cff !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .data-table th, .data-table td {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.75rem !important;
  }
}

/* ==========================================================================
   RESPONSIVE UTILITY CLASSES
   ========================================================================== */
.modal-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.edu-diagrams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

/* ==========================================================================
   MAIN NAVIGATION TABS (NO TOPO)
   ========================================================================== */
.main-tabs-wrapper {
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

.main-nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  width: max-content;
  min-width: 100%;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

.nav-tab-btn.active {
  background: var(--primary-600);
  color: #ffffff;
  border-color: var(--primary-600);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.tab-btn-icon {
  font-size: 1rem;
}

.tab-btn-pill {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-tab-btn:not(.active) .tab-btn-pill {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-600);
}

/* ==========================================================================
   NEXT ACTIONS DASHBOARD (PRÓXIMAS AÇÕES)
   ========================================================================== */
.next-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  border-top: 4px solid var(--primary-600);
}

.next-actions-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
}

.next-actions-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success-600);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  margin-bottom: 0.5rem;
}

.next-actions-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.next-actions-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  max-width: 650px;
  line-height: 1.5;
}

.status-pill-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.status-pill-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.status-pill-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.status-pill-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-600);
}

.status-pill-sep {
  width: 1px;
  height: 32px;
  background: var(--border-color);
}

/* Metric Cards Grid */
.next-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.metric-action-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.metric-action-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-500);
}

.metric-action-card.highlight {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1.5px solid var(--primary-500);
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.metric-horizon-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary-600);
}

.metric-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-card-amount {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.metric-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 0.6rem;
}

.metric-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-detail-row b {
  color: var(--text-main);
}

/* Special Alert Banner */
.special-alert-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.special-alert-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.special-alert-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.special-alert-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}

.special-alert-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Timeline & Upcoming Months */
.next-timeline-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.timeline-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.horizon-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.horizon-btn-group {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card-subtle);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.horizon-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.horizon-btn.active {
  background: var(--primary-600);
  color: white;
}

.timeline-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.timeline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.timeline-table th {
  background: var(--bg-card-subtle);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.timeline-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  white-space: nowrap;
}

.timeline-table tr:last-child td {
  border-bottom: none;
}

.timeline-table tr.row-current {
  background: rgba(37, 99, 235, 0.05);
}

.timeline-table tr.row-next {
  background: rgba(16, 185, 129, 0.07);
}

.timeline-table tr.row-special {
  background: rgba(245, 158, 11, 0.08);
}

.badge-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.badge-tag.current {
  background: rgba(37, 99, 235, 0.15);
  color: var(--primary-600);
}

.badge-tag.next {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-700);
}

.badge-tag.special {
  background: rgba(245, 158, 11, 0.25);
  color: #b45309;
}

.badge-tag.regular {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
}

.next-actions-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px dashed var(--border-color);
  padding-top: 1.25rem;
}

.next-footer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (MOBILE, TABLET & DESKTOP)
   ========================================================================== */

/* Prevent horizontal overflow across all mobile screens */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base image & SVG flexibility */
img, svg, canvas {
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   TABLETS (max-width: 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .header-container {
    padding: 0.75rem 1rem;
  }
  .main-wrapper {
    padding: 1.25rem 1rem 3.5rem;
    gap: 1.5rem;
  }
  .comparison-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   TABLET PORTRAIT & MOBILE PHONES (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-container {
    padding: 0.625rem 0.875rem;
    gap: 0.5rem;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 1rem;
    line-height: 1.15;
  }

  .brand-subtitle {
    font-size: 0.7rem;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .header-actions .btn-sm {
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
  }

  .header-actions .btn-sm .btn-text {
    display: none;
  }

  .main-wrapper {
    padding: 1rem 0.875rem 3rem;
    gap: 1.25rem;
  }

  .page-hero {
    padding: 0.25rem 0 0.5rem;
  }

  .hero-title {
    font-size: 1.45rem;
    line-height: 1.25;
  }

  .hero-desc {
    font-size: 0.875rem;
    line-height: 1.55;
  }

  /* Main Nav Tabs */
  .main-tabs-wrapper {
    margin-bottom: 1rem;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .main-tabs-wrapper::-webkit-scrollbar {
    display: none;
  }

  .main-nav-tabs {
    padding: 0.3rem;
    gap: 0.35rem;
  }

  .nav-tab-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.82rem;
    gap: 0.35rem;
    scroll-snap-align: start;
  }

  .tab-btn-pill {
    font-size: 0.65rem;
    padding: 0.05rem 0.4rem;
  }

  /* Próximas Ações */
  .next-actions-panel {
    padding: 1.15rem 1rem;
    gap: 1.25rem;
  }

  .next-actions-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding-bottom: 1rem;
  }

  .next-actions-title {
    font-size: 1.2rem;
  }

  .next-actions-subtitle {
    font-size: 0.825rem;
  }

  .status-pill-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
    padding: 0.85rem 1rem;
  }

  .status-pill-sep {
    display: none;
  }

  .status-pill-label {
    font-size: 0.68rem;
  }

  .status-pill-val {
    font-size: 0.95rem;
  }

  .next-metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .metric-action-card {
    padding: 0.9rem 1rem;
  }

  .metric-card-amount {
    font-size: 1.35rem;
  }

  .special-alert-banner {
    padding: 0.875rem 1rem;
    gap: 0.75rem;
  }

  .timeline-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .timeline-title {
    font-size: 0.95rem;
  }

  .horizon-selector {
    width: 100%;
    justify-content: space-between;
  }

  .horizon-btn-group {
    flex: 1;
    display: flex;
  }

  .horizon-btn {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.5rem;
  }

  .timeline-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .timeline-table th, .timeline-table td {
    padding: 0.6rem 0.7rem;
    font-size: 0.78rem;
  }

  .next-actions-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .next-footer-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

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

  /* Form & Parameters */
  .card-panel {
    padding: 1.15rem 1rem;
    border-radius: var(--radius-md);
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .panel-title {
    font-size: 1.15rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }

  .form-actions-bar {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.85rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
  }

  #btnSimulate {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }

  .privacy-note {
    font-size: 0.75rem;
    text-align: center;
    justify-content: center;
  }

  /* Plans Strategy */
  .plan-actions-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .plan-actions-group .btn {
    width: 100%;
    justify-content: center;
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
  }

  .plan-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .plan-desc {
    font-size: 0.825rem;
  }

  .plan-item-actions {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.45rem;
  }

  /* Achievement Banner */
  .hero-achievement {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-md);
  }

  .achievement-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .achievement-headline {
    font-size: 1.2rem;
  }

  .achievement-sub {
    font-size: 0.825rem;
  }

  .achievement-stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-pill {
    padding: 0.75rem;
  }

  .stat-pill-label {
    font-size: 0.68rem;
  }

  .stat-pill-val {
    font-size: 1.15rem;
  }

  /* Comparison Cards */
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .compare-card {
    border-radius: var(--radius-md);
  }

  .compare-header {
    padding: 0.875rem 1rem;
  }

  .compare-title {
    font-size: 1rem;
  }

  .compare-body {
    padding: 0.875rem 1rem;
    gap: 0.65rem;
  }

  .compare-row {
    font-size: 0.825rem;
    padding-bottom: 0.5rem;
  }

  .compare-row.total {
    font-size: 0.95rem;
  }

  /* Charts */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .chart-card {
    padding: 1rem 0.875rem;
    border-radius: var(--radius-md);
    min-height: auto;
  }

  .chart-title {
    font-size: 0.925rem;
  }

  .svg-chart-container {
    height: 190px;
  }

  .donut-chart-container {
    min-height: auto;
  }

  .donut-content-layout {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  .donut-legend-box {
    width: 100%;
    min-width: 0;
  }

  .donut-legend-row {
    padding: 0.4rem 0.55rem;
    font-size: 0.78rem;
  }

  /* Detailed Table */
  .table-tabs-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .tab-nav {
    width: 100%;
    display: flex;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.5rem;
    font-size: 0.78rem;
  }

  .table-filter-bar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .search-input {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .table-filter-bar .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
    padding: 0.45rem 0.65rem;
  }

  .table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .data-table th, .data-table td {
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
  }

  .pagination-footer {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    padding: 0.75rem 0 0;
  }

  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  .pagination-controls .btn {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
    min-width: 32px;
  }

  /* Modals */
  .modal-overlay {
    padding: 0.65rem;
  }

  .modal-card {
    max-height: 94vh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 0.875rem 1rem;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-body {
    padding: 1rem 0.875rem;
    gap: 0.875rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
    padding: 0.75rem 0.875rem;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* Toast Notifications */
  .toast-container {
    left: 0.875rem;
    right: 0.875rem;
    bottom: 0.875rem;
    max-width: none;
  }

  .toast {
    max-width: 100%;
    width: 100%;
    font-size: 0.825rem;
  }
}

/* --------------------------------------------------------------------------
   SMARTPHONES (max-width: 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .brand-subtitle {
    display: none;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
  }

  .api-badge {
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
  }

  /* Prevent zoom on inputs in iOS Safari */
  .input-control, input, select, textarea {
    font-size: 16px !important;
  }

  .edu-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .edu-table th, .edu-table td {
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------
   SMALL SMARTPHONES (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .site-header {
    border-bottom: 1px solid var(--border-color);
  }

  .header-container {
    padding: 0.5rem 0.65rem;
  }

  .header-print-btn {
    display: none !important;
  }

  .api-badge span:not(.pulse-dot) {
    display: none;
  }

  .api-badge {
    padding: 0.35rem;
    border-radius: 50%;
  }

  .main-wrapper {
    padding: 0.75rem 0.6rem 2.5rem;
    gap: 1rem;
  }

  .hero-title {
    font-size: 1.25rem;
  }

  .hero-desc {
    font-size: 0.8rem;
  }

  .status-pill-card {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .achievement-stats-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .modal-grid-2col {
    grid-template-columns: 1fr !important;
  }

  .radio-cards-row {
    grid-template-columns: 1fr;
  }

  .edu-diagrams-grid {
    grid-template-columns: 1fr !important;
  }

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

  .donut-visual-box {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
  }

  .donut-visual-box svg.donut-svg {
    width: 120px !important;
    height: 120px !important;
  }

  .donut-legend-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }

  .donut-legend-values {
    width: 100%;
    justify-content: space-between;
  }

  .chart-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}

/* --------------------------------------------------------------------------
   ULTRA-COMPACT (max-width: 360px)
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .brand-title {
    font-size: 0.85rem;
  }

  .nav-tab-btn {
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
  }

  .metric-card-amount {
    font-size: 1.15rem;
  }
}

/* --------------------------------------------------------------------------
   TOUCH DEVICE SPECIFIC ENHANCEMENTS
   -------------------------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-tab-btn, .horizon-btn, .tab-btn {
    min-height: 38px;
  }

  .btn:active, .nav-tab-btn:active {
    transform: scale(0.98);
  }

  /* Disable sticky hover states on touch */
  .plan-item:hover {
    transform: none;
    background-color: var(--bg-card);
  }

  .metric-action-card:hover {
    transform: none;
  }
}

