/* ==========================================================================
   GoldenRobber Docs — shared stylesheet
   Identity kept from the original README: bullion gold on a warm stone ground.
   Theme: body.theme-light / body.theme-dark (set by boot.js, toggle in top bar)
   Language: body.lang-vi / body.lang-en + .vi-only / .en-only blocks
   ========================================================================== */

:root, body.theme-light {
  --bg: #e8e4dc; --bg-elevated: #ddd8ce; --card: #f2efe8; --card-border: #c9c2b5;
  --gold: #8b7319; --gold-light: #a68b2e; --gold-dim: #6b5a14;
  --text: #1f1d1a; --muted: #5c564e;
  --accent-soft: rgba(139,115,25,0.12);
  --table-border: #d1cbbf; --table-hover: #e3dfd6;
  --code-bg: #e0dcd4; --tag-bg: #e0dcd4; --tag-color: #4a453d;
  --warn-bg: #f5ecd8; --warn-border: #c9a227; --warn-text: #4a3d1a;
  --info-bg: #dce8f2; --info-border: #4a7ba7; --info-text: #1a365d;
  --tip-bg: #d8e8d8; --tip-border: #5a8a5a; --tip-text: #1e4620;
  --danger-bg: #f0e0e2; --danger-border: #b54a58; --danger-text: #6b2030;
  --ok: #2e7d32; --ok-soft: rgba(46,125,50,0.12);
  --bad: #b3261e; --bad-soft: rgba(179,38,30,0.10);
  --shadow-sm: 0 1px 4px rgba(31,29,26,0.1); --shadow-md: 0 6px 22px rgba(31,29,26,0.14);
  --side-bg: #e1dcd2; --top-bg: rgba(232,228,220,0.94); --link: #6b5a14;
  --font-body: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Roboto Condensed', 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', Consolas, 'Cascadia Mono', ui-monospace, monospace;
  --top-h: 58px;
}
body.theme-dark {
  --bg: #0f0e0c; --bg-elevated: #1a1814; --card: #1c1a16; --card-border: rgba(201,162,39,0.16);
  --gold: #d4af37; --gold-light: #e8d48a; --gold-dim: #b8952c;
  --text: #ebe8e3; --muted: #9d978e;
  --accent-soft: rgba(212,175,55,0.11);
  --table-border: rgba(255,255,255,0.08); --table-hover: rgba(255,255,255,0.03);
  --code-bg: #25221d; --tag-bg: #25221d; --tag-color: #a59f95;
  --warn-bg: #2a2418; --warn-border: #d4af37; --warn-text: #e8d48a;
  --info-bg: #0f1820; --info-border: #5b9bd5; --info-text: #9ccbf5;
  --tip-bg: #0f1a0f; --tip-border: #6b9b6b; --tip-text: #a5d6a7;
  --danger-bg: #261014; --danger-border: #c75c6a; --danger-text: #f0a8b0;
  --ok: #81c784; --ok-soft: rgba(129,199,132,0.14);
  --bad: #ef9a9a; --bad-soft: rgba(239,154,154,0.14);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3); --shadow-md: 0 8px 26px rgba(0,0,0,0.45);
  --side-bg: #131210; --top-bg: rgba(15,14,12,0.92); --link: #e8d48a;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 16px; font-weight: 400; line-height: 1.72;
}
.lang-vi .en-only { display: none !important; }
.lang-en .vi-only { display: none !important; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--card-border); margin: 2rem 0; }
[hidden] { display: none !important; }

