/* ==========================================================================
   Il Fuoglio — accounting firm knowledge handbook
   Concept: technical handbook / knowledge base
   Palette: slate paper, near-black, cyan-teal accent, numbered chapters
   Type: Space Grotesk (headings) + IBM Plex Serif (body) + IBM Plex Mono (labels)
   ========================================================================== */

:root {
  --paper: #f7f7f5;
  --surface: #ffffff;
  --ink: #15181b;
  --ink-2: #474f56;
  --ink-3: #767f87;
  --rule: #dfe2e3;
  --rule-2: #c4c9cc;
  --slate: #262f38;
  --slate-deep: #171d23;
  --teal: #0d6a73;
  --teal-tint: #e2f0f1;
  --amber: #a06005;
  --amber-tint: #fbf1de;
  --red: #a02c2c;
  --wrap: 1140px;
  --head: "Space Grotesk", "Archivo", system-ui, sans-serif;
  --body: "IBM Plex Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0125rem;
  line-height: 1.7;
}

img { max-width: 100%; height: auto; }
a { color: var(--teal); text-underline-offset: .18em; }
a:hover { color: var(--slate-deep); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; background: var(--slate); color: #fff; padding: .7rem 1rem; z-index: 80; }
.skip-link:focus { left: .75rem; top: .75rem; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.3rem; }

/* ---------- Handbook header ---------- */

.handbook-head { background: var(--slate-deep); color: #e9edef; }
.handbook-head .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.6rem; padding-top: .9rem; padding-bottom: .9rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: inherit; }
.brand-mark { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-family: var(--head); font-size: 1.22rem; font-weight: 700; letter-spacing: -.01em; color: #fff; }
.brand-sub { font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #8fa0aa; }
.head-meta { margin-left: auto; font-family: var(--mono); font-size: .72rem; color: #8fa0aa; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }

.nav { background: var(--slate); border-bottom: 1px solid #2f3a44; }
.nav .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.nav a { font-family: var(--head); font-size: .82rem; color: #cfd8dd; text-decoration: none; padding: .7rem .85rem; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a[aria-current="page"] { color: #fff; background: rgba(13, 106, 115, .38); box-shadow: inset 0 -2px 0 var(--teal); }
.nav .nav-end { margin-left: auto; }

.breadcrumb { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); padding: 1rem 0 0; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "→"; margin-right: .4rem; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Type ---------- */

h1, h2, h3, h4, h5 { font-family: var(--head); font-weight: 700; line-height: 1.2; color: var(--ink); margin: 0 0 .55em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.1vw, 2.9rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); margin-top: 2.4rem; }
h3 { font-size: 1.16rem; margin-top: 1.7rem; }
h4 { font-size: 1rem; margin-top: 1.3rem; }
p { margin: 0 0 1.05em; }
.lede { font-size: 1.16rem; color: var(--ink-2); }
.eyebrow { font-family: var(--mono); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); margin: 0 0 .7rem; }
.meta-line { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }
.small { font-size: .92rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4rem 0; }
blockquote { margin: 1.6rem 0; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--teal); padding: 1rem 1.2rem; color: var(--ink-2); font-size: 1rem; }
ul, ol { padding-left: 1.3rem; margin: 0 0 1.1em; }
li { margin-bottom: .45em; }
code { font-family: var(--mono); font-size: .88em; background: #eceff0; padding: .1em .35em; }

/* ---------- Chapter numbering ---------- */

.chapter-no {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--rule-2);
  padding: .1rem .45rem;
  background: var(--surface);
  display: inline-block;
  margin-bottom: .7rem;
}
h2[data-chapter]::before {
  content: attr(data-chapter);
  display: block;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  color: var(--teal);
  margin-bottom: .35rem;
}

/* ---------- Hero ---------- */

.hero { background: var(--surface); border-bottom: 1px solid var(--rule); }
.hero .wrap { padding: 2.6rem 0 2.4rem; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 2.6rem; align-items: start; }
.role-panel { border: 1px solid var(--rule-2); background: var(--paper); padding: 1.2rem 1.3rem; font-size: .92rem; color: var(--ink-2); }
.role-panel strong { display: block; font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); margin-bottom: .5rem; }
.checklist-box { background: var(--slate-deep); color: #dde5e9; padding: 1.2rem 1.3rem; font-size: .9rem; }
.checklist-box h2 { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #8fa0aa; margin: 0 0 .6rem; }
.checklist-box ul { list-style: none; padding: 0; margin: 0; }
.checklist-box li { padding-left: 1.5rem; position: relative; margin-bottom: .45rem; }
.checklist-box li::before { content: "□"; position: absolute; left: 0; color: var(--teal); }
.checklist-box a { color: #9fd6d9; }

/* ---------- Section machinery ---------- */

section { padding: 2.4rem 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1.4rem; border-bottom: 2px solid var(--ink); padding-bottom: .5rem; margin-bottom: 1.6rem; }
.section-head h2 { margin: 0; }
.section-head .section-note { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }

/* ---------- Chapter index (numbered rows, not cards) ---------- */

.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list > li { margin: 0; border-bottom: 1px solid var(--rule); }
.chapter-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: 1rem; align-items: baseline; padding: .95rem .3rem; text-decoration: none; color: inherit; }
.chapter-row:hover { background: var(--surface); }
.chapter-row .no { font-family: var(--mono); font-size: 1.05rem; color: var(--teal); }
.chapter-row .ttl { font-family: var(--head); font-size: 1.08rem; font-weight: 700; }
.chapter-row .ttl small { display: block; font-family: var(--body); font-weight: 400; font-size: .88rem; color: var(--ink-3); margin-top: .2rem; }
.chapter-row .go { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }

/* ---------- Grid cards (service modules) ---------- */

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.module { background: var(--surface); padding: 1.2rem 1.3rem; }
.module h3 { margin: 0 0 .45rem; font-size: 1.06rem; }
.module p { font-size: .94rem; color: var(--ink-2); margin-bottom: .6rem; }
.module .module-tag { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.module ul { font-size: .92rem; margin-bottom: 0; }

/* ---------- Callouts ---------- */

.callout { border: 1px solid var(--rule-2); border-left: 4px solid var(--teal); background: var(--surface); padding: 1rem 1.15rem; font-size: .95rem; color: var(--ink-2); }
.callout-warn { border-left-color: var(--amber); background: var(--amber-tint); }
.callout-stop { border-left-color: var(--red); }
.callout p:last-child { margin-bottom: 0; }

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; border: 1px solid var(--rule-2); background: var(--surface); }
table.hb { border-collapse: collapse; width: 100%; min-width: 1000px; font-size: .88rem; }
table.hb caption { text-align: left; font-family: var(--mono); font-size: .76rem; color: var(--ink-3); padding: .7rem .9rem; }
table.hb th, table.hb td { text-align: left; vertical-align: top; padding: .65rem .8rem; border-bottom: 1px solid var(--rule); }
table.hb thead th { background: var(--slate); color: #e6ebee; font-family: var(--mono); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; position: sticky; top: 0; }
table.hb tbody tr:nth-child(even) { background: #fbfbfa; }
table.hb tbody tr:hover { background: var(--teal-tint); }
table.hb tbody tr:target { background: var(--amber-tint); }
.p-name { font-family: var(--head); font-weight: 700; display: block; font-size: .98rem; }
.p-meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.badge { display: inline-block; font-family: var(--mono); font-size: .7rem; border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink-2); padding: .05rem .4rem; margin: 0 .2rem .2rem 0; }
.badge-teal { background: var(--teal-tint); border-color: #a9cfd2; color: #0a545c; }

/* ---------- Filters ---------- */

.filters { background: var(--surface); border: 1px solid var(--rule-2); padding: 1.15rem; }
.filters fieldset { border: 0; margin: 0 0 1.05rem; padding: 0; }
.filters legend { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--slate); margin-bottom: .5rem; }
.filters label.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .88rem; color: var(--ink-2); margin-bottom: .28rem; }
.filters select, .filters input[type="search"] { width: 100%; font-family: var(--mono); font-size: .84rem; padding: .5rem .55rem; border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink); }
.filter-actions { display: flex; flex-wrap: wrap; gap: .5rem; border-top: 1px solid var(--rule); padding-top: .9rem; }
.result-count { font-family: var(--mono); font-size: .8rem; color: var(--ink-2); }
.filter-toggle { display: none; }

/* ---------- Buttons ---------- */

.btn { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--head); font-size: .84rem; font-weight: 700; padding: .55rem .95rem; border: 1px solid var(--slate); background: var(--slate); color: #fff; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--slate-deep); color: #fff; }
.btn-teal { background: var(--teal); border-color: var(--teal); }
.btn-teal:hover { background: #0a545c; }
.btn-quiet { background: transparent; color: var(--slate); }
.btn-quiet:hover { background: #e9edef; }
.btn-sm { padding: .35rem .65rem; font-size: .76rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Profile ---------- */

.profile-top { background: var(--surface); border-top: 4px solid var(--teal); padding: 1.8rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.profile-cols { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 2.4rem; align-items: start; }
.spec { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); border-top: 1px solid var(--rule); font-size: .94rem; }
.spec dt { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: .62rem .9rem .62rem 0; border-bottom: 1px solid var(--rule); }
.spec dd { margin: 0; padding: .62rem 0; border-bottom: 1px solid var(--rule); }
.aside { background: var(--paper); border: 1px solid var(--rule-2); padding: 1.1rem; font-size: .9rem; }
.aside h2 { font-family: var(--mono); font-size: .72rem; letter-spacing: .13em; text-transform: uppercase; color: var(--teal); margin: 0 0 .7rem; }
.aside dl { margin: 0; }
.aside dt { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; color: var(--ink-3); margin-top: .7rem; }
.aside dd { margin: .15rem 0 0; overflow-wrap: break-word; }
.only-note { background: var(--amber-tint); border: 1px solid #e3cfa3; border-left: 4px solid var(--amber); padding: .8rem 1rem; font-size: .85rem; color: #6b4708; }

/* ---------- Shortlist ---------- */

.shortlist { border: 1px solid var(--rule-2); background: var(--surface); }
.shortlist header { background: var(--slate-deep); color: #fff; font-family: var(--mono); font-size: .76rem; padding: .7rem 1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; letter-spacing: .06em; }
.shortlist ul { list-style: none; margin: 0; padding: .5rem 1rem; font-size: .88rem; }
.shortlist li { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--rule); margin: 0; }
.shortlist li:last-child { border-bottom: 0; }
.shortlist .empty { padding: 1rem; margin: 0; color: var(--ink-3); font-family: var(--mono); font-size: .8rem; }

/* ---------- Article ---------- */

.article-grid { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 2.6rem; align-items: start; padding-top: 2rem; }
.prose > * { max-width: 70ch; }
.toc { background: var(--surface); border: 1px solid var(--rule); padding: 1rem 1.1rem; font-family: var(--mono); font-size: .78rem; }
.toc h2 { font-family: var(--mono); font-size: .72rem; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .6rem; }
.toc ol { margin: 0; padding-left: 1.3rem; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.sticky { position: sticky; top: 1.2rem; }

.q-list { list-style: none; padding: 0; counter-reset: q; }
.q-list li { counter-increment: q; position: relative; padding: .8rem 1rem .8rem 3.1rem; background: var(--surface); border: 1px solid var(--rule); margin-bottom: .6rem; }
.q-list li::before { content: "Q" counter(q); position: absolute; left: .9rem; top: .8rem; font-family: var(--mono); font-size: .78rem; color: var(--teal); }
.q-list li b { display: block; }

/* ---------- Footer ---------- */

.site-footer { background: var(--slate-deep); color: #b6c1c8; padding: 2.6rem 0 1.3rem; margin-top: 3.2rem; font-size: .86rem; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 2rem; }
.site-footer h2 { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #fff; margin: 0 0 .7rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: .38rem; }
.site-footer a { color: #b6c1c8; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-brand { display: flex; gap: .7rem; align-items: center; margin-bottom: .7rem; }
.footer-brand .brand-title { color: #fff; }
.footer-legal { border-top: 1px solid #2b343c; margin-top: 2rem; padding-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; color: #8b979f; font-size: .78rem; }
.footer-legal p { margin: 0; max-width: 72ch; }

/* ---------- Misc ---------- */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.source-line { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }
.updated { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }
.faq dt { font-family: var(--head); font-weight: 700; font-size: 1.02rem; margin-top: 1.3rem; }
.faq dd { margin: .3rem 0 0; color: var(--ink-2); }
.empty-state { border: 1px dashed var(--rule-2); background: var(--surface); padding: 1.4rem; text-align: center; color: var(--ink-3); font-family: var(--mono); font-size: .84rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.4rem; }
.compare-note { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }

@media (max-width: 960px) {
  .hero .wrap, .profile-cols, .article-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky { position: static; }
}

@media (max-width: 660px) {
  .filter-toggle { display: inline-flex; }
  .filters { display: none; }
  .filters.is-open { display: block; }
  .spec { grid-template-columns: minmax(0, 1fr); }
  .spec dt { padding-bottom: 0; border-bottom: 0; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .chapter-row { grid-template-columns: 42px minmax(0, 1fr); }
  .chapter-row .go { display: none; }
}
