/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ===== CSS VARIABLES ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #7c3aed;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== HEADER ===== */
.site-header {
  background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
  color: white;
  padding: 0 1rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}
.logo {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.logo span { color: #fbbf24; }
.nav-links {
  display: flex;
  gap: .25rem;
  list-style: none;
}
.nav-links a {
  padding: .4rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255,255,255,.85);
  transition: background .2s, color .2s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.2);
  color: white;
}
.header-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px;
  overflow: hidden;
}
.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  padding: .4rem .75rem;
  font-size: .875rem;
  width: 180px;
}
.header-search input::placeholder { color: rgba(255,255,255,.6); }
.header-search button {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: .4rem .6rem;
  font-size: 1rem;
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
  color: white;
  padding: 3rem 1rem 4rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 800;
  margin-bottom: .75rem;
  line-height: 1.2;
}
.hero h1 span { color: #fbbf24; }
.hero p {
  font-size: 1.125rem;
  color: rgba(255,255,255,.85);
  max-width: 600px;
  margin: 0 auto 1.5rem;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat strong { display: block; font-size: 1.75rem; font-weight: 800; color: #fbbf24; }
.hero-stat span { font-size: .875rem; color: rgba(255,255,255,.75); }

/* ===== SEARCH BAR MAIN ===== */
.search-section {
  background: var(--surface);
  padding: 1.5rem 1rem;
  box-shadow: var(--shadow);
}
.search-wrap {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
}
.search-wrap input {
  width: 100%;
  padding: .875rem 3rem .875rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 50px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.search-wrap .search-icon {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
}
#search-results {
  position: absolute;
  top: calc(100% + .5rem);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}
#search-results.open { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-item .icon { font-size: 1.25rem; }
.search-result-item .info strong { display: block; font-size: .9rem; }
.search-result-item .info span { font-size: .8rem; color: var(--muted); }

/* ===== MAIN LAYOUT ===== */
.main { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.4em;
  background: var(--primary);
  border-radius: 2px;
}
.see-all {
  color: var(--primary);
  font-size: .875rem;
  font-weight: 600;
  transition: opacity .2s;
}
.see-all:hover { opacity: .7; }

/* ===== CATEGORY TABS ===== */
.categories {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.cat-btn {
  padding: .5rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: white;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
}
.cat-btn:hover { border-color: var(--primary); color: var(--primary); }
.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== CALCULATOR GRID ===== */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
.calc-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.calc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
}
.calc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.calc-card .icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: var(--card-light, var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.calc-card h3 { font-size: 1rem; font-weight: 700; }
.calc-card p { font-size: .825rem; color: var(--muted); flex: 1; }
.calc-card .use-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  padding: .4rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  align-self: flex-start;
}
.calc-card:hover .use-btn { background: var(--primary); color: white; }
.calc-card .badge {
  position: absolute;
  top: .75rem; right: .75rem;
  background: #fef3c7;
  color: #92400e;
  font-size: .7rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 50px;
}

/* ===== CALCULATOR PAGE LAYOUT ===== */
.calc-page { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }
.calc-page-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .calc-page-grid { grid-template-columns: 1fr; }
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb span { color: var(--muted); }

/* ===== CALCULATOR BOX ===== */
.calc-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.calc-box-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.calc-box-header .icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.calc-box-header h1 { font-size: 1.4rem; font-weight: 800; }
.calc-box-header p { font-size: .875rem; color: var(--muted); }
.calc-body { padding: 1.5rem; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }
label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
label .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.input-wrap {
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  background: white;
}
.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-wrap .prefix, .input-wrap .suffix {
  padding: .6rem .75rem;
  background: #f8fafc;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.input-wrap .suffix { border-right: none; border-left: 1px solid var(--border); }
.input-wrap input, .input-wrap select {
  flex: 1;
  border: none;
  outline: none;
  padding: .6rem .75rem;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  min-width: 0;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  margin-top: .5rem;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
}
select {
  width: 100%;
  padding: .65rem .75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: .9rem;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s;
}
select:focus { border-color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-full { width: 100%; }
.btn-sm { padding: .4rem .9rem; font-size: .825rem; }
.btn-group {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ===== RESULT CARD ===== */
.result-card {
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  display: none;
}
.result-card.show { display: block; }
.result-main {
  text-align: center;
  margin-bottom: 1rem;
}
.result-label { font-size: .875rem; color: var(--muted); font-weight: 500; }
.result-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}
.result-sub { font-size: .875rem; color: var(--muted); margin-top: .25rem; }
.result-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(37,99,235,.2);
}
.breakdown-item {
  text-align: center;
  background: white;
  border-radius: var(--radius-sm);
  padding: .75rem;
}
.breakdown-item .val { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.breakdown-item .lbl { font-size: .75rem; color: var(--muted); }

/* ===== SIDEBAR ===== */
.sidebar { display: flex; flex-direction: column; gap: 1.25rem; }
.sidebar-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.sidebar-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.related-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.related-list li a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  transition: background .15s, color .15s;
  border: 1px solid var(--border);
}
.related-list li a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.tip-box {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: var(--radius-sm);
  padding: .75rem;
  font-size: .825rem;
  color: #78350f;
  line-height: 1.5;
}
.tip-box strong { display: block; margin-bottom: .3rem; }

/* ===== INFO SECTION ===== */
.info-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
}
.info-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .75rem; }
.info-section h3 { font-size: 1rem; font-weight: 600; margin: 1rem 0 .4rem; color: var(--text); }
.info-section p { font-size: .9rem; color: #475569; margin-bottom: .75rem; line-height: 1.7; }
.info-section ul { padding-left: 1.25rem; margin-bottom: .75rem; }
.info-section li { font-size: .875rem; color: #475569; margin-bottom: .4rem; line-height: 1.6; }
.formula-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .75rem 1rem;
  font-family: monospace;
  font-size: .875rem;
  color: var(--text);
  margin: .75rem 0;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  gap: .25rem;
}
.tab-btn {
  padding: .6rem 1rem;
  border: none;
  background: none;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .2s, border-color .2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  background: #f8fafc;
  padding: .6rem .75rem;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--primary-light); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ===== CHART ===== */
.chart-wrap {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.chart-bar-group { display: flex; flex-direction: column; gap: .5rem; }
.chart-bar-row { display: flex; align-items: center; gap: .75rem; }
.chart-bar-label { font-size: .75rem; color: var(--muted); width: 90px; flex-shrink: 0; text-align: right; }
.chart-bar-track { flex: 1; height: 24px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; display: flex; align-items: center; padding-left: .5rem; }
.chart-bar-fill span { font-size: .75rem; font-weight: 600; color: white; }

/* ===== FOOTER ===== */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 3rem 1rem 1.5rem;
  margin-top: 3rem;
}
.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-brand .logo { color: white; font-size: 1.2rem; margin-bottom: .75rem; }
.footer-brand p { font-size: .875rem; line-height: 1.7; }
.footer-col h4 { color: white; font-size: .9rem; font-weight: 700; margin-bottom: .75rem; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.footer-col li a { font-size: .825rem; color: #94a3b8; transition: color .2s; }
.footer-col li a:hover { color: white; }
.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .8rem;
}

/* ===== TOAST / COPY ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: white;
  padding: .75rem 1.25rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all .3s;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: .4rem;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .5s ease;
}

/* ===== AD PLACEHOLDER ===== */
.ad-placeholder {
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: .825rem;
}
.ad-placeholder strong { display: block; margin-bottom: .25rem; color: var(--text); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .header-search { display: none; }
  .hero { padding: 2rem 1rem 3rem; }
  .calc-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .calc-card { padding: 1rem; }
}
@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .main { padding: 1.25rem .75rem; }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.hidden { display: none; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.font-bold { font-weight: 700; }