/* ---- shell ---- */
.gr-shell {
  display: grid; min-height: 100vh;
  --side-w: 276px; --toc-w: 232px;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top top" "side main toc";
}
.gr-top {
  grid-area: top; position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding-inline: 18px; height: var(--top-h);
  background: var(--top-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.gr-brand {
  display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 0.02em; white-space: nowrap;
}
.gr-brand .gold { color: var(--gold-dim); }
body.theme-dark .gr-brand .gold { color: var(--gold); }
.gr-brand small { font-family: var(--font-body); font-weight: 500; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
/* Badge phiên bản EA production, ngay cạnh logo (nav.js: GR_VERSION). */
.gr-ver {
  display: inline-flex; align-items: center; flex: none; white-space: nowrap; text-decoration: none;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--card-border); background: var(--accent-soft); color: var(--gold-dim);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
}
.gr-ver:hover { border-color: var(--gold-light); color: var(--gold); }
body.theme-dark .gr-ver { color: var(--gold-light); }
@media (max-width: 760px) { .gr-ver { display: none; } }
.gr-menu-btn, .gr-toc-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  border: 1px solid var(--card-border); border-radius: 8px; background: var(--card); color: var(--text);
}
.gr-menu-btn:hover, .gr-toc-btn:hover { border-color: var(--gold-light); }
.gr-menu-btn[aria-pressed="true"], .gr-toc-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--gold-dim); }
body.theme-dark .gr-menu-btn[aria-pressed="true"], body.theme-dark .gr-toc-btn[aria-pressed="true"] { color: var(--gold-light); }
.gr-top-spacer { flex: 1; }

.gr-search { position: relative; width: min(420px, 38vw); }
.gr-search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px; border-radius: 8px;
  border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  font: inherit; font-size: 14px;
}
.gr-search input::placeholder { color: var(--muted); }
.gr-search svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.gr-search-results {
  position: absolute; top: 42px; left: 0; width: min(560px, 92vw); max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px;
}
.gr-search-results a {
  display: block; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--text);
}
.gr-search-results a[aria-selected="true"], .gr-search-results a:hover { background: var(--accent-soft); }
.gr-search-results .r-page { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-dim); font-weight: 600; }
body.theme-dark .gr-search-results .r-page { color: var(--gold); }
.gr-search-results .r-head { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.gr-search-results .r-snip { display: block; font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.gr-search-results mark { background: rgba(201,162,39,0.35); color: inherit; border-radius: 2px; padding: 0 1px; }
.gr-search-results .r-empty { padding: 10px; color: var(--muted); font-size: 14px; }

.gr-switch { display: inline-flex; border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; background: var(--card); }
.gr-switch button {
  font: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0.04em;
  padding: 6px 11px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.gr-switch button + button { border-left: 1px solid var(--card-border); }
.gr-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--gold-dim); font-weight: 600; }
body.theme-dark .gr-switch button[aria-pressed="true"] { color: var(--gold-light); }

.gr-side {
  grid-area: side; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
  background: var(--side-bg); border-right: 1px solid var(--card-border);
  padding: 18px 12px 40px;
}
.gr-side .g-title {
  font-family: var(--font-display); font-weight: 600; font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin: 18px 10px 6px;
}
.gr-side .g-title:first-child { margin-top: 2px; }
.gr-side ul { list-style: none; margin: 0; padding: 0; }
.gr-side a {
  display: block; padding: 6px 10px; border-radius: 7px; text-decoration: none;
  color: var(--text); font-size: 14.5px; line-height: 1.4;
}
.gr-side a:hover { background: var(--accent-soft); color: var(--text); }
.gr-side a[aria-current="page"] { background: var(--accent-soft); color: var(--gold-dim); font-weight: 600; box-shadow: inset 2px 0 0 var(--gold); }
body.theme-dark .gr-side a[aria-current="page"] { color: var(--gold-light); }
.gr-side .badge { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--gold-dim); margin-left: 6px; }
body.theme-dark .gr-side .badge { color: var(--gold); }
/* Starred group (nav.js `star: true`): the core pages, highlighted in gold. */
.gr-side .g-title.g-star { color: var(--gold-dim); }
body.theme-dark .gr-side .g-title.g-star { color: var(--gold); }
.gr-side .g-star .star { margin-right: 5px; letter-spacing: 0; }

