/* FormFill UI styles (one file for the local app and formfill.help: no inline styles, CSP-friendly). */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1d2430; --muted: #687385; --line: #dfe3ea;
  --accent: #0f3786; --accent-2: #2457c5; --ok: #1f8a4c; --warn: #b7791f; --err: #c53030;
  --ok-bg: rgba(31,138,76,.16); --empty-bg: rgba(104,115,133,.12); --err-bg: rgba(197,48,48,.18);
  --hdr: 52px; --sum: 68px; /* sticky offsets, re-measured by the script */
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 8px rgba(16,24,40,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #1a1f26; --text: #e6e9ef; --muted: #9aa4b2; --line: #2c333d;
    --accent: #8fb0ff; --accent-2: #a9c2ff; --ok-bg: rgba(52,199,120,.18); --empty-bg: rgba(154,164,178,.14);
    --err-bg: rgba(245,101,101,.22); --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
header { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line);
         background: var(--panel); position: sticky; top: 0; z-index: 5; }
header h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--ok); border-color: currentColor; }
main { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; padding: 20px 24px; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; padding: 16px; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.left { display: flex; flex-direction: column; gap: 14px; align-self: start; position: sticky; top: calc(var(--hdr) + 20px); }
@media (max-width: 900px) { .left { position: static; } }
label.title { font-weight: 600; font-size: 13px; display: block; margin-bottom: 6px; }
#drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 14px; text-align: center;
        cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s; }
#drop.over { border-color: var(--accent-2); background: var(--empty-bg); }
#drop strong { color: var(--text); display: block; margin-bottom: 4px; word-break: break-all; }
#drop.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-bg); padding: 14px; text-align: left; }
.drop-file { display: flex; gap: 12px; align-items: center; }
.drop-ok { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--ok); color: #fff;
           display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.drop-info { min-width: 0; }
.drop-info strong { margin-bottom: 2px; }
.drop-meta { font-size: 12.5px; color: var(--muted); }
.drop-meta b { color: var(--ok); font-weight: 600; }
textarea { width: 100%; min-height: 220px; resize: vertical; padding: 10px 12px; border-radius: 10px;
           border: 1px solid var(--line); background: var(--bg); color: var(--text); font: 13px/1.5 ui-monospace, Menlo, monospace; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); }
