/* Base layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #1f2933;
}

/* Utility */
.hidden {
  display: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===========================
   HEADER (green gradient)
   =========================== */

.header {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.15);
}

/* Tailwind-like utilities used by the header/footer (minimal) */
.max-w-7xl {
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.px-6 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.space-x-3 > *:not(:last-child) {
  margin-right: 0.75rem;
}

.space-x-4 > *:not(:last-child) {
  margin-right: 1rem;
}

.space-x-8 > *:not(:last-child) {
  margin-right: 2rem;
}

.text-white {
  color: #ffffff;
}

.text-xl {
  font-size: 1.25rem;
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.inline-block {
  display: inline-block;
}

.text-gray-200 {
  color: #e5e7eb;
}

.text-gray-400 {
  color: #cbd5e0;
}

.leading-relaxed {
  line-height: 1.625;
}

/* Hover utility styles with escaped classnames */
.hover\:text-gray-200:hover {
  color: #e5e7eb;
}

.transition-all {
  transition: all 0.3s ease;
}

.duration-300 {
  /* handled by transition-all timing */
}

.hover\:scale-110:hover {
  transform: scale(1.1);
}

/* Media-based utilities */
@media (min-width: 768px) {
  .md\:flex {
    display: flex;
  }
  .md\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .md\:hidden {
    display: none;
  }
}

/* Desktop nav tweaks */
.nav-links {
  list-style: none;
}

.main-nav a {
  text-decoration: none;
}

/* "More" dropdown */
.dropdown { position: relative; }

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  min-width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  border-radius: 12px;
  margin-top: 8px;
  overflow: hidden;
  animation: fadeInDown 0.3s ease;
  z-index: 50;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: #4a5568;
  padding: 12px 20px;
  text-decoration: none;
  display: block;
  transition: all 0.3s ease;
  font-size: 14px;
}

.dropdown-content a:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white;
  padding-left: 28px;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile menu button */
.mobile-menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

/* Mobile nav container with slide animation */
.mobile-nav {
  background: #065f46;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.28s ease, opacity 0.28s ease;
}

.mobile-nav.open {
  max-height: 480px;
  opacity: 1;
}

.mobile-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 24px 16px;
}

.mobile-nav a {
  display: block;
  color: #e5e7eb;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 15px;
  text-decoration: none;
}

.mobile-nav a:last-child {
  border-bottom: none;
}

.mobile-nav a:hover {
  color: #ffffff;
}

/* ===========================
   MAIN LAYOUT
   =========================== */

.page-main {
  padding: 24px 0 48px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
  gap: 24px;
  align-items: flex-start;
}

/* Hero */
.hero {
  margin-bottom: 16px;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b7280;
  margin: 0 0 4px;
}

.hero h1 {
  font-size: 26px;
  margin: 0 0 8px;
  color: #111827;
}

.hero-subtitle {
  margin: 0 0 8px;
  color: #4b5563;
  font-size: 15px;
  max-width: 640px;
}

.period-summary {
  margin: 0 0 16px;
  font-size: 13px;
  color: #6b7280;
}

/* Calculator section */
.calculator-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Card basics */
.card,
.calculator-card,
.charts-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
}