/* ---- price-ladder figures (ea/init-add-logic): colours come from theme tokens ---- */
.fig-ladder { display: block; width: 100%; height: auto; background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; }
.fig-ladder .ax { stroke: var(--card-border); stroke-width: 1; fill: none; }
.fig-ladder .lvl { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; fill: none; }
.fig-ladder .price { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.fig-ladder .sell { fill: var(--bad); }
.fig-ladder .buy { fill: var(--info-border); }
.fig-ladder .newinit { fill: var(--card); stroke: var(--gold); stroke-width: 2.4; }
.fig-ladder .band { fill: var(--accent-soft); stroke: var(--gold-light); stroke-width: 1; stroke-dasharray: 3 3; }
.fig-ladder text { font-family: var(--font-body); font-size: 11px; fill: var(--text); }
.fig-ladder .t-muted { fill: var(--muted); font-size: 10px; }
.fig-ladder .t-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; fill: var(--gold-dim); }
body.theme-dark .fig-ladder .t-title { fill: var(--gold-light); }
.fig-ladder .t-sell { fill: var(--bad); font-weight: 700; }
.fig-ladder .t-buy { fill: var(--info-border); font-weight: 700; }

/* ---- network topology figure (services/architecture#infrastructure) ----
   Wide drawing: scrolls sideways inside its own box on phones instead of shrinking the text. */
.fig-net-wrap { overflow-x: auto; margin: 1.2rem 0 0.35rem; border-radius: 12px; }
.fig-net { display: block; width: 100%; min-width: 760px; height: auto; background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; }
.fig-net .srv { fill: var(--bg); stroke: var(--card-border); stroke-width: 1.2; }
.fig-net .node { fill: var(--card); stroke: var(--muted); stroke-width: 1; }
.fig-net .node-key { fill: var(--accent-soft); stroke: var(--gold); stroke-width: 1.6; }
.fig-net .ip { fill: var(--tag-bg); stroke: var(--card-border); stroke-width: 1; }
.fig-net .lan { fill: var(--info-bg); stroke: var(--info-border); stroke-width: 1; stroke-dasharray: 4 3; }
.fig-net .vps { fill: var(--card); stroke: var(--card-border); stroke-width: 1; }
.fig-net .vps-on { fill: var(--card); stroke: var(--info-border); stroke-width: 1.8; }
.fig-net .wire { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.fig-net .tun { fill: none; stroke: var(--gold); stroke-width: 3.4; stroke-linejoin: round; stroke-linecap: round; }
.fig-net .vnc { fill: none; stroke: var(--info-border); stroke-width: 1.8; stroke-dasharray: 6 4; }
.fig-net .ah-tun { fill: var(--gold); }
.fig-net .ah-vnc { fill: var(--info-border); }
.fig-net text { font-family: var(--font-body); font-size: 12px; fill: var(--text); }
.fig-net .t-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; fill: var(--gold-dim); }
.fig-net .t-strong { font-weight: 700; }
.fig-net .t-sub { font-size: 11px; fill: var(--muted); }
.fig-net .t-mono { font-family: var(--font-mono); font-size: 10.5px; fill: var(--muted); }
.fig-net .t-vnc { font-size: 10.5px; font-weight: 600; fill: var(--info-border); }
body.theme-dark .fig-net .t-title { fill: var(--gold-light); }

.gr-main { grid-area: main; min-width: 0; padding-inline: 40px; padding-block: 34px 80px; }
.gr-doc { max-width: 900px; margin: 0 auto; }

.gr-toc {
  grid-area: toc; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: 30px 18px 40px 6px; font-size: 13.5px;
}
.gr-toc .t-title { font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.gr-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--card-border); }
.gr-toc a { display: block; padding: 3px 10px; color: var(--muted); text-decoration: none; line-height: 1.4; margin-left: -1px; border-left: 2px solid transparent; }
.gr-toc a.lvl3 { padding-left: 22px; font-size: 13px; }
.gr-toc a:hover { color: var(--text); }
.gr-toc a.active { color: var(--gold-dim); border-left-color: var(--gold); font-weight: 600; }
body.theme-dark .gr-toc a.active { color: var(--gold-light); }

