:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --danger: #b91c1c;
  --danger-border: #fecaca;
  --max-width: 1060px;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

header, main, footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand:hover { text-decoration: none; color: var(--accent); }

.brand::before {
  content: "";
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  background-color: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/%3E%3Cpolyline points='3.27 6.96 12 12.01 20.73 6.96'/%3E%3Cline x1='12' y1='22.08' x2='12' y2='12'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/%3E%3Cpolyline points='3.27 6.96 12 12.01 20.73 6.96'/%3E%3Cline x1='12' y1='22.08' x2='12' y2='12'/%3E%3C/svg%3E") center / contain no-repeat;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.32rem 0.62rem;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}

nav a:hover {
  color: var(--accent);
  background: var(--surface-alt);
  text-decoration: none;
}

nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

h1 {
  margin-top: 0;
  margin-bottom: 0.45rem;
  font-size: 1.65rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h2 { margin-top: 0; margin-bottom: 0.5rem; font-size: 1.2rem; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 1rem; font-size: 0.96rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0.9rem 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

main > .card:first-child {
  border-top: 4px solid var(--accent);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 100%);
  border-top: 4px solid var(--accent);
}

.pill-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.trust-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: #ffffff;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.14rem 0.52rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 700;
}

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

@media (min-width: 680px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tool-card.featured {
    grid-column: 1 / -1;
  }
}

.tool-card {
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 0;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.tool-card h2 a {
  color: var(--text);
  text-decoration: none;
}

.tool-card:hover h2 a {
  color: var(--accent);
}

.tool-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.86rem;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 39px;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.45rem 0;
  font-size: 0.92rem;
}

.inline-controls, .preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: center;
  margin: 0.4rem 0 0.75rem;
}

.preset-bar button {
  font-size: 0.82rem;
  padding: 0.36rem 0.68rem;
}

.btn-row, .btn-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
  align-items: center;
}

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

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s;
}

button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }

button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

button.secondary:hover { background: var(--surface-alt); }

button.danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}

button.danger-outline:hover { background: #fef2f2; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.7rem 0;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td {
  text-align: left;
  padding: 0.44rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.table-wrap input[data-field="label"] {
  min-width: 9.2rem;
}

.table-wrap input[type="number"] {
  min-width: 4.7rem;
  height: 35px;
  padding: 0.25rem 0.45rem;
  font-size: 0.88rem;
}

.table-wrap select {
  min-width: 4.5rem;
  height: 35px;
  padding: 0.25rem 0.4rem;
  font-size: 0.88rem;
}

.table-wrap .secondary {
  padding: 0.34rem 0.62rem;
  font-size: 0.8rem;
}

.cell-pcf, .cell-cls, .cell-cbm {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.85rem 0;
}

@media (min-width: 700px) {
  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  }
  .summary-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  padding: 0.75rem 0.85rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stat-value {
  font-size: 1.32rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.15rem;
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.meter-card {
  margin: 0.65rem 0 0.85rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-light);
  border-radius: 9px;
  background: #fafafa;
}

.spectrum-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 38%, #10b981 72%, #1d4ed8 100%);
  margin: 0.55rem 0 0.35rem;
}

.spectrum-marker {
  position: absolute;
  top: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #0f172a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transform: translateX(-50%);
  transition: left 0.2s ease;
}

.spectrum-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 600;
}

.container-bars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin: 0.65rem 0 0.9rem;
}

@media (min-width: 680px) {
  .container-bars {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.cbar-item {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
}

.cbar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.cbar-track {
  height: 9px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.cbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.cbar-fill.over {
  background: #dc2626;
}

.alert-banner {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.92rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

.alert-banner.near-cliff {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.faq-item { border-top: 1px solid var(--border-light); padding: 0.75rem 0; }
.faq-item h3 { margin: 0 0 0.35rem; font-size: 1.02rem; }

footer {
  border-top: 1px solid var(--border-light);
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 1.75rem;
  padding-bottom: 1.75rem;
}

footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

.print-only { display: none; }

/* Reserve fixed height when AdSense renders to prevent CLS layout shifts */
.ad-slot {
  min-height: 100px;
  margin: 1rem 0;
  border-radius: 8px;
}
.ad-slot:empty {
  display: none;
  min-height: 0;
  margin: 0;
}

@media print {
  header, nav, .btn-row, .btn-bar, .no-print, footer { display: none !important; }
  .print-only { display: block !important; }
  .print-bol-header {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
  }
  body { background: #ffffff; }
  .card, main > .card:first-child { border: none; box-shadow: none; padding: 0; }
}
