:root {
  /* Studio Legale Oltre brand palette */
  --blue: #1a3a5c;          /* firm navy (primary accent) */
  --blue-dark: #0f2840;     /* firm navy, darker */
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d9d0c3;          /* warm border (cream-400) */
  --bg: #f7f4ee;            /* warm reading surface */
  --hl: #fff3c4;
  --header-bg: #e8e0d5;     /* cream-300 — matches the site header */
  --header-line: #d9d0c3;   /* cream-400 */
  --tint: #ece5d9;          /* warm hover/active tint (replaces light blue) */
  --topbar-h: 46px;         /* sticky-offset reference for toc / banners */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Charter", "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.65;
}

/* ---------- barra superiore ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 6px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-line);
  font-family: var(--sans);
  font-size: 13px;
}
/* logo «Home» → sito Studio Legale Oltre */
.site-home {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding-right: 14px;
  border-right: 1px solid var(--header-line);
}
.site-home img { height: 30px; width: auto; display: block; }
.topbar .home { color: var(--blue); text-decoration: none; font-weight: 600; white-space: nowrap; }
.actnav { display: flex; flex-wrap: wrap; gap: 2px; }
.actnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}
.actnav .nav-kw { font-weight: 600; }
@media (max-width: 1150px) {
  .actnav .nav-kw { display: none; }
}
.actnav a:hover { background: var(--tint); color: var(--blue); }
.actnav a.current { background: var(--blue); color: #fff; }

/* ---------- layout ---------- */
.layout { display: flex; align-items: flex-start; }
.toc {
  position: sticky;
  top: var(--topbar-h);
  width: 320px;
  flex: 0 0 320px;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 14px 10px 40px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.4;
}
.toc-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.toc-title span { font-weight: 400; color: var(--muted); }
.toc a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 3px 6px;
  border-radius: 5px;
}
.toc a:hover { background: var(--tint); }
.toc a b { color: var(--blue-dark); }
.toc-part { margin-top: 10px; font-size: 12.5px; }
.toc-chap { margin-top: 6px; }
.toc-sect { margin-top: 2px; padding-left: 14px !important; color: var(--muted) !important; }
.toc-art { padding-left: 18px !important; color: #3a3a3c; }
.toc-art .toc-n {
  display: inline-block;
  min-width: 22px;
  color: var(--blue);
  font-weight: 600;
}
.toc-art.active { background: var(--tint); }
.toc-h { margin-top: 10px; font-weight: 600; }

main.doc {
  flex: 1;
  min-width: 0;
  max-width: 860px;
  padding: 28px 48px 80px;
  margin: 0 auto;
}

/* ---------- contenuto EUR-Lex ---------- */
.doc p { margin: 0.45em 0; }
.doc .oj-doc-ti { font-size: 21px; font-weight: 700; line-height: 1.35; margin: 0.4em 0; }
.doc .oj-ti-art {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  margin-top: 2.2em;
  color: var(--blue-dark);
}
.doc .oj-sti-art { font-style: italic; font-weight: 600; margin-bottom: 0.8em; }
.doc .oj-ti-section-1 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  margin-top: 2.6em;
  letter-spacing: 0.04em;
}
.doc .oj-ti-section-2 { text-align: center; font-style: italic; margin-bottom: 1.4em; }
.doc .oj-normal { text-align: justify; }
.doc table { border-collapse: collapse; margin: 0.4em 0; width: 100%; }
.doc td { vertical-align: top; padding: 2px 6px 2px 0; }
.doc col { width: auto !important; }
.doc .oj-note { font-size: 13px; color: var(--muted); }
.doc .oj-tbl-txt, .doc .oj-tbl-hdr { font-size: 14px; }
.doc hr.oj-separator { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.doc .eli-title { margin-bottom: 0.2em; }
.disclaimer {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- atti esterni (formato consolidato CELLAR) ---------- */
.ext-banner {
  position: sticky;
  top: var(--topbar-h);
  z-index: 35;
  background: #fdf6e3;
  border-bottom: 1px solid #e8d9a0;
  font-family: var(--sans);
  font-size: 12.5px;
  color: #7a6420;
  padding: 6px 16px;
}
.ext-banner a { color: var(--blue); text-decoration: none; font-weight: 600; }
.doc .title-doc-first { font-size: 20px; font-weight: 700; line-height: 1.35; margin: 0.3em 0; }
.doc .title-doc-last { font-size: 17px; font-weight: 600; font-style: italic; margin: 0.3em 0; }
.doc .title-article-norm {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  margin-top: 2.2em;
  color: var(--blue-dark);
}
.doc .stitle-article-norm { font-style: italic; font-weight: 600; margin-bottom: 0.8em; }
.doc .norm, .doc .grid-container { text-align: justify; }
.doc .reference { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.doc .disclaimer-cons, .doc p.disclaimer { font-size: 12px; color: var(--muted); }
.doc .arrow, .doc .boldface { font-family: var(--sans); font-size: 11px; color: #b08c2e; }
.doc .title-division-1, .doc .title-division-2 {
  font-family: var(--sans);
  font-weight: 700;
  text-align: center;
  margin-top: 2em;
}
.doc .modref { font-size: 11px; color: #b08c2e; }
.tip-body .title-article-norm, .panel-body .title-article-norm { display: none; }
.panel-foot a { margin-right: 14px; }

/* ---------- link incrociati ---------- */
a.xref {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px dotted rgba(26, 58, 92, 0.55);
  cursor: pointer;
}
a.xref:hover { background: var(--tint); border-bottom-style: solid; }
a.xref.ext { border-bottom-style: dashed; }
a.xref.ext::after {
  content: "\2197";
  font-size: 0.72em;
  vertical-align: super;
  margin-left: 1px;
  color: var(--muted);
}

/* evidenziazione del bersaglio */
.flash { animation: flashbg 2.4s ease-out; }
@keyframes flashbg {
  0% { background: var(--hl); box-shadow: 0 0 0 6px var(--hl); }
  70% { background: var(--hl); box-shadow: 0 0 0 6px var(--hl); }
  100% { background: transparent; box-shadow: none; }
}

/* ---------- tooltip ---------- */
.tip {
  position: absolute;
  z-index: 60;
  width: min(560px, 88vw);
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
}
.tip-head { font-family: var(--sans); margin-bottom: 6px; }
.tip-head .t-label { font-weight: 700; font-size: 13.5px; }
.tip-head .t-heading { font-style: italic; font-size: 13px; }
.tip-head .t-ver {
  font-family: var(--sans);
  font-size: 11px;
  color: #b08c2e;
  margin-left: 6px;
}
.tip-head .t-act {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--tint);
  border-radius: 4px;
  padding: 1px 7px;
  margin-bottom: 4px;
}
.tip-body p { margin: 0.35em 0; text-align: left; }
.tip-body table { border-collapse: collapse; }
.tip-body td { vertical-align: top; padding: 1px 6px 1px 0; }
.tip-foot { margin-top: 8px; font-family: var(--sans); font-size: 12px; }
.tip-foot a { color: var(--blue); text-decoration: none; cursor: pointer; }
.tip .hl-par { background: var(--hl); display: block; border-radius: 4px; padding: 2px 4px; }
.fn-mark { font-size: 0.72em; vertical-align: super; color: var(--muted); }

/* ---------- pannello laterale ---------- */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  width: min(560px, 94vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
}
.panel-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
}
.crumb { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb b { color: var(--ink); }
.pbtn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.pbtn:hover { background: #f2f2f4; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 20px 20px; font-size: 14.5px; }
.panel-body p { margin: 0.4em 0; text-align: left; }
.panel-body table { border-collapse: collapse; }
.panel-body td { vertical-align: top; padding: 2px 6px 2px 0; }
.panel-body .hl-par { background: var(--hl); display: block; border-radius: 4px; padding: 2px 6px; }
.panel-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 13px;
}
.panel-foot a { color: var(--blue); text-decoration: none; font-weight: 600; }

/* ---------- chip di ritorno ---------- */
#return-chip {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  border: none;
  background: var(--blue);
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
#return-chip:hover { background: var(--blue-dark); }

/* ---------- indice ---------- */
body.index { background: var(--bg); }
.idx { max-width: 980px; margin: 0 auto; padding: 48px 24px 80px; }
.idx h1 { font-size: 30px; margin-bottom: 6px; }
.idx h1, .idx-h2 { font-family: "Playfair Display", var(--serif); letter-spacing: -0.01em; }
.idx-sub { color: var(--muted); font-size: 16px; max-width: 720px; margin-bottom: 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
}
.card:hover { border-color: var(--blue); box-shadow: 0 4px 18px rgba(26, 58, 92, 0.16); }
.card-num { font-family: var(--sans); font-size: 12px; font-weight: 700; color: var(--blue); }
.card-name { font-size: 18px; font-weight: 700; margin: 2px 0 6px; }
.card-sub { font-size: 13px; color: var(--muted); line-height: 1.45; }
.card-meta { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.ext-list { margin-top: 28px; font-family: var(--sans); }
.ext-list summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--blue-dark); }
.ext-list ul { list-style: none; padding: 10px 0 0; margin: 0; }
.ext-list li { font-size: 13px; padding: 3px 0; }
.ext-list li a { color: var(--blue); text-decoration: none; font-weight: 600; }
.ext-list li span { color: var(--muted); }

/* ---------- mobile ---------- */
#toc-toggle { display: none; }
@media (max-width: 1000px) {
  .toc {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s;
    z-index: 50;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
  }
  .toc.open { transform: none; }
  #toc-toggle {
    display: inline-block;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 3px 10px;
    font-family: var(--sans);
    font-size: 12px;
    cursor: pointer;
  }
  main.doc { padding: 20px 18px 80px; }
}

@media print {
  .topbar, .toc, .panel, .tip, #return-chip { display: none !important; }
  main.doc { max-width: none; padding: 0; }
  a.xref { color: inherit; border-bottom: none; }
}

/* --- deploy: breadcrumb + «torna al Patto» nel pannello --- */
.home-here{ font-family:var(--sans); font-size:13px; font-weight:600; color:var(--blue-dark); text-decoration:none; }
.home-here::before{ content:"\203A"; color:#8a8f98; font-weight:400; margin:0 6px; }
.panel-foot{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.panel-foot a{ margin-right:0; }
.panel-home{ font-size:13px; white-space:nowrap; }