/* ---- thu gọn cột trái / phải (desktop) để mở rộng vùng nội dung giữa ---- */
body.side-collapsed .gr-shell { --side-w: 0px; }
body.toc-collapsed .gr-shell { --toc-w: 0px; }
@media (min-width: 921px) {
  body.side-collapsed .gr-side { display: none; }
  body.side-collapsed .gr-doc { max-width: 1120px; }
}
@media (min-width: 1281px) {
  body.toc-collapsed .gr-toc { display: none; }
  body.toc-collapsed .gr-doc { max-width: 1040px; }
  body.side-collapsed.toc-collapsed .gr-doc { max-width: 1280px; }
}

@media (max-width: 1280px) {
  .gr-shell { --side-w: 264px; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-areas: "top top" "side main"; }
  .gr-toc-btn { display: none; }
  .gr-toc { display: none; }
}
@media (max-width: 920px) {
  .gr-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .gr-menu-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    border: 1px solid var(--card-border); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer;
  }
  .gr-side {
    position: fixed; z-index: 50; top: var(--top-h); left: 0; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow-md);
  }
  body.nav-open .gr-side { transform: none; }
  .gr-main { padding-inline: 18px; padding-block: 24px 64px; }
  .gr-search { width: auto; flex: 1; }
  .gr-brand small { display: none; }
}
@media (max-width: 560px) {
  .gr-top { gap: 8px; padding-inline: 12px; }
  .gr-brand { font-size: 17px; }
  .gr-switch button { padding: 6px 8px; }
  .gr-search-results { left: auto; right: -80px; }
}

/* ---- document typography ---- */
.gr-crumb { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-dim); font-weight: 600; }
body.theme-dark .gr-crumb { color: var(--gold); }
.gr-doc h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 4.4vw, 42px); line-height: 1.12;
  letter-spacing: 0.005em; margin: 0 0 10px; text-wrap: balance;
}
.gr-doc h1 .gold { color: var(--gold-dim); }
body.theme-dark .gr-doc h1 .gold { color: var(--gold); }
.gr-lede { font-size: 17.5px; color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
.gr-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 28px; padding: 0 0 16px; border-bottom: 1px solid var(--card-border); font-size: 13.5px; color: var(--muted); list-style: none; }
.gr-meta li { margin: 0; }
.gr-meta b { font-weight: 600; color: var(--text); }
.gr-doc h2 {
  font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.25;
  color: var(--gold-dim); margin: 2.8rem 0 1rem; padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--accent-soft); letter-spacing: 0.01em; text-wrap: balance;
}
body.theme-dark .gr-doc h2 { color: var(--gold-light); }
.gr-doc h3 { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--text); margin: 2rem 0 0.7rem; text-wrap: balance; }
.gr-doc h4 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 1.4rem 0 0.5rem; text-transform: uppercase; letter-spacing: 0.08em; }
.gr-doc p { margin: 0 0 0.85rem; }
.gr-doc ul, .gr-doc ol { margin: 0 0 0.9rem; padding-left: 1.5rem; }
.gr-doc li { margin-bottom: 0.3rem; }
.gr-doc li::marker { color: var(--gold-dim); }
body.theme-dark .gr-doc li::marker { color: var(--gold); }
.gr-doc strong { font-weight: 600; }
.gr-doc code {
  font-family: var(--font-mono); font-size: 0.84em; background: var(--code-bg);
  padding: 0.1em 0.38em; border-radius: 4px; color: var(--gold-dim);
}
body.theme-dark .gr-doc code { color: var(--gold-light); }
.gr-doc pre {
  position: relative; background: var(--code-bg); border: 1px solid var(--table-border); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; margin: 0.6rem 0 1.2rem;
}
.gr-doc pre code { background: none; padding: 0; color: var(--text); font-size: inherit; white-space: pre; }
.gr-copy {
  position: absolute; top: 8px; right: 8px; font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--card-border); background: var(--card); color: var(--muted); cursor: pointer; opacity: 0.85;
}
.gr-copy:hover { color: var(--text); opacity: 1; }
.gr-doc blockquote { margin: 1rem 0; padding: 0.4rem 1rem; border-left: 3px solid var(--gold); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--text); }
.gr-doc kbd { font-family: var(--font-mono); font-size: 0.8em; padding: 0.05em 0.4em; border: 1px solid var(--card-border); border-bottom-width: 2px; border-radius: 4px; background: var(--card); }

