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

:root {
  --green-dark: #1a3a2a;
  --green-mid: #2d6a4f;
  --green-light: #40916c;
  --green-accent: #52b788;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-400: #ced4da;
  --gray-600: #868e96;
  --gray-800: #343a40;
  --gray-900: #212529;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 720px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  background: var(--green-dark);
  padding: 1.5rem 1rem;
  text-align: center;
}

.site-header a {
  text-decoration: none;
  color: var(--white);
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.02em;
}

.site-header h1 span {
  color: var(--green-accent);
}

.site-header p {
  color: var(--gray-400);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Navigation */
.site-nav {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.site-nav a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover {
  color: var(--white);
}

/* Page wrapper (main + sidebar) */
.page-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  gap: 2rem;
}

/* Main content */
main {
  flex: 1;
  min-width: 0;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
}

.sidebar h3 {
  font-size: 0.9rem;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--green-accent);
}

.sidebar-tools {
  margin-bottom: 1.5rem;
}

.sidebar-tools h3 {
  font-size: 0.9rem;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--green-accent);
}

.sidebar-tool {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--gray-800);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s;
}

.sidebar-tool:hover {
  background: var(--gray-100);
  color: var(--green-dark);
}

.sidebar-tool-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  line-height: 1.8;
}

.cloud-tag {
  display: inline-block;
  color: var(--green-mid);
  text-decoration: none;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.cloud-tag:hover {
  background: var(--green-accent);
  color: var(--green-dark);
}

/* Post cards */
.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.post-card .category {
  display: inline-block;
  background: var(--green-accent);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.post-card h2 {
  font-size: 1.25rem;
  margin-top: 0.75rem;
  color: var(--green-dark);
  line-height: 1.4;
}

.post-card .summary {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.post-card .date {
  color: var(--gray-400);
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

/* Article page */
.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--gray-200);
}

.article-header .category {
  display: inline-block;
  background: var(--green-accent);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.article-header h1 {
  font-size: 2rem;
  color: var(--green-dark);
  line-height: 1.3;
  margin-top: 0.75rem;
  letter-spacing: -0.02em;
}

.article-header .meta {
  color: var(--gray-600);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Article content */
.article-content h2 {
  font-size: 1.4rem;
  color: var(--green-dark);
  margin: 2rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.article-content p {
  margin-bottom: 1rem;
}

.article-content .lead {
  font-size: 1.1rem;
  color: var(--gray-800);
  line-height: 1.8;
}

.article-content ul,
.article-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content li p {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.article-content strong {
  color: var(--green-dark);
}

.article-content em {
  color: var(--gray-600);
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.article-content thead {
  background: var(--green-dark);
  color: var(--white);
}

.article-content th,
.article-content td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border: 1px solid var(--gray-200);
}

.article-content tbody tr:nth-child(even) {
  background: var(--gray-100);
}

.article-content tbody tr:hover {
  background: var(--gray-200);
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--green-mid);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--green-dark);
  text-decoration: underline;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--gray-600);
  font-size: 0.8rem;
  border-top: 1px solid var(--gray-200);
}

/* Loading / empty states */
.loading,
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-600);
}

/* Tools page */
.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.tool-card .tool-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.tool-card h2 {
  font-size: 1.25rem;
  color: var(--green-dark);
  line-height: 1.4;
}

.tool-card p {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

/* Calculator */
.calc-form {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.calc-field {
  display: flex;
  flex-direction: column;
}

.calc-field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.4rem;
}

.calc-field input,
.calc-field select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-400);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-900);
  transition: border-color 0.2s;
}

.calc-field input:focus,
.calc-field select:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.15);
}

.calc-field .input-with-select {
  display: flex;
  gap: 0.5rem;
}

.calc-field .input-with-select input {
  flex: 1;
  min-width: 0;
}

.calc-field .input-with-select select {
  width: auto;
  flex-shrink: 0;
}

.calc-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
}

.calc-buttons button {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-clear {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-clear:hover {
  background: var(--gray-200);
}

.btn-calc {
  background: var(--green-mid);
  color: var(--white);
}

.btn-calc:hover {
  background: var(--green-dark);
}

.calc-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--gray-400);
  border-radius: 6px;
  overflow: hidden;
}

.calc-toggle-btn {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border: none;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.calc-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--gray-400);
}

.calc-toggle-btn.active {
  background: var(--green-mid);
  color: var(--white);
}

.calc-toggle-btn:hover:not(.active) {
  background: var(--gray-100);
}

.calc-chart-wrapper {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

.calc-chart-wrapper h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  margin-bottom: 1rem;
}

.calc-chart-wrapper canvas {
  max-height: 350px;
}

.calc-results {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

.calc-results h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  margin-bottom: 1rem;
}

.calc-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.calc-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.calc-summary-row:last-child {
  border-bottom: none;
}

.calc-summary-label {
  color: var(--gray-600);
  font-size: 0.9rem;
}

.calc-summary-value {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.9rem;
}

.calc-summary-row.highlight .calc-summary-value {
  color: var(--green-mid);
  font-size: 1.1rem;
}

.calc-table-wrapper {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  margin-bottom: 2rem;
}

.calc-table-wrapper h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  padding: 1.5rem 1.5rem 0;
}

.calc-table-wrapper .table-scroll {
  overflow-x: auto;
  margin-top: 1rem;
}

.calc-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  display: table;
}

.calc-table-wrapper thead {
  background: var(--green-dark);
  color: var(--white);
}