/* Config card */
.calculator-card {
  border-top: 4px solid #4f46e5;
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.calculator-title {
  font-size: 20px;
  margin: 0 0 4px;
  color: #111827;
}

.calculator-tagline {
  margin: 0;
  font-size: 14px;
  color: #4b5563;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill-free {
  background: #ecfdf5;
  color: #166534;
}

/* Config grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
  margin-top: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.form-group--investment .help-text {
  font-size: 11px;
  color: #6b7280;
}

/* Inputs */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

textarea {
  resize: vertical;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border-radius: 16px;
  padding: 14px 14px 16px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background: radial-gradient(circle at top left, #ffffff 0, transparent 60%);
}

.stat-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  font-size: 13px;
  margin: 0 0 4px;
  opacity: 0.95;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
}

.stat-meta {
  font-size: 11px;
  margin: 0;
}

/* Stat colors */
.stat-card--revenue {
  background: linear-gradient(135deg, #059669, #16a34a);
}
.stat-card--expense {
  background: linear-gradient(135deg, #dc2626, #f97316);
}
.stat-card--profit {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.stat-card--margin {
  background: linear-gradient(135deg, #ec4899, #f97316);
}
.stat-card--roi {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

/* Icon 3D float */
.icon-3d {
  font-size: 28px;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.25));
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Charts */
.charts-card .section-title {
  margin-top: 0;
  margin-bottom: 12px;
}

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

.chart-container {
  height: 260px;
  padding: 10px;
  border-radius: 14px;
  background: #f9fafb;
}

/* Transaction section */
.transaction-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 18px;
  margin: 0 0 6px;
  color: #111827;
}

.section-subtitle {
  margin: 0 0 14px;
  font-size: 13px;
  color: #6b7280;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}

.form-group--full {
  grid-column: 1 / -1;
}

.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Preview box */
.preview-box {
  background: #f9fafb;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.preview-row--total {
  padding-top: 6px;
  margin-top: 6px;
  border-top: 1px dashed #d1d5db;
  font-weight: 700;
}

.preview-value {
  font-weight: 600;
}

/* Buttons */
.btn {
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.45);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #16a34a);
  color: #ffffff;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(5, 150, 105, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #f97316);
  color: #ffffff;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(220, 38, 38, 0.4);
}

.btn-secondary {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover,
.btn-tertiary:hover {
  background: #f3f4f6;
}

.btn-tertiary {
  background: #f9fafb;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

.btn-large {
  padding: 10px 22px;
  font-size: 14px;
}

.btn-icon {
  padding: 6px 10px;
}

/* Pulse animation for main button */
#calculateBtn {
  animation: pulseShadow 2s ease-in-out infinite;
}

@keyframes pulseShadow {
  0%, 100% {
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
  }
  50% {
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.6);
  }
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 14px;
}

/* Export card */
.export-card {
  border-left: 4px solid #10b981;
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

.transactions-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 13px;
}

.transactions-table thead th {
  background: #f3f4ff;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #111827;
}

.transactions-table thead th:first-child {
  border-radius: 10px 0 0 10px;
}
.transactions-table thead th:last-child {
  border-radius: 0 10px 10px 0;
}

.transactions-table tbody tr {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.transactions-table tbody td {
  background: #ffffff;
  padding: 8px 10px;
}

.transactions-table tbody td:first-child {
  border-radius: 10px 0 0 10px;
}
.transactions-table tbody td:last-child {
  border-radius: 0 10px 10px 0;
}

.col-description {
  font-weight: 600;
  color: #111827;
}

.col-total {
  font-weight: 800;
}

.col-total--revenue {
  color: #059669;
}

.col-total--expense {
  color: #dc2626;
}

.action-buttons {
  display: inline-flex;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-revenue {
  background: #ecfdf5;
  color: #166534;
}
.badge-expense {
  background: #fef2f2;
  color: #b91c1c;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 26px 10px;
  color: #6b7280;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

/* Inline confirm */
.inline-confirm {
  display: inline-flex;
  gap: 6px;
}

/* Category breakdown */
.category-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.category-item {
  padding: 10px 12px;
  border-radius: 12px;
  border-left: 4px solid #4b5563;
  background: #f9fafb;
}

.category-item--revenue {
  border-left-color: #16a34a;
}
.category-item--expense {
  border-left-color: #dc2626;
}

.category-name {
  margin: 0 0 4px;
  font-size: 13px;
  color: #4b5563;
}

.category-amount {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.category-empty {
  font-size: 13px;
  color: #6b7280;
}

/* Subheading */
.subheading {
  font-size: 15px;
  margin: 12px 0 4px;
}
.subheading--spaced {
  margin-top: 16px;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 14px 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.sidebar-card h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

.sidebar-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-card li {
  margin-bottom: 6px;
}

.sidebar-card a {
  text-decoration: none;
  font-size: 13px;
  color: #4b5563;
}

.sidebar-card a:hover {
  text-decoration: underline;
}

/* Content section */
.content-section {
  margin-top: 24px;
}

.seo-article h2 {
  font-size: 20px;
  margin: 16px 0 6px;
}

.seo-article p {
  font-size: 14px;
  line-height: 1.7;
  color: #4b5563;
  margin: 0 0 10px;
}

.seo-article ul,
.seo-article ol {
  font-size: 14px;
  color: #4b5563;
  padding-left: 20px;
  margin: 0 0 10px;
}

.seo-article li {
  margin-bottom: 6px;
}

/* Related calculators block */
.related-calculators {
  margin-top: 24px;
  padding: 16px 14px;
  border-radius: 16px;
  background: #f3f4ff;
  border-left: 4px solid #4f46e5;
}

.related-calculators h2 {
  font-size: 18px;
  margin: 0 0 8px;
  color: #111827;
}

.related-calculators p {
  margin: 0 0 8px;
  font-size: 14px;
  color: #4b5563;
}

.related-calculators ul {
  margin: 0;
  padding-left: 18px;
}

.related-calculators li {
  margin-bottom: 4px;
}

.related-calculators a {
  color: #4f46e5;
  text-decoration: none;
}

.related-calculators a:hover {
  text-decoration: underline;
}

/* FAQ */
.faq-section {
  margin-top: 26px;
}

.faq-section h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.faq-item {
  border-top: 1px solid #e5e7eb;
  padding: 10px 0;
}

.faq-item h3 {
  margin: 4px 0;
  font-size: 15px;
  color: #111827;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item p {
  margin: 4px 0 2px;
  font-size: 14px;
  color: #4b5563;
  display: none;
}

.faq-item.open p {
  display: block;
}

/* FOOTER (global) */
.footer {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  color: white;
  padding: 60px 0 20px;
  margin-top: 40px;
}

.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.gap-12 {
  gap: 3rem;
}

.footer-column h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column ul li {
  margin-bottom: 12px;
}

.footer-column ul li a {
  color: #cbd5e0;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-block;
}

.footer-column ul li a:hover {
  color: #667eea;
  transform: translateX(5px);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 40px;
  padding-top: 30px;
  text-align: center;
  color: #a0aec0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 16px;
  background: #111827;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.4);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 70;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  background: #16a34a;
}
.toast--error {
  background: #dc2626;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 80;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 16px 16px;
  max-width: 360px;
  width: 92%;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.5);
  z-index: 90;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.modal p {
  font-size: 13px;
  color: #4b5563;
  margin: 0 0 10px;
}

.modal input[type="text"] {
  width: 100%;
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Responsive */
@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    order: -1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .config-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero h1 {
    font-size: 22px;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .transactions-table thead {
    font-size: 12px;
  }

  .transactions-table tbody {
    font-size: 12px;
  }

  .hide-mobile {
    display: none;
  }
}

@media (max-width: 480px) {
  .card,
  .calculator-card,
  .charts-card {
    padding: 14px 12px 16px;
  }

  .sidebar {
    gap: 12px;
  }
}