/* ---- callouts (names kept from original README) ---- */
.box { border-radius: 10px; padding: 1.1rem 1.35rem; margin: 1.2rem 0; border-left: 4px solid; font-size: 0.94rem; }
.box > :last-child { margin-bottom: 0; }
.box-warn  { background: var(--warn-bg);   border-color: var(--warn-border);   color: var(--warn-text); }
.box-info  { background: var(--info-bg);   border-color: var(--info-border);   color: var(--info-text); }
.box-tip   { background: var(--tip-bg);    border-color: var(--tip-border);    color: var(--tip-text); }
.box-danger{ background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.box > strong:first-child { display: block; margin-bottom: 0.35rem; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.06em; }
.box code { color: inherit; }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; margin: 0.8rem 0 1.6rem; border-radius: 10px; border: 1px solid var(--table-border); background: var(--card); }
.gr-doc table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.gr-doc thead th {
  background: var(--bg-elevated); color: var(--gold-dim); font-weight: 600; text-align: left;
  padding: 0.65rem 0.9rem; white-space: nowrap; border-bottom: 2px solid var(--table-border); letter-spacing: 0.02em;
}
body.theme-dark .gr-doc thead th { color: var(--gold-light); }
.gr-doc tbody td { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--table-border); vertical-align: top; }
.gr-doc tbody tr:last-child td { border-bottom: none; }
.gr-doc tbody tr:hover td { background: var(--table-hover); }
.gr-doc td code { white-space: nowrap; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-default { font-weight: 600; color: var(--gold-dim); }
body.theme-dark .td-default { color: var(--gold-light); }
body.theme-light td[style*="color:#ffffff"], body.theme-light td[style*="color: #ffffff"] { color: var(--text) !important; }
.tbl-row-layout tbody td, .tbl-row-layout tbody td code { color: var(--text) !important; }
.tbl-autobal-status tbody td:first-child, .tbl-autobal-status tbody td:first-child code,
.tbl-autobal-status tbody td:nth-child(2), .tbl-autobal-status tbody td:nth-child(3) { color: var(--text) !important; }

/* ---- tags / pills ---- */
.tag { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.12em 0.55em; border-radius: 10px; margin-right: 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: 0.1em; }
.tag-pos  { background: rgba(56,142,60,0.15); color: #2e7d32; }
.tag-neg  { background: rgba(198,40,40,0.12); color: #c62828; }
.tag-neutral { background: var(--tag-bg); color: var(--tag-color); }
.tag-gold { background: var(--accent-soft); color: var(--gold-dim); }
body.theme-dark .tag-pos  { background: rgba(102,187,106,0.2); color: #a5d6a7; }
body.theme-dark .tag-neg  { background: rgba(239,154,154,0.2); color: #ffcdd2; }
body.theme-dark .tag-gold { color: var(--gold-light); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }
.pill-warn { color: var(--warn-text); background: var(--warn-bg); }
.pill-gold { color: var(--gold-dim); background: var(--accent-soft); }
.pill-muted { color: var(--tag-color); background: var(--tag-bg); }
body.theme-dark .pill-gold { color: var(--gold-light); }

/* ---- cards / grids ---- */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 1.3rem 1.5rem; margin: 1.1rem 0; }
.card > :last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0.6rem 0 1.2rem; }
.kv dt { font-weight: 600; color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: minmax(0, 1fr); } .kv dd { margin-bottom: 8px; } }
.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.4rem; margin-bottom: 0.8rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0.1rem; width: 1.65rem; height: 1.65rem; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
  background: var(--accent-soft); color: var(--gold-dim); border: 1px solid var(--gold-light);
}
body.theme-dark .steps > li::before { color: var(--gold-light); }

/* ---- doc map (home) ---- */
.docmap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
@media (max-width: 760px) { .docmap { grid-template-columns: minmax(0, 1fr); } }
.docmap section { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 1rem 1.2rem 1.1rem; }
.docmap h3 { margin: 0 0 0.4rem !important; font-size: 18px; }
.docmap ul { list-style: none; padding: 0 !important; margin: 0 !important; }
.docmap li { margin: 0; border-top: 1px solid var(--table-border); }
.docmap li:first-child { border-top: 0; }
.docmap a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; text-decoration: none; color: var(--text); }
.docmap a:hover { color: var(--gold-dim); }
.docmap a span:last-child { color: var(--muted); font-size: 13px; text-align: right; }

