/* BAP Business Hub — staff interface. Field-service back office: calm teal ink, amber for attention.
   Layout: sticky header, one centred column, bottom tab bar on phones, top tabs on wide screens. */
:root {
  --bg: #f2f5f4; --surface: #ffffff; --raised: #f8faf9; --ink: #14201e; --muted: #57686a; --line: #d6dfdc; --control-line: #7a8b88;
  --accent: #0b6e60; --accent-ink: #ffffff; --accent-soft: #dcefe9;
  --warn: #9a5800; --warn-soft: #fbefd8; --bad: #b3261e; --bad-soft: #fbe4e1; --ok: #2b7a35; --ok-soft: #e1f1e3;
  --font-display: "Secular One", "IBM Plex Sans Hebrew", "Noto Sans Hebrew", Arial, sans-serif;
  --font-body: "IBM Plex Sans Hebrew", "Noto Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 10px; --nav-h: 62px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1413; --surface: #161f1d; --raised: #1b2522; --ink: #e5eeeb; --muted: #9bb0ab; --line: #2a3733; --control-line: #5d726d;
  --accent: #43b9a3; --accent-ink: #062019; --accent-soft: #15352f;
  --warn: #e3a64b; --warn-soft: #382a13; --bad: #f08b80; --bad-soft: #3c1a17; --ok: #7fc586; --ok-soft: #1a321e;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0e1413; --surface: #161f1d; --raised: #1b2522; --ink: #e5eeeb; --muted: #9bb0ab; --line: #2a3733; --control-line: #5d726d;
  --accent: #43b9a3; --accent-ink: #062019; --accent-soft: #15352f;
  --warn: #e3a64b; --warn-soft: #382a13; --bad: #f08b80; --bad-soft: #3c1a17; --ok: #7fc586; --ok-soft: #1a321e;
  color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=date]:focus-within, input[type=time]:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.bap-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.bap-header-row { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.bap-brand { font: 22px/1.1 var(--font-display); letter-spacing: .01em; }
.bap-brand small { display: block; font: 12px/1.3 var(--font-body); color: var(--muted); }
.bap-spacer { flex: 1; }
.bap-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.bap-demo-banner { background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center;
  padding-block: 6px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

main.bap-main { max-width: 760px; margin: 0 auto; padding-block: 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 14px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font: 24px/1.2 var(--font-display); }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.bap-muted { color: var(--muted); }
.bap-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.bap-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bap-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.bap-nav { position: fixed; inset: auto 0 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.bap-nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 760px; display: flex;
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.bap-nav ul::-webkit-scrollbar { display: none; }
.bap-nav li { flex: 1 0 auto; min-width: 58px; }
.bap-nav a { padding: 0 10px; white-space: nowrap; }
.bap-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--nav-h); gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12.5px; border-top: 3px solid transparent; }
.bap-nav a .bap-nav-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.bap-nav a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }
.bap-nav a .bap-nav-label { font-size: 14px; }
@media (min-width: 900px) {
  .bap-nav { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 57px); inset: auto; border-top: 0; border-bottom: 1px solid var(--line); }
  .bap-nav a { flex-direction: row; height: 46px; border-top: 0; border-bottom: 3px solid transparent; }
  .bap-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
  main.bap-main { padding-bottom: 32px; }
}

.bap-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bap-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .bap-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.bap-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.bap-tile b { font: 28px/1.1 var(--font-num); font-variant-numeric: tabular-nums; }
.bap-tile.is-warn { border-color: var(--warn); background: var(--warn-soft); }
.bap-tile.is-bad { border-color: var(--bad); background: var(--bad-soft); }

.bap-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bap-list > li + li { border-top: 1px solid var(--line); }
.bap-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; text-align: right; cursor: pointer; min-height: 56px; }
.bap-item:hover { background: var(--raised); }
.bap-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bap-item-main span { overflow-wrap: anywhere; }
.bap-time { font: 600 15px/1.2 var(--font-num); font-variant-numeric: tabular-nums; min-width: 3.4em; color: var(--accent); }
.bap-empty { padding: 18px 14px; color: var(--muted); text-align: center; }

