/* ==========================================================================
   SheetFormulas — classic reference-site stylesheet.
   Deliberately conservative: serif headings, boxed panels, underlined links,
   bevelled buttons and a fixed-width centered page.
   ========================================================================== */

:root {
  --navy: #1e5c3a;
  --navy-dark: #133f27;
  --gold: #e3a32b;
  --link: #1a4e9a;
  --link-visited: #5a3f8c;
  --link-hover: #c0451a;
  --text: #222;
  --muted: #5e6672;
  --border: #b9c4d3;
  --border-light: #d6dde7;
  --panel: #f3f8f4;
  --head-a: #eef6f0;
  --head-b: #d6e8db;
  --page-bg: #dde5df;
  --result-bg: #fffbe8;
  --result-border: #e2cf86;
  --green-a: #5fa84d;
  --green-b: #3e8130;
  --serif: Georgia, 'Times New Roman', Times, serif;
  --sans: Verdana, Geneva, Tahoma, 'DejaVu Sans', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page-bg) linear-gradient(#c6d3c9, var(--page-bg) 260px) no-repeat;
  color: var(--text);
  font: 14px/1.6 var(--sans);
}

a { color: var(--link); }
a:visited { color: var(--link-visited); }
a:hover, a:focus { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }

h1, h2, h3 { font-family: var(--serif); color: var(--navy); line-height: 1.25; }
h1 { font-size: 27px; font-weight: normal; margin: 4px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-light); }
h2 { font-size: 20px; margin: 28px 0 10px; padding-bottom: 3px; border-bottom: 1px dotted var(--border); }
h3 { font-size: 16px; margin: 20px 0 6px; }
p { margin: 0 0 12px; }

/* ---------- page frame ---------- */
#wrap {
  max-width: 1080px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #aeb7c3;
  border-top: 0;
  box-shadow: 0 0 10px rgba(0, 0, 0, .12);
}

