:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0f172a;
  --accent: #f59e0b;
  --text: #1e293b;
  --text-light: #64748b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --border: #e2e8f0;
  --success: #10b981;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --max-width: 1200px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
}

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

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--secondary);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 1.6rem; }

nav ul {
  display: flex;
  list-style: none;
  gap: 4px;
}
nav > ul > li {
  position: relative;
}
nav a {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-block;
}
nav a:hover, nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}
nav .has-dropdown > a::after {
  content: " \25BE";
  font-size: 0.7rem;
  opacity: 0.7;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  z-index: 100;
  list-style: none;
  margin-top: 4px;
}
.dropdown-menu li { margin: 0; }
.dropdown-menu a {
  display: block;
  padding: 8px 18px;
  color: var(--text);
  font-size: 0.85rem;
  border-radius: 0;
  white-space: nowrap;
}
.dropdown-menu a:hover {
  background: var(--bg-alt);
  color: var(--primary);
  text-decoration: none;
}
nav > ul > li:hover > .dropdown-menu {
  display: block;
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.dropdown-label {
  display: block;
  padding: 6px 18px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 60px 20px;
  text-align: center;
}
.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 12px;
  font-weight: 800;
}
.hero p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 30px;
}
.hero .subtitle {
  font-size: 1rem;
  opacity: 0.75;
  margin-top: 8px;
}

/* Page Hero (sub pages) */
.page-hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 40px 20px;
  text-align: center;
}
.page-hero h1 { font-size: 2rem; margin-bottom: 8px; }
.page-hero p { opacity: 0.85; max-width: 650px; margin: 0 auto; }
.breadcrumb {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 12px;
}
.breadcrumb a { color: #fff; opacity: 0.8; }
.breadcrumb a:hover { opacity: 1; }

/* Calculator Card */
.calc-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
  max-width: 700px;
  margin: -30px auto 40px;
  position: relative;
  z-index: 10;
}
.calc-card h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: var(--secondary);
}

.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text);
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* Result Box */
.result-box {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  text-align: center;
  display: none;
}
.result-box.show { display: block; }
.result-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary-dark);
}
.result-label {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 4px;
}
.result-breakdown {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-light);
  text-align: left;
}

/* Content Section */
.content-section {
  padding: 50px 20px;
}
.content-section h2 {
  font-size: 1.6rem;
  margin-bottom: 16px;
  color: var(--secondary);
}
.content-section h3 {
  font-size: 1.2rem;
  margin: 24px 0 10px;
  color: var(--secondary);
}
.content-section p {
  margin-bottom: 14px;
  color: var(--text);
  line-height: 1.7;
}
.content-section ul, .content-section ol {
  margin: 10px 0 16px 24px;
}
.content-section li { margin-bottom: 6px; }

/* Tool Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin: 30px 0;
}
.tool-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s;
}
.tool-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--primary);
}
.tool-card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.tool-card h3 a { color: var(--secondary); }
.tool-card h3 a:hover { color: var(--primary); text-decoration: none; }
.tool-card p {
  font-size: 0.88rem;
  color: var(--text-light);
  margin: 0;
}
.tool-card .tool-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

/* Section Headers */
.section-header {
  text-align: center;
  margin-bottom: 30px;
}
.section-header h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.section-header p {
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
}
.data-table th {
  background: var(--secondary);
  color: #fff;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
}
.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:nth-child(even) { background: var(--bg-alt); }
.data-table tr:hover { background: var(--primary-light); }

/* Blog */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin: 30px 0;
}
.blog-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
}
.blog-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.blog-card-img {
  height: 180px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2.5rem;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}
.blog-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.blog-card-body { padding: 20px; }
.blog-card-body h3 { font-size: 1.05rem; margin-bottom: 8px; }
.blog-card-body h3 a { color: var(--secondary); }
.blog-card-body h3 a:hover { color: var(--primary); text-decoration: none; }
.blog-card-body p { font-size: 0.88rem; color: var(--text-light); margin: 0; }
.blog-card-body .blog-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 10px;
}

/* Article */
.article-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 20px;
}
.article-content h2 {
  font-size: 1.5rem;
  margin: 32px 0 12px;
  color: var(--secondary);
}
.article-content h3 {
  font-size: 1.2rem;
  margin: 24px 0 10px;
}
.article-content p {
  margin-bottom: 16px;
  line-height: 1.8;
}
.article-content ul, .article-content ol {
  margin: 10px 0 16px 24px;
}
.article-content li { margin-bottom: 8px; line-height: 1.7; }
.article-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 20px 0;
}
.article-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 20px;
  margin: 20px 0;
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.article-content .formula-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
  font-family: 'Courier New', monospace;
  font-size: 1.05rem;
  text-align: center;
}
.article-content .key-point {
  background: #fef3c7;
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Internal Links Box */
.related-links {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 30px 0;
}
.related-links h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--secondary);
}
.related-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.related-links li {
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
}
.related-links li::before {
  content: "\2192";
  position: absolute;
  left: 0;
  color: var(--primary);
}

/* TOC */
.toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
}
.toc h4 { margin-bottom: 10px; font-size: 0.95rem; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin-bottom: 6px; font-size: 0.9rem; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--primary); }

/* Footer */
.site-footer {
  background: var(--secondary);
  color: #94a3b8;
  padding: 40px 20px 20px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 30px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.footer-col h4 {
  color: #fff;
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 6px; }
.footer-col a { color: #94a3b8; font-size: 0.88rem; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}
.social-links {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  font-size: 1.1rem;
  transition: background 0.2s, color 0.2s;
}
.social-links a:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}
.footer-legal {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.footer-legal a {
  color: #94a3b8;
  font-size: 0.82rem;
}
.footer-legal a:hover { color: #fff; }

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.8rem; }
  .form-row { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  nav ul { display: none; }
  .mobile-toggle { display: block; }
  nav.open ul {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--secondary);
    padding: 10px 20px;
    gap: 0;
  }
  nav.open .dropdown-menu {
    position: static;
    box-shadow: none;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius);
    margin: 4px 0 4px 12px;
    padding: 4px 0;
    min-width: 0;
  }
  nav.open .dropdown-menu a {
    color: #94a3b8;
    padding: 8px 16px;
    font-size: 0.82rem;
    white-space: normal;
  }
  nav.open .dropdown-menu a:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
  }
  nav.open .dropdown-label {
    color: #64748b;
    padding: 6px 16px 2px;
  }
  nav.open .has-dropdown > a::after {
    content: " \25BE";
    margin-left: 4px;
  }
  nav.open .has-dropdown.open > .dropdown-menu {
    display: block;
  }
  nav.open .has-dropdown > .dropdown-menu {
    display: none;
  }
  .tools-grid { grid-template-columns: 1fr; }
  .blog-grid { grid-template-columns: 1fr; }
  .calc-card { margin: -20px 10px 30px; padding: 20px; }
}

/* Utility */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.bg-alt { background: var(--bg-alt); }
.highlight { color: var(--primary); font-weight: 700; }
