/* webaccess: ledger-paper look. Dense, ruled, bottle-green ink, amber for unsaved edits. */

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../fonts/atkinson-hyperlegible-next-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --paper: #fbfcfa;
  --ledger: #f1f5f1;
  --pane: #e6ece7;
  --rule: #cad5cd;
  --rule-strong: #9fb1a5;
  --ink: #20262a;
  --ink-soft: #5b6660;
  --green: #1f5c4a;
  --green-dark: #164536;
  --green-tint: #dceae3;
  --amber: #b97a12;
  --amber-tint: #fbf0d9;
  --danger: #a3342b;
  --danger-tint: #f7e3e1;

  --font: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --step--1: 12px;
  --step-0: 14px;
  --step-1: 16px;
  --step-2: 20px;
  --row: 28px;
  --radius: 3px;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
[hidden] { display: none !important; }

/* ---------- buttons and inputs ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--ledger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-tint); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--pane); }
.btn.small { height: 26px; padding: 0 8px; font-size: var(--step--1); }
.btn[aria-pressed="true"] { background: var(--green-tint); border-color: var(--green); color: var(--green-dark); }

.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: var(--step--1); color: var(--ink-soft); }
.input, select.input, textarea.input {
  height: 32px; padding: 0 8px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: #fff; width: 100%;
}
textarea.input { height: auto; min-height: 64px; padding: 6px 8px; resize: vertical; }
.input:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }

.error-text { color: var(--danger); margin: 0 0 12px; white-space: pre-line; }
.muted { color: var(--ink-soft); }

/* ---------- sign-in ---------- */

.login {
  min-height: 100%;
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(to bottom, transparent 0 27px, var(--rule) 27px 28px),
    var(--ledger);
}
.login-sheet {
  width: min(380px, calc(100% - 32px));
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-left: 6px solid var(--green);
  padding: 28px 28px 20px;
}
.login-sheet h1 { font-size: var(--step-2); margin: 0 0 10px; line-height: 1; }
.login-logo { display: block; width: 276px; max-width: 100%; height: auto; }
.login-note { margin: 18px 0 0; font-size: var(--step--2, 12px); color: var(--ink-soft); }
.login-sheet p.lead { margin: 0 0 20px; color: var(--ink-soft); }

/* ---------- shell ---------- */

.shell {
  height: 100%;
  display: grid;
  grid-template-rows: 44px auto 1fr;
  grid-template-columns: 240px 1fr;
  grid-template-areas: "top top" "ribbon ribbon" "nav main";
}
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 0 16px;
  background: var(--green); color: #fff;
}
.topbar .brand { display: flex; align-items: center; }
.brand-logo { display: block; height: 21px; width: auto; }
.brand-mark { display: none; height: 26px; width: 26px; }
@media (max-width: 760px) { .brand-logo { display: none; } .brand-mark { display: block; } }
.topbar .dbname { opacity: .8; }
.topbar .spacer { flex: 1; }
.topbar .btn.quiet { color: #fff; }
.topbar .btn.quiet:hover { background: var(--green-dark); }
.topbar .nav-toggle { display: none; }
.role-badge {
  font-size: var(--step--1); padding: 1px 6px; border-radius: var(--radius);
  background: rgba(255,255,255,.18);
}

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  min-width: 200px; background: #fff; color: var(--ink);
  border: 1px solid var(--rule-strong); box-shadow: 0 6px 18px rgba(20, 40, 30, .16);
  padding: 4px 0;
}
.menu-list button {
  display: block; width: 100%; text-align: left;
  border: 0; background: none; padding: 7px 14px; cursor: pointer;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--ledger); }

/* the ribbon and Navigation Pane can be hidden (Hide the ribbon / Hide the Navigation Pane) */
.shell.no-ribbon .ribbon { display: none; }
.shell.no-nav { grid-template-columns: 0 1fr; }
.shell.no-nav .nav { display: none; }

/* Pop Up forms */
.popup-window {
  position: fixed; display: flex; flex-direction: column; background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: 4px; overflow: hidden;
  box-shadow: 0 18px 48px rgba(20, 40, 30, .28);
}
.pw-bar {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 4px 0 10px; flex: none;
  background: var(--green); color: #fff; cursor: move; user-select: none; touch-action: none;
}
.pw-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-close { border: 0; background: none; color: #fff; width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer; border-radius: 3px; }
.pw-close:hover { background: var(--danger); }
.pw-design:hover { background: rgba(255, 255, 255, .2); }
.pw-body { flex: 1; min-height: 0; position: relative; }
.pw-grip {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; touch-action: none; z-index: 5;
  background: linear-gradient(135deg, transparent 0 55%, var(--rule-strong) 55% 62%, transparent 62% 72%, var(--rule-strong) 72% 79%, transparent 79%);
}
.popup-backdrop { position: fixed; inset: 0; background: rgba(32, 38, 42, .28); }
.popup-window .formdoc > .toolbar { display: none; }

/* quick access toolbar (Save, Undo, Redo) */
.qat { display: flex; gap: 2px; margin-left: 4px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.25); }
.qat .btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
.qat .btn:disabled { opacity: .4; }

/* ribbon */
.ribbon { grid-area: ribbon; background: var(--paper); border-bottom: 1px solid var(--rule-strong); position: relative; z-index: 15; min-width: 0; }
.ribbon-head { display: flex; align-items: flex-end; gap: 2px; padding: 4px 8px 0; background: var(--ledger); border-bottom: 1px solid var(--rule); overflow-x: auto; }
.ribbon-head .spacer { flex: 1; }
.ribbon-tabs { display: flex; align-items: flex-end; gap: 2px; }
.ribbon-tab {
  border: 1px solid transparent; border-bottom: 0; background: none; cursor: pointer;
  padding: 5px 14px 6px; font: inherit; color: var(--ink); white-space: nowrap; border-radius: var(--radius) var(--radius) 0 0;
}
.ribbon-tab:hover { background: var(--pane); }
.ribbon-tab[aria-selected="true"] {
  background: var(--paper); border-color: var(--rule); color: var(--green-dark); font-weight: 600;
  position: relative; top: 1px; box-shadow: inset 0 3px 0 var(--green);
}
.ribbon-tab.contextual { color: var(--amber); }
.ribbon-tab.contextual[aria-selected="true"] { color: #7a5009; box-shadow: inset 0 3px 0 var(--amber); }
.ribbon-context-label {
  align-self: stretch; display: flex; align-items: center; margin-left: 10px; padding: 0 8px;
  font-size: var(--step--1); color: #7a5009; background: var(--amber-tint); border-radius: var(--radius) var(--radius) 0 0;
  white-space: nowrap;
}
.ribbon-collapse { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 16px; padding: 2px 8px 6px; }
.ribbon-collapse:hover { color: var(--green); }
.ribbon-panel { display: flex; align-items: stretch; gap: 0; padding: 4px 4px 0; min-height: 88px; overflow-x: auto; overflow-y: hidden; }
.ribbon.collapsed .ribbon-panel { display: none; }
.ribbon.collapsed.peek .ribbon-panel {
  display: flex; position: absolute; left: 0; right: 0; top: 100%;
  background: var(--paper); border-bottom: 1px solid var(--rule-strong); box-shadow: 0 8px 18px rgba(20, 40, 30, .16);
}
.rb-group { display: flex; flex-direction: column; padding: 0 6px; border-right: 1px solid var(--rule); flex: none; }
.rb-items { flex: 1; display: flex; align-items: flex-start; gap: 2px; }
.rb-label { text-align: center; font-size: 11px; color: var(--ink-soft); padding: 2px 0 3px; white-space: nowrap; }
.rb-stack { display: grid; grid-template-rows: repeat(3, 24px); grid-auto-flow: column; gap: 1px 4px; }
.rb-gallery { display: grid; grid-template-rows: repeat(2, 28px); grid-auto-flow: column; gap: 2px; padding-top: 4px; }
.rb-btn {
  border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink); font: inherit;
  border-radius: var(--radius); display: flex; align-items: center;
}
.rb-btn:hover:not(:disabled) { background: var(--green-tint); border-color: var(--rule); }
.rb-btn:disabled { opacity: .38; cursor: default; }
.rb-btn[aria-pressed="true"] { background: var(--green-tint); border-color: var(--green); color: var(--green-dark); }
.rb-btn:focus-visible, .rb-arrow:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.rb-icon { display: inline-flex; color: var(--green); }
.rb-btn:disabled .rb-icon { color: var(--ink-soft); }
.rb-large { flex-direction: column; justify-content: flex-start; gap: 4px; min-width: 56px; max-width: 86px; height: 66px; padding: 6px 6px 2px; font-size: 12px; line-height: 1.15; text-align: center; }
.rb-large .icon { width: 26px; height: 26px; }
.rb-small { gap: 6px; height: 24px; padding: 0 6px; font-size: 12px; white-space: nowrap; }
.rb-icon-btn, .rb-btn.rb-icon { width: 28px; height: 28px; justify-content: center; padding: 0; }
.rb-gallery .rb-btn { width: 28px; height: 28px; justify-content: center; padding: 0; }
.rb-gallery .rb-btn .icon { width: 18px; height: 18px; }
.rb-split { display: flex; flex-direction: column; }
.rb-split-large .rb-large { height: 52px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.rb-arrow { border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink-soft); border-radius: 0 0 var(--radius) var(--radius); height: 14px; line-height: 10px; font-size: 11px; }
.rb-arrow:hover:not(:disabled) { background: var(--green-tint); }
.rb-arrow:disabled { opacity: .38; }
.ribbon-menu {
  position: fixed; z-index: 40; min-width: 180px; background: #fff; border: 1px solid var(--rule-strong);
  box-shadow: 0 8px 20px rgba(20, 40, 30, .18); padding: 4px 0;
}
.ribbon-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 14px; cursor: pointer; text-align: left; font: inherit; }
.ribbon-menu button:hover:not(:disabled), .ribbon-menu button:focus-visible { background: var(--green-tint); outline: none; }
.ribbon-menu button[aria-checked="true"] { font-weight: 600; color: var(--green-dark); }
.ribbon-menu button:disabled { opacity: .4; cursor: default; }
.ribbon-menu .icon { color: var(--green); }