.consent input { margin-top: 2px; }
button { font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
button.primary { background: var(--accent); color: #fff; width: 100%; font-size: 15px; padding: 12px; }
button.apply { background: var(--accent); color: #fff; padding: 8px 14px; display: inline-flex; align-items: center; gap: 8px;
               box-shadow: 0 1px 3px rgba(15,55,134,.35); transition: filter .15s, box-shadow .15s; }
button.apply:hover:not(:disabled) { filter: brightness(1.12); }
button.apply.dirty { box-shadow: 0 0 0 3px rgba(183,121,31,.45); }
button.apply .badge { background: var(--warn); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; line-height: 18px; }
@media (prefers-color-scheme: dark) { button.primary, button.apply { color: #0c1220; } button.apply { box-shadow: none; } }
button.secondary { background: var(--empty-bg); color: var(--text); }
button:disabled { opacity: .5; cursor: progress; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#status { min-height: 20px; color: var(--muted); font-size: 13px; }
#status.error { color: var(--err); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent);
           border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { color: var(--muted); text-align: center; padding: 60px 20px; }
/* Freeze panes: the summary sticks under the app header, the field toolbar under the summary. */
.summary { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between;
           position: sticky; top: var(--hdr); z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line);
           margin: -16px -16px 12px; padding: 14px 16px 12px; border-radius: var(--radius) var(--radius) 0 0; }
.summary-title { flex: 1 1 280px; min-width: 0; }
.summary h2 { margin: 0 0 4px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 12.5px; }
.stats { display: flex; gap: 10px; }
.stat { padding: 6px 12px; border-radius: 10px; background: var(--bg); font-size: 12.5px; }
.stat b { font-size: 15px; }
a.download { white-space: nowrap; background: var(--ok); color: #fff; text-decoration: none; padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.notes { margin: 12px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.results { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 20px; margin-top: 16px; }
@media (max-width: 1250px) { .results { grid-template-columns: 1fr; } }
.pages { display: flex; flex-direction: column; gap: 16px; }
.page { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.page img { display: block; width: 100%; height: auto; }
.page .num { position: absolute; top: 6px; right: 8px; font-size: 11px; color: #687385; background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 6px; }
.box { position: absolute; border-radius: 2px; outline: 1.5px solid transparent; cursor: pointer; }
.box.filled { background: var(--ok-bg); outline-color: rgba(31,138,76,.55); }
.box.empty { background: var(--empty-bg); outline-color: rgba(104,115,133,.35); }
.box.error { background: var(--err-bg); outline-color: var(--err); }
.box.prefilled { background: rgba(43,108,176,.10); outline-color: rgba(43,108,176,.45); }
.box.hot { outline: 2.5px solid var(--accent-2); z-index: 2; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.side { position: sticky; top: calc(var(--hdr) + var(--sum) + 12px); align-self: start; display: flex; flex-direction: column;
        max-height: max(320px, calc(100vh - var(--hdr) - var(--sum) - 64px)); }
.side-bar { flex: none; position: sticky; top: 0; z-index: 15; background: var(--panel);
            padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.fields { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.field { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.field.hot { border-color: var(--accent-2); }
.field .lbl { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field .lbl span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field input[type=text] { width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
                          background: var(--panel); color: var(--text); font: 13px ui-monospace, Menlo, monospace; }
.field .msg { color: var(--err); font-size: 12px; margin-top: 3px; }
.field .choice-hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field input.line { margin-top: 3px; border-style: dashed; }  /* one input per dotted line on the form */
.field input.line.hot { border-color: var(--accent-2); border-style: solid; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; margin-top: 5px; }
.dot.filled { background: var(--ok); } .dot.empty { background: #a0a8b5; } .dot.error { background: var(--err); }
.dot.prefilled { background: var(--accent-2); }
.field[data-status="prefilled"] input { color: var(--muted); cursor: not-allowed; }
.filter { display: flex; gap: 6px; margin-bottom: 8px; }
.filter button { padding: 4px 10px; font-size: 12px; font-weight: 500; }
.filter button.active { background: var(--accent); color: #fff; }
.lang { margin-left: 8px; font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line);
        background: var(--panel); color: var(--text); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--empty-bg); }
.tabs button { padding: 8px 6px; font-size: 13px; background: transparent; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.data-tools { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
button.link, a.link { background: transparent; color: var(--accent-2); padding: 4px 2px; font-weight: 600; font-size: 13px; text-decoration: none; }
button.link:hover, a.link:hover { text-decoration: underline; }
a.profile { white-space: nowrap; border: 1.5px solid var(--ok); color: var(--ok); text-decoration: none; padding: 8.5px 14px;
            border-radius: 10px; font-weight: 600; background: transparent; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.field .src { font-size: 11px; color: var(--muted); margin-left: 6px; }
.field .lbl .tags { display: flex; gap: 6px; align-items: center; flex: none; }
.tag { font-size: 10.5px; line-height: 16px; padding: 0 7px; border-radius: 99px; white-space: nowrap; cursor: help;
       border: 1px solid var(--line); color: var(--muted); background: var(--panel); }
.tag.in-pdf { border-color: rgba(31,138,76,.45); color: var(--ok); }
.tag.edited { border-color: rgba(183,121,31,.55); color: var(--warn); }
.tag.on-sheet { border-color: rgba(43,108,176,.5); color: var(--accent-2); }
.info { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--empty-bg); color: var(--text);
        font-size: 12.5px; line-height: 1.45; border-left: 3px solid var(--accent-2); }
.notice { margin: 8px 0 16px; padding: 14px 16px; border-radius: 10px; background: var(--err-bg); color: var(--text);
          border-left: 4px solid var(--warn); font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }
.tagline { margin-left: auto; }
#cloud-opts { margin-bottom: 12px; }
#cloud-opts .consent + .consent { margin-top: 8px; }
#status { margin-top: 10px; }
.legend i.sw.filled { background: var(--ok-bg); outline: 1px solid var(--ok); }
.legend i.sw.empty { background: var(--empty-bg); }
.legend i.sw.error { background: var(--err-bg); outline: 1px solid var(--err); }
.legend i.sw.prefilled { background: rgba(43,108,176,.10); outline: 1px solid rgba(43,108,176,.45); }

/* formfill.help (the browser build sets <html data-mode="web">): privacy line, engine progress, example, footer */
.web-only { display: none !important; }
html[data-mode="web"] .web-only { display: block !important; }
html[data-mode="web"] span.web-only { display: inline !important; }
.intro { margin: 16px 24px 0; padding: 10px 14px; border-radius: 10px; background: var(--ok-bg); color: var(--text);
         font-size: 13.5px; border-left: 3px solid var(--ok); }
.drop-extra { margin-top: 10px; }
.engine { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); min-height: 18px; }
.engine-bar { flex: 0 0 90px; height: 6px; border-radius: 99px; background: var(--empty-bg); overflow: hidden; }
.engine-bar i { display: block; height: 100%; width: 0; background: var(--accent-2); transition: width .3s; }
.engine.ready .engine-bar { display: none; }
.engine.ready { color: var(--ok); }
.engine.failed { color: var(--err); }
footer { padding: 8px 24px 28px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
footer p { margin: 4px 0; max-width: 980px; }
footer a { color: var(--accent-2); }
@media (max-width: 900px) { .intro { margin: 12px 16px 0; } footer { padding: 8px 16px 24px; } }
@media (max-width: 600px) {  /* phones: the header keeps the name, the mode and the language */
  header { padding: 10px 16px; gap: 8px; }
  .tagline { display: none; }
  header h1 { flex: none; }
  .pill { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
  .lang { margin-left: auto; flex: 0 0 auto; max-width: 42vw; }
}
