/* Lead Ace Portal PWA.
   Layout follows the Power App (1366x768 tablet frame: 16px padding, white header band, 30/70
   list and form split). Colours and type follow simplifiedbusinessolutions.ph. */
:root {
  --navy: #1e3a5f; --navy-deep: #15293f; --navy-900: #0f1f30;
  --teal: #3cbfd6; --teal-bright: #4ac6e0; --blue: #2f74b5;
  --ink: #1b2733; --slate: #5a6b7b; --slate-light: #8a99a8;
  --line: #e3e9ef; --bg: #ffffff; --bg-soft: #f5f8fb; --bg-mist: #eef4f9;
  --amber: #f5a623; --green: #1f9d63; --red: #c62828;
  --grad: linear-gradient(135deg, #2f74b5 0%, #3cbfd6 60%, #4ac6e0 100%);
  --grad-deep: linear-gradient(150deg, #15293f 0%, #1e3a5f 55%, #235682 100%);
  --shadow-sm: 0 2px 8px rgba(21, 41, 63, .06);
  --shadow-md: 0 12px 30px rgba(21, 41, 63, .10);
  --shadow-lg: 0 24px 60px rgba(21, 41, 63, .16);
  --r: 16px; --r-sm: 10px;
  --font: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tap: 44px;            /* minimum touch target */
  --pad: 16px;
  /* surfaces and text that themes override */
  --panel: #dfeaf2; --sel: #e2f5fa; --tile: rgba(255, 255, 255, .74); --tile-hover: rgba(255, 255, 255, .92); --brand-text: var(--navy); --field-line: #000; --photo: url('../assets/img/home.webp');
  --scale: 1; --senior: 1;
  font-size: calc(16px * var(--scale) * var(--senior));
}
/* Senior-friendly mode: larger text, larger targets, stronger contrast, no motion. */
:root.senior { --senior: 1.25; --tap: 56px; --slate: #3d4a57; --slate-light: #55636f; --line: #b9c6d2; }
:root.senior * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--navy-900); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--pad); padding: var(--pad); }
.screen.photo { background: var(--navy-900) var(--photo) left bottom / cover no-repeat; }
.screen.module { background: var(--bg-mist); gap: 10px; }

