/* =========================================
   1. CSS VARIABLES & CONFIGURATION
   ========================================= */
:root {
  /* --- COLOR PALETTE (Modern Fintech) --- */
  /* --primary:       #2563eb;  Royal Blue: Main Brand, Buttons, Sliders */
  --primary:       #242145;
  --primary-hover: #1d4ed8;  /* Darker Blue: Hover states */
  --accent:        #10b981;  /* Emerald Green: Success, Growth, Secondary Data */
  --accent-warm:   #f59e0b;  /* Amber: Warnings, Secondary Charts */
  
  --dark:          #0f172a;  /* Dark Slate: Headings, Footer, Strong Text */
  --text:          #334155;  /* Slate Gray: Body text */
  --text-muted:    #64748b;  /* Light Gray: Labels, Hints */
  
  --bg-body:       #f8fafc;  /* Cool Gray: Page Background */
  --bg-card:       #ffffff;  /* Pure White: Cards */
  --bg-light:      #eff6ff;  /* Light Blue Tint: Result Boxes */
  
  /* --- LAYOUT & SHAPES --- */
  --container-width: 1200px;
  --header-height:   70px;
  --radius:          12px;
  --shadow:          0 10px 30px -10px rgba(0,0,0,0.08);
  
  /* --- TYPOGRAPHY --- */
  --font-main:       'Poppins', sans-serif;
}

/* =========================================
   2. GLOBAL RESET & BASE STYLES
   ========================================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  /* padding: 0 20px; */
}

h1, h2, h3, h4 { color: var(--dark); margin-top: 0; }
a { text-decoration: none; color: inherit; transition: 0.2s; }

/* Utilities */
.hidden { display: none !important; }
.text-right { text-align: right; }
.bold { font-weight: 700; }

/* =========================================
   3. HEADER STYLES
   ========================================= */
.site-header {
  background: var(--bg-card);
  height: var(--header-height);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}


