/* Populate, Update and Extract sheets. */
.docs { display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.4fr); gap: 22px; align-items: start; }
.docs__form { display: grid; gap: 14px; padding: 20px; align-content: start; position: sticky; top: 0; max-height: calc(100vh - 180px); overflow: auto; }
.docs__form h3 { font-size: 1.05rem; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--lime); margin-top: 4px; }
.docs__lock { margin: 0; padding: 0; border: 0; display: grid; gap: 14px; min-width: 0; }
.docs__lock:disabled { opacity: 0.45; }
.docs__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.docs__msg { min-height: 20px; font-size: 13px; color: var(--muted); }
.docs__msg[data-kind="bad"] { color: var(--bad); }
.docs__msg[data-kind="ok"] { color: var(--ok); }
.docs__meta { margin-top: 10px; }
.docs__preview { display: grid; gap: 10px; min-width: 0; }
.docs__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.docs__toolbar .mono-label { flex: 1; }

.fields { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--lime); width: 16px; height: 16px; }

.opts { display: grid; gap: 10px; }
.opt { margin: 0; padding: 0; border: 0; min-width: 0; }
.opt legend { padding: 0 0 4px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: grid; gap: 1px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: #0a0f15; font-size: 13px; cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.seg label small { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.seg label:hover { border-color: var(--word); }
.seg input:checked + label { border-color: var(--lime); background: rgba(185, 255, 102, 0.1); color: var(--text); box-shadow: inset 0 0 0 1px var(--lime); }
.seg input:focus-visible + label { outline: 2px solid var(--lime); outline-offset: 2px; }

.summary { display: flex; gap: 22px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.summary span { display: grid; gap: 2px; }
.summary strong { font-family: var(--font-display); font-size: 1.35rem; }

.dropzone { display: grid; gap: 4px; padding: 18px; text-align: center; border: 2px dashed var(--line-strong); border-radius: 12px; cursor: pointer; background: rgba(255, 255, 255, 0.02); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone:hover, .dropzone.is-over { border-color: var(--lime); background: rgba(185, 255, 102, 0.06); }

.tabbtn { padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.tabbtn[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); color: #0a0d12; font-weight: 700; }

/* ---------------------------------------------------------------- the white page */
.paper-scroll { max-height: calc(100vh - 230px); min-height: 420px; overflow: auto; padding: 18px; background: #1a212b; border: 1px solid var(--line); border-radius: var(--radius); }
.paper-scroll[hidden] { display: none; }
.paper.doc { max-width: 794px; margin: 0 auto; padding: 56px 60px 70px; font-family: Calibri, "Segoe UI", system-ui, sans-serif; font-size: 13.5px; line-height: 1.5; }
.paper.doc p { margin: 0 0 9px; }
.doc-title { font-size: 33px; color: #1f2a37; margin: 0 0 4px; letter-spacing: -0.01em; }
.doc-subtitle { font-size: 19px; color: #4a5663; margin-bottom: 18px; }
.doc-small { color: #6b7785; font-size: 11px; }
.doc-h1, .doc-h2 { color: #1f2a37; margin: 22px 0 8px; font-family: Calibri, "Segoe UI", system-ui, sans-serif; letter-spacing: 0; }
.doc-h1 { font-size: 20px; }
.doc-h2 { font-size: 16px; margin-top: 16px; }
.doc .num { display: inline-block; min-width: 36px; }
.doc-toc-h { font-size: 20px; font-weight: 700; color: #1f2a37; margin-top: 22px; }
.doc-toc { margin: 2px 0 !important; font-size: 13px; }
.doc-toc.l1 { font-weight: 700; margin-top: 6px !important; }
.doc-toc.l2 { padding-left: 22px; }
.doc-li { position: relative; padding-left: 20px; }
.doc-li::before { content: "\2022"; position: absolute; left: 6px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 12px; table-layout: auto; }
.doc-table th { background: #1f2a37; color: #fff; text-align: left; font-weight: 700; }
.doc-table th, .doc-table td { padding: 5px 8px; border-bottom: 1px solid #d5dae0; vertical-align: top; }
.doc-table td.num, .doc-table th.num { text-align: right; }
.doc-table.plain td:first-child { font-weight: 700; width: 28%; }
.fld { border-radius: 2px; }
.paper.show-fields .fld { background: #eaf7cf; box-shadow: 0 1px 0 #8cc63f; }
.cond { position: relative; }
.paper.show-rules .cond { border-left: 3px solid #8cc63f; margin-left: -12px; padding-left: 9px; }
.paper.show-rules .cond[data-rule]::before { content: attr(data-rule); position: absolute; right: 0; top: -10px; padding: 0 6px; background: #1f2a37; color: #b9ff66; font: 10px/16px ui-monospace, Consolas, monospace; border-radius: 3px; }
ins { color: #1a7f37; text-decoration: underline; background: #e6f6ea; text-decoration-thickness: 1px; }
del { color: #b42318; background: #fdeaea; }
tr.row-ins td, tr.row-ins th { background: #e6f6ea; }
tr.row-del td { background: #fdeaea; }
p.row-ins { background: #e6f6ea; }
p.row-del { background: #fdeaea; }

/* ---------------------------------------------------------------- change list */
.changes { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 230px); overflow: auto; }
.changes[hidden] { display: none; }
.changes__list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.changes__list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); font-size: 13.5px; }
.changes__list .chip { flex: none; width: 66px; justify-content: center; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; }
.changes__list li[data-kind="field"] .chip { color: var(--word); border-color: var(--word); }
.changes__list li[data-kind="row"] .chip, .changes__list li[data-kind="cell"] .chip { color: var(--excel); border-color: var(--excel); }
.changes__list li[data-kind="chapter"] .chip, .changes__list li[data-kind="text"] .chip { color: var(--warn); border-color: var(--warn); }

/* ---------------------------------------------------------------- Excel-like grid */
.found { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0; }
.found div { display: grid; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.found dt { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; color: var(--faint); letter-spacing: 0.04em; }
.found dd { margin: 0; font-family: var(--font-display); font-size: 1.3rem; color: var(--excel); }
.xl-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.xl-tabs button { flex: none; padding: 6px 14px; border: 1px solid var(--line); border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.xl-tabs button[aria-selected="true"] { border-bottom-color: var(--excel); color: var(--text); background: var(--panel); }
.xl-wrap { overflow: auto; max-height: calc(100vh - 300px); border: 1px solid var(--line); border-radius: var(--radius); background: #0b1117; }
.xl { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12.5px; }
.xl th, .xl td { padding: 5px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; max-width: 420px; }
.xl thead th, .xl tbody th { background: var(--bg-2); color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; text-align: center; position: sticky; }
.xl thead th { top: 0; z-index: 2; }
.xl tbody th { left: 0; z-index: 1; min-width: 34px; }
.xl__corner { left: 0; z-index: 3 !important; }
.xl__header td { background: var(--excel); color: #07120b; font-weight: 800; }
.xl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.xl-host { display: grid; gap: 8px; }

@media (max-width: 1020px) {
  .docs { grid-template-columns: 1fr; }
  .docs__form { position: static; max-height: none; }
  .paper-scroll { max-height: 70vh; }
  .paper.doc { padding: 32px 26px 40px; }
  .found { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
