:root {
  /* Color Palette - Premium Fintech Trust */
  --primary: #0f4c75;
  /* Deep Trust Blue */
  --primary-dark: #0a3350;
  --secondary: #3282b8;
  /* Accessible Blue */
  --accent: #28a745;
  /* Growth Green */
  --accent-hover: #218838;
  --bg-light: #f8f9fa;
  /* Clean Background */
  --text-main: #333333;
  --text-muted: #666666;
  --white: #ffffff;
  --border: #e0e0e0;
  --danger: #dc3545;

  /* Typography */
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --container-width: 1200px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 48px;

  /* Shadows & Radius */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
}

/* Layout */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Header */
header {
  background: var(--white);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: var(--spacing-lg);
}

.nav-links a {
  color: var(--text-main);
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--primary);
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  padding: 60px 0;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-md);
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Calculator Grid (Home) */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-lg);
  padding: var(--spacing-xl) 0;
}

.tool-card {
  background: var(--white);
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.tool-icon {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  color: var(--secondary);
}

.tool-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--primary);
}

.tool-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
  /* Mobile touch friendly */
  min-width: 44px;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--white);
}

/* Detailed Calculator UI */
.calculator-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-lg);
  margin-top: -40px;
  /* Overlap hero */
  position: relative;
  z-index: 10;
  border: 1px solid var(--border);
}

.calc-flex {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xl);
}

.calc-inputs {
  flex: 1;
  min-width: 300px;
}

.calc-result {
  flex: 1;
  min-width: 300px;
  background: #f0fdf4;
  /* Light green tint */
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.input-group {
  margin-bottom: var(--spacing-lg);
}

.input-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-sm);
}

.input-label {
  font-weight: 600;
  color: var(--text-main);
}

/* Editable Input Fields */
.input-wrapper {
  display: flex;
  align-items: center;
  background: #ffffff;
  /* User requested clean look */
  border-radius: 4px;
  padding: 2px 8px;
  border: 1px solid #ccc;
  transition: border 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--secondary);
}

.currency-symbol {
  color: var(--primary);
  font-weight: 700;
  margin-right: 4px;
  font-size: 0.9rem;
}

.val-input {
  width: 70px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
  text-align: right;
  outline: none;
  padding: 0;
  -moz-appearance: textfield;
  /* Remove spin buttons Firefox */
  font-family: var(--font-main);
}

.val-input::-webkit-outer-spin-button,
.val-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Legacy Support */
.input-val-display {
  color: var(--primary);
  font-weight: 700;
  background: #eef6fc;
  padding: 2px 8px;
  background: var(--secondary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Results */
.result-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-sm);
  font-size: 1.1rem;
}

.result-total {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px dashed #28a745;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

/* Content Sections */
.content-section {
  padding: var(--spacing-xl) 0;
  max-width: 800px;
  margin: 0 auto;
}

.content-section h2 {
  color: var(--primary);
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

.content-section p {
  margin-bottom: var(--spacing-md);
  color: var(--text-main);
}

.content-section ul {
  margin-left: 20px;
  margin-bottom: var(--spacing-md);
}

/* Footer */
footer {
  background: var(--primary-dark);
  color: var(--white);
  padding: var(--spacing-xl) 0;
  margin-top: var(--spacing-xl);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.footer-links a {
  color: #ddd;
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--white);
}

.copyright {
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Responsive Typography & Layout */
@media (max-width: 768px) {
  :root {
    --spacing-xl: 32px;
    --container-width: 100%;
  }

  /* Global Container Padding */
  .container {
    padding: 0 20px;
    /* More breathing room */
  }

  /* Navigation */
  .nav-bar {
    flex-direction: column;
    height: auto;
    padding: 15px 0;
  }

  .nav-links {
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }

  .nav-links a {
    font-size: 1rem;
    padding: 5px 10px;
    background: #f0f4f8;
    /* Touch target bg */
    border-radius: 4px;
  }

  /* Typography Scale */
  h1 {
    font-size: 1.75rem;
    line-height: 1.3;
  }

  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  h3 {
    font-size: 1.25rem;
  }

  /* Hero */
  .hero {
    padding: 40px 0 60px 0;
  }

  .hero h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
  }

  .hero p {
    font-size: 1rem;
    padding: 0 10px;
  }

  /* Content Readability */
  .content-section p,
  .content-section ul li {
    font-size: 1.05rem;
    /* Slightly larger for reading */
    line-height: 1.7;
    text-align: left;
    /* Ensure left align */
  }

  /* Calculator Stack */
  .calculator-container {
    margin-top: -30px;
    padding: 20px;
  }

  .calc-flex {
    flex-direction: column;
    gap: 30px;
  }

  .calc-inputs,
  .calc-result {
    min-width: 100%;
    width: 100%;
  }

  /* Touch Targets */
  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  .input-val-display,
  .val-input {
    font-size: 1rem;
  }

  /* Mobile Grid */
  .tool-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Footer Fix */
  .footer-links {
    flex-direction: column;
    gap: 15px;
  }

  .footer-links a {
    display: block;
    padding: 5px;
  }

  /* Chart & Share */
  .chart-container {
    width: 160px;
    /* Smaller on mobile */
    height: 160px;
    margin: 0 auto 20px auto;
  }
}

@media (max-width: 480px) {
  .calculator-container {
    padding: 15px;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .result-total {
    font-size: 1.3rem;
  }
}

/* Premium Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  /* Thicker track */
  background: #e0e6ed;
  border-radius: 10px;
  outline: none;
  margin: 15px 0;
  transition: background 0.3s;
}

/* Slider Track (Progress effect logic requires JS or complex CSS, keeping simple premium look for now) */
/* We can simulate a 'filled' look if we want, but standard premium track is clean gray with colorful thumb */

/* Webkit Thumb (Chrome/Safari/Edge) */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--secondary);
  /* Accent color thumb */
  border: 3px solid #fff;
  /* White border for 'ring' effect */
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  /* Soft shadow */
  transition: transform 0.1s, box-shadow 0.2s;
  margin-top: -8px;
  /* Center alignment fix calculation: (8px track - 24px thumb) / 2 */
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Firefox Thumb */
input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--secondary);
  border: 3px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Fix Firefox Track alignment */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 8px;
  background: #e0e6ed;
  border-radius: 10px;
}

/* Chart & Share */
.chart-container {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px auto;
}

.btn-whatsapp {
  margin-top: 20px;
  background: #25D366;
  color: white;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border: none;
  font-size: 1rem;
}

.btn-whatsapp:hover {
  background: #128C7E;
  color: white;
}

/* AdSense Placeholder - Hidden */
.ad-slot {
  display: none;
  background: #eee;
  border: 1px dashed #ccc;
  text-align: center;
  padding: 10px;
  margin: 20px 0;
  font-size: 0.8rem;
  color: #999;
}

body.ads-active .ad-slot {
  display: block;
}

/* --- Advanced Features Styles --- */

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked+.slider {
  background-color: var(--secondary);
}

input:checked+.slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.toggle-label {
  font-weight: 600;
  color: var(--text-main);
}

/* Breakdown Table */
.table-container {
  margin-top: 30px;
  display: none;
  /* Hidden by default */
  overflow-x: auto;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9rem;
}

.breakdown-table th,
.breakdown-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: center;
}

.breakdown-table th {
  background-color: var(--primary);
  color: white;
}

.breakdown-table tr:nth-child(even) {
  background-color: #f2f2f2;
}

.breakdown-table tr:hover {
  background-color: #ddd;
}