/* ---- prev / next ---- */
.gr-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 3.5rem; padding-top: 1.2rem; border-top: 1px solid var(--card-border); }
.gr-pager a { display: block; padding: 10px 14px; border: 1px solid var(--card-border); border-radius: 10px; text-decoration: none; color: var(--text); background: var(--card); }
.gr-pager a:hover { border-color: var(--gold-light); }
.gr-pager small { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.gr-pager .next { text-align: right; grid-column: 2; }

/* ---- diagrams ---- */
.mermaid-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 16px; margin: 0.8rem 0 0.4rem; }
.gr-doc pre.mermaid { background: transparent; border: 0; padding: 0; margin: 0; text-align: center; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); white-space: pre; }
/* Once rendered, labels must use the same metrics Mermaid measured with (body font, normal flow). */
.gr-doc pre.mermaid[data-rendered] { font-family: var(--font-body); font-size: 16px; line-height: 1.5; white-space: normal; color: var(--text); overflow: visible; }
.gr-doc pre.mermaid[data-rendered="error"] { font-family: var(--font-mono); font-size: 12.5px; white-space: pre; color: var(--muted); }
.gr-doc pre.mermaid svg { max-width: 100%; height: auto; }
.gr-doc pre.mermaid p, .gr-doc pre.mermaid span, .gr-doc pre.mermaid div { margin: 0; line-height: 1.5; }
.gr-doc .gr-meta { padding-left: 0; }
.diagram-caption, figcaption { font-size: 0.83rem; color: var(--muted); margin: 0.35rem 0 1.4rem; }
.diagram-wrap { text-align: center; margin: 1.5rem 0; }
.diagram-wrap img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figure { margin: 0; }

