/* ZoneACC logo colours. The webapp draws its logo as plain paths in one colour; these rules
   paint them like the other Zone tiles: tile = house blue gradient (#zoneacc-g in index.html),
   band = #ffc6ff, receipt = white, wordmark = --ink (#1d1d1f) or, on dark, #f5f5f7. */
svg[data-icon="zoneacc"] path:nth-of-type(1),
svg[data-icon="zoneacc-alt"] path:nth-of-type(1),
svg[data-icon="mini-zoneacc"] path:nth-of-type(1) { fill: url(#zoneacc-g) !important; }
svg[data-icon="zoneacc"] path:nth-of-type(2),
svg[data-icon="zoneacc-alt"] path:nth-of-type(2),
svg[data-icon="mini-zoneacc"] path:nth-of-type(2) { fill: #ffc6ff !important; }
svg[data-icon="zoneacc"] path:nth-of-type(3),
svg[data-icon="zoneacc-alt"] path:nth-of-type(3),
svg[data-icon="mini-zoneacc"] path:nth-of-type(3) { fill: #fff !important; }
svg[data-icon="zoneacc"] path:nth-of-type(4),
svg[data-icon="zoneacc-alt"] path:nth-of-type(4) { fill: #1d1d1f; fill-rule: nonzero; }
.bp4-dark svg[data-icon="zoneacc"] path:nth-of-type(4),
.bp4-dark svg[data-icon="zoneacc-alt"] path:nth-of-type(4) { fill: #f5f5f7; }
svg[data-icon="zoneacc"][fill] path:nth-of-type(4),
svg[data-icon="zoneacc-alt"][fill] path:nth-of-type(4) { fill: inherit; }

/* Sign-in pages (login, sign-up, reset, invite), laid out like ZoneCRM's and ZoneCHAT's: light
   grey page, one small white card with the app tile and name at its top, a dark single-sign-on
   button and a light e-mail option. Always light, like the other apps' sign-in pages. The
   stock page has no stable class names, so the parts are found by structure with :has(); a
   browser without :has() keeps the stock layout with these colours. */
html:has(> body.authentication),
body.authentication {
  background: #f5f5f7 !important;
  color-scheme: light;
}
body.authentication {
  min-height: 100vh;
  color: #333 !important;
  font: 13px/1.4 -apple-system, "system-ui", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
/* The app has a 1100px minimum width; the sign-in pages fit a phone. */
body.authentication .App { min-width: 0 !important; }
/* Column: as wide as the other apps' card, a little below the top. */
body.authentication .App > div > div {
  width: 349px !important;
  max-width: calc(100% - 32px);
  padding-top: min(22vh, 180px) !important;
}
/* The big logo above the card and the small one below it: the card carries the name instead. */
body.authentication .App > div > div > div:first-child:has(> svg),
body.authentication div:has(> .bp4-icon-zoneacc) { display: none !important; }

/* Card */
body.authentication div:has(> form) {
  background: #fff !important;
  border: 0.5px solid #e8e8ed !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04) !important;
  padding: 24px 24px 20px !important;
  color: #333 !important;
}
body.authentication div:has(> form)::before {
  content: "Legibooks";
  display: block;
  height: 23px;
  padding-left: 31px;
  margin-bottom: 16px;
  background: url("/zoneacc-icon.svg") no-repeat left center / 23px 23px;
  font-weight: 600;
  line-height: 23px;
  color: #333;
}
body.authentication div:has(> form) > div:first-child:has(button)::before {
  content: "Welcome to Legibooks";
  display: block;
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.1;
  color: #333;
}

/* Buttons: pill-shaped, 13px semibold, like the other apps. */
body.authentication div:has(> form) .bp4-button.bp4-fill.bp4-large {
  min-height: 30px !important;
  height: auto !important;
  padding: 8px 12px !important;
  border-radius: 16px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  background-image: none !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .04), 0 0 0 .5px rgba(0, 0, 0, .12) !important;
}
/* Single sign-on: dark, with a key. */
body.authentication div:has(> form) .bp4-button.bp4-fill:not(.bp4-intent-primary) {
  background-color: #333 !important;
  color: #fff !important;
  border: 0 !important;
}
body.authentication div:has(> form) .bp4-button.bp4-fill:not(.bp4-intent-primary):hover { background-color: #1d1d1f !important; }
body.authentication div:has(> form) .bp4-button.bp4-fill:not(.bp4-intent-primary) .bp4-button-text {
  display: inline-flex; align-items: center; gap: 8px; color: #fff !important;
}
body.authentication div:has(> form) .bp4-button.bp4-fill:not(.bp4-intent-primary) svg { display: none; }
body.authentication div:has(> form) .bp4-button.bp4-fill:not(.bp4-intent-primary) .bp4-button-text::before {
  content: "";
  width: 16px; height: 16px; flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16.555 3.843l3.602 3.602a2.877 2.877 0 0 1 0 4.069l-2.643 2.643a2.877 2.877 0 0 1 -4.069 0l-.301 -.301l-6.558 6.558a2 2 0 0 1 -1.239 .578l-.175 .008h-1.172a1 1 0 0 1 -.993 -.883l-.007 -.117v-1.172a2 2 0 0 1 .467 -1.284l.119 -.13l.414 -.414h2v-2h2v-2l2.144 -2.144l-.301 -.301a2.877 2.877 0 0 1 0 -4.069l2.643 -2.643a2.877 2.877 0 0 1 4.069 0'/%3E%3Cpath d='M15 9h.01'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16.555 3.843l3.602 3.602a2.877 2.877 0 0 1 0 4.069l-2.643 2.643a2.877 2.877 0 0 1 -4.069 0l-.301 -.301l-6.558 6.558a2 2 0 0 1 -1.239 .578l-.175 .008h-1.172a1 1 0 0 1 -.993 -.883l-.007 -.117v-1.172a2 2 0 0 1 .467 -1.284l.119 -.13l.414 -.414h2v-2h2v-2l2.144 -2.144l-.301 -.301a2.877 2.877 0 0 1 0 -4.069l2.643 -2.643a2.877 2.877 0 0 1 4.069 0'/%3E%3Cpath d='M15 9h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* E-mail sign-in: light. */
body.authentication div:has(> form) .bp4-button.bp4-intent-primary {
  background-color: #fff !important;
  color: #333 !important;
  border: 0 !important;
}
body.authentication div:has(> form) .bp4-button.bp4-intent-primary:hover { background-color: #f5f5f7 !important; }
body.authentication div:has(> form) .bp4-button.bp4-intent-primary .bp4-button-text { color: #333 !important; }
body.authentication div:has(> form) .bp4-button.bp4-intent-primary:focus-visible,
body.authentication div:has(> form) .bp4-button.bp4-fill:focus-visible { outline: 2px solid #0071e3 !important; outline-offset: 2px; }

/* "or" between the two */
body.authentication div:has(> form) div:has(> span):not(.bp4-form-group *) { color: #86868b !important; }
body.authentication div:has(> form) > div:first-child > div:last-child::before,
body.authentication div:has(> form) > div:first-child > div:last-child::after { background: #e8e8ed !important; border-color: #e8e8ed !important; }
body.authentication div:has(> form) > div:first-child > div:last-child span { color: #86868b !important; background: #fff !important; font-size: 11px; }

/* Fields */
body.authentication .bp4-form-group { margin-bottom: 14px; }
body.authentication .bp4-label,
body.authentication .bp4-label .bp4-text-muted,
body.authentication .bp4-control { color: #333 !important; font-size: 13px; }
body.authentication .bp4-label { font-weight: 600; margin-bottom: 6px !important; }
body.authentication .bp4-input {
  height: 34px !important;
  background: #fff !important;
  color: #1d1d1f !important;
  border-radius: 8px !important;
  border: 1px solid #d2d2d7 !important;
  box-shadow: none !important;
  font-size: 13px !important;
}
body.authentication .bp4-input::placeholder { color: #86868b !important; }
body.authentication .bp4-input:focus { border-color: #0071e3 !important; box-shadow: 0 0 0 3px rgba(0, 113, 227, .2) !important; }
body.authentication .bp4-input-action .bp4-button { margin: 4px !important; }
body.authentication .bp4-input-action .bp4-icon { color: #86868b !important; }
body.authentication .bp4-control .bp4-control-indicator {
  background: #fff !important;
  box-shadow: inset 0 0 0 1px #d2d2d7 !important;
}
body.authentication .bp4-control input:checked ~ .bp4-control-indicator {
  background-color: #0071e3 !important;
  box-shadow: none !important;
}

/* Links under the card */
body.authentication div:has(> form) ~ div { text-align: center; margin-top: 16px; }
body.authentication div:has(> form) ~ div p { color: #6e6e73 !important; font-size: 12px; margin: 0 0 6px; }
body.authentication div:has(> form) ~ div a { color: #0071e3 !important; }

/* Light theme: stylesheet rules Bigcapital wrote for the dark theme only (it always ran dark).
   Component styles are fixed in patch_webapp.py (light theme). */
body:not(.bp4-dark) .financial-header-drawer .bp4-tabs.bp4-vertical .bp4-tab-list { border-right-color: #e1e2e8; }
body:not(.bp4-dark) .batch-form-table.batch-allocations-table--sale td { border-top-color: #e1e2e8; }
/* Muted text: Bigcapital uses the dark theme's grey (#abb3bf) on white too, which hardly reads. */
body:not(.bp4-dark) { --color-muted-text: #6b7480; }

/* New workspace, invite step: the role picker fills its column (zone_workspace_ui.py). */
.zoneacc-invite-role .bp4-popover-wrapper,
.zoneacc-invite-role .bp4-popover-target { display: block; width: 100%; }
.zoneacc-invite-role .bp4-button-text { flex: 1; text-align: left; }

/* Drawer tabs (bill, invoice, expense details): the selected tab was the pale primary blue and,
   once clicked, wore the browser's focus box. The focus
   ring shows only for keyboard focus. Selected: dark text over a brand-blue bar; hover: blue. */
.bp4-drawer .bp4-tab-list > .bp4-tab { font-weight: 500; transition: color .15s; }
.bp4-drawer .bp4-tab-list > .bp4-tab:focus:not(:focus-visible) { outline: none; }
.bp4-drawer .bp4-tab-list > .bp4-tab:focus-visible { outline: 2px solid #0071e3; outline-offset: 2px; border-radius: 4px; }
body:not(.bp4-dark) .bp4-drawer .bp4-tab-list > .bp4-tab { color: #6b7480; }
body:not(.bp4-dark) .bp4-drawer .bp4-tab-list > .bp4-tab:not([aria-disabled="true"]):hover { color: #0071e3; }
body:not(.bp4-dark) .bp4-drawer .bp4-tab-list > .bp4-tab[aria-selected="true"] { color: #1d1d1f; }
body:not(.bp4-dark) .bp4-drawer .bp4-tab-list .bp4-tab-indicator-wrapper .bp4-tab-indicator { background-color: #0071e3; border-radius: 2px 2px 0 0; }

/* Homepage dashboard (webapp/home.js, put in place of the shortcut grid by patch_webapp.py). */
.zoneacc-home { --zh-card: #fff; --zh-tile: #f3f4f7; --zh-line: #e3e5ea; --zh-text: #1d1d1f; --zh-muted: #6b7180;
  --zh-good: #1a7f4b; --zh-bad: #c23030; --zh-warn-bg: #fdf1d7; --zh-warn: #8a5a00; --zh-bad-bg: #fbe6e6;
  --zh-in: #1d9e75; --zh-out: #b4b2a9; --zh-accent: #0071e3;
  max-width: 1120px; padding: 24px 28px 40px; color: var(--zh-text); font-size: 13px; }
.bp4-dark .zoneacc-home { --zh-card: #252a31; --zh-tile: #2b313a; --zh-line: #3a414c; --zh-text: #f5f5f7; --zh-muted: #a7adb8;
  --zh-good: #5fd39a; --zh-bad: #ff8a8a; --zh-warn-bg: #4a3a12; --zh-warn: #ffd27a; --zh-bad-bg: #4a1e1e; --zh-out: #6b6a64; --zh-accent: #4da3ff; }
.zoneacc-home a, .zoneacc-home a:hover { color: inherit; text-decoration: none; }
.zh-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.zh-greet { font-size: 20px; font-weight: 600; }
.zh-sub, .zh-loading, .zh-label, .zh-mlabel, .zh-legend { color: var(--zh-muted); }
.zh-actions { display: flex; gap: 8px; }
.zh-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.zoneacc-home .zh-tile { display: block; background: var(--zh-tile); border-radius: 10px; padding: 14px 16px; transition: background .15s; }
.zoneacc-home .zh-tile:hover { background: var(--zh-line); }
.zh-value { font-size: 24px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.zh-good { color: var(--zh-good); } .zh-bad { color: var(--zh-bad); } .zh-note { color: var(--zh-muted); }
.zh-note.zh-good { color: var(--zh-good); } .zh-note.zh-bad { color: var(--zh-bad); }
.zh-cards { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; margin-bottom: 14px; }
.zh-card { background: var(--zh-card); border: 1px solid var(--zh-line); border-radius: 12px; padding: 14px 16px; }
.zh-wide { grid-column: 1 / -1; }
.zh-card-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.zh-legend { font-weight: 400; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.zoneacc-home .zh-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 4px; border-top: 1px solid var(--zh-line); font-variant-numeric: tabular-nums; }
.zoneacc-home .zh-row:hover { background: var(--zh-tile); }
.zh-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--zh-accent); }
.zh-dot.zh-cc { background: #b5179e; }
.zh-count { min-width: 28px; text-align: center; padding: 1px 8px; border-radius: 6px; background: var(--zh-tile); }
.zh-count-warn { background: var(--zh-warn-bg); color: var(--zh-warn); } .zh-count-bad { background: var(--zh-bad-bg); color: var(--zh-bad); }
.zh-chart { display: flex; gap: 18px; height: 140px; align-items: stretch; padding-top: 6px; }
.zh-month { flex: 1; display: flex; flex-direction: column; }
.zh-bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; }
.zh-bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.zh-in { background: var(--zh-in); } .zh-out { background: var(--zh-out); }
.zh-key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-left: 8px; }
.zh-mlabel { text-align: center; padding-top: 4px; font-size: 12px; }
.zh-links { display: flex; flex-wrap: wrap; gap: 8px; }
.zoneacc-home .zh-link { border: 1px solid var(--zh-line); border-radius: 8px; padding: 7px 12px; background: var(--zh-card); }
.zoneacc-home .zh-link:hover { border-color: var(--zh-accent); color: var(--zh-accent); }
@media (max-width: 760px) { .zh-cards { grid-template-columns: minmax(0, 1fr); } .zoneacc-home { padding: 16px; } }
.zh-status.zh-busy { color: var(--zh-accent); }

/* Bank account page: "Export" downloads the account's bank lines (webapp/statement.js). */
dialog.zb-stmt { --zs-bg: #fff; --zs-text: #1d1d1f; --zs-muted: #6b7180; --zs-bad: #c23030;
  position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100vh - 32px);
  border: 0; border-radius: 12px; padding: 20px 22px; width: min(380px, calc(100vw - 32px));
  background: var(--zs-bg); color: var(--zs-text); box-shadow: 0 12px 40px rgba(0,0,0,.25); font-size: 13px; }
dialog.zb-stmt.bp4-dark { --zs-bg: #252a31; --zs-text: #f5f5f7; --zs-muted: #a7adb8; --zs-bad: #ff8a8a; }
dialog.zb-stmt::backdrop { background: rgba(16,22,26,.45); }
.zb-stmt h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.zb-stmt .zb-stmt-acc, .zb-stmt .zb-stmt-note { margin: 0 0 14px; color: var(--zs-muted); }
.zb-stmt .zb-stmt-note { margin: 12px 0 0; font-size: 12px; }
.zb-stmt label { display: flex; flex-direction: column; gap: 4px; flex: 1; font-weight: 500; }
.zb-stmt .zb-stmt-row { display: flex; gap: 10px; margin-bottom: 12px; }
.zb-stmt .bp4-input { width: 100%; }
.zb-stmt .zb-stmt-err { margin: 10px 0 0; color: var(--zs-bad); }
.zb-stmt .zb-stmt-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Bank Accounts page as a list (webapp/accounts_list.js). */
.zb-accts { --za-line: #e3e5ea; --za-muted: #6b7180; --za-hover: #f5f7fa; --za-warn: #a15c00; --za-bg: #fff;
  background: var(--za-bg); border: 1px solid var(--za-line); border-radius: 8px; overflow-x: auto; }
.bp4-dark .zb-accts { --za-line: #3a414c; --za-muted: #a7adb8; --za-hover: #2b313a; --za-warn: #ffc56b; --za-bg: #252a31; }
.zb-accts > a { display: block; }
.zb-acct-row { display: grid; grid-template-columns: minmax(220px, 2.4fr) minmax(70px, .7fr) repeat(2, minmax(120px, 1fr)) minmax(100px, .8fr);
  gap: 16px; align-items: center; min-width: 680px; padding: 11px 16px; border-top: 1px solid var(--za-line); font-size: 13px; }
.zb-accts > :nth-child(2) .zb-acct-row, .zb-acct-head + .zb-acct-row { border-top-color: var(--za-line); }
.zb-acct-head { border-top: 0; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--za-muted); padding-block: 9px; }
.zb-accts a:hover .zb-acct-row { background: var(--za-hover); }
.zb-acct-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.zb-acct-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zb-acct-name small, .zb-acct-code { color: var(--za-muted); font-size: 12px; }
.zb-accts .zb-num { text-align: right; font-variant-numeric: tabular-nums; }
.zb-acct-diff { color: var(--za-warn); font-weight: 600; }
.zb-acct-open { font-weight: 600; }
.zb-acct-loading { color: var(--za-muted); }

/* Legibooks (branding/legibooks/make_variant.py): the logo's six paths in Legibooks' colours,
   over the ZoneBOOKS colours above; and no single sign-on on the sign-in pages. */
svg[data-icon="zoneacc"] path:nth-of-type(1), svg[data-icon="zoneacc-alt"] path:nth-of-type(1),
svg[data-icon="mini-zoneacc"] path:nth-of-type(1) { fill: #1c3d6e !important; }
svg[data-icon="zoneacc"] path:nth-of-type(2), svg[data-icon="zoneacc-alt"] path:nth-of-type(2),
svg[data-icon="mini-zoneacc"] path:nth-of-type(2) { fill: #fff !important; }
svg[data-icon="zoneacc"] path:nth-of-type(3), svg[data-icon="zoneacc-alt"] path:nth-of-type(3),
svg[data-icon="mini-zoneacc"] path:nth-of-type(3) { fill: #3b8fd9 !important; }
svg[data-icon="zoneacc"] path:nth-of-type(4), svg[data-icon="zoneacc-alt"] path:nth-of-type(4),
svg[data-icon="mini-zoneacc"] path:nth-of-type(4) { fill: #9cccf5 !important; }
svg[data-icon="zoneacc"] path:nth-of-type(5), svg[data-icon="zoneacc-alt"] path:nth-of-type(5) { fill: #0f2240 !important; }
svg[data-icon="zoneacc"] path:nth-of-type(6), svg[data-icon="zoneacc-alt"] path:nth-of-type(6) { fill: #275a94 !important; }
.bp4-dark svg[data-icon="zoneacc"] path:nth-of-type(5), .bp4-dark svg[data-icon="zoneacc-alt"] path:nth-of-type(5) { fill: #f3f6fb !important; }
.bp4-dark svg[data-icon="zoneacc"] path:nth-of-type(6), .bp4-dark svg[data-icon="zoneacc-alt"] path:nth-of-type(6) { fill: #4d9be0 !important; }
body.authentication div:has(> form) > div:first-child:has(button) > * { display: none !important; }
