/* ─────────────────────────────────────────────────────────────────────────
   The app's own styles. Everything that exists in the prototype's
   componenten.css is used from there (served from _basis/); this file
   adds only what the prototype never needed: forms that save, the door,
   loading and error states, and the layout on a phone.
   ───────────────────────────────────────────────────────────────────────── */

/* ── the door (sign in) ───────────────────────────────────────────── */
#topbar.tb-door-only { display: none; }
.stage.door { overflow: auto; }
.door-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.door-card { width: min(420px, 100%); padding: 28px 28px 22px; background: var(--card); border: 1px solid var(--card-line); border-radius: var(--r-xl); box-shadow: var(--card-shadow); }
.door-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.door-brand .logo { width: 28px; height: 28px; }
.door-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.door-sub { margin-top: 6px; font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.door-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.door-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-faint); }
.door-list { margin: 16px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.door-list li code, .door-note code { font-family: var(--f-mono); font-size: 12.5px; padding: 2px 6px; border-radius: 4px; background: var(--fill); }
.door-note { font-size: 12.5px; color: var(--text-3); line-height: 1.55; margin-top: 10px; }
.btn.wide { width: 100%; height: 36px; }

/* ── loading, errors ──────────────────────────────────────────────── */
.skeleton { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.skeleton i { display: block; height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--fill) 0%, var(--fill-hover) 50%, var(--fill) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton i:nth-child(1) { height: 120px; border-radius: var(--card-r); }
.skeleton i:nth-child(2) { width: 70%; }
.skeleton i:nth-child(3) { width: 45%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.btn.busy { opacity: 0.6; cursor: progress; }
.btn.danger { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.danger:hover { filter: brightness(0.95); }
.form-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; margin-bottom: 4px; border-radius: 8px; background: var(--attn-soft); color: var(--signal); font-size: 13px; font-weight: 600; line-height: 1.45; }
.form-error .i { margin-top: 1px; flex: none; }
.toast.bad { background: var(--signal); }

/* ── forms ────────────────────────────────────────────────────────── */
.modal-body form, .modal-body .form { display: flex; flex-direction: column; gap: 14px; }
form.modal .modal-body { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field.wide { grid-column: 1 / -1; }
.field.bad .input, .field.bad .select, .field.bad .textarea { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal); }
.field.bad > label { color: var(--signal); }
.field .hint, .check-field .hint { font-size: 11.5px; color: var(--text-3); line-height: 1.45; }
.field .opt { font-weight: 400; color: var(--text-3); }
.field.money .input, .field.rate .input { font-variant-numeric: tabular-nums; }
.form-note { font-size: 12.5px; color: var(--text-3); line-height: 1.55; }
.form-section { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.form-section + .form-section { border-top: 1px solid var(--line-faint); padding-top: 14px; }
.form-section-h { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.check-field { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.check-field input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-field .toggle-ui { width: 30px; height: 18px; flex: none; margin-top: 1px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background var(--d-fast) var(--ease); }
.check-field .toggle-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--d) var(--ease-out); }
.check-field input:checked + .toggle-ui { background: var(--ink); }
.check-field input:checked + .toggle-ui::after { transform: translateX(12px); }
.check-field input:focus-visible + .toggle-ui { outline: 2px solid var(--ink); outline-offset: 2px; }
.check-field .col { gap: 2px; }

/* a setting in a card: what it does, and the control on the right */
.set-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-faint); }
.set-row:last-child { border-bottom: 0; }
.set-row .main { flex: 1; min-width: 0; }
.set-row .t { font-size: 13.5px; font-weight: 600; }
.set-row .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.set-row .end { flex: none; display: flex; gap: 8px; align-items: center; }
.set-row .input, .set-row .select { width: auto; min-width: 140px; }

/* a value you need elsewhere (KvK, VAT, IBAN): one click on the field or on
   the icon behind it copies it; the icon turns into a check for a moment */
.copy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.copy-box { position: relative; }
.copy-box .input { padding-right: 36px; cursor: copy; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
.copy-box .input:hover { border-color: var(--line-strong); }
.copy-box.copied .input { border-color: var(--ink); }
.copy-btn { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; color: var(--text-3); cursor: pointer; }
.copy-btn:hover { background: var(--fill-hover); color: var(--text); }
.copy-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.copy-btn .i + .i, .copy-box.copied .copy-btn .i:first-child { display: none; }
.copy-box.copied .copy-btn .i + .i { display: block; color: var(--text); }
.copy-none { height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); font-size: 13px; color: var(--text-3); }
button.copy-none { width: 100%; cursor: pointer; }
button.copy-none:hover { color: var(--text); border-color: var(--ink); }

/* a fact list in a card */
dl.facts.tight { gap: 6px 16px; font-size: 13px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* a table inside a card (settings, schedules) */
.card-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.card-table th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.card-table td { padding: 8px; border-bottom: 1px solid var(--line-faint); vertical-align: middle; }
.card-table tr:last-child td { border-bottom: 0; }
.card-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.card-table tr.past td { color: var(--text-3); }
.card-table tr.attn td { color: var(--signal); }
.card-table tfoot td { border-top: 1px solid var(--line-strong); font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* the colour picker (colour.js): the palette, and any colour on a wheel.
   Hue round the circle, saturation from the middle out, brightness as a
   black veil over it; the sliders draw their own gradients. */
.cpick { display: flex; flex-direction: column; gap: 16px; }
.cpick-presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cpick-preset { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px; background: var(--tone); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); cursor: pointer; }
.cpick-preset.on { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ink); }
.cpick-preset:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.cpick-preset.more { position: relative; border-radius: 50%; background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cpick-preset.more::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--tone, var(--bg-elev)); box-shadow: 0 0 0 1.5px var(--bg-elev); }
.cpick-preset:disabled { cursor: default; }
.cpick-body { display: none; gap: 24px; align-items: center; flex-wrap: wrap; }
.cpick.open .cpick-body { display: flex; }
.cpick-wheel {
  position: relative; flex: none; width: 184px; height: 184px; border-radius: 50%;
  cursor: crosshair; touch-action: none; outline: none; user-select: none;
  background: radial-gradient(circle closest-side, #fff, rgba(255, 255, 255, 0)), conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.cpick-wheel:focus-visible { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ink); }
.cpick-dim { position: absolute; inset: 0; border-radius: 50%; background: #000; pointer-events: none; }
.cpick-knob { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35); pointer-events: none; transition: transform var(--d-fast) var(--ease); }
.cpick-wheel.drag .cpick-knob { transform: scale(1.18); }
.cpick.off .cpick-wheel { cursor: default; }
.cpick-side { flex: 1 1 240px; min-width: 0; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.cpick-row { display: flex; align-items: center; gap: 10px; }
.cpick-k { flex: none; width: 76px; font-size: 12.5px; color: var(--text-3); }
.cpick-range { flex: 1; min-width: 0; height: 12px; margin: 0; border-radius: 6px; background: var(--grad); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); -webkit-appearance: none; appearance: none; cursor: pointer; }
.cpick-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3); }
.cpick-range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3); }
.cpick-range::-moz-range-track { background: transparent; }
.cpick-range:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.cpick-range:disabled { cursor: default; }
.cpick-num, .cpick-num-gap { flex: none; width: 64px; }
.cpick-num { text-align: right; font-variant-numeric: tabular-nums; }
.cpick-hex { flex: none; width: 104px; font-family: var(--f-mono); text-transform: uppercase; }
.cpick-rgb { font-size: 12.5px; color: var(--text-3); font-family: var(--f-mono); white-space: nowrap; }
.cpick-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }

/* a company's logo: on a white tile in both themes, so a dark logo stays visible */
.mono-tile.has-logo { padding: 1px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.mono-tile.has-logo.lg, .mono-tile.has-logo.xl { padding: 3px; }
.mono-tile.has-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-set { display: flex; gap: 18px; align-items: center; }
.logo-box { flex: none; width: 112px; height: 112px; padding: 12px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; box-shadow: inset 0 0 0 1px var(--card-line); transition: box-shadow var(--d-fast) var(--ease); }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-box.empty { background: var(--bg-sunken); }
.logo-box.over { box-shadow: inset 0 0 0 2px var(--ink); }

/* the "where it came from" of a figure: imported, calculated, estimated, reviewed, filed */
.src-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-strong); white-space: nowrap; }
.src-tag.estimate { border-style: dashed; }
.src-tag.filed, .src-tag.reviewed { color: var(--text); border-color: var(--ink); }

/* the sync status of a connection, quiet unless something is wrong */
.sync-line { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.sync-line.bad { color: var(--signal); font-weight: 600; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--money-in, #2f9e44); }
.sync-line.bad .sync-dot { background: var(--signal); }
.sync-line.idle .sync-dot { background: var(--line-strong); }

/* a list of links on a record (task ↔ email, document ↔ transaction) */
.links { display: flex; flex-direction: column; }
.link-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--line-faint); }
.link-row:last-child { border-bottom: 0; }
.link-row .i { color: var(--text-3); }
.link-row a, .link-row button.go { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.link-row a:hover, .link-row button.go:hover { text-decoration: underline; text-underline-offset: 3px; }

/* drop a file anywhere in a zone */
.dropzone.drop-on { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.dropzone input[type="file"] { display: none; }

/* a document preview inside the app (sandboxed by the server) */
.doc-frame { width: 100%; height: 70vh; border: 1px solid var(--card-line); border-radius: 8px; background: var(--bg-elev); }
.doc-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--card-line); }