/* ---------- header band ---------- */
.band { display: flex; align-items: center; gap: 12px; min-height: 75px; padding: 8px 12px 8px 14px; border-radius: 8px; background: var(--bg); box-shadow: var(--shadow-sm); }
.band.primary { min-height: 68px; border-radius: 0; background: var(--grad-deep); color: #fff; }
.band .logo { width: 52px; height: 52px; flex: none; border-radius: 10px; background: #fff url('../assets/img/logo-mark.png') center / 82% no-repeat; }
.band:not(.primary) .logo { width: 150px; border-radius: 0; background: transparent url('../assets/img/logo-full.png') left center / contain no-repeat; }
[data-theme="dark"] .band:not(.primary) .logo { width: 52px; border-radius: 10px; background: #fff url('../assets/img/logo-mark.png') center / 82% no-repeat; }
.band h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.25rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band .who { font-size: .8125rem; color: var(--slate); text-align: right; line-height: 1.25; }
.band.primary .who { color: #cfe3f3; }
.icon-btn { display: inline-grid; place-items: center; width: 63px; height: 57px; flex: none; border: 0; border-radius: 4px; background: var(--navy); color: #fff; }
.band.primary .icon-btn { background: rgba(255, 255, 255, .14); }
.icon-btn:hover { background: var(--blue); }
.icon-btn svg { width: 34px; height: 34px; }
.icon-btn.small { width: var(--tap); height: var(--tap); background: transparent; color: inherit; }
.icon-btn.small svg { width: 24px; height: 24px; }
.band:not(.primary) .icon-btn.small:hover { background: var(--bg-mist); }

.demo-tag { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--amber); color: #3b2a00; font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
/* ---------- status pill (network / sync / quick save) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 0; border-radius: 999px; background: var(--bg-mist); color: var(--brand-text); font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.pill.offline { background: #fff3d6; color: #6b4700; } .pill.offline::before { background: var(--amber); }
.pill.pending { background: #e2f5fa; color: #0d5a6b; } .pill.pending::before { background: var(--teal); }
.band.primary .pill { background: rgba(255, 255, 255, .92); }
.offline-bar { padding: 8px 16px; background: #fff3d6; color: #6b4700; font-size: .875rem; font-weight: 600; text-align: center; }

/* ---------- sign-in panel ---------- */
.center { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: flex-start; overflow: auto; }
.panel { width: min(450px, 100%); min-height: 500px; padding: 30px 36px 28px; border-radius: 50px; background: var(--panel); color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow-lg); }
.panel.dark { background: var(--grad-deep); color: #fff; justify-content: center; }
.panel .avatar { width: 93px; height: 93px; color: var(--brand-text); }
.panel h2 { margin: 0 0 8px; font-size: 2.1875rem; font-weight: 500; text-align: center; }
.panel p { margin: 0; text-align: center; color: var(--slate); line-height: 1.45; }
.panel.dark p { color: #cfe3f3; }
.field-lg { width: 100%; height: 50px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 4px; background: var(--bg); font-size: 1.5rem; }
:root.senior .field-lg { height: 60px; }
.msg { width: 100%; min-height: 1.5em; font-size: 1rem; }
.msg.err { color: var(--red); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--brand-text); font-weight: 600; font-size: .9375rem; white-space: nowrap; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover:not(:disabled) { background: var(--bg-mist); }
.btn.primary { background: var(--navy); color: #fff; } .btn.primary:hover:not(:disabled) { background: var(--blue); }
.btn.secondary { border-color: var(--slate-light); background: var(--bg); }
.btn.accent { background: var(--grad); color: #06212e; }
.btn.big { min-height: 57px; padding: 0 28px; font-size: 1.5625rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ms { width: 100%; min-height: 54px; border-color: #8c8c8c; background: var(--bg); color: #2b2b2b; font-size: 1.0625rem; }
.ms-logo { width: 22px; height: 22px; background: conic-gradient(from 0deg at 50% 50%, #7fba00 0 25%, #ffb900 0 50%, #00a4ef 0 75%, #f25022 0); }
.link { border: 0; background: none; color: var(--blue); font-weight: 600; text-decoration: underline; min-height: var(--tap); padding: 0 8px; }
.hint { font-size: .875rem; color: var(--slate); text-align: center; }
.pin-dots { display: flex; gap: 12px; margin: 6px 0; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--navy); }
.pin-dots i.on { background: var(--navy); }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; }
.keypad button { height: 60px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.625rem; font-weight: 600; color: var(--brand-text); }
.keypad button:active { background: var(--bg-mist); }
:root.senior .keypad { grid-template-columns: repeat(3, 88px); } :root.senior .keypad button { height: 68px; }
.steps { display: flex; gap: 6px; width: 100%; margin-bottom: 4px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: #b9cbd9; } .steps i.on { background: var(--navy); }

/* ---------- menu tiles ---------- */
.tiles { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(220px, 1fr); gap: 16px; padding: 2px; }
.tile { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 10px 5px; border: 0; border-radius: 4px; background: var(--tile); color: var(--brand-text); }
.tile:hover, .tile:focus-visible { background: var(--tile-hover); }
.tile img { width: 200px; height: 170px; object-fit: contain; border-radius: 10px; }
.tile img.sm { width: 150px; height: 140px; }
.tile span { padding-top: 20px; font-size: 1.875rem; font-weight: 700; }
.tile small { font-size: .875rem; font-weight: 600; color: var(--slate); }

/* ---------- popups ---------- */
.scrim { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-start; padding: 140px 16px 16px; background: rgba(15, 31, 48, .35); overflow: auto; }
.card { width: min(527px, 100%); padding: 20px; border-radius: 10px; background: var(--bg); box-shadow: var(--shadow-lg); }
.card.wide { width: min(760px, 100%); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.card-head h3 { flex: 1; margin: 0; font-size: 1.0625rem; font-weight: 700; }
.pick { display: block; width: 100%; min-height: 57px; margin-bottom: 2px; border: 0; background: var(--bg-mist); color: var(--brand-text); font-size: .9375rem; font-weight: 600; }
.pick:hover, .pick:focus-visible { background: var(--navy); color: #fff; }
.card p { margin: 0 0 14px; line-height: 1.5; }
.card .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- module: list + form ---------- */
.body { flex: 1; min-height: 0; display: flex; gap: 16px; padding-top: 4px; }
.side { flex: 3; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--bg); }
.main { flex: 7; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.search { display: flex; align-items: center; gap: 6px; min-height: 44px; padding-right: 5px; background: var(--bg-soft); }
.search select { color: var(--ink); width: 130px; height: var(--tap); border: 1px solid var(--navy); border-radius: 4px; background: var(--bg); font-size: .75rem; padding: 0 4px; }
.search input { color: var(--ink); flex: 1; min-width: 0; height: var(--tap); border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; background: var(--bg); }
.rows { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); }
.row { display: block; width: 100%; padding: 10px 10px 10px 12px; border: 0; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; background: var(--bg); text-align: left; min-height: var(--tap); }
.row:hover { background: var(--bg-soft); }
.row[aria-selected="true"] { background: var(--sel); border-left-color: var(--teal); }
.row b { display: block; font-size: .9375rem; }
.row span { display: block; font-size: .8125rem; color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg-mist); color: var(--brand-text); font-size: .75rem; font-weight: 700; }
.tag.Open { background: #eef4f9; } .tag.Pending { background: #fff3d6; color: #6b4700; } .tag.Released { background: #e0f5ea; color: #0f5b38; } .tag.device { background: #e2f5fa; color: #0d5a6b; }
.empty { padding: 24px 12px; color: var(--slate); text-align: center; line-height: 1.5; }
.count { font-size: .75rem; color: var(--slate); padding: 0 2px; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; min-height: 60px; padding: 6px 6px 6px 12px; background: var(--bg); position: relative; }
.toolbar .btn { min-height: max(32px, var(--tap) - 8px); padding: 0 12px; font-size: .875rem; }
.menu { position: absolute; z-index: 20; min-width: 250px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); box-shadow: var(--shadow-md); }
.menu .btn { width: 100%; justify-content: flex-start; min-height: var(--tap); }

.form-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-soft); padding-top: 8px; }
.form-wrap.editing { background: var(--bg); }
.ref { padding: 0 15px; min-height: 30px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 8px 15px 0; overflow-x: auto; border-bottom: 2px solid var(--line); }
.tabs button { min-height: var(--tap); padding: 0 16px; border: 0; border-radius: 6px 6px 0 0; background: transparent; color: var(--slate); font-weight: 600; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; }
.form { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-content: start; padding: 4px 0 12px; }   /* 1, 2 or 3 columns by the room available */
:root.senior .form { grid-template-columns: 1fr; }
.fld { padding: 10px 24px 0; min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld label { display: block; height: 22px; font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fld label .req { color: var(--red); margin-right: 3px; }
.fld .ctl { display: flex; gap: 4px; margin-top: 4px; }
.fld input, .fld select, .fld textarea { color: var(--ink); flex: 1; min-width: 0; min-height: max(36px, var(--tap) - 6px); padding: 4px 10px; border: 1px solid #c4ced8; border-bottom-color: var(--slate); border-radius: 4px; background: var(--bg); }
.fld textarea { min-height: 84px; resize: vertical; }
.fld input:disabled, .fld select:disabled, .fld textarea:disabled, .fld input[readonly] { background: var(--bg-soft); color: var(--ink); opacity: 1; border-color: var(--line); }
.fld .lk { width: max(36px, var(--tap) - 6px); flex: none; border: 1px solid var(--navy); border-radius: 4px; background: var(--bg); color: var(--brand-text); display: grid; place-items: center; }
.fld .lk svg { width: 18px; height: 18px; }
.fld .err { min-height: 18px; font-size: .75rem; color: var(--red); font-weight: 600; }
.fld.bad input, .fld.bad select { border-color: var(--red); }
.form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 60px; padding: 8px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form-foot .saved { margin-right: auto; font-size: .8125rem; color: var(--slate); }
.confirm { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; font-size: 1rem; text-align: center; padding: 24px; }
.confirm .actions { display: flex; gap: 15px; }

/* lines / attachments / sync tables */
.table-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { position: sticky; top: 0; background: var(--bg-mist); color: var(--brand-text); text-align: left; font-weight: 700; padding: 10px 12px; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.sel td { background: var(--sel); }
tbody tr { cursor: pointer; }
.totals { display: flex; justify-content: flex-end; gap: 28px; padding: 10px 16px; background: var(--bg); font-weight: 700; flex-wrap: wrap; }
.totals span { color: var(--slate); font-weight: 600; margin-right: 8px; }

.settings { display: grid; gap: 14px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting b { display: block; } .setting small { color: var(--slate); }
.switch { width: 58px; height: 32px; flex: none; border: 0; border-radius: 999px; background: #b9c6d2; position: relative; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--teal); } .switch[aria-checked="true"]::after { left: 30px; }

#toasts { position: fixed; z-index: 50; top: 12px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(560px, calc(100% - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: var(--r-sm); background: var(--navy-deep); color: #fff; font-weight: 600; box-shadow: var(--shadow-md); }
.toast.ok { background: #14633f; } .toast.warn { background: #7a5200; } .toast.err { background: #8e1c1c; }

/* ---------- themes (Settings > Theme). Navy is the default, from simplifiedbusinessolutions.ph ---------- */
[data-theme="steel"]    { --navy: #287086; --navy-deep: #1e5465; --navy-900: #102c34; --blue: #3e7e92; --teal: #5991a2; --bg-mist: #e3eef1; --panel: #d4e2e7; --sel: #dcebef; --grad-deep: linear-gradient(150deg, #194553 0%, #287086 60%, #3e7e92 100%); }
[data-theme="ocean"]    { --navy: #0b5cad; --navy-deep: #084a8c; --navy-900: #06284d; --blue: #1a7fd6; --teal: #35b6e6; --bg-mist: #e8f2fc; --panel: #d8e8f8; --sel: #dbeefd; --grad-deep: linear-gradient(150deg, #084a8c 0%, #0b5cad 55%, #1a7fd6 100%); }
[data-theme="teal"]     { --navy: #0f766e; --navy-deep: #0b5a54; --navy-900: #06322f; --blue: #14958b; --teal: #2dd4bf; --bg-mist: #e6f5f3; --panel: #d5ece9; --sel: #d9f3ef; --grad-deep: linear-gradient(150deg, #0b5a54 0%, #0f766e 55%, #14958b 100%); }
[data-theme="forest"]   { --navy: #256b3a; --navy-deep: #1b502b; --navy-900: #0f2e19; --blue: #33874b; --teal: #6cc487; --bg-mist: #eaf4ec; --panel: #d9eadd; --sel: #dff2e4; --grad-deep: linear-gradient(150deg, #1b502b 0%, #256b3a 55%, #33874b 100%); }
[data-theme="purple"]   { --navy: #5b3a9e; --navy-deep: #45297d; --navy-900: #24143f; --blue: #7350bd; --teal: #a78bfa; --bg-mist: #f0ecf9; --panel: #e2daf3; --sel: #ebe4fb; --grad-deep: linear-gradient(150deg, #45297d 0%, #5b3a9e 55%, #7350bd 100%); }
[data-theme="crimson"]  { --navy: #a3262f; --navy-deep: #7f1c24; --navy-900: #3d0e12; --blue: #c23a43; --teal: #f08a90; --bg-mist: #faeced; --panel: #f3dcde; --sel: #fbe3e5; --grad-deep: linear-gradient(150deg, #7f1c24 0%, #a3262f 55%, #c23a43 100%); }
[data-theme="sunset"]   { --navy: #b4530a; --navy-deep: #8f4108; --navy-900: #452004; --blue: #d26a17; --teal: #f5a623; --bg-mist: #fbf1e6; --panel: #f4e2cf; --sel: #fdecd6; --grad-deep: linear-gradient(150deg, #8f4108 0%, #b4530a 55%, #d26a17 100%); }
[data-theme="rose"]     { --navy: #a8336f; --navy-deep: #842657; --navy-900: #3f122a; --blue: #c44a88; --teal: #f29ac4; --bg-mist: #faecf3; --panel: #f3dbe7; --sel: #fbe2ee; --grad-deep: linear-gradient(150deg, #842657 0%, #a8336f 55%, #c44a88 100%); }
[data-theme="graphite"] { --navy: #3d4852; --navy-deep: #2c353d; --navy-900: #171c21; --blue: #56636f; --teal: #9aa7b3; --bg-mist: #eceff1; --panel: #dde2e6; --sel: #e2e8ed; --grad-deep: linear-gradient(150deg, #2c353d 0%, #3d4852 55%, #56636f 100%); }
[data-theme="sand"]     { --navy: #7a5c2e; --navy-deep: #5f4722; --navy-900: #2e2210; --blue: #957340; --teal: #d4b072; --bg: #fffdf8; --bg-soft: #f8f3e8; --bg-mist: #f3ecdd; --panel: #ece2cd; --sel: #f5e9cf; --line: #e2d8c3; --grad-deep: linear-gradient(150deg, #5f4722 0%, #7a5c2e 55%, #957340 100%); }
[data-theme="dark"]     { --navy: #2f74b5; --navy-deep: #15293f; --navy-900: #0a1119; --blue: #3c8ad2; --teal: #3cbfd6; --ink: #e6edf3; --slate: #a7b4c0; --slate-light: #8191a0; --line: #2b3947; --bg: #17212b; --bg-soft: #111a22; --bg-mist: #0d141b; --panel: #1b2733; --sel: #1d3a4a; --tile: rgba(23, 33, 43, .86); --tile-hover: rgba(34, 48, 62, .95); --brand-text: #9fd9ec; --field-line: #5a6b7b; --grad-deep: linear-gradient(150deg, #0f1f30 0%, #15293f 55%, #1e3a5f 100%); color-scheme: dark; }
[data-theme="contrast"] { --navy: #000; --navy-deep: #000; --navy-900: #000; --blue: #1a1a1a; --teal: #ffd400; --ink: #000; --slate: #000; --slate-light: #1a1a1a; --line: #000; --bg-soft: #fff; --bg-mist: #fff; --panel: #fff; --sel: #fff3a6; --tile: #fff; --tile-hover: #fff3a6; --photo: none; --grad-deep: linear-gradient(#000, #000); }
[data-theme="dark"] .tile img { filter: invert(1) brightness(1.6); }
[data-theme="dark"] .keypad button, [data-theme="dark"] .btn.secondary, [data-theme="dark"] .btn.ms { color: var(--ink); background: var(--bg); }
[data-theme="dark"] .pill:not(.offline):not(.pending) { background: #1d3a4a; color: #cfeefa; }
[data-theme="contrast"] .tile, [data-theme="contrast"] .panel, [data-theme="contrast"] .card { border: 3px solid #000; }
[data-theme="contrast"] .row[aria-selected="true"] { outline: 3px solid #000; outline-offset: -3px; }

/* theme and text-size pickers */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-top: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 6px 10px; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font-weight: 600; font-size: .875rem; text-align: left; }
.swatch i { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); }
.swatch[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
.seg { display: inline-flex; border: 1px solid var(--slate-light); border-radius: var(--r-sm); overflow: hidden; }
.seg button { min-width: 52px; min-height: var(--tap); padding: 0 12px; border: 0; border-right: 1px solid var(--slate-light); background: var(--bg); color: var(--ink); font-weight: 700; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.setting.stack { display: block; }

/* "Please wait" screen */
.wait { width: min(520px, 100%); padding: 28px 32px; border-radius: 28px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow-lg); text-align: center; }
.wait .logo { width: 220px; height: 68px; margin: 0 auto 16px; background: url('../assets/img/logo-full.png') center / contain no-repeat; }
[data-theme="dark"] .wait .logo { width: 84px; height: 84px; border-radius: 16px; background: #fff url('../assets/img/logo-mark.png') center / 82% no-repeat; }
.wait h2 { margin: 0 0 6px; font-size: 1.625rem; }
.wait p { margin: 0 0 16px; color: var(--slate); line-height: 1.45; }
.wait .bar { height: 14px; border-radius: 999px; background: var(--bg-mist); border: 1px solid var(--line); overflow: hidden; }
.wait .bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width .3s ease; }
.wait .pct { display: flex; justify-content: space-between; margin: 8px 2px 16px; font-size: .875rem; font-weight: 600; }
.wait ol { list-style: none; margin: 0 0 16px; padding: 0; text-align: left; display: grid; gap: 8px; }
.wait li { display: flex; align-items: center; gap: 10px; color: var(--slate); }
.wait li::before { content: ''; width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--line); }
.wait li.now { color: var(--ink); font-weight: 700; }
.wait li.now::before { border-color: var(--teal); border-top-color: transparent; animation: spin .9s linear infinite; }
.wait li.done { color: var(--ink); }
.wait li.done::before { content: '✓'; display: grid; place-items: center; border-color: var(--green); background: var(--green); color: #fff; font-size: .75rem; font-weight: 700; }
.wait small { display: block; color: var(--slate); line-height: 1.4; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ---------- phones and narrow windows ---------- */
@media (max-width: 900px) {
  :root { --pad: 10px; }
  .band h1 { font-size: 1rem; }
  .band .who, .pill .long { display: none; }
  .body { flex-direction: column; gap: 10px; }
  .body.detail .side { display: none; }
  .body:not(.detail) .main { display: none; }
  .panel { border-radius: 28px; padding: 24px 20px; min-height: 0; }
  .scrim { padding-top: 40px; }
  .only-wide { display: none; }
}
/* ---------- adapting to the device ----------
   Sizes are fluid first (clamp, auto-fit); the breakpoints below only change the arrangement.
     phone            up to 599px   one pane at a time, 2 tiles per row, full-width dialogs
     large phone /
     tablet portrait  600 - 900px   one pane at a time, 3 tiles per row
     tablet landscape /
     small laptop     901 - 1199px  list + form side by side, narrower list
     desktop          1200px +      as the Power App's 1366 x 768 frame
     large desktop    1600px +      list keeps a comfortable width; forms use three or four columns  */
html, body { height: 100dvh; }
.screen { padding: max(var(--pad), env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) max(var(--pad), env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left)); }
.tile img { width: clamp(84px, 14vw, 200px); height: clamp(72px, 12vw, 170px); }
.tile img.sm { width: clamp(70px, 11vw, 150px); height: clamp(64px, 10vw, 140px); }
.tile span { font-size: clamp(1.05rem, 2.2vw, 1.875rem); padding-top: clamp(6px, 1.4vw, 20px); text-align: center; }
.band h1 { font-size: clamp(.95rem, 1.6vw, 1.25rem); }
.table-wrap table { min-width: 560px; }
.card { max-height: calc(100dvh - 32px); overflow: auto; }

@media (min-width: 1600px) {
  .side { flex: 0 0 460px; }
  .scrim { padding-top: 12vh; }
}
@media (min-width: 901px) and (max-width: 1199px) {
  .side { flex: 0 0 300px; }
  .band .who { display: none; }
  .toolbar .btn { padding: 0 9px; }
}
@media (max-width: 900px) {
  .band { min-height: 60px; gap: 8px; padding: 6px 8px; }
  .band:not(.primary) .logo { width: 44px; height: 44px; border-radius: 10px; background: #fff url('../assets/img/logo-mark.png') center / 82% no-repeat; }
  .band .logo { width: 44px; height: 44px; }
  .icon-btn { width: 48px; height: 48px; } .icon-btn svg { width: 26px; height: 26px; }
  .demo-tag { font-size: .6875rem; padding: 2px 7px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .toolbar .btn { flex: none; }
  .menu { position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: 8px; min-width: 0; }
  .tabs button { padding: 0 12px; }
  .fld { padding: 10px 14px 0; }
  .form-foot { padding: 8px 14px; }
  .wait { padding: 22px 18px; border-radius: 22px; }
}
@media (max-width: 599px) {
  .tiles { grid-template-columns: repeat(2, 1fr); grid-auto-rows: minmax(150px, 1fr); gap: 10px; }
  .pill { padding: 4px 8px; font-size: .75rem; }
  .scrim { padding: 12px 8px; align-items: flex-end; }
  .card, .card.wide { width: 100%; border-radius: 16px 16px 10px 10px; padding: 16px; }
  .card .actions .btn { flex: 1; }
  .swatches { grid-template-columns: repeat(2, 1fr); }
  .setting { flex-wrap: wrap; }
  .keypad { grid-template-columns: repeat(3, minmax(64px, 1fr)); width: 100%; }
  .field-lg { font-size: 1.25rem; }
  .panel h2 { font-size: 1.75rem; }
  .band .icon-btn.small { width: 40px; }
  .totals { gap: 12px; justify-content: space-between; }
}
/* short screens (phones on their side, small laptops): nothing may be cut off */
@media (max-height: 560px) {
  .panel { min-height: 0; padding-top: 16px; padding-bottom: 16px; gap: 8px; }
  .panel .avatar { display: none; }
  .keypad button { height: 46px; }
  .tiles { grid-auto-rows: minmax(130px, 1fr); }
  .band { min-height: 52px; }
  /* the whole record scrolls as one, so the fields are not squeezed between fixed bars */
  .form-wrap { overflow: auto; }
  .form { flex: none; overflow: visible; }
  .toolbar { min-height: 48px; }
  .screen.module { gap: 6px; }
}
/* phones on their side: enough width for list + form */
@media (max-height: 560px) and (min-width: 700px) and (max-width: 900px) {
  .body { flex-direction: row; }
  .body .side, .body.detail .side { display: flex; flex: 0 0 240px; }
  .body .main, .body:not(.detail) .main { display: flex; }
  .only-narrow { display: none !important; }
}
/* touch devices: no hover-only affordances, larger hit areas */
@media (pointer: coarse) { :root { --tap: 48px; } :root.senior { --tap: 58px; } }
@media (min-width: 901px) { .only-narrow { display: none !important; } }
/* ---------- printing (hidden #prt sheet, shown only while html.prt is set) ---------- */
#prt { display: none; }
@page { size: A4 portrait; margin: 12mm 12mm 14mm; }
@media print {
  html, body { height: auto !important; background: #fff !important; overflow: visible !important; }
  body > *:not(#prt) { display: none !important; }
  html.prt #prt { display: block !important; color: #000; font: 10pt/1.35 var(--font); }
  html:not(.prt) body::after { content: 'Use the Print button on a record to print it.'; display: block; padding: 40px; font: 14pt system-ui, sans-serif; }
  #prt .p-head { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid #1e3a5f; }
  #prt .logo { width: 170px; height: 52px; background: url('../assets/img/logo-full.png') left center / contain no-repeat; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #prt .p-title { margin-left: auto; text-align: right; } #prt .p-title b { font-size: 15pt; color: #1e3a5f; }
  #prt .p-note { margin-top: 8px; padding: 6px 8px; border: 1px solid #999; font-weight: 600; }
  #prt .p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 24px; margin: 12px 0; }
  #prt .p-grid div { display: flex; gap: 8px; break-inside: avoid; border-bottom: 1px dotted #bbb; padding: 2px 0; }
  #prt .p-grid span, #prt .p-block span { flex: 0 0 44%; color: #444; } #prt .p-grid b { font-weight: 600; }
  #prt .p-block { margin: 8px 0; }
  #prt table { font-size: 9.500pt; margin-top: 8px; } #prt th { position: static; background: #e9eef3; -webkit-print-color-adjust: exact; print-color-adjust: exact; } #prt td, #prt th { padding: 5px 6px; border: 1px solid #999; }
  #prt tfoot td { font-weight: 700; }
  #prt .p-sign { display: flex; gap: 28px; margin-top: 44px; break-inside: avoid; } #prt .p-sign div { flex: 1; text-align: center; } #prt .p-sign i { display: block; border-top: 1px solid #000; margin-bottom: 4px; }
  #prt .p-foot { margin-top: 18px; font-size: 8pt; color: #555; }
}
