/* CalculatorEdge — same look as the original site (grey canvas, white page, orange/blue logo,
   colour-coded category buttons and sections), rebuilt mobile-first with modern CSS. */

:root {
  --canvas: #cccccc;
  --page: #ffffff;
  --text: #1d1d1f;
  --muted: #5a5a66;
  --title: #00008b;        /* old "darkblue" headings */
  --accent: #e8212b;       /* old red rule / "Enter your values" */
  --link: #0645ad;
  --line: #d6d6de;
  --btn-top: #fbfbfb;
  --btn-bottom: #e9e9ee;
  --radius: 6px;
  --focus: #1e88e5;
  --result-bg: #f2f8ff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Verdana, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 15px/1.5 var(--font); }
img { max-width: 100%; height: auto; }
a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; top: 0; inset-inline-start: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); background: #fff; padding: 0; z-index: 10; }
.skip:focus { width: auto; height: auto; clip: auto; padding: .5rem 1rem; inset-inline-start: 1rem; }

.page { max-width: 1140px; margin: 0 auto; background: var(--page); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding: 1rem; }
@media (min-width: 768px) { main { padding: 1.25rem 2rem 2rem; } }

/* ---------- Header ---------- */
.site-header { padding: .75rem 1rem 0; border-bottom: 1px solid #eee; }
.brand-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.logo { display: block; flex: 0 1 auto; }
.logo img { display: block; width: 200px; }
@media (min-width: 768px) { .logo img { width: 290px; } .brand-row { justify-content: space-between; } }

.search { position: relative; display: flex; flex: 1 1 260px; max-width: 420px; margin-left: auto; }
.search input { flex: 1; min-width: 0; padding: .55rem .75rem; border: 1px solid #b9b9c3; border-radius: var(--radius) 0 0 var(--radius); font: inherit; }
.search button { padding: .55rem .9rem; border: 1px solid #c7a400; border-left: 0; background: #ffff44; border-radius: 0 var(--radius) var(--radius) 0; font: inherit; font-weight: 600; cursor: pointer; }
.search-suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid #b9b9c3; border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; }
.search-suggest a { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; text-decoration: none; color: var(--text); }
.search-suggest a:hover, .search-suggest a.on { background: #eef4ff; }
.search-suggest small { color: var(--muted); }

.nav-toggle { display: none; }
.catnav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: .75rem 0; }
.catnav a {
  display: flex; align-items: center; justify-content: center; min-height: 32px; padding: .25rem .4rem;
  background: var(--pill, #ddd); color: #111; text-decoration: none; text-transform: uppercase;
  font-weight: 700; font-size: 12px; letter-spacing: .02em; text-align: center; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.08); transition: filter .15s, transform .15s;
}
.catnav a:hover { filter: brightness(.94); transform: translateY(-1px); }
.catnav a.active { box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }
.catnav a.dark { background: #111; color: #ffe100; }
@media (min-width: 600px) { .catnav { grid-template-columns: repeat(6, 1fr); max-width: 760px; margin: 0 auto; } }
@media (max-width: 599px) {
  .nav-toggle { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 42px; height: 42px; border: 1px solid #ccc; border-radius: var(--radius); background: #fafafa; cursor: pointer; padding: 0 9px; }
  .nav-toggle .bar { display: block; height: 3px; background: #333; border-radius: 2px; }
  .catnav { display: none; }
  .catnav.open { display: grid; }
  .search { flex-basis: 100%; max-width: none; }
}

.flags { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem .6rem; padding: .25rem 0 .9rem; }
.flags-label { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.flags img { display: block; border: 1px solid #333; width: 30px; height: 15px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid #eee; padding: 1rem; text-align: center; font-size: 13px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.25rem; margin-bottom: .5rem; }
.site-footer a { color: #111; text-decoration: none; text-transform: uppercase; font-size: 12px; font-weight: 600; }
.site-footer a::before { content: "●"; color: #999; margin-right: .35rem; font-size: 8px; vertical-align: middle; }

/* ---------- Headings, prose ---------- */
h1 { color: var(--title); font-size: 1.45rem; line-height: 1.25; margin: .25rem 0 .5rem; text-align: center; }
h1 + .rule, .rule { border: 0; height: 2px; background: var(--accent); max-width: 640px; margin: .25rem auto 1rem; }
h2 { color: var(--title); font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.lead { text-align: center; color: var(--muted); max-width: 720px; margin: 0 auto 1rem; }
.prose { max-width: 820px; margin: 0 auto; overflow-wrap: anywhere; }
.prose img { height: auto; }
.prose table { border-collapse: collapse; }
.breadcrumb { font-size: 13px; color: var(--muted); margin: 0 0 .5rem; }
.breadcrumb a { color: var(--muted); }
.welcome { max-width: 800px; margin: 0 auto 1rem; text-align: justify; font-family: Georgia, "Times New Roman", serif; font-size: 14.5px; }

/* ---------- Home sections (colour-coded like the original) ---------- */
.sections { display: grid; gap: 1.25rem; }
.section { border: 1px solid var(--border, #9966ff); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 1rem; }
.section > h2 { margin: 0; padding: .4rem .75rem; background: var(--band, #b4aaf3); color: #111; text-align: center; font-family: Georgia, "Times New Roman", serif; font-size: 14px; letter-spacing: .03em; text-transform: uppercase; }
.section > h2 a { color: inherit; text-decoration: none; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: .75rem; margin: 0; list-style: none; }
@media (min-width: 768px) { .tool-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); } }
.tool-grid a, .btn {
  display: flex; align-items: center; justify-content: center; min-height: 34px; padding: .3rem .5rem;
  border: 1px solid #a9a9b3; border-radius: 4px; background: linear-gradient(var(--btn-top), var(--btn-bottom));
  color: #111; text-decoration: none; text-align: center; font-size: 13.5px; line-height: 1.2;
}
.tool-grid a:hover, .btn:hover { border-color: #555; background: #fff; }
.tool-grid a.excel::after { content: "XLS"; margin-left: .4rem; font-size: 10px; font-weight: 700; color: #1d6f42; border: 1px solid #1d6f42; border-radius: 3px; padding: 0 3px; }
.section-more { padding: 0 .75rem .75rem; text-align: right; font-size: 13px; }

.promo { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 1.25rem 0; }
.promo a { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); background: #fafafc; }
.promo a:hover { border-color: #888; }
.promo img { max-height: 64px; width: auto; }

/* ---------- Calculator page ---------- */
.calc-layout { display: grid; gap: 1.5rem; }
@media (min-width: 960px) { .calc-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.calc-card { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
@media (min-width: 600px) { .calc-card { padding: 1.25rem 1.5rem; } }
.calc-card .hint { margin: 0 0 .75rem; font-weight: 600; font-size: 14px; }
.modes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1rem; }
.modes button { padding: .4rem .7rem; border: 1px solid #a9a9b3; border-radius: 999px; background: #f6f6f8; font: inherit; font-size: 13.5px; cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--title); color: #fff; border-color: var(--title); }
.calc-form fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.calc-form legend { color: var(--accent); font-weight: 700; font-size: 14px; margin-bottom: .5rem; padding: 0; }
.field { display: grid; grid-template-columns: 1fr; gap: .25rem; margin-bottom: .7rem; }
@media (min-width: 600px) { .field { grid-template-columns: 220px 1fr; align-items: center; gap: .75rem; } }
.field > label { color: var(--title); font-weight: 600; font-size: 14px; }
.field .ctl { display: flex; gap: .4rem; align-items: center; min-width: 0; }
.field input, .field select { font: inherit; padding: .5rem .6rem; border: 1px solid #a9a9b3; border-radius: var(--radius); background: #fff; min-width: 0; }
.field input { flex: 1 1 140px; max-width: 220px; }
.field select.unit { flex: 0 0 auto; max-width: 140px; }
.field .unit-label { color: var(--title); font-weight: 600; font-size: 14px; white-space: nowrap; }
.field input[readonly] { background: var(--result-bg); font-weight: 700; border-color: #9fc3ec; }
.field input.invalid { border-color: var(--accent); background: #fff4f4; }
.field .err { grid-column: 1 / -1; color: var(--accent); font-size: 13px; margin: 0; }
@media (min-width: 600px) { .field .err { grid-column: 2; } }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 1.25rem; }
.actions button { font: inherit; font-weight: 600; padding: .55rem 1.2rem; border-radius: var(--radius); cursor: pointer; border: 1px solid #0b4fa0; background: #1565c0; color: #fff; }
.actions button.secondary { background: #f2f2f5; color: #222; border-color: #a9a9b3; }
.results { border-top: 1px dashed #c9c9d3; padding-top: .9rem; }
.results[data-state="ready"] { animation: flash .6s ease; }
@keyframes flash { from { background: #fffbe0; } to { background: transparent; } }
.result-table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: 14px; }
.result-table th, .result-table td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: right; }
.result-table th { background: #f4f4f8; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.copy-btn { margin-left: .25rem; border: 1px solid #c9c9d3; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; padding: .2rem .45rem; }
.formula { margin-top: 1.5rem; }
.formula img { background: #fff; }
.side .card { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.side h2 { margin-top: 0; font-size: 1rem; }
.side ul { margin: 0; padding-left: 1.1rem; }
.side li { margin: .2rem 0; }
.excel-card { text-align: center; }
.excel-card .download { display: inline-block; margin-top: .75rem; padding: .7rem 1.2rem; background: #1d6f42; color: #fff; border-radius: var(--radius); font-weight: 700; text-decoration: none; }

/* ---------- Content pages & lists ---------- */
.list { columns: 1; gap: 2rem; padding-left: 1.1rem; }
@media (min-width: 700px) { .list { columns: 2; } }
@media (min-width: 1000px) { .list { columns: 3; } }
.list li { break-inside: avoid; margin: .2rem 0; }
.card-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding: 0; list-style: none; }
.card-list li { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.card-list h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.data-table { border-collapse: collapse; margin: 1rem auto; font-size: 14px; }
.data-table th, .data-table td { border: 1px solid #b9b9c3; padding: .35rem .55rem; text-align: center; }
.data-table th, .data-table tr:first-child td { background: #f1f1f6; font-weight: 700; }
.data-table tbody tr:nth-child(even) td { background: #fafafd; }

/* ---------- Ads (reserved space avoids layout shift) ---------- */
.ad-slot { margin: 1rem auto; text-align: center; min-height: 90px; max-width: 100%; overflow: hidden; }
.ad-adslotside { min-height: 250px; }
@media (max-width: 959px) { .side .ad-adslotside { display: none; } }
.ad-placeholder { display: flex; align-items: center; justify-content: center; min-height: inherit; height: 100%; border: 1px dashed #c4c4cc; color: #9a9aa5; font-size: 12px; border-radius: var(--radius); padding: .5rem; background: repeating-linear-gradient(45deg, #fafafa, #fafafa 10px, #f4f4f6 10px, #f4f4f6 20px); }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .site-header .search, .catnav, .flags, .ad-slot, .site-footer nav, .actions, .side, .nav-toggle { display: none !important; }
  .page { max-width: none; }
}