#masthead {
  background: linear-gradient(#2c7a4d, var(--navy) 60%, var(--navy-dark));
  border-bottom: 3px solid var(--gold);
  color: #fff;
}
.mast-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 14px 20px 12px;
}
.logo { display: flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none; }
.logo-mark { flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.logo-text {
  font: bold 30px/1 var(--serif);
  letter-spacing: -.5px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .45);
}
.tagline { font: italic 14px var(--serif); color: #d3eadb; margin-top: 8px; }

.top-search { margin-left: auto; display: flex; position: relative; }
.top-search input {
  width: 230px;
  font: 13px var(--sans);
  padding: 5px 7px;
  border: 1px solid #0e2e1c;
  border-right: 0;
  border-radius: 3px 0 0 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
}
.top-search button {
  font: bold 12px var(--sans);
  padding: 4px 11px;
  color: #3b2a05;
  background: linear-gradient(#f8d27c, #e3a32b);
  border: 1px solid #a3741a;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
}
.top-search button:hover { background: linear-gradient(#fbdf9c, #eab042); }

#topnav { background: linear-gradient(#f8f9fb, #e6ebf1); border-top: 1px solid #0e2e1c; border-bottom: 1px solid #b8c2cf; }
#topnav ul { list-style: none; margin: 0; padding: 0 12px; display: flex; flex-wrap: wrap; }
#topnav li { border-right: 1px solid #cdd4de; }
#topnav li:first-child { border-left: 1px solid #cdd4de; }
#topnav a { display: block; padding: 7px 12px; font-size: 12.5px; font-weight: bold; color: var(--navy); text-decoration: none; }
#topnav a:hover { background: #fff; color: var(--link-hover); }
#topnav li.active a { background: #fff; color: #000; box-shadow: inset 0 3px 0 var(--gold); }

#page { display: flex; align-items: flex-start; }
#content { flex: 1; min-width: 0; padding: 14px 24px 28px; }
#sidebar { width: 260px; flex: none; padding: 16px 14px; background: #f7f8fa; border-left: 1px solid var(--border-light); align-self: stretch; }
#page.full #content { padding-right: 24px; }

.breadcrumbs { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.breadcrumbs .sep { color: #9aa3ae; margin: 0 2px; }

/* ---------- boxes ---------- */
.box { border: 1px solid var(--border); background: #fff; margin: 0 0 18px; }
.box-head {
  background: linear-gradient(var(--head-a), var(--head-b));
  border-bottom: 1px solid var(--border);
  padding: 5px 10px;
  font: bold 14px var(--serif);
  color: var(--navy);
}
.box-head a { color: var(--navy); text-decoration: none; }
.box-head a:hover { text-decoration: underline; }
.box-head .count { float: right; font: normal 11px var(--sans); color: var(--muted); background: #fff; border: 1px solid var(--border-light); border-radius: 8px; padding: 0 6px; margin-top: 1px; }
.box-body { padding: 10px 12px; }
.box-body p:last-child { margin: 0; }
.box-foot { border-top: 1px solid var(--border-light); background: var(--panel); padding: 4px 10px; font-size: 12px; text-align: right; }
.box > ul { margin: 0; padding: 8px 12px 8px 28px; }
.box > p { padding: 8px 12px 0; }

.side-list { list-style: none !important; padding: 4px 0 !important; }
.side-list li { padding: 3px 12px 3px 24px; position: relative; font-size: 13px; }
.side-list li::before { content: '\25B8'; position: absolute; left: 11px; color: var(--gold); }
.side-list li.current { background: #fff6dd; font-weight: bold; }
.side-list .count { color: var(--muted); font-size: 11px; }
.note-box p { font-size: 12.5px; padding-bottom: 8px; margin: 0; }

ul.cols { columns: 2; column-gap: 24px; }
ul.cols.three { columns: 3; }
ul.cols li { break-inside: avoid; margin-bottom: 3px; }

/* ---------- home ---------- */
.welcome {
  background: linear-gradient(#fbfcfe, #eef3f9);
  border: 1px solid var(--border);
  padding: 12px 18px 16px;
  margin-bottom: 18px;
}
.welcome h1 { border: 0; margin-bottom: 4px; }
.big-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: relative; margin: 12px 0 4px; }
.big-search label { font-weight: bold; color: var(--navy); }
.big-search input {
  flex: 1;
  min-width: 200px;
  font: 16px var(--sans);
  padding: 7px 9px;
  border: 1px solid #8a97ab;
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .12);
}
.dir-title { margin-top: 6px; }
.directory { columns: 2; column-gap: 18px; }
.cat-box { break-inside: avoid; display: inline-block; width: 100%; }
.cat-blurb { font-size: 12px; color: var(--muted); padding: 6px 12px 0 !important; margin: 0; }
.cat-box ul { padding: 4px 12px 10px 28px !important; font-size: 13px; }
.cat-box li { margin: 2px 0; }
.home-about { margin-top: 10px; }

/* ---------- calculator page ---------- */
.lead { font-size: 15px; color: #333; }
.calc-box {
  border: 1px solid #98a8bf;
  background: var(--panel);
  margin: 16px 0 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  max-width: 620px;
}
.calc-title {
  background: linear-gradient(#3a8a5c, var(--navy));
  color: #fff;
  font: bold 15px var(--serif);
  padding: 7px 12px;
  border-bottom: 2px solid var(--gold);
}
.calc-form { padding: 12px 14px 4px; }
.calc-row { display: grid; grid-template-columns: 40% 1fr; gap: 10px; align-items: center; margin-bottom: 9px; }
.calc-row label { text-align: right; font-weight: bold; font-size: 13px; color: #333; }
.calc-row.wide { align-items: start; }
.calc-row.wide label { padding-top: 4px; }
.calc-field { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.calc-field .unit { font-size: 12.5px; color: var(--muted); }
.calc-field .hint { flex-basis: 100%; color: var(--muted); font-size: 11px; }
.calc-field input, .calc-field select, .calc-field textarea {
  font: 14px var(--sans);
  padding: 4px 6px;
  border: 1px solid #8a97ab;
  border-radius: 2px;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
  color: #000;
}
.calc-field input[type='number'] { width: 150px; }
.calc-field input[type='date'] { width: 170px; }
.calc-field select { max-width: 100%; box-shadow: none; }
.calc-field textarea { width: 100%; max-width: 330px; resize: vertical; }
.calc-field input:focus, .calc-field select:focus, .calc-field textarea:focus { border-color: var(--navy); background: #fffef4; outline: none; box-shadow: 0 0 0 2px rgba(227, 163, 43, .35); }

.calc-actions { padding: 6px 0 10px 40%; margin-left: 10px; display: flex; gap: 8px; }
.btn {
  font: bold 13px var(--sans);
  padding: 6px 18px;
  border-radius: 3px;
  cursor: pointer;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
}
.btn-go { color: #fff; background: linear-gradient(var(--green-a), var(--green-b)); border: 1px solid #2c6522; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn-go:hover { background: linear-gradient(#6cb85a, #448c36); }
.btn-go:active { background: var(--green-b); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25); }
.btn-clear { color: #333; text-shadow: 0 1px 0 #fff; background: linear-gradient(#fdfdfd, #dfe3e8); border: 1px solid #9aa4b1; }
.btn-clear:hover { background: linear-gradient(#fff, #e9ecf0); }

.calc-results { background: var(--result-bg); border-top: 1px solid var(--result-border); padding: 8px 14px 6px; }
.calc-results.flash { animation: flash .9s ease-out; }
@keyframes flash { from { background: #fff1a8; } to { background: var(--result-bg); } }
.results-head { font: bold 14px var(--serif); color: #6b5410; margin-bottom: 4px; }
.results-table { border-collapse: collapse; width: 100%; }
.results-table th, .results-table td { padding: 4px 6px; border-bottom: 1px dotted #e3d79f; text-align: left; vertical-align: top; }
.results-table th { font-weight: normal; width: 45%; color: #444; }
.results-table td { font-weight: bold; }
.results-table tr:last-child th, .results-table tr:last-child td { border-bottom: 0; }
.results-table tr.primary td .val { font-size: 21px; color: #23661a; font-family: var(--serif); }
.results-table tr.primary th { font-weight: bold; color: #222; padding-top: 8px; }
.results-table .unit { font-weight: normal; color: var(--muted); }
.calc-error { color: #a1260d; background: #fdecea; border: 1px solid #f0b4a8; padding: 6px 9px; margin: 4px 0 8px; font-size: 13px; }
.results-tools { font-size: 11.5px; text-align: right; margin: 4px 0 2px; }
.copied { color: #23661a; }

.toc { max-width: 620px; }
.toc ol { margin: 0; padding: 6px 12px 8px 32px; columns: 2; font-size: 13px; }

.formula {
  font: 19px/1.7 'Times New Roman', Times, serif;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  padding: 10px 16px;
  margin: 8px 0 14px;
  overflow-x: auto;
}
table.data { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 13px; }
table.data caption { text-align: left; font: bold 13px var(--serif); color: var(--navy); padding: 0 0 4px; }
table.data th, table.data td { border: 1px solid #c5ceda; padding: 5px 8px; text-align: left; vertical-align: top; }
table.data thead th { background: linear-gradient(var(--head-a), var(--head-b)); color: var(--navy); }
table.data tbody tr:nth-child(even) { background: #f6f8fb; }
table.data th[scope='row'] { background: #f3f6fa; font-weight: normal; width: 50%; }
table.vars td.sym { font: 16px 'Times New Roman', serif; white-space: nowrap; width: 1%; }
.example-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.steps li { margin-bottom: 4px; }

.prose { max-width: 720px; }
.prose ul, .prose ol { padding-left: 24px; }
.faq dt { font: bold 15px var(--serif); color: var(--navy); margin-top: 12px; }
.faq dd { margin: 4px 0 0 0; padding-left: 14px; border-left: 3px solid var(--border-light); }
.related ul { font-size: 13px; }
.page-meta { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border-light); padding-top: 8px; margin-top: 18px; }

/* ---------- category / index pages ---------- */
.lead-block { margin-bottom: 12px; }
.calc-index td:first-child { white-space: nowrap; font-weight: bold; }
.az-jump { font-size: 15px; font-weight: bold; letter-spacing: 2px; word-spacing: 4px; }
.az-letter { font-size: 22px; }
.az-list { columns: 2; column-gap: 24px; padding-left: 20px; }
.az-list li { break-inside: avoid; margin-bottom: 3px; }

/* ---------- search ---------- */
.has-suggest { position: relative; }
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  background: #fff;
  border: 1px solid #8a97ab;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
  color: var(--text);
  text-align: left;
  min-width: 260px;
}
.suggest li a { display: block; padding: 5px 9px; text-decoration: none; color: var(--text); border-bottom: 1px solid #eef1f5; }
.suggest li a b { color: var(--link); font-weight: bold; }
.suggest li a span { display: block; font-size: 11px; color: var(--muted); }
.suggest li.active a, .suggest li a:hover { background: #fff3cf; }
.suggest li.none { padding: 6px 9px; color: var(--muted); font-size: 12px; }
.suggest li.group { padding: 4px 9px 3px; font: bold 11px var(--sans); color: #6b5410; background: #f7f1dc; border-top: 1px solid #e6dcb5; border-bottom: 1px solid #e6dcb5; text-transform: uppercase; letter-spacing: .5px; }
.result-list li { margin-bottom: 12px; }
.result-list li a { font: bold 16px var(--serif); }
.result-list p { margin: 2px 0 0; font-size: 13px; color: #444; }

/* ---------- ads ---------- */
.ad { margin: 16px 0; text-align: center; min-height: 90px; }
.ad-label { display: block; font-size: 10px; color: #8c949e; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
#sidebar .ad { min-height: 250px; }

/* ---------- footer ---------- */
#footer { background: linear-gradient(#eef1f5, #dfe4ea); border-top: 3px solid var(--navy); padding: 14px 20px 18px; font-size: 12px; color: #555; text-align: center; }
.foot-links { list-style: none; margin: 0 0 8px; padding: 0; }
.foot-links li { display: inline; }
.foot-links li + li::before { content: ' | '; color: #a0a8b3; }
.foot-cats { font-size: 11.5px; }
#footer p { margin: 4px 0; }

.contact-box { max-width: 420px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #page { flex-direction: column; }
  #sidebar { width: auto; border-left: 0; border-top: 1px solid var(--border-light); align-self: auto; }
  .directory { columns: 1; }
}
@media (max-width: 640px) {
  body { font-size: 15px; background: #fff; }
  #wrap { border: 0; box-shadow: none; }
  .mast-inner { padding: 10px 16px; }
  .logo-text { font-size: 24px; }
  .tagline { display: none; }
  .top-search { margin-left: 0; width: 100%; }
  .top-search input { flex: 1; width: auto; font-size: 16px; }
  #topnav ul { padding: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #topnav li { flex: none; }
  #topnav li, #topnav li:first-child { border: 0; }
  #topnav a { padding: 6px 9px; }
  #content { padding: 10px 16px 24px; }
  h1 { font-size: 24px; }
  .calc-row { grid-template-columns: 1fr; gap: 3px; }
  .calc-row label { text-align: left; }
  .calc-actions { padding-left: 0; margin-left: 0; }
  .calc-field input[type='number'], .calc-field input[type='date'] { width: 100%; max-width: 220px; font-size: 16px; }
  .calc-field select, .calc-field textarea { font-size: 16px; }
  ul.cols, ul.cols.three, .az-list, .toc ol { columns: 1; }
  .example-grid { grid-template-columns: 1fr; gap: 0; }
  .calc-index td:first-child { white-space: normal; }
  .formula { font-size: 17px; }
}

@media print {
  #masthead, #topnav, #sidebar, #footer, .ad, .toc, .calc-actions, .results-tools { display: none !important; }
  #wrap { box-shadow: none; border: 0; }
}

/* ==========================================================================
   SheetFormulas additions
   ========================================================================== */
code, pre { font-family: Consolas, 'Lucida Console', 'Courier New', monospace; font-size: 13px; }
code { background: #f4f7f4; border: 1px solid #dfe7e1; padding: 0 3px; border-radius: 2px; }
.small { font-size: 12px; }
.h1-sub { display: block; font-size: 16px; color: var(--muted); font-style: italic; margin-top: 2px; }

/* app identity dots — muted, classic */
.app-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; border: 1px solid rgba(0,0,0,.25); }
.app-excel { background: #217346; }
.app-sheets { background: #34a853; }
.app-airtable { background: #f7b500; }
.app-notion { background: #333; }
.app-list li::before { content: none !important; }
.app-list li { padding-left: 12px !important; }

/* availability badges */
.st { font-weight: bold; white-space: nowrap; font-size: 12.5px; }
.st-yes { color: #23661a; }
.st-alt { color: #a26a00; }
.st-none { color: #a1260d; }
td.c, th.c { text-align: center !important; }
.legend { font-size: 12px; color: var(--muted); }
.tag { font-size: 10px; font-weight: normal; color: #a26a00; text-transform: uppercase; letter-spacing: .5px; }
.opt { font-size: 10.5px; font-weight: normal; color: var(--muted); }
.since { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.app-note { font-size: 12.5px; color: #444; margin-top: 3px; }
table.syntax th[scope='row'] { width: 22%; white-space: nowrap; background: #f3f8f4; font-weight: bold; }
table.syntax td.c { width: 16%; }
table.args td.arg { white-space: nowrap; width: 1%; }
table.examples td.res { font-weight: bold; white-space: nowrap; }
table.examples td:first-child code { white-space: nowrap; }

/* tester */
.tester { max-width: none; }
.tester .calc-row { grid-template-columns: 30% 1fr; }
.tester .calc-actions { padding-left: 30%; }
.calc-field textarea { font: 13px Consolas, 'Courier New', monospace; }
.result-line { padding: 4px 6px 10px; border-bottom: 1px dotted #e3d79f; margin-bottom: 8px; }
.result-val { font: bold 24px var(--serif); color: #23661a; word-break: break-word; }
.result-val.is-error { color: #a1260d; font-family: Consolas, 'Courier New', monospace; }
.result-sub { display: block; font-size: 12px; color: var(--muted); }
.fx-head { margin-top: 6px; }
.fx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fx-table th, .fx-table td { padding: 6px 6px; border-bottom: 1px dotted #e3d79f; vertical-align: middle; text-align: left; }
.fx-table th { width: 18%; white-space: nowrap; font-weight: bold; color: #333; }
.fx-table tr:last-child th, .fx-table tr:last-child td { border-bottom: 0; }
.fx-table code.fx { display: block; background: #fff; border: 1px solid #c9d6cc; padding: 4px 7px; font-size: 13px; word-break: break-all; color: #0b3b20; }
.fx-table td.fx-btn { width: 1%; white-space: nowrap; }
.fx-none td { color: #555; font-size: 12.5px; }
.open-app { display: block; font-size: 11px; margin-top: 3px; text-align: center; }
.btn-copy { font-size: 12px; padding: 4px 10px; color: #fff; background: linear-gradient(#4f8fc9, #2f6aa3); border: 1px solid #23507c; text-shadow: 0 -1px 0 rgba(0,0,0,.25); min-width: 150px; }
.btn-copy:hover { background: linear-gradient(#5d9bd3, #3574b0); }
.btn-small { font: bold 11.5px var(--sans); padding: 2px 9px; border-radius: 3px; cursor: pointer; color: #333; background: linear-gradient(#fdfdfd, #dfe3e8); border: 1px solid #9aa4b1; }
.btn-small:hover { background: linear-gradient(#fff, #e9ecf0); }
.btn.done, .btn-small.done { background: linear-gradient(var(--green-a), var(--green-b)); border-color: #2c6522; color: #fff; text-shadow: none; }
.linkish { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; font: inherit; }
.linkish.done { color: #23661a; text-decoration: none; }
.sample { margin-top: 10px; padding: 8px 10px; background: #fff; border: 1px dashed #cdb96a; font-size: 12.5px; }
.sample p { margin: 0 0 6px; }
.sample pre { margin: 0; max-height: 160px; overflow: auto; background: #fbfbf7; padding: 4px 6px; border: 1px solid #eee5bf; font-size: 12px; tab-size: 14; }
.tester-note { font-size: 12px; color: #555; margin: 8px 0 0; }

/* home */
.app-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 8px; }
.app-card { border: 1px solid var(--border); background: #fff; font-size: 12.5px; }
.app-card-head { background: linear-gradient(var(--head-a), var(--head-b)); border-bottom: 1px solid var(--border); padding: 4px 8px; font: bold 13.5px var(--serif); color: var(--navy); }
.app-card p { padding: 6px 8px; margin: 0; }

/* index tables */
table.fn-index td:first-child, table.compat td:first-child { white-space: nowrap; font-weight: bold; }
table.compat tr.group th { background: #eef6f0; font: bold 14px var(--serif); color: var(--navy); text-align: left; }
table.compat { max-width: 720px; }
table.summary-table { max-width: 520px; }
.guide-table { font-size: 12.5px; }
.guide-table th[scope='row'] { width: 14%; background: #f3f8f4; font-weight: bold; }

@media (max-width: 900px) {
  .app-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .app-cards { grid-template-columns: 1fr; }
  .tester .calc-row { grid-template-columns: 1fr; }
  .tester .calc-actions { padding-left: 0; }
  .fx-table, .fx-table tbody, .fx-table tr, .fx-table th, .fx-table td { display: block; width: auto !important; }
  .fx-table th { border-bottom: 0; padding-bottom: 0; }
  .fx-table td.fx-btn { white-space: normal; }
  .btn-copy { width: 100%; }
  table.syntax th[scope='row'] { white-space: normal; }
  .data { display: block; overflow-x: auto; }
  table.examples td:first-child code { white-space: normal; word-break: break-all; }
}