/* ---- MT5 info panel illustration (always a black chart panel) ---- */
.panel-demo {
  font-family: var(--font-mono); font-size: 0.8rem; background: #0b0b0b; color: #e0e0e0; border-radius: 6px;
  padding: 0.9rem 1.1rem; line-height: 1.8; display: inline-block; border: 1px solid #333; max-width: 100%; overflow-x: auto; white-space: pre;
}
.panel-buy { color: #4fc3f7; } .panel-sell { color: #ff7043; } .panel-net { color: #ffd54f; } .panel-dca { color: #bdbdbd; }
.panel-profit { color: #69f0ae; } .panel-eq { color: #69f0ae; } .panel-bal { color: #ffffff; } .panel-trend { color: #4fc3f7; }
.panel-autobal-on { color: #ffffff; } .panel-autobal-act { color: #9acd32; } .panel-autobal-wait { color: #bdbdbd; }
.panel-autobal-loss { color: #ffa726; } .panel-autobal-off { color: #757575; } .panel-emg { color: #ffa726; } .panel-sw { color: #ff7043; }
.panel-lime { color: #00ff00; } .panel-yellow { color: #ffff00; } .panel-silver { color: #c0c0c0; } .panel-red { color: #ff4500; }

/* ---- legacy helpers used by the inputs page ---- */
.section-anchor { display: block; height: 0; }
.toc { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 1.2rem 1.6rem; margin: 0 0 2.4rem; }
.toc h4 { margin: 0 0 0.8rem; font-size: 0.82rem; }
.toc ol { margin: 0; padding-left: 1.5rem; columns: 2; column-gap: 2rem; }
@media (max-width: 760px) { .toc ol { columns: 1; } }
.toc li { font-size: 0.9rem; margin-bottom: 0.3rem; break-inside: avoid; }
.toc a { color: var(--gold-dim); text-decoration: none; }
.toc a:hover { color: var(--gold-light); text-decoration: underline; }
body.theme-dark .toc a { color: var(--gold-light); }
.comment-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.comment-tag { font-family: var(--font-mono); font-size: 0.8rem; background: var(--code-bg); border: 1px solid var(--table-border); border-radius: 4px; padding: 0.2em 0.6em; color: var(--gold-dim); }
body.theme-dark .comment-tag { color: var(--gold-light); }
a.btn-download {
  font-weight: 500; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--gold-dim); color: #fff; text-decoration: none; padding: 0.45rem 1rem; border-radius: 8px; white-space: nowrap;
}
a.btn-download:hover { background: var(--gold); color: #fff; }
body.theme-dark a.btn-download { background: var(--gold); color: #1a1814; }

/* ---- small helpers requested by page writers ---- */
.gr-doc th.hl, .gr-doc td.hl { background: var(--accent-soft); }
.gr-doc tr.group td { background: var(--bg-elevated); color: var(--gold-dim); font-weight: 600; letter-spacing: 0.02em; }
body.theme-dark .gr-doc tr.group td { color: var(--gold-light); }
.footnote { font-size: 0.85rem; color: var(--muted); margin: 0.3rem 0 1rem; }
ul.checklist { list-style: none; padding-left: 0.1rem !important; }
ul.checklist > li { position: relative; padding-left: 1.7rem; }
ul.checklist > li::before {
  content: ''; position: absolute; left: 0; top: 0.35em; width: 1rem; height: 1rem;
  border: 1.5px solid var(--gold-dim); border-radius: 3px; background: var(--card);
}
figure .panel-demo { display: block; width: fit-content; margin: 0.5rem 0 0.4rem; }
.card .tbl-wrap { border: 0; border-radius: 0; margin: 0.4rem 0 0; background: transparent; }
@media (max-width: 760px) { .gr-doc td code { white-space: normal; overflow-wrap: anywhere; } }

/* ---- pip calculator (ea/inputs.html) ---- */
.pip-calc-input {
  width: 100%; padding: 0.5rem 0.6rem; border-radius: 6px; border: 1px solid var(--card-border);
  background: var(--bg-elevated); color: var(--text); font-variant-numeric: tabular-nums;
  font-family: var(--font-mono); font-size: 1rem;
}
.pip-calc-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px var(--accent-soft); }
.btn-preset {
  padding: 0.35rem 0.6rem; font-size: 0.8rem; border-radius: 6px; border: 1px solid var(--card-border);
  background: var(--code-bg); color: var(--text); cursor: pointer; font-family: var(--font-mono); transition: background 0.15s;
}
.btn-preset:hover { background: var(--table-hover); border-color: var(--gold-dim); }

/* ---- print ---- */
@media print {
  .gr-top, .gr-side, .gr-toc, .gr-pager, .gr-copy { display: none !important; }
  .gr-shell { display: block; }
  .gr-main { padding: 0; }
  body { background: #fff; color: #000; }
}
