:root {
  color-scheme: light;
  --ink: #151719;
  --muted: #5c6670;
  --line: #d8dee4;
  --soft: #f4f7f8;
  --paper: #ffffff;
  --accent: #196f68;
  --accent-strong: #10524d;
  --signal: #b3472f;
  --focus: #5b8def;
  --ok: #24734d;
  --shadow: 0 18px 40px rgba(27, 38, 49, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

main {
  flex: 1 0 auto;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--signal);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 20;
  padding: 10px 14px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 8px;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-logo {
  width: auto;
  height: 40px;
}

.main-nav,
.site-footer nav,
.admin-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.main-nav a,
.site-footer a,
.admin-nav a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.main-nav a:first-child {
  color: var(--accent-strong);
}

.site-footer {
  margin-top: auto;
  padding: 32px 0;
  background: var(--soft);
  border-top: 1px solid var(--line);
}

.footer-grid {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.footer-grid p {
  margin: 6px 0 0;
  color: var(--muted);
}

.hero,
.tool-hero {
  padding: 42px 0 34px;
  background: linear-gradient(180deg, #f7faf9 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line);
}

.hero-grid,
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 36px;
  align-items: start;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.16;
  letter-spacing: 0;
}

h1 {
  margin: 0 0 16px;
  font-size: 2.6rem;
}

h2 {
  margin: 0 0 18px;
  font-size: 1.7rem;
}

h3 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

.lead {
  max-width: 720px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-image {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.home-hero {
  padding: 72px 0 64px;
  background: linear-gradient(180deg, #f7faf9 0%, #ffffff 100%);
}

.home-hero-shell {
  display: block;
}

.home-hero-copy {
  max-width: 980px;
}

.home-hero .lead {
  max-width: 980px;
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 18px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.mode-tab:hover {
  border-color: var(--signal);
  color: var(--signal);
}

.mode-tab.is-active {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--paper);
}

.mode-tab.is-active:hover {
  border-color: var(--signal);
  background: var(--signal);
  color: var(--paper);
}

.mode-question {
  margin: 0 0 18px;
  color: var(--ink);
  font-weight: 800;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 800;
}

.rate-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.rate-chip {
  position: relative;
  display: inline-flex;
}

.rate-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rate-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--accent-strong);
  font-weight: 700;
}

.rate-chip.is-selected span {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--paper);
}

.directory-category {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-kicker {
  display: inline-block;
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  color: var(--signal);
}

.calculators-hero {
  padding-bottom: 18px;
}

.directory-summary {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.calculator-directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.directory-category {
  padding: 26px;
}

.directory-category-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

.directory-category-image {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(19, 42, 51, 0.12);
}

.directory-tool-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.directory-tool-list li {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.directory-tool-list a {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
}

.directory-tool-list a:hover {
  color: var(--accent-strong);
}

.directory-tool-list p,
.directory-empty {
  margin: 4px 0 0;
  color: var(--muted);
}

.directory-tool-list p {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.section {
  padding: 54px 0 0;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-header p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  color: var(--paper);
  background: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  color: var(--accent-strong);
  background: var(--paper);
}

.button.danger {
  border-color: var(--signal);
  background: var(--signal);
}

.button:hover {
  color: var(--paper);
  background: var(--signal);
  border-color: var(--signal);
}

.cards-grid,
.category-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card,
.calculator-card,
.result-card,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.card,
.admin-panel {
  padding: 22px;
}

.card p,
.admin-panel p {
  color: var(--muted);
}

.category-section {
  scroll-margin-top: 96px;
  padding-top: 18px;
}

.calculator-card,
.result-card {
  padding: 24px;
}

.result-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.result-value {
  color: var(--accent-strong);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.1;
}

.ad-unit {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.ad-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ad-unit ins.adsbygoogle {
  min-height: 120px;
  background: var(--paper);
  border-radius: 8px;
}

.calculator-card {
  position: relative;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label,
.radio-group legend {
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.hint,
.validation-message,
.field-validation-error {
  color: var(--muted);
  font-size: 0.92rem;
}

.validation-message,
.field-validation-error,
.validation-summary-errors {
  color: var(--signal);
}

.radio-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.results-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.result-line:last-child {
  border-bottom: 0;
}

.result-line strong {
  font-size: 1.2rem;
}

.total {
  color: var(--accent-strong);
  font-size: 1.45rem;
}

.notice {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: var(--soft);
  border-radius: 8px;
}

.notice.warning {
  border-left-color: var(--signal);
}

.formula-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.formula-box strong {
  display: block;
  margin-bottom: 8px;
}

.formula-box code {
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  line-height: 1.6;
}

.formula-list {
  display: grid;
  gap: 8px;
}

.content-flow {
  display: grid;
  gap: 26px;
}

.faq-list {
  display: grid;
  gap: 12px;
}

.faq-list details {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.faq-list summary {
  cursor: pointer;
  font-weight: 800;
}

.example-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.example-list strong {
  color: var(--ink);
}

.admin-shell {
  padding-top: 32px;
}

.admin-nav {
  margin: 16px 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
}

.status-active,
.status-inactive {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 800;
}

.status-active {
  color: var(--ok);
  background: #edf7f1;
}

.status-inactive {
  color: var(--signal);
  background: #fbefec;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .header-inner,
  .footer-grid,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-grid,
  .tool-grid,
  .home-hero-shell,
  .cards-grid,
  .category-grid,
  .stat-grid,
  .form-grid,
  .calculator-directory-grid,
  .directory-category-head {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.1rem;
  }

  .hero,
  .tool-hero,
  .home-hero {
    padding-top: 30px;
  }

  .home-hero {
    padding-bottom: 42px;
  }

  .directory-category-head {
    align-items: start;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 24px, 1120px);
  }

  .main-nav,
  .site-footer nav {
    gap: 10px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .calculator-card,
  .result-card,
  .card,
  .admin-panel {
    padding: 18px;
  }

  .result-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