.calc-table-wrapper th,
.calc-table-wrapper td {
  padding: 0.5rem 0.75rem;
  text-align: right;
  white-space: nowrap;
}

.calc-table-wrapper th:first-child,
.calc-table-wrapper td:first-child {
  text-align: center;
}

.calc-table-wrapper tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.calc-table-wrapper tbody tr:hover {
  background: var(--gray-200);
}

.btn-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem auto 1.25rem;
  padding: 0.6rem 1.5rem;
  background: var(--green-mid);
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-expand:hover {
  background: var(--green-dark);
}

.btn-expand-icon {
  font-size: 0.65rem;
}

.calc-table-wrapper .table-footer {
  padding: 0.6rem 1rem;
  background: var(--gray-50);
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-600);
  border-top: 1px solid var(--gray-200);
}

/* Comparador */
.comp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.comp-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* === MOBILE (<640px) === */
@media (max-width: 639px) {
  .calc-grid,
  .comp-grid {
    grid-template-columns: 1fr;
  }

  .page-wrapper {
    padding: 1.25rem 1rem;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
  }

  .post-card {
    padding: 1.25rem;
  }

  .post-card h2 {
    font-size: 1.1rem;
  }

  .article-header h1 {
    font-size: 1.5rem;
  }

  .article-content h2 {
    font-size: 1.2rem;
  }

  .site-nav {
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* Touch-friendly inputs */
  .calc-field input,
  .calc-field select,
  .search-input,
  .search-btn,
  .calc-buttons button {
    min-height: 44px;
    font-size: 1rem;
  }

  .search-input {
    padding: 0.75rem;
  }

  /* Tables: smaller text, less padding */
  .article-content th,
  .article-content td {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
  }

  .calc-table-wrapper th,
  .calc-table-wrapper td {
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Tags slightly larger for readability */
  .tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }

  .calc-form {
    padding: 1.25rem;
  }

  .calc-results {
    padding: 1.25rem;
  }

  .calc-table-wrapper h2 {
    padding: 1.25rem 1.25rem 0;
  }
}

/* Comparador — moved BEFORE media queries so overrides work */
.comp-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--green-dark);
}

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.tag {
  display: inline-block;
  background: var(--gray-100);
  color: var(--green-mid);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid var(--gray-200);
  transition: background 0.2s;
}
a.tag:hover { background: var(--green-accent); color: var(--green-dark); }

/* Search */
.search-form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.search-input {
  flex: 1; padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-400); border-radius: 6px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
}
.search-input:focus { outline: none; border-color: var(--green-mid); box-shadow: 0 0 0 2px rgba(45,106,79,0.15); }
.search-btn {
  padding: 0.6rem 1.2rem; border: none; border-radius: 6px;
  background: var(--green-mid); color: var(--white);
  font-weight: 600; cursor: pointer; font-family: var(--font-sans);
}
.search-btn:hover { background: var(--green-dark); }

/* === TABLET (>=640px) === */
@media (min-width: 640px) {
  .site-header h1 {
    font-size: 1.75rem;
  }

  .article-header h1 {
    font-size: 2.25rem;
  }

  .page-wrapper {
    padding: 2.5rem 1.5rem;
  }
}

/* === TABLET LARGE (>=768px) === */
@media (min-width: 768px) {
  .posts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .related-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  :root {
    --max-width: 900px;
  }
}

/* === DESKTOP (>=1024px) === */
@media (min-width: 1024px) {
  :root {
    --max-width: 960px;
  }
}

/* === ACTIVE STATES FOR TOUCH === */
.post-card:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tool-card:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.calc-buttons button:active,
.search-btn:active {
  opacity: 0.8;
}

a.tag:active {
  background: var(--green-accent);
  color: var(--green-dark);
}

/* Disclaimer */
.disclaimer {
  background: var(--gray-100);
  border-left: 4px solid var(--gray-400);
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  font-size: 0.85rem;
  color: var(--gray-600);
  border-radius: 0 6px 6px 0;
  line-height: 1.6;
}

/* Author box */
.author-box {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.author-info strong {
  display: block;
  color: var(--green-dark);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.author-info p {
  color: var(--gray-600);
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
}

/* Share buttons */
.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.share-buttons span {
  color: var(--gray-600);
  font-weight: 600;
}

.share-buttons a {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: var(--gray-100);
  color: var(--green-mid);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.share-buttons a:hover {
  background: var(--green-accent);
  color: var(--green-dark);
}

/* Related posts */
.related-posts {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--gray-200);
}

.related-posts h2 {
  font-size: 1.2rem;
  color: var(--green-dark);
  margin-bottom: 1rem;
}

.related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.related-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
}

.related-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.related-card h3 {
  font-size: 1rem;
  color: var(--green-dark);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.related-card p {
  font-size: 0.85rem;
  color: var(--gray-600);
  line-height: 1.5;
  margin: 0;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-bottom: 1rem;
}

.breadcrumbs a {
  color: var(--green-mid);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* Highlight boxes */
.highlight-box {
  background: #e8f5e9;
  border-left: 4px solid var(--green-mid);
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.highlight-box.warning {
  background: #fff3e0;
  border-left-color: #f57c00;
}

.highlight-box strong {
  color: var(--green-dark);
}

.highlight-box.warning strong {
  color: #e65100;
}

/* === TABLE SCROLL INDICATOR === */
.article-content table {
  -webkit-overflow-scrolling: touch;
}

.calc-table-wrapper .table-scroll {
  -webkit-overflow-scrolling: touch;
}