.header-container {
  max-width: var(--container-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.5px;
}
.logo img {
    width: 50px;
    height: 50px;
    filter: 
        grayscale(100%)
        brightness(40%)
        sepia(100%)
        hue-rotate(230deg)
        saturate(300%);
}


/* Page Title (Below Header) */
.page-header { text-align: center; margin: 30px 15px; }
.page-title { font-size: 32px; font-weight: 700; color: var(--dark); margin-bottom: 5px; }
.page-subtitle { color: var(--text-muted); font-size: 15px; }
.icon-box {
  width: 60px; height: 60px; margin: 0 auto 15px;
  background: var(--primary); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* =========================================
   4. CALCULATOR LAYOUT & COMPONENTS
   ========================================= */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 30px;
  border: 1px solid #e2e8f0;
}

.grid {
  display: grid;
  gap: 40px;
}
@media(min-width: 900px) { 
  .grid { grid-template-columns: 1.2fr 0.8fr; align-items: start; } 
}

/* Controls (Currency) */
.top-controls { display: flex; justify-content: center; gap: 10px; margin-bottom: 24px; }
.select-box {
  padding: 8px 16px; border-radius: 50px; border: 1px solid #cbd5e1;
  background: var(--bg-card); font-weight: 600; color: var(--dark);
  cursor: pointer; outline: none; transition: 0.2s;
}
.select-box:hover { border-color: var(--primary); }

/* Input Fields */
.field { margin-bottom: 24px; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.val-display { color: var(--primary); font-weight: 700; font-size: 16px; }

/* Custom Range Slider */
.slider {
  width: 100%; height: 8px; border-radius: 10px;
  -webkit-appearance: none; background: #e2e8f0;
  outline: none; margin-bottom: 15px; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px;
  border-radius: 50%; background: var(--bg-card);
  border: 2px solid var(--primary);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: transform 0.1s; margin-top: -1px;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Number Input */
.input-wrap input {
  width: 100%; padding: 12px; border-radius: 8px;
  border: 1px solid #cbd5e1; font-family: var(--font-main);
  font-weight: 600; color: var(--dark); font-size: 16px;
  transition: 0.2s;
}
.input-wrap input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* Advanced Toggle */
.adv-toggle {
  width: 100%; padding: 12px; border: 1px dashed #cbd5e1;
  background: var(--bg-body); color: var(--text-muted);
  font-weight: 600; border-radius: 8px; cursor: pointer;
  margin-top: 10px; transition: 0.2s; font-size: 14px;
}
.adv-toggle:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.adv-content { display: none; margin-top: 15px; padding: 20px; background: var(--bg-body); border-radius: 10px; }
.adv-content.show { display: block; animation: slideDown 0.3s ease; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   5. RESULTS SECTION
   ========================================= */
.res-box {
  background: var(--bg-light);
  padding: 25px; border-radius: var(--radius);
  text-align: center; margin-bottom: 24px;
  border: 1px solid #dbeafe;
}
.res-emi { font-size: 38px; font-weight: 800; color: var(--primary); line-height: 1.2; margin: 5px 0; }
.res-lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.breakdown {
  background: var(--bg-card); border: 1px solid #e2e8f0;
  border-radius: var(--radius); padding: 20px;
}
.b-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 12px; color: var(--text-muted); }
.b-row strong { color: var(--dark); font-weight: 600; }
.b-total { border-top: 1px solid #e2e8f0; padding-top: 15px; margin-top: 5px; font-weight: 700; color: var(--dark); font-size: 16px; }

/* Buttons */
.btn-print, .btn-shorten {
  background: var(--dark); color: white; border: none;
  padding: 12px 24px; border-radius: 50px; cursor: pointer;
  font-weight: 600; display: inline-flex; align-items: center;
  gap: 8px; transition: 0.2s; font-size: 14px;
}
.btn-print:hover { background: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,0.2); }

/* =========================================
   6. CHARTS & TABLES
   ========================================= */
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 25px; flex-wrap: wrap; gap: 15px;
}
.tabs { display: flex; gap: 5px; background: #f1f5f9; padding: 5px; border-radius: 8px; }
.tab-btn {
  padding: 8px 20px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; font-weight: 600;
  color: var(--text-muted); transition: 0.2s;
}
.tab-btn.active { background: var(--bg-card); color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Chart Grid (Responsive + Fix) */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
}
/* @media(min-width: 900px) { .charts-grid { grid-template-columns: 1fr 1fr 1fr; } } */

.chart-card {
  background: var(--bg-body); border-radius: var(--radius);
  padding: 15px; border: 1px solid #e2e8f0;
  min-height: 250px;
  min-width: 0; /* CRITICAL FIX: Prevents Grid Overflow */
}
.chart-title { text-align: center; font-size: 14px; font-weight: 600; margin-bottom: 15px; color: var(--text-muted); }

/* Amortization Table */
.table-wrap { max-height: 500px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 15px; background: var(--bg-body); color: var(--text-muted); position: sticky; top: 0; font-weight: 600; }
td { padding: 12px 15px; border-bottom: 1px solid #f1f5f9; color: var(--text); }
.num { text-align: right; font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8fafc; }

/* =========================================
   7. ADS & SEO CONTENT
   ========================================= */
.ad-slot {
  background: #f1f5f9; border: 2px dashed #e2e8f0; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px; border-radius: 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
}
.ad-leaderboard { width: 100%; height: 90px; max-width: 728px; margin: 0 auto 30px; }
.ad-rect { width: 100%; height: 250px; margin-top: 20px; }
.ad-responsive { width: 100%; height: 100px; margin: 40px 0; }

.seo-content { margin-top: 60px; padding: 0 20px; max-width: 800px; margin-left: auto; margin-right: auto; }
.seo-content h2 { font-size: 24px; margin-top: 40px; margin-bottom: 15px; position: relative; }
.seo-content h2::after { content: ''; display: block; width: 50px; height: 3px; background: var(--primary); margin-top: 10px; }
.seo-content p { margin-bottom: 15px; font-size: 16px; color: var(--text); }
.seo-content li { margin-bottom: 10px; color: var(--text); }

/* =========================================
   8. FOOTER STYLES
   ========================================= */
.site-footer {
  background: var(--dark);
  color: white;
  padding: 60px 0 20px;
  margin-top: 80px;
  border-top: 4px solid var(--primary);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

.footer-col h4 { margin-bottom: 20px; font-size: 18px; color: #f8fafc; font-weight: 600; }
.footer-links a {
  display: block; color: #94a3b8; margin-bottom: 12px; font-size: 14px; transition: 0.2s;
}
.footer-links a:hover { color: var(--accent); padding-left: 5px; }

.copyright {
  text-align: center; border-top: 1px solid #334155;
  margin-top: 50px; padding-top: 25px; color: #64748b; font-size: 13px;
}

/* =========================================
   9. PRINT STYLES
   ========================================= */
@media print {
  body { background: white; color: black; }
  .site-header, .site-footer, .top-controls, .field, .adv-toggle, .tabs, .seo-content, .btn-print, .ad-slot, .slider { display: none !important; }
  .card { box-shadow: none; border: 1px solid #000; padding: 20px; margin: 0 0 20px 0; }
  .grid { display: block; }
  .res-box { background: #eee; border: 1px solid #ccc; color: black; page-break-inside: avoid; }
  .res-emi { color: black; }
  .table-wrap { max-height: none; overflow: visible; }
  .section-head h2 { display: block; text-align: center; width: 100%; border-bottom: 1px solid #000; padding-bottom: 10px; }
  #view-tbl { display: block !important; }
  #view-graph { display: none !important; }
  .container { max-width: 100%; padding: 0; }
}


/*for ads*/

.top-bar-ad {
    width: 100%;
    margin-top: 1rem;
}