/* navigation pane */
.nav {
  grid-area: nav;
  background: var(--pane);
  border-right: 1px solid var(--rule-strong);
  overflow: auto;
  padding: 10px 0 16px;
}
.nav-search.input { margin: 0 10px 10px; height: 30px; width: calc(100% - 20px); }
.nav-group { margin-bottom: 6px; }
.nav-group-head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 12px;
  font-weight: 700; color: var(--green-dark);
  border-bottom: 1px solid var(--rule);
}
.nav-group-head .count { font-weight: 400; color: var(--ink-soft); font-size: var(--step--1); }
.nav-group-head .btn { margin-left: auto; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 12px 5px 22px; border: 0; background: none; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--ledger); }
.nav-item.active { background: var(--green-tint); box-shadow: inset 3px 0 0 var(--green); }
.nav-empty { padding: 4px 12px 4px 22px; color: var(--ink-soft); font-size: var(--step--1); }
.icon { width: 16px; height: 16px; flex: none; }

/* document area */
.main { grid-area: main; display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.doc-tabs {
  display: flex; gap: 2px; padding: 6px 8px 0;
  background: var(--ledger); border-bottom: 1px solid var(--rule-strong);
  overflow-x: auto;
}
.doc-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 10px; border: 1px solid var(--rule); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--pane); cursor: pointer; white-space: nowrap;
}
.doc-tab.active { background: var(--paper); border-color: var(--rule-strong); position: relative; top: 1px; }
.doc-tab .close { border: 0; background: none; cursor: pointer; padding: 0 4px; color: var(--ink-soft); font-size: 16px; line-height: 1; }
.doc-tab .close:hover { color: var(--danger); }
.filtered-badge { color: var(--amber); border-color: var(--amber); gap: 4px; }
.filtered-badge .icon { width: 13px; height: 13px; }
.doc-tab .dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.doc-body { min-height: 0; min-width: 0; position: relative; }
.doc-pane { position: absolute; inset: 0; display: flex; flex-direction: column; }

.welcome { padding: 32px; max-width: 640px; }
.welcome h2 { margin: 0 0 8px; font-size: var(--step-2); }
.welcome p { margin: 0 0 12px; }

.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 10px; border-bottom: 1px solid var(--rule); background: var(--paper);
}
.toolbar .sep { width: 1px; align-self: stretch; background: var(--rule); margin: 2px 4px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 0 10px; height: 28px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--green); color: #fff; }

/* ---------- datasheet ---------- */

.sheet-wrap { flex: 1; overflow: auto; min-height: 0; }
.sheet-wrap:focus-visible { outline: none; } /* the focused cell shows where you are */
table.sheet { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.sheet th, .sheet td {
  height: var(--row); padding: 0 8px;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px;
  text-align: left;
}
.sheet thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--pane); font-weight: 600;
  border-bottom: 1px solid var(--rule-strong);
  cursor: pointer; user-select: none;
}
.sheet thead th:hover { background: #dbe4dd; }
.sheet thead th .sort { color: var(--green); margin-left: 4px; }
.sheet thead th.selector { cursor: default; }
.sheet .selector {
  position: sticky; left: 0; z-index: 1;
  width: 28px; min-width: 28px; padding: 0; text-align: center;
  background: var(--pane); color: var(--ink-soft); cursor: pointer;
  border-right: 1px solid var(--rule-strong);
}
.sheet thead .selector { z-index: 3; }
.sheet tbody tr:nth-child(even) td:not(.selector) { background: var(--ledger); }
.sheet tbody tr.current td:not(.selector) { background: var(--green-tint); }
.sheet tbody tr.current .selector { color: var(--green); }
.sheet tbody tr.dirty .selector { color: var(--amber); background: var(--amber-tint); }
.sheet tbody tr.selected td { background: #c3dbcf !important; }
.sheet td.num { text-align: right; }
.sheet td.bool { text-align: center; }
.sheet td.cell-focus { outline: 2px solid var(--green); outline-offset: -2px; }
.sheet td.editing { padding: 0; }
.sheet td.editing input {
  width: 100%; height: calc(var(--row) - 1px); border: 0; padding: 0 7px;
  outline: 2px solid var(--green); outline-offset: -2px; background: #fff;
}
.sheet td.editing.num input { text-align: right; }
.sheet tr.new-row td:not(.selector) { background: var(--paper); color: var(--ink-soft); }
.sheet td.null { color: var(--ink-soft); }
.sheet input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; margin: 0; vertical-align: middle; }

.recordbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 4px 10px; border-top: 1px solid var(--rule-strong); background: var(--pane);
  font-size: var(--step--1);
}
.recordbar .btn { height: 24px; min-width: 26px; padding: 0 6px; justify-content: center; }
.recordbar input { width: 64px; height: 24px; text-align: center; border: 1px solid var(--rule-strong); border-radius: var(--radius); }
.recordbar .spacer { flex: 1; }
.recordbar .status-msg { color: var(--danger); }

/* ---------- table designer ---------- */