.bap-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--raised); color: var(--muted); border: 1px solid var(--line); }
.bap-pill.s-new, .bap-pill.s-open, .bap-pill.s-booked { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.bap-pill.s-qualified, .bap-pill.s-in_progress, .bap-pill.s-contacted { background: var(--raised); color: var(--ink); }
.bap-pill.s-won, .bap-pill.s-completed, .bap-pill.s-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.bap-pill.s-lost, .bap-pill.s-cancelled, .bap-pill.s-no_show, .bap-pill.s-spam, .bap-pill.s-disqualified { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.bap-pill.s-blocked, .bap-pill.p-high, .bap-pill.is-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.bap-pill.p-urgent, .bap-pill.is-bad { background: var(--bad); color: var(--surface); border-color: transparent; }

.bap-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.bap-filters button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.bap-filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.bap-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 600; text-decoration: none; }
.bap-btn.is-quiet { background: var(--surface); color: var(--accent); }
.bap-btn.is-danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.bap-btn:disabled { opacity: .55; cursor: not-allowed; }

.bap-form { display: flex; flex-direction: column; gap: 12px; }
.bap-field { display: flex; flex-direction: column; gap: 4px; }
.bap-field label { font-size: 13.5px; color: var(--muted); }
.bap-field input, .bap-field select, .bap-field textarea { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--control-line); background: var(--surface); }
/* Form controls need 3:1 against their background (WCAG 1.4.11); checkboxes at least 24px (2.5.8). */
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea { border-color: var(--control-line); }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex: none; }
.bap-field textarea { min-height: 80px; resize: vertical; }
.bap-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bap-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.bap-slots button { min-width: 4.6em; min-height: 44px; border-radius: 8px; border: 1px solid var(--control-line); background: var(--surface); cursor: pointer; font-family: var(--font-num); }
.bap-slots button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.bap-sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 13, .45); display: flex; align-items: flex-end; justify-content: center; }
.bap-sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 16px 16px 0 0;
  padding-block: 16px calc(16px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 700px) { .bap-sheet-back { align-items: center; } .bap-sheet { border-radius: 16px; } }
.bap-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin: 0; }
.bap-kv dt { color: var(--muted); }
.bap-kv dd { margin: 0; overflow-wrap: anywhere; }
.bap-note { font-size: 13px; color: var(--muted); }
.bap-toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); }
.bap-error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; }
.bap-bar { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.bap-bar span { display: block; height: 100%; background: var(--accent); }
.bap-login { max-width: 420px; margin: 8vh auto 0; }
.bap-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bap-section-title a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
/* Skip link: hidden until it receives keyboard focus. */
.bap-skip { position: absolute; inset-inline-start: 8px; top: -100px; z-index: 20; padding: 10px 14px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.bap-skip:focus { top: 8px; }
.bap-sheet:focus { outline: none; }

.bap-tab { font-variant-numeric: tabular-nums; }
.bap-daybar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.bap-daybar h2 { text-align: center; }
.bap-daybar .bap-btn { min-width: 44px; padding: 0 12px; font-size: 18px; }
.bap-stock { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.bap-qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bap-stock-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bap-stock-lines li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted);
  padding: 4px 8px; border-radius: 6px; background: var(--raised); }
.bap-stock-lines li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.bap-stock-lines li.is-expired { background: var(--bad-soft); color: var(--bad); }
/* Names and titles come from data and may mix Hebrew and English: let each line pick its own direction. */
.bap-item-main strong, .bap-item-main span, .bap-sheet h2 { overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.bap-service-row { gap: 8px; padding: 10px; background: var(--raised); }
.bap-service-row input, .bap-service-row select { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--control-line); background: var(--surface); }
.bap-pre { white-space: pre-line; }
.bap-row > select { min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--control-line); background: var(--surface); max-width: 100%; }
.bap-field input[type=color] { padding: 4px; height: 44px; }
/* Custom role editor: permissions grouped by area (decision A8). */
fieldset.bap-card { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset.bap-card legend { font-weight: 600; padding: 0 4px; }
fieldset.bap-card label.bap-row { min-height: 40px; flex-wrap: nowrap; cursor: pointer; }