/* who a bill is addressed to, beside where it is booked (money.js › adrBlock) */
.adr-ok { margin: 10px 0 4px; }
dl.facts dd.adr-ent { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── the phone: one column, the side menu as a strip ─────────────── */
@media (max-width: 900px) {
  #app { min-width: 0; }
  body { overflow: auto; }
  #topbar { grid-template-columns: minmax(0, 1fr) auto !important; height: auto; min-height: var(--topbar-h); padding: 6px 8px !important; row-gap: 4px; }
  #topbar .tb-center { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; }
  #topbar .tb-right .cmd-btn { width: auto; }
  #topbar .tb-right .cmd-btn .grow, #topbar .tb-right .cmd-btn kbd { display: none; }
  #topbar .lens-name { max-width: 110px; }
  .wordmark, .tb-slash, .tb-where { display: none; }
  .stage { overflow: visible; }
  .ptool { height: auto; min-height: var(--bar-h); flex-wrap: wrap; padding: 8px 12px; margin-left: 0 !important; padding-left: 12px !important; white-space: normal; }
  .ptool .cw-search, .ptool .lg-search { width: 100% !important; }
  .rw, .rw.two, .cw, .lg-ws, .railed, .lg-main { display: flex; flex-direction: column; padding: 0 12px 12px; gap: 12px; }
  .stage > * > .rw-rail:first-child { margin: 0 -12px; border-radius: 0; padding: 6px 8px; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--frame-edge); }
  .rw-rail .rw-views { flex-direction: row; gap: 4px; }
  .rw-rail .rw-label, .rw-rail .rw-foot, .rw-rail .rw-block { display: none; }
  .rw-rail .rw-view { flex: none; height: 32px; }
  .rw-rail .rw-view.sub { padding-left: 9px; }
  .rw-list, .lg-ledger { max-height: 60vh; }
  .rw-record, .lg-record { min-height: 50vh; }
  .rw-wrap { padding: 16px; }
  .lg-cols { --lg-cols: minmax(0, 1fr) auto !important; }
  .lg-cols > :not(:first-child):not(.lg-amt):not(:last-child) { display: none; }
  .page { padding: 4px 12px 48px; }
  .stand { padding: 14px; }
  .stand-fig { font-size: 24px; line-height: 30px; }
  .modal { top: 0; width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .peek-panel { top: 0 !important; right: 0 !important; bottom: 0 !important; width: 100vw !important; border-radius: 0 !important; }
  .stage.docked { margin-right: 0; }
  #peek.dock .peek-panel { top: 0; }
  .cw-col { flex-basis: 85vw; }
  .split2 { grid-template-columns: 1fr; }
}