.designer { flex: 1; display: grid; grid-template-rows: auto minmax(120px, 1fr) auto; min-height: 0; }
.designer-head {
  display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--rule);
}
.designer-head .field { margin: 0; }
.design-grid-wrap { overflow: auto; min-height: 0; }
table.design-grid { border-collapse: separate; border-spacing: 0; width: 100%; }
.design-grid th, .design-grid td {
  height: var(--row); padding: 0; text-align: left;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.design-grid thead th {
  position: sticky; top: 0; z-index: 1; padding: 0 8px; background: var(--pane); font-weight: 600;
  border-bottom: 1px solid var(--rule-strong);
}
.design-grid .selector { width: 32px; text-align: center; background: var(--pane); color: var(--green); cursor: pointer; }
.design-grid td input, .design-grid td select {
  width: 100%; height: calc(var(--row) - 1px); border: 0; padding: 0 8px; background: transparent;
}
.design-grid td input:focus, .design-grid td select:focus { outline: 2px solid var(--green); outline-offset: -2px; background: #fff; }
.design-grid tr.current td { background: var(--green-tint); }
.design-grid col.c-sel { width: 34px; }
.design-grid col.c-name { width: 28%; }
.design-grid col.c-type { width: 18%; }

.props {
  border-top: 1px solid var(--rule-strong); background: var(--ledger);
  padding: 10px 12px 4px;
}
.props h3 { margin: 0 0 8px; font-size: var(--step-0); color: var(--green-dark); }
.props-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.props .field { margin-bottom: 10px; }
.props .hint { grid-column: 1 / -1; color: var(--ink-soft); font-size: var(--step--1); margin: 0 0 8px; }

/* ---------- query designer ---------- */

.qd-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.qd-data { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.qd-data > .doc-pane { position: absolute; inset: 0; }
.qd-design { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(150px, 42%) 1fr; }
.qd-design > .qd-banner { grid-row: 1; }
.qd-design > .qd-tables { grid-row: 2; }
.qd-design > .qd-grid-wrap { grid-row: 3; }
.qd-tables {
  overflow: auto; position: relative;
  border-bottom: 1px solid var(--rule-strong);
  background:
    linear-gradient(var(--rule) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--ledger);
}
.qd-canvas { position: relative; min-width: 100%; min-height: 100%; width: 1400px; height: 520px; }
.qd-joins { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.qd-join { fill: none; stroke: var(--green); stroke-width: 2; }
.qd-join-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.qd-arrow { fill: var(--green); }

.qd-box {
  position: absolute; width: 180px; z-index: 1;
  background: #fff; border: 1px solid var(--rule-strong);
  box-shadow: 0 3px 10px rgba(20, 40, 30, .12);
}
.qd-box.missing { border-color: var(--danger); }
.qd-box-head {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 8px; background: var(--green); color: #fff;
  font-weight: 600; cursor: move; touch-action: none; user-select: none;
}
.qd-box-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qd-box-close { border: 0; background: none; color: #fff; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.qd-fields { list-style: none; margin: 0; padding: 2px 0; max-height: 180px; overflow-y: auto; }
.qd-fields li {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 8px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qd-fields li:hover { background: var(--ledger); }
.qd-fields li.drop { background: var(--green-tint); outline: 1px dashed var(--green); }
.qd-fields li .icon { width: 12px; height: 12px; color: var(--green); }

.qd-grid-wrap { overflow: auto; min-height: 0; background: var(--paper); }
table.qd-grid { border-collapse: separate; border-spacing: 0; }
.qd-grid th, .qd-grid td { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 0; height: var(--row); }
.qd-grid .qd-rowhead {
  position: sticky; left: 0; z-index: 1; min-width: 74px; padding: 0 10px;
  background: var(--pane); text-align: right; font-weight: 600; color: var(--green-dark);
}
.qd-grid thead th { height: 22px; background: var(--pane); }
.qd-grid .qd-colhead { text-align: center; white-space: nowrap; }
.qd-grid .qd-colhead.current { background: var(--green-tint); }
.qd-mini { border: 0; background: none; cursor: pointer; padding: 0 4px; font-size: 11px; color: var(--ink-soft); }
.qd-mini:hover:not(:disabled) { color: var(--green); }
.qd-mini:disabled { opacity: .3; cursor: default; }
.qd-grid td { min-width: 160px; width: 170px; }
.qd-grid td.current { background: var(--green-tint); }
.qd-grid td input:not([type="checkbox"]), .qd-grid td select {
  width: 100%; height: calc(var(--row) - 1px); border: 0; padding: 0 7px; background: transparent;
}
.qd-grid td input[type="checkbox"] { display: block; margin: 0 auto; width: 15px; height: 15px; accent-color: var(--green); }
.qd-grid td input:focus, .qd-grid td select:focus { outline: 2px solid var(--green); outline-offset: -2px; background: #fff; }
.qd-grid td input:disabled, .qd-grid td select:disabled { visibility: hidden; }
.qd-grid tr.or-row .qd-rowhead { font-weight: 400; color: var(--ink-soft); }

.qd-banner { padding: 16px; background: var(--amber-tint); border-bottom: 1px solid var(--rule-strong); }
.qd-banner p { margin: 0 0 10px; }
.qd-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.qd-sql-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; gap: 6px; }
.qd-sql {
  flex: 1; min-height: 160px; resize: none; padding: 10px 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff;
  font: 14px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
.qd-sql:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.qd-sql-hint { margin: 0; font-size: var(--step--1); }

.pick-group { border: 1px solid var(--rule); margin: 0 0 12px; padding: 6px 10px 8px; max-height: 220px; overflow: auto; }
.pick-group legend { font-weight: 600; color: var(--green-dark); padding: 0 4px; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.pick-item input { accent-color: var(--green); }

/* ---------- forms: shared ---------- */

.formdoc-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.formdoc-body > .doc-pane, .formdoc-body > .fd { position: absolute; inset: 0; }

/* ---------- Form view ---------- */

.fv-scroll { flex: 1; overflow: auto; padding: 16px; background: var(--ledger); }
.fv-surface { background: #fff; border: 1px solid var(--rule-strong); box-shadow: 0 2px 8px rgba(20, 40, 30, .08); }
.fv-section { position: relative; }
.fv-header { border-bottom: 1px solid var(--rule); }
.fv-footer { border-top: 1px solid var(--rule); }
.fv-ctl { position: absolute; box-sizing: border-box; }
.fv-label { display: flex; align-items: center; overflow: hidden; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.2; color: var(--ink); }
.fv-input {
  border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0 6px; background: #fff;
  font: inherit; font-size: inherit; resize: none;
}
textarea.fv-input { padding: 4px 6px; }
.fv-input:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
.fv-input[readonly] { background: var(--paper); color: var(--ink-soft); }
.fv-input.num { text-align: right; }
.fv-input.calc { background: var(--ledger); }
.fv-check { display: flex; align-items: center; justify-content: center; }
.fv-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.fv-button { justify-content: center; height: auto; font-size: inherit; }
.fv-rect { border: 1px solid var(--rule-strong); }
.fd-sql { font-family: var(--mono, ui-monospace, monospace); font-size: 12px; width: 100%; resize: vertical; }
.fv-message { padding: 10px 12px; margin: 0; }
.fv-note { padding: 6px 12px; background: var(--amber-tint); border-bottom: 1px solid var(--rule); font-size: var(--step--1); }
.fv-editing { color: var(--amber); font-weight: 600; margin-left: 8px; }
.fv-combo { padding: 0 4px; }
.fv-combo-wrap { display: flex; }
.fv-combo-wrap .fv-combo { width: 100%; height: 100%; }

.fv-ctl { z-index: 1; }
.fv-list { padding: 2px 0; }
.fv-list option { padding: 2px 6px; }
.fv-radio {
  appearance: none; -webkit-appearance: none; width: 16px !important; height: 16px !important;
  border: 1.5px solid var(--ink-soft); border-radius: 50%; background: #fff; display: grid; place-items: center; margin: 0;
}
.fv-radio:checked { border-color: var(--green); }
.fv-radio:checked::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.fv-toggle { justify-content: center; font-size: inherit; height: auto; }
.fv-toggle[aria-pressed="true"] { background: var(--green); border-color: var(--green-dark); color: #fff; box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25); }
.fv-group { margin: 0; padding: 6px 10px 6px; border: 1px solid var(--rule-strong); display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.fv-group.horizontal { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.fv-group legend { padding: 0 4px; font-weight: 600; }
.fv-opt { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.fv-opt input { accent-color: var(--green); margin: 0; width: 15px; height: 15px; }
.fv-link { color: var(--green); text-decoration: underline; display: flex; align-items: center; }
.fv-image { display: block; }
.fv-image.zoom { object-fit: contain; }
.fv-image.stretch { object-fit: fill; }
.fv-image.clip { object-fit: none; object-position: top left; }
.fv-image.empty { border: 1px dashed var(--rule-strong); }
.fv-tabctl { z-index: 0 !important; display: flex; flex-direction: column; }
.fv-tabs { display: flex; gap: 2px; height: 30px; align-items: flex-end; flex: none; }
.fv-tab {
  border: 1px solid var(--rule-strong); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--pane); padding: 4px 12px; cursor: pointer; font: inherit; font-size: var(--step--1);
}
.fv-tab[aria-selected="true"] { background: #fff; font-weight: 600; position: relative; top: 1px; }
.fv-tabbody { flex: 1; border: 1px solid var(--rule-strong); background: #fff; }
.fv-subform { border: 1px solid var(--rule-strong); background: var(--paper); overflow: hidden; }
.fv-subform > .doc-pane { position: absolute; inset: 0; }
.fv-subform .toolbar { display: none; }
.fv-subform .fv-message { padding: 12px; }

/* A form fills its window: header at the top, footer at the bottom, the detail between */
.fv.fill .fv-scroll { padding: 0; background: #fff; }
.fv.fill .fv-surface { width: 100%; min-height: 100%; display: flex; flex-direction: column; border: 0; box-shadow: none; box-sizing: border-box; }
.fv.fill .fv-surface > .fv-detail, .fv.fill .fv-surface > .fv-rows { flex: 1 0 auto; }
.fv.fill .fv-surface > .fv-header { position: sticky; top: 0; z-index: 3; background-color: #fff; }
.fv.fill .fv-surface > .fv-footer { position: sticky; bottom: 0; z-index: 3; background-color: #fff; }

/* Continuous forms: a selector strip down the left; header and footer stay in view */
.fv-surface.continuous {
  background: linear-gradient(to right, var(--pane) 18px, #fff 18px);
}
.fv-surface.continuous > .fv-section { margin-left: 18px; background-color: #fff; }
.fv-surface.continuous.no-selectors { background: #fff; }
.fv-surface.no-selectors > .fv-section { margin-left: 0; }
.fv-surface.no-selectors .fv-row-body { left: 0; }
.fv-surface.no-selectors .fv-selector { display: none; }
.fv-surface.continuous > .fv-header { position: sticky; top: -16px; z-index: 3; }
.fv-surface.continuous > .fv-footer { position: sticky; bottom: -16px; z-index: 3; }
.fv-row { position: relative; border-bottom: 1px solid var(--rule); }
.fv-row.current { background-color: #f6faf7; }
.fv-row-body { position: absolute; left: 18px; right: 0; top: 0; bottom: 0; }
.fv-selector {
  /* sticky, so it stays at the left edge when a wide form scrolls sideways */
  position: sticky; left: 0; z-index: 2; height: 100%; width: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--pane); border-right: 1px solid var(--rule-strong);
  color: var(--green); font-size: 13px; line-height: 1; cursor: pointer; user-select: none;
}
.fv-selector[data-state="new"], .sheet tr.new-row td.selector { font-size: 20px; font-weight: 700; padding-top: 6px; }
.fv-selector[data-state="dirty"] { font-size: 15px; }
.fv-selector[data-state="dirty"]:hover { background: var(--amber); color: #fff; }
.fv-row.dirty .fv-selector { color: var(--amber); background: var(--amber-tint); }

/* ---------- Form Design view ---------- */

.fd { display: flex; flex-direction: column; min-height: 0; }
.fd-status { padding: 4px 12px; border-top: 1px solid var(--rule); background: var(--paper); font-size: var(--step--1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-main.no-side { grid-template-columns: 1fr; }
.fd-main.no-side .fd-side { display: none; }
.fd-canvas.no-grid .fd-section { background-image: none; }
.fd-marquee { position: absolute; z-index: 5; border: 1px dashed var(--green); background: rgba(31, 92, 74, .08); pointer-events: none; }
.fd-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 300px; }
.fd-canvas { overflow: auto; padding: 16px 16px 48px; background: var(--ledger); }
.fd-canvas:focus-visible { outline: none; }
.fd-canvas.placing .fd-section { cursor: crosshair; }
.fd-surface { position: relative; background: #fff; border: 1px solid var(--rule-strong); }
.fd-bar {
  height: 22px; padding: 0 8px; display: flex; align-items: center;
  background: var(--pane); border-bottom: 1px solid var(--rule-strong); border-top: 1px solid var(--rule-strong);
  font-size: var(--step--1); font-weight: 600; color: var(--green-dark); cursor: default; user-select: none;
}
.fd-bar:first-child { border-top: 0; }
.fd-bar.selected { background: var(--green); color: #fff; }
.fd-section {
  position: relative; overflow: hidden;
  background-image: radial-gradient(circle, #c9d3cc 1px, transparent 1.2px);
  background-size: 8px 8px; background-color: #fff;
}
.fd-grip { height: 5px; margin-top: -3px; position: relative; z-index: 2; cursor: ns-resize; }
.fd-grip:hover { background: var(--green-tint); }
.fd-width-grip { position: absolute; top: 0; right: -4px; width: 7px; height: 100%; cursor: ew-resize; z-index: 3; }
.fd-width-grip:hover { background: var(--green-tint); }

.fd-ctl {
  position: absolute; box-sizing: border-box; cursor: move; user-select: none;
  display: flex; align-items: center; overflow: visible; white-space: nowrap;
}
.fd-ctl.invisible { opacity: .45; }
.fd-label { padding: 0 2px; outline: 1px dashed transparent; white-space: pre-line; overflow: hidden; overflow-wrap: anywhere; line-height: 1.2; }
.fd-label:hover { outline-color: var(--rule-strong); }
.fd-textbox, .fd-combobox { border: 1px solid var(--rule-strong); background: #fff; padding: 0 6px; }
.fd-combobox { justify-content: space-between; }
.fd-arrow { color: var(--ink-soft); padding-left: 4px; }
.fd-source { overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.fd-source.unbound { color: var(--ink-soft); font-style: italic; }
.fd-checkbox { justify-content: center; }
.fd-checkmark { width: 14px; height: 14px; border: 1px solid var(--ink-soft); border-radius: 2px; background: #fff; }
.fd-button { justify-content: center; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper); }
.fd-rectangle { border: 1px solid var(--rule-strong); }
.fd-line { }
.fd-ctl { z-index: 1; }
.fd-ctl.selected { outline: 2px solid var(--green); outline-offset: 1px; z-index: 2; }

/* the newer controls in Design view */
.fd-checkmark.round { border-radius: 50%; }
.fd-optionbutton { justify-content: center; }
.fd-togglebutton { justify-content: center; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--pane); }
.fd-linktext { color: var(--green); text-decoration: underline; overflow: hidden; text-overflow: ellipsis; }
.fd-listbox { border: 1px solid var(--rule-strong); background: #fff; flex-direction: column; align-items: stretch; padding: 4px 6px; gap: 4px; overflow: hidden; }
.fd-lines { flex: 1; background: repeating-linear-gradient(to bottom, transparent 0 14px, var(--rule) 14px 15px, transparent 15px 20px); }
.fd-optiongroup { border: 1px solid var(--rule-strong); flex-direction: column; align-items: flex-start; justify-content: flex-start; padding: 0 10px 6px; }
.fd-legend { background: #fff; padding: 0 4px; margin: -9px 0 0 -4px; font-weight: 600; line-height: 1.2; }
.fd-options { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.fd-options.horizontal { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
.fd-option { display: flex; align-items: center; gap: 6px; }
.fd-mini-toggle { border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 1px 8px; background: var(--pane); }
.fd-image { border: 1px dashed var(--rule-strong); justify-content: center; gap: 6px; color: var(--ink-soft); overflow: hidden; }
.fd-image img { width: 100%; height: 100%; pointer-events: none; }
.fd-tabcontrol, .fd-tabcontrol.selected { z-index: 0; flex-direction: column; align-items: stretch; }
.fd-tabs { display: flex; gap: 2px; height: 30px; align-items: flex-end; flex: none; overflow: hidden; }
.fd-tab {
  border: 1px solid var(--rule-strong); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--pane); padding: 3px 10px; font-size: var(--step--1); cursor: pointer;
}
.fd-tab.current { background: #fff; font-weight: 600; position: relative; top: 1px; }
.fd-tabbody { flex: 1; border: 1px solid var(--rule-strong); background: rgba(255, 255, 255, .55); }
.fd-subform {
  border: 1px solid var(--rule-strong); background: var(--paper); flex-direction: column;
  align-items: flex-start; justify-content: flex-start; padding: 6px 8px; gap: 4px; overflow: hidden;
}
.fd-subhead { display: flex; gap: 6px; align-items: center; font-weight: 600; color: var(--green-dark); }
.fd-sublink { font-size: var(--step--1); }
.fd-prop textarea.input { height: auto; min-height: 72px; resize: vertical; font: inherit; padding: 4px 6px; }
.fd-file { font-size: var(--step--1); max-width: 100%; }
.fd-handle {
  position: absolute; width: 8px; height: 8px; background: #fff; border: 1.5px solid var(--green);
  z-index: 2;
}
.fd-handle.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.fd-handle.n { left: calc(50% - 4px); top: -6px; cursor: ns-resize; }
.fd-handle.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.fd-handle.e { right: -6px; top: calc(50% - 4px); cursor: ew-resize; }
.fd-handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.fd-handle.s { left: calc(50% - 4px); bottom: -6px; cursor: ns-resize; }
.fd-handle.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.fd-handle.w { left: -6px; top: calc(50% - 4px); cursor: ew-resize; }

.fd-side { border-left: 1px solid var(--rule-strong); background: var(--paper); overflow: auto; }
.fd-side section { padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.fd-side h3 { margin: 0 0 6px; font-size: var(--step-0); color: var(--green-dark); }
.fd-small { font-size: var(--step--1); margin: 0 0 6px; }
.fd-fieldlist { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; border: 1px solid var(--rule); background: #fff; }
.fd-fieldlist li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 8px; cursor: grab; }
.fd-fieldlist li:hover, .fd-fieldlist li:focus-visible { background: var(--green-tint); }
.fd-fieldlist li .muted { font-size: var(--step--1); }
.fd-side select.input { margin-bottom: 8px; }
.fd-props { display: grid; gap: 6px; }
.fd-proptabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin: 0 0 8px; }
.fd-proptab { border: 1px solid transparent; border-bottom: 0; background: none; padding: 4px 12px; cursor: pointer; font: inherit; font-size: var(--step--1); border-radius: var(--radius) var(--radius) 0 0; color: var(--ink-soft); }
.fd-proptab[aria-selected="true"] { background: #fff; border-color: var(--rule); color: var(--green-dark); font-weight: 600; position: relative; top: 1px; }
.fd-event-cell { display: flex; gap: 4px; }
.fd-event-cell .input { flex: 1; min-width: 0; background: var(--paper); font-size: var(--step--1); }
.btn.fd-builder { width: 30px; padding: 0; justify-content: center; height: 28px; font-weight: 700; }
.fd-prop { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; }
.fd-prop label { font-size: var(--step--1); color: var(--ink-soft); }
.fd-prop .input { height: 28px; }
.fd-prop input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); justify-self: start; }
.fd-colour { display: flex; gap: 6px; align-items: center; }
.fd-colour input[type="color"] { width: 32px; height: 28px; padding: 0; border: 1px solid var(--rule-strong); background: #fff; }
.fd-hex { flex: 1; }

@media (max-width: 900px) {
  .fd-main { grid-template-columns: 1fr; grid-template-rows: 1fr 40%; }
  .fd-side { border-left: 0; border-top: 1px solid var(--rule-strong); }
}

/* ---------- code editor and the Visual Basic window ---------- */

.ce {
  display: grid; grid-template-columns: auto 1fr; height: 100%; min-height: 0; background: #fff;
  font-family: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, 'Liberation Mono', monospace;
  font-size: 14px; line-height: 20px; font-variant-ligatures: none;
}
.ce-gutter { overflow: hidden; background: var(--ledger); border-right: 1px solid var(--rule); color: var(--ink-soft); text-align: right; user-select: none; }
.ce-gutter-inner { padding: 6px 8px 40px 10px; min-width: 30px; }
.ce-ln { height: 20px; font-size: 12px; }
.ce-ln-cur { color: var(--ink); font-weight: 700; }
.ce-ln-err { color: #c62828; font-weight: 700; box-shadow: inset -3px 0 0 #c62828; }
.ce-main { position: relative; overflow: hidden; }
.ce-hl { position: absolute; top: 0; left: 0; padding: 6px 10px 40px; white-space: pre; min-width: 100%; box-sizing: border-box; pointer-events: none; tab-size: 4; color: var(--ink); }
.ce-line { height: 20px; }
.ce-proc { box-shadow: inset 0 1px 0 var(--rule-strong); }
.ce-input {
  position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; padding: 6px 10px 40px; margin: 0; border: 0;
  resize: none; outline: none; background: transparent; color: transparent; caret-color: var(--ink);
  font: inherit; line-height: inherit; white-space: pre; overflow: auto; tab-size: 4; font-variant-ligatures: none;
}
.ce-input::selection { background: rgba(31, 92, 74, .22); color: transparent; }
.ce-cur { background: #f3f7f4; }
.ce-kw { color: #1b3d9c; }
.ce-com { color: #2e7d32; }
.ce-str { color: #8a3b12; }
.ce-num { color: var(--ink); }
.ce-bad { color: #c62828; }
.ce-err, .ce-err span { color: #c62828; }
.ce-cerr { text-decoration: underline wavy #d97706; text-underline-offset: 4px; text-decoration-skip-ink: none; }

.doc-pane.vbe { display: grid; grid-template-columns: 220px 1fr; }
.vbe-side { border-right: 1px solid var(--rule-strong); background: var(--paper); overflow: auto; }
.vbe-side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--rule); }
.vbe-side-head h3 { margin: 0; font-size: var(--step-0); color: var(--green-dark); }
.vbe-group { padding: 10px 12px 4px; font-size: var(--step--1); font-weight: 700; color: var(--ink-soft); }
.vbe-item { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; text-align: left; padding: 4px 10px 4px 18px; cursor: pointer; font: inherit; }
.vbe-item:hover { background: var(--ledger); }
.vbe-item.active { background: var(--green-tint); box-shadow: inset 3px 0 0 var(--green); }
.vbe-item.empty { color: var(--ink-soft); }
.vbe-item .icon { color: var(--green); }
.vbe-none { padding: 2px 18px; color: var(--ink-soft); font-size: var(--step--1); }
.vbe-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.vbe-bar { display: flex; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.vbe-bar select.input { flex: 1; max-width: 320px; height: 28px; }
.vbe-banner { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; background: #fdecea; color: #8e1b14; border-bottom: 1px solid #f0b4ad; }
.vbe-banner[hidden] { display: none; }
.vbe-banner .btn { margin-left: auto; }
.vbe-banner .vbe-banner-acts { margin-left: auto; display: flex; gap: 6px; }
.vbe-banner .vbe-banner-acts .btn { margin-left: 0; }

/* AI help with errors */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
dialog.dlg.ai-dlg { width: min(640px, calc(100% - 32px)); }
dialog.dlg.ai-dlg.wide-ai { width: min(860px, calc(100% - 32px)); }
.ai-error { margin: 0 0 10px; padding: 8px 10px; background: #fdecea; color: #8e1b14; border-left: 3px solid #c0392b; }
.ai-body { min-height: 80px; max-height: 55vh; overflow: auto; }
.ai-text p { margin: 0 0 8px; line-height: 1.5; }
.ai-text ul { margin: 0 0 8px; padding-left: 20px; line-height: 1.5; }
.ai-text code, .ai-text pre { font-family: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, 'Liberation Mono', monospace; font-size: .92em; background: var(--pane); }
.ai-text code { padding: 0 3px; }
.ai-text pre { padding: 8px 10px; overflow: auto; margin: 0 0 8px; }
.ai-wait { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); }
.ai-spin { width: 16px; height: 16px; border: 2px solid var(--rule-strong); border-top-color: var(--green); border-radius: 50%; animation: ai-spin .8s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai-spin { animation-duration: 3s; } }
.ai-note { margin: 10px 0 0; font-size: var(--step--1); }
.ai-diff-head { margin: 10px 0 4px; font-weight: 600; }
.ai-diff { margin: 0; border: 1px solid var(--rule); font-family: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, 'Liberation Mono', monospace; font-size: 12.5px; line-height: 1.5; overflow: auto; background: #fff; }
.ai-d { display: flex; white-space: pre; padding: 0 8px 0 0; }
.ai-dmark { width: 18px; flex: none; text-align: center; color: var(--ink-soft); user-select: none; }
.ai-dadd { background: #e6f4ea; }
.ai-dadd .ai-dmark { color: #1e7e34; }
.ai-ddel { background: #fdecea; text-decoration: line-through; text-decoration-color: rgba(142, 27, 20, .35); }
.ai-ddel .ai-dmark { color: #8e1b14; }
.vbe-banner-close { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: #8e1b14; padding: 0 6px; }
.vbe-code { flex: 1; min-height: 0; position: relative; }
.vbe-code > .ce { position: absolute; inset: 0; }
.vbe-empty { padding: 24px; color: var(--ink-soft); margin: 0; }
.vbe-bottom { height: 170px; flex: none; border-top: 1px solid var(--rule-strong); display: flex; flex-direction: column; background: #fff; }
.vbe-tabs { display: flex; gap: 2px; background: var(--ledger); border-bottom: 1px solid var(--rule); padding: 3px 6px 0; }
.vbe-tab { border: 1px solid transparent; border-bottom: 0; background: none; padding: 3px 10px; cursor: pointer; font: inherit; font-size: var(--step--1); border-radius: var(--radius) var(--radius) 0 0; }
.vbe-tab[aria-selected="true"] { background: #fff; border-color: var(--rule); font-weight: 600; }
.vbe-imm { flex: 1; display: flex; flex-direction: column; min-height: 0; font-family: 'Cascadia Mono', Consolas, Menlo, monospace; font-size: 13px; }
.vbe-imm[hidden], .vbe-errpane[hidden] { display: none; }
.vbe-log { flex: 1; overflow: auto; padding: 4px 10px; }
.vbe-out { white-space: pre-wrap; }
.vbe-out.in { color: var(--ink-soft); }
.vbe-out.err { color: #c62828; }
.vbe-out.note { color: #8a5a0b; }
.vbe-imm-input { border: 0; border-top: 1px solid var(--rule); padding: 6px 10px; font: inherit; outline: none; }
.vbe-imm-input:focus { box-shadow: inset 0 2px 0 var(--green); }
.vbe-errpane { flex: 1; overflow: auto; }
.vbe-errors { list-style: none; margin: 0; padding: 0; }
.vbe-errors button { display: flex; gap: 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rule); background: none; padding: 5px 10px; cursor: pointer; font: inherit; }
.vbe-errors button:hover { background: var(--ledger); }
.vbe-errline { color: #c62828; font-weight: 600; min-width: 64px; }
.vbe-ok { padding: 8px 10px; color: var(--green); }
.vbe-status { display: flex; gap: 10px; padding: 3px 10px; border-top: 1px solid var(--rule); background: var(--paper); font-size: var(--step--1); color: var(--ink-soft); }
.vbe-status .spacer { flex: 1; }
@media (max-width: 760px) {
  .doc-pane.vbe { grid-template-columns: 1fr; }
  .vbe-side { display: none; }
}

/* ---------- users ---------- */

.users { padding: 16px; overflow: auto; }
.users h2 { margin: 0 0 12px; font-size: var(--step-1); }
table.list { border-collapse: collapse; width: 100%; max-width: 980px; }
.list th, .list td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.list th { background: var(--pane); font-weight: 600; }
.list td .btn + .btn { margin-left: 4px; }
.pill { font-size: var(--step--1); padding: 1px 7px; border-radius: 10px; background: var(--pane); }
.pill.admin { background: var(--green-tint); color: var(--green-dark); }
.pill.off { background: var(--danger-tint); color: var(--danger); }

/* ---------- dialogs and toasts ---------- */

dialog.dlg {
  border: 1px solid var(--rule-strong); border-top: 4px solid var(--green);
  padding: 20px 22px 16px; width: min(460px, calc(100% - 32px));
  box-shadow: 0 16px 40px rgba(20, 40, 30, .25); color: var(--ink);
}
dialog.dlg.warn { border-top-color: var(--amber); }
dialog.dlg::backdrop { background: rgba(32, 38, 42, .35); }
dialog.dlg h2 { margin: 0 0 10px; font-size: var(--step-1); }
dialog.dlg .body { margin-bottom: 16px; }
dialog.dlg ul { margin: 8px 0 0; padding-left: 20px; }
dialog.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; }
dialog.dlg.wide { width: min(980px, calc(100% - 32px)); max-height: calc(100% - 32px); }
dialog.dlg.wide form, dialog.dlg.wide { display: flex; flex-direction: column; }
dialog.dlg.wide:not([open]) { display: none; }
dialog.dlg.wide .body { overflow: auto; min-height: 0; flex: 1; }
/* Tools > References */
dialog.dlg.refs-dlg { width: min(560px, calc(100% - 32px)); }
.refs-label { margin: 0 0 6px; font-weight: 600; }
.refs-list { border: 1px solid var(--rule-strong); height: 250px; overflow: auto; background: #fff; }
.refs-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; cursor: default; user-select: none; }
.refs-row input { accent-color: var(--green); width: 15px; height: 15px; margin: 0; }
.refs-row.sel { background: var(--green-dark); color: #fff; }
.refs-row .refs-kind { margin-left: auto; font-size: var(--step--1); color: var(--ink-soft); }
.refs-row.sel .refs-kind { color: #dfe9e3; }
.refs-info { border: 1px solid var(--rule); margin-top: 10px; padding: 8px 10px; min-height: 64px; font-size: var(--step--1); }
.refs-info p { margin: 0 0 4px; }
.refs-info b { font-weight: 600; }
.imp h3, .imp-h { margin: 14px 0 6px; font-size: var(--step-0); color: var(--green-dark); }
.imp p { margin: 0 0 10px; }
.imp-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.imp-field { display: flex; align-items: center; gap: 8px; }
.imp-field .input { width: auto; }
.imp-check { display: flex; align-items: center; gap: 8px; padding: 3px 0; flex-wrap: wrap; }
.imp-check input[type="checkbox"], .imp-check input[type="radio"], .imp-list input[type="checkbox"], .imp-fields input[type="checkbox"] { accent-color: var(--green); width: 16px; height: 16px; }
.imp-dest { border: 1px solid var(--rule); padding: 6px 12px 8px; margin: 0 0 10px; }
.imp-dest legend { font-weight: 600; color: var(--green-dark); padding: 0 4px; }
.imp .imp-name { width: 240px; max-width: 100%; height: 30px; flex: none; }
.imp-fields { max-height: 300px; overflow: auto; border: 1px solid var(--rule); }
.imp-fields table.list, .imp-list { max-width: none; }
.imp-fields .input { height: 28px; }
.imp-size { width: 76px; }
.imp-sample { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-preview { max-height: 240px; overflow: auto; border: 1px solid var(--rule); }
.imp-preview table.sheet { font-size: var(--step--1); }
.imp-result { border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.imp-errors { max-height: 200px; overflow: auto; font-size: var(--step--1); }
.list td.num { text-align: right; }
.busy-dlg { width: auto; }
.busy { display: flex; align-items: center; gap: 12px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--green-tint); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--radius);
  max-width: 420px; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.toast.error { background: var(--danger); }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "ribbon" "main"; }
  .rb-label { display: none; }
  .ribbon-panel { min-height: 0; padding-bottom: 4px; }
  .qat { display: none; }
  .topbar .nav-toggle { display: inline-flex; }
  .topbar .dbname { display: none; }
  .nav {
    position: fixed; top: 44px; bottom: 0; left: 0; width: 260px; z-index: 30;
    transform: translateX(-100%); transition: transform .18s ease;
  }
  .shell.nav-open .nav { transform: none; box-shadow: 6px 0 18px rgba(0,0,0,.18); }
  .designer-head { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* DoCmd.Hourglass True / Screen.MousePointer = 11 */
.vba-wait, .vba-wait * { cursor: progress !important; }

/* ---------- conditional formatting ---------- */
dialog.dlg.cf-dlg { width: min(640px, calc(100% - 32px)); }
dialog.dlg.cf-dlg.wide { width: min(720px, calc(100% - 32px)); }
.cf-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.cf-lbl { color: var(--ink-soft); min-width: 92px; }
.cf-hint { margin: 10px 0 4px; font-weight: 600; }
.cf-buttons { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.cf-list { border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; max-height: 300px; overflow: auto; }
.cf-head, .cf-item { display: grid; grid-template-columns: 1fr 180px; gap: 10px; padding: 5px 8px; align-items: center; }
.cf-head { background: var(--ledger); border-bottom: 1px solid var(--rule); font-weight: 600; font-size: var(--step--1); position: sticky; top: 0; }
.cf-item { cursor: pointer; border-bottom: 1px solid var(--ledger); }
.cf-item.on { background: var(--green-tint); outline: 1px solid var(--green); outline-offset: -1px; }
.cf-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-empty { padding: 10px; margin: 0; }
.cf-preview { display: inline-block; min-width: 150px; padding: 3px 8px; border: 1px solid var(--rule); background: #fff; font-size: var(--step--1); text-align: center; }
.cf-preview.cf-disabled { background: #eee; }
.cf-kinds { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
.cf-kind { text-align: left; border: 0; background: none; padding: 6px 10px; font: inherit; cursor: pointer; }
.cf-kind.on { background: var(--green-tint); font-weight: 600; }
.cf-detail { border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 10px 8px; background: var(--paper); }
.cf-parts { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cf-val { width: 130px; }
.cf-expr { width: 320px; max-width: 100%; }
.cf-and { color: var(--ink-soft); }
.cf-toggle { min-width: 30px; }
.cf-toggle.on { background: var(--green-tint); border-color: var(--green); }
.cf-colour { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.cf-colour input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--rule); background: none; }
.cf-none { display: inline-flex; align-items: center; gap: 3px; font-size: var(--step--1); color: var(--ink-soft); }
.fv-ctl.cf-disabled, .fv-ctl .cf-disabled, td.cf-disabled { color: #9a9a9a !important; }
.cf-dlg .input { width: auto; }
.cf-dlg .cf-val { width: 140px; }
.cf-dlg .cf-expr { width: 340px; max-width: 100%; }

/* ---------- PivotTable view ---------- */
.pv-main { flex: 1; min-height: 0; display: flex; }
.pv-area { flex: 1; min-width: 0; overflow: auto; padding: 10px 12px 24px; background: #fff; }
.pv-fields { width: 250px; flex: none; border-left: 1px solid var(--rule); background: var(--paper); overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.pv-fields[hidden] { display: none; }
.pv-fields-head { display: flex; align-items: center; justify-content: space-between; }
.pv-field-list, .pv-field-list ul { list-style: none; margin: 0; padding: 0; }
.pv-field-list { border: 1px solid var(--rule); background: #fff; border-radius: var(--radius); flex: 1; overflow: auto; min-height: 120px; }
.pv-field { display: flex; justify-content: space-between; gap: 6px; padding: 3px 8px; cursor: grab; user-select: none; }
.pv-field:hover { background: var(--ledger); }
.pv-field.on { background: var(--green-tint); }
.pv-ftype { color: var(--ink-soft); font-size: var(--step--1); }
.pv-date { padding: 0 0 2px 14px; font-size: var(--step--1); }
.pv-date .pv-field { padding-left: 12px; }
.pv-addto { display: flex; gap: 6px; }
.pv-addto .input { width: auto; flex: 1; }
.pv-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 28px; padding: 3px 4px; border: 1px dashed transparent; border-radius: var(--radius); }
.pv-zone-filters { margin-bottom: 8px; border-color: var(--rule); background: var(--paper); }
.pv-zone.over { border-color: var(--green); background: var(--green-tint); }
.pv-area:not(.no-zones) .pv-zone { border-color: var(--rule); }
.pv-zone-hint { color: var(--ink-soft); font-size: var(--step--1); font-weight: 400; padding: 0 4px; }
.pv-area.no-zones .pv-zone:not(:has(.pv-chip)) { display: none; }
/* a PivotChart without field buttons and drop zones shows only the chart (Access 2010's toggle) */
.pv-area.no-zones .pc-layout .pv-zone { display: none; }
.pv-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 2px 2px 8px; border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--pane); font-weight: 600; font-size: var(--step--1); cursor: grab; white-space: nowrap; }
.pv-chip.active { outline: 2px solid var(--green); outline-offset: 1px; }
.pv-chip.filtered { color: var(--green-dark); }
.pv-chip svg { width: 12px; height: 12px; }
.pv-chip-btn { border: 0; background: none; cursor: pointer; padding: 0 4px; color: var(--ink-soft); font: inherit; }
.pv-chip-btn:hover { color: var(--ink); }
.pv-note { margin: 6px 0; }
.pv-table-wrap { display: inline-block; min-width: 100%; }
.pv-table { border-collapse: collapse; font-size: var(--step-0); }
.pv-table th, .pv-table td { border: 1px solid var(--rule); padding: 3px 8px; }
.pv-table thead th { background: var(--ledger); font-weight: 600; text-align: left; vertical-align: top; }
.pv-corner { background: #fff !important; vertical-align: bottom !important; min-width: 140px; }
.pv-corner .pv-zone + .pv-zone { margin-top: 4px; }
.pv-zone-cell { background: #fff !important; padding: 2px !important; }
.pv-item { white-space: nowrap; }
tbody .pv-item { background: var(--paper); font-weight: 600; text-align: left; }
.pv-pad { background: var(--paper); }
.pv-toggle { width: 16px; height: 16px; margin-right: 4px; padding: 0; line-height: 14px; border: 1px solid var(--rule-strong); background: #fff; border-radius: 2px; font-size: 12px; cursor: pointer; vertical-align: middle; }
.pv-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 70px; }
.pv-sub { background: #f3f6f4; font-weight: 600; }
.pv-subrow th, .pv-subrow td { background: #f3f6f4; font-weight: 600; }
.pv-grand, .pv-grandrow th, .pv-grandrow td, .pv-grand-h { background: var(--green-tint) !important; font-weight: 700; }
.pv-total-h { font-size: var(--step--1); white-space: nowrap; }
.pv-empty { background: #fafafa; }
.pv-hint { color: var(--ink-soft); padding: 10px !important; text-align: left; }
.pv-pop { position: fixed; z-index: 90; min-width: 200px; max-width: 320px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--rule-strong); box-shadow: 0 8px 24px rgba(20, 40, 30, .2); padding: 4px 0; border-radius: var(--radius); }
.pv-pop-title { padding: 6px 12px 2px; font-size: var(--step--1); color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pv-pop-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 12px; font: inherit; cursor: pointer; }
.pv-pop-item:hover, .pv-pop-item:focus-visible { background: var(--ledger); }
.pv-pop-item.on::before { content: '✓ '; color: var(--green); }
.pv-values { padding: 2px 12px 6px; }
.pv-value { display: flex; gap: 6px; align-items: center; padding: 1px 0; }
.pv-value-list { max-height: 200px; overflow: auto; border: 1px solid var(--rule); padding: 2px 6px; margin: 2px 0 6px; }
.pv-all { font-weight: 600; }
.pv-pop-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pv-grandrow th, tbody .pv-item.pv-sub { text-align: left; }

/* ---------- PivotChart view ---------- */
.pc .pv-area { display: flex; flex-direction: column; }
.pc-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.pc-top { display: flex; gap: 8px; flex-wrap: wrap; }
.pc-top .pv-zone { flex: 1; min-width: 200px; }
.pc-middle { flex: 1; min-height: 240px; display: flex; gap: 10px; }
.pc-host { flex: 1; min-width: 0; min-height: 0; overflow: auto; }
.pc-side { width: 200px; flex: none; display: flex; flex-direction: column; gap: 8px; }
.pc-legend-title { font-size: var(--step--1); font-weight: 600; color: #52514e; }
.pc-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--step--1); color: #0b0b0b; }
.pc-legend li { display: flex; align-items: center; gap: 6px; }
.pc-key { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.pc-key.line { height: 2px; width: 14px; border-radius: 1px; }
.pc-grid { display: grid; gap: 12px; }
.pc-title { text-align: center; margin: 2px 0 8px; color: var(--ink); line-height: 1.25; }
.pc-chart { position: relative; }
.pc-chart svg { display: block; overflow: visible; font-family: var(--font); }
.pc-num { font-variant-numeric: tabular-nums; }
.pc-mark { cursor: default; }
.pc-mark:hover, .pc-mark:focus-visible { filter: brightness(1.08); outline: none; }
.pc-mark:focus-visible { stroke: #0b0b0b; stroke-width: 1px; }
.pc-tip { position: absolute; z-index: 5; pointer-events: none; background: #fff; border: 1px solid rgba(11, 11, 11, .12); box-shadow: 0 6px 18px rgba(20, 40, 30, .16); border-radius: 4px; padding: 6px 9px; font-size: var(--step--1); min-width: 120px; white-space: nowrap; }
.pc-tip-head { color: #52514e; margin-bottom: 3px; }
.pc-tip-row { display: flex; align-items: center; gap: 6px; }
.pc-tip-row strong { color: #0b0b0b; font-variant-numeric: tabular-nums; }
.pc-tip-label { color: #52514e; }
.pc-empty { color: #52514e; max-width: 520px; margin: 24px auto; text-align: center; }
.pc .pv-zone-rows { min-height: 30px; }

/* ---------- debugging in the code window ---------- */
.ce-gutter { cursor: pointer; }
.ce-ln { position: relative; }
.ce-ln-bp::before { content: ''; position: absolute; left: -8px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #9b1c1c; }
.ce-ln-exec::after { content: ''; position: absolute; left: -9px; top: 5px; border: 5px solid transparent; border-left: 8px solid #d4a017; }
.ce-bp { background: #8e2a2a; }
.ce-bp, .ce-bp span { color: #fff !important; }
.ce-exec { background: #fff3a6 !important; }
.ce-exec, .ce-exec span { color: var(--ink) !important; }
.ce-exec-err { box-shadow: inset 3px 0 0 #c62828; }
.ce-tip { position: absolute; z-index: 6; pointer-events: none; background: #ffffe1; border: 1px solid #a8a17a; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); padding: 2px 6px; font-family: system-ui, sans-serif; font-size: 12.5px; white-space: nowrap; color: #111; }
.ce-tip b { font-weight: 700; }

/* ---------- code window: toolbar, Immediate, Locals and Watches ---------- */
.vbe-toolbar { display: flex; align-items: center; gap: 2px; padding: 3px 6px; border-bottom: 1px solid var(--rule); background: var(--paper); flex-wrap: wrap; }
.vbe-tool { width: 28px; height: 26px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--green-dark); cursor: pointer; }
.vbe-tool:hover:not(:disabled) { background: var(--ledger); border-color: var(--rule); }
.vbe-tool.on { background: var(--green-tint); border-color: var(--green); }
.vbe-tool:disabled { color: #b7beb9; cursor: default; }
.vbe-tool[data-cmd="code.run"]:not(:disabled) { color: #1a7f37; }
.vbe-tool[data-cmd="code.reset"]:not(:disabled), .vbe-tool[data-cmd="code.breakpoint"]:not(:disabled) { color: #9b1c1c; }
.vbe-sep { width: 1px; height: 18px; background: var(--rule); margin: 0 4px; }
.vbe-run-state { margin-left: auto; font-size: var(--step--1); color: var(--ink-soft); padding: 0 6px; }
.vbe-run-state.on { color: #7a5b00; background: #fff3a6; border-radius: 3px; font-weight: 600; }
.vbe-bottom { height: 200px; flex-direction: row; }
.vbe-imm { flex: 1; min-width: 0; border-right: 1px solid var(--rule-strong); }
.vbe-pane-title { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 2px 10px; background: var(--ledger); border-bottom: 1px solid var(--rule); font-family: var(--font); font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); }
.vbe-imm-text { flex: 1; min-height: 0; border: 0; resize: none; outline: none; padding: 4px 10px; font: inherit; line-height: 18px; white-space: pre; overflow: auto; }
.vbe-imm-text:focus { box-shadow: inset 0 2px 0 var(--green); }
.vbe-side-pane { width: 42%; min-width: 280px; display: flex; flex-direction: column; min-height: 0; }
.vbe-pane { flex: 1; overflow: auto; min-height: 0; }
.vbe-pane[hidden] { display: none; }
.vbe-grid { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.vbe-grid th { text-align: left; background: var(--paper); border-bottom: 1px solid var(--rule); padding: 3px 8px; position: sticky; top: 0; font-weight: 600; color: var(--ink-soft); }
.vbe-grid td { border-bottom: 1px solid var(--ledger); padding: 2px 8px; font-family: 'Cascadia Mono', Consolas, Menlo, monospace; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.vbe-watch-input { width: 100%; border-radius: 0; border-width: 0 0 1px; height: 28px; }
.vbe-x { border: 0; background: none; color: var(--ink-soft); cursor: pointer; margin-left: 6px; }
.vbe-stack { margin: 0; padding: 6px 10px 6px 30px; font-family: 'Cascadia Mono', Consolas, Menlo, monospace; font-size: var(--step--1); }

/* ---------- code window: the lists offered as you type (IntelliSense) ---------- */
.ce-list { position: absolute; z-index: 7; min-width: 190px; max-width: 360px; max-height: 164px; overflow-y: auto; background: #fff; border: 1px solid #8a948e; box-shadow: 0 3px 10px rgba(0, 0, 0, .18); font-family: system-ui, sans-serif; font-size: 12.5px; color: #111; padding: 1px 0; }
.ce-list-item { display: flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px 0 4px; white-space: nowrap; cursor: default; }
.ce-list-item.sel { background: #1f5c4a; color: #fff; }
.ce-list-item.sel.soft { background: none; color: inherit; outline: 1px dotted #1f5c4a; outline-offset: -1px; }
.ce-list-icon { width: 10px; height: 10px; flex: none; border-radius: 1px; background: #9aa39d; }
.k-method .ce-list-icon { background: #7a3fb0; transform: rotate(45deg) scale(.85); }
.k-property .ce-list-icon, .k-field .ce-list-icon, .k-control .ce-list-icon { background: #2f6db5; border-radius: 2px 5px 2px 5px; }
.k-constant .ce-list-icon, .k-enum .ce-list-icon { background: #8b8f8c; height: 6px; }
.k-class .ce-list-icon, .k-form .ce-list-icon { background: #c27c13; border-radius: 0; box-shadow: inset 0 0 0 2px #e5b867; }
.k-variable .ce-list-icon { background: #1a7f6b; border-radius: 50%; }
.k-keyword .ce-list-icon { background: none; border: 1px solid #555; height: 8px; width: 8px; }
.ce-list-item.sel .ce-list-icon { box-shadow: 0 0 0 1px #fff; }
.vbe-imm { position: relative; } /* the Immediate window's lists sit inside it */

/* ---------- reports ---------- */

.reportdoc-body > .rp-scroll { flex: 1; }
.rp-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--ledger); padding: 20px; }
.rp-scroll:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.rp-continuous { width: fit-content; margin: 0 auto; background: #fff; box-shadow: 0 2px 10px rgba(20, 40, 30, .14); }
.rp-continuous .rp-content { position: relative; }
.rp-pages { display: flex; gap: 24px; justify-content: center; align-items: flex-start; min-width: fit-content; }
.rp-holder { position: relative; flex: none; }
.rp-page { position: absolute; left: 0; top: 0; background: #fff; box-shadow: 0 2px 10px rgba(20, 40, 30, .22); transform-origin: 0 0; overflow: hidden; color: #000; }
.rp-page .rp-content { position: absolute; overflow: hidden; }
.rp-sec { position: absolute; left: 0; overflow: hidden; }
.rp-ctl { position: absolute; box-sizing: border-box; overflow: hidden; }
.rp-label, .rp-text { display: flex; align-items: center; white-space: nowrap; }
.rp-text.multi { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.rp-err { color: #b3261e; }
.rp-check { display: flex; align-items: center; justify-content: center; }
.rp-box { width: 13px; height: 13px; border: 1px solid #333; position: relative; }
.rp-box.on::after { content: ''; position: absolute; left: 3.5px; top: .5px; width: 4px; height: 8px; border: solid #000; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.rp-image { display: flex; align-items: center; justify-content: center; }
.rp-image img { width: 100%; height: 100%; }
.rp-rect { border: 1px solid #000; }
.rp-link { display: flex; align-items: center; color: #1a56a8; text-decoration: underline; white-space: nowrap; }
.rp-nav { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-top: 1px solid var(--rule); background: var(--paper); font-size: var(--step--1); }
.rp-nav .rp-pagebox { width: 4em; text-align: center; padding: 2px 4px; }
.rp-nav .rp-zoom { width: auto; padding: 2px 4px; }
.rp-note { margin: 0; padding: 6px 12px; background: var(--amber-tint); border-bottom: 1px solid var(--rule); font-size: var(--step--1); }
.rp-reportview .rp-note { margin: 12px auto 0; width: fit-content; border: 1px solid var(--rule); }

/* Report Design view: the Group, Sort, and Total pane */
.rd-centre { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.rd-centre > .fd-canvas { flex: 1; min-height: 0; }
.rd-groups { flex: none; max-height: 38%; overflow: auto; border-top: 1px solid var(--rule-strong); background: var(--paper); font-size: var(--step--1); }
.rd-groups-head { display: flex; align-items: center; padding: 4px 8px 2px 12px; position: sticky; top: 0; background: var(--paper); }
.rd-groups-head h3 { margin: 0; font-size: var(--step--1); color: var(--green-dark); }
.rd-levels { padding: 2px 8px; }
.rd-level { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 4px 8px; margin: 2px 0; background: #fff; border: 1px solid var(--rule); border-left: 3px solid var(--green); }
.rd-level.sort { border-left-color: var(--rule-strong); }
.rd-level .input { width: auto; padding: 2px 4px; font-size: var(--step--1); }
.rd-what { font-weight: 600; min-width: 5em; }
.rd-add { display: flex; gap: 8px; padding: 6px 16px 10px; }
.rd-add .btn { display: inline-flex; align-items: center; gap: 4px; }
.fd-bar-note { font-weight: 400; opacity: .75; }

/* printing a report: only its pages, on paper of its size (see reportdoc.js) */
@media screen { .rp-print-root { display: none; } }
@media print {
  body.printing-report > *:not(.rp-print-root) { display: none !important; }
  body.printing-report { margin: 0; background: #fff; }
  .rp-print-root .rp-page { position: relative; box-shadow: none; break-after: page; page-break-after: always; transform: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rp-print-root .rp-page:last-child { break-after: auto; page-break-after: auto; }
}

/* Access's Import Objects dialog */
.imp-objects { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.imp-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--rule-strong); }
.imp-tab { border: 1px solid var(--rule); border-bottom: 0; background: var(--ledger); padding: 5px 10px; font: inherit; font-size: var(--step--1); cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.imp-tab[aria-selected="true"] { background: #fff; border-color: var(--rule-strong); color: var(--green-dark); font-weight: 600; position: relative; top: 1px; }
.imp-pane { border: 1px solid var(--rule-strong); border-top: 0; padding: 8px; height: 320px; overflow: auto; background: #fff; }
.imp-pane .imp-list { width: 100%; }
.imp-side { display: flex; flex-direction: column; gap: 8px; min-width: 150px; padding-top: 30px; }
.imp-option { display: flex; flex-direction: column; gap: 4px; font-size: var(--step--1); margin-top: 10px; }
.imp-note { font-size: var(--step--1); color: var(--ink-soft); }
.imp-later { padding: 8px 10px; background: var(--amber-tint); font-size: var(--step--1); }
.imp-names { columns: 2; font-size: var(--step--1); margin: 0; padding-left: 20px; }
.imp-queries { font-size: var(--step--1); padding-left: 20px; }
@media (max-width: 760px) { .imp-objects { grid-template-columns: 1fr; } .imp-side { flex-direction: row; flex-wrap: wrap; padding-top: 0; } }
.imp-warn { color: #7a5009; }
.imp-later p { margin: 0 0 6px; }
.imp-later ol { margin: 0 0 8px; padding-left: 20px; }
.imp-later li { margin: 2px 0; }
.imp-choose { display: flex; gap: 8px; flex-wrap: wrap; }

/* a label's Text Orientation (formview.js applyBox) */
.orient-down, .orient-up { writing-mode: vertical-rl; }
.orient-up { transform: rotate(180deg); }

/* the Chart control */
.fv-chart, .fd-chart-view { background: #fff; overflow: hidden; }
.fd-chart-view { position: absolute; inset: 0; pointer-events: none; }
.fv-chart .chart-svg, .fd-chart-view .chart-svg { display: block; font-family: inherit; }
.fv-chart-error { position: absolute; left: 6px; right: 6px; bottom: 4px; margin: 0; padding: 4px 6px; font-size: 12px; color: #b3261e; background: rgba(255, 255, 255, .92); }
.fd-prop-head { margin: 10px 0 2px; padding-bottom: 2px; border-bottom: 1px solid var(--rule); font-size: var(--step--1); font-weight: 600; color: var(--green-dark); }

/* ---------- demo mode ---------- */

.demo-box { margin: 4px 0 22px; padding: 14px 16px; background: var(--ledger); border: 1px solid var(--rule-strong); }
.demo-box h2 { font-size: var(--step-1, 18px); margin: 0 0 6px; }
.demo-box p { margin: 0 0 12px; }
.demo-start { width: 100%; justify-content: center; }
.login-ended { margin: 0 0 16px; padding: 8px 10px; background: var(--amber-tint); border-left: 3px solid var(--amber); }
.demo-note { display: flex; align-items: center; gap: 8px; font-size: var(--step--1); }
.demo-text { opacity: .9; }
.topbar .demo-end { background: var(--amber-tint); color: var(--ink); border-color: transparent; }
.topbar .demo-end:hover { background: #fff; }
@media (max-width: 900px) { .demo-text { display: none; } }

/* ---------- TreeView (Microsoft TreeView Control 6.0) ---------- */

.tv {
  --tv-row: 22px; --tv-line: #9aa3a0;
  overflow: auto; background: #fff; color: var(--ink); border: 1px solid var(--rule-strong);
  padding: 2px 0; outline: none; user-select: none; box-sizing: border-box;
}
.tv.tv-flat { border-color: var(--rule); }
.tv.tv-noborder { border-color: transparent; }
.tv.tv-noscroll { overflow: hidden; }
.tv:focus-visible { box-shadow: inset 0 0 0 2px var(--green); }
.tv-row { display: flex; align-items: center; height: var(--tv-row); white-space: nowrap; padding: 0 6px 0 2px; cursor: default; }
.tv-g { position: relative; flex: none; width: var(--tv-indent); height: 100%; }
.tv-lines .tv-g.line::before, .tv-elbow.on::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px dotted var(--tv-line); }
.tv-elbow.on:not(.more)::before { bottom: 50%; }
.tv-elbow.on.first::before { top: 50%; }
.tv-elbow.on.first:not(.more)::before { display: none; }
.tv-elbow.on::after { content: ''; position: absolute; left: 50%; right: 1px; top: 50%; border-top: 1px dotted var(--tv-line); }
.tv-exp {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; transform: translate(-50%, -50%); z-index: 1;
  background: #fff; border: 1px solid #8a948f; box-sizing: border-box; cursor: pointer;
}
.tv-exp::before { content: ''; position: absolute; left: 1px; right: 1px; top: 3px; border-top: 1px solid #333; }
.tv-exp.plus::after { content: ''; position: absolute; top: 1px; bottom: 1px; left: 3px; border-left: 1px solid #333; }
.tv-check { margin: 0 3px 0 2px; }
.tv-pic { flex: none; margin-right: 4px; object-fit: contain; }
.tv-text { padding: 1px 3px; border: 1px solid transparent; border-radius: 2px; line-height: 1.25; }
.tv-row.selected .tv-text { background: #dde6e1; }
.tv:focus .tv-row.selected .tv-text { background: var(--green); color: #fff; }
.tv-hide-sel:not(:focus) .tv-row.selected .tv-text { background: transparent; }
.tv-fullrow .tv-row.selected { background: #dde6e1; }
.tv-fullrow:focus .tv-row.selected { background: var(--green); }
.tv-fullrow .tv-row.selected .tv-text { background: transparent; }
.tv-fullrow:focus .tv-row.selected .tv-text { color: #fff; }
.tv-hot .tv-row:hover .tv-text { text-decoration: underline; color: #1a5fb4; }
.tv-disabled { color: var(--ink-soft); background: #f4f5f3; }
.tv-edit { font: inherit; padding: 0 2px; border: 1px solid var(--ink); min-width: 90px; height: calc(var(--tv-row) - 3px); box-sizing: border-box; }
/* an ImageList holds pictures for other controls: a small box in Design view, nothing in Form view */
.fd-imagelist { display: grid; place-items: center; background: #f4f5f3; border: 1px dashed var(--rule-strong); color: var(--ink-soft); }
.fd-treeview .tv { width: 100%; height: 100%; pointer-events: none; }
.fv-tree > .tv { width: 100%; height: 100%; }
.fv-imagelist { display: none; }
.fd-images { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: 260px; overflow: auto; }
.fd-images { min-width: 0; }
.fd-images li { display: grid; grid-template-columns: 18px 22px minmax(0, 1fr) auto auto; gap: 4px; align-items: center; }
.fd-images .input { padding: 2px 4px; min-width: 0; height: 26px; }
.fd-prop.fd-prop-wide { grid-template-columns: minmax(0, 1fr); }
