:root {
  --navy: #3c467b;
  --navy-light: #5a6ba8;
  --navy-tint: #eef0f8;
  --charcoal: #363435;
  --text: #2d2d2d;
  --muted: #6c757d;
  --line: #dee2e6;
  --bg: #f8f9fa;
  --card: #ffffff;
  --red: #c8102e;
  --red-tint: #fef2f2;
  --green: #1f7a4d;
  --green-tint: #edf7f1;
  --amber: #8a5a00;
  --amber-tint: #fff7e0;
  --radius: 12px;
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--navy); }
h1, h2, h3 { color: var(--charcoal); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }
code, .mono { font-family: "Geist Mono", ui-monospace, Menlo, monospace; font-size: .92em; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.site-header .inner { max-width: 1100px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--charcoal); }
.brand img { height: 44px; width: auto; }
.brand .title { font-weight: 600; font-size: 1.05rem; line-height: 1.1; }
.brand .title small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.header-contact { margin-left: auto; font-size: .9rem; text-align: right; }
.header-contact a { text-decoration: none; font-weight: 600; }
nav.staff-nav { background: var(--navy); }
nav.staff-nav .inner { max-width: 1100px; margin: 0 auto; padding: 0 8px; display: flex; flex-wrap: wrap; align-items: center; }
nav.staff-nav a, nav.staff-nav button { color: #fff; text-decoration: none; padding: .7rem .75rem; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
nav.staff-nav a:hover, nav.staff-nav a.active, nav.staff-nav button:hover { background: rgba(255,255,255,.12); }
nav.staff-nav form { margin-left: auto; }
nav.staff-nav .who { color: #dfe3f3; font-size: .85rem; padding: 0 .5rem; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
main.narrow { max-width: 520px; }

/* Footer */
.site-footer { background: var(--charcoal); color: #e8e8e8; font-size: .88rem; }
.site-footer .inner { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.site-footer a { color: #fff; }
.site-footer strong { color: #fff; }

/* Cards, forms, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card h2:first-child { margin-top: 0; }
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input:not([type]), select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid #c4c9d0; border-radius: 8px; font: inherit; font-size: 16px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-light); outline-offset: 1px; border-color: var(--navy-light); }
.radio-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.radio-row label, ul.radio li label { font-weight: 400; display: flex; gap: .4rem; align-items: center; margin: 0; }
ul.radio { list-style: none; padding: 0; margin: 0; display: flex; gap: 1.25rem; }
.errorlist { color: var(--red); list-style: none; padding: 0; margin: .3rem 0 0; font-size: .9rem; }
.help { color: var(--muted); font-size: .88rem; margin: .3rem 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .7rem 1.1rem; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { background: #323b69; }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: var(--navy-tint); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-tint); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: wait; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
form.inline { display: inline; }

/* Messages */
.msg { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.msg.success { background: var(--green-tint); border-color: #b9dfc8; color: var(--green); }
.msg.error { background: var(--red-tint); border-color: #f3c1c1; color: var(--red); }
.msg.warning { background: var(--amber-tint); border-color: #f0dca0; color: var(--amber); }
.msg.info { background: var(--navy-tint); border-color: #cfd5ec; color: var(--navy); }

/* Tables -> stacked cards on phones */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { background: var(--navy-tint); color: var(--charcoal); font-size: .85rem; }
table.list tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.list td { border: 0; padding: .25rem .8rem; }
  table.list td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); }
  .header-contact { margin-left: 0; text-align: left; width: 100%; }
}

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.ok { background: var(--green-tint); color: var(--green); }
.badge.off { background: #eceef1; color: var(--muted); }
.badge.warn { background: var(--amber-tint); color: var(--amber); }
.badge.bad { background: var(--red-tint); color: var(--red); }
.badge.admin { background: var(--navy-tint); color: var(--navy); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { dl.facts { grid-template-columns: 1fr; } dl.facts dd { margin-bottom: .5rem; } }

.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; font-family: "Geist Mono", ui-monospace, monospace; font-size: 1.1rem; background: var(--bg); padding: 1rem; border-radius: 8px; }
.copybox { display: flex; gap: .5rem; }
.copybox input { font-family: "Geist Mono", ui-monospace, monospace; font-size: 14px; }
.steps { padding-left: 1.2rem; } .steps li { margin-bottom: .5rem; }
.faceid { text-align: center; padding: 1rem 0 .5rem; }
.faceid svg { width: 56px; height: 56px; color: var(--navy); }
.muted { color: var(--muted); }

/* Settings tabs */
nav.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
nav.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
nav.tabs a.active { color: var(--navy); border-bottom-color: var(--navy); }

nav.staff-nav .count { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .2rem; border-radius: 999px; background: #fff; color: var(--navy); font-size: .8rem; font-weight: 700; text-align: center; }
.hero { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 2rem 1.5rem; margin-bottom: 1.25rem; }
.hero h1 { color: #fff; font-size: 1.8rem; margin-bottom: .5rem; }
.hero p { margin: 0 0 1.25rem; color: #dfe3f3; max-width: 40rem; }
.hero .btn.secondary { border-color: #fff; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.check-row { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; margin-top: 1.2rem; }
.check-row input { width: 22px; height: 22px; margin-top: .1rem; flex: none; }
input.code { font-size: 1.8rem; letter-spacing: .4em; text-align: center; font-family: "Geist Mono", ui-monospace, monospace; }
.legal h2 { margin-top: 1.75rem; }
.legal { max-width: 760px; }
.req { color: var(--red); }

/* Jobs */
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; margin-right: auto; }
.page-head h1 + .badge { margin-right: auto; }
.joblist { display: grid; gap: .75rem; }
.jobcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit; }
.jobcard:hover { border-color: var(--navy-light); }
.jobcard-top { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .3rem; }
.jobcard-site { font-weight: 600; color: var(--charcoal); }
.small { font-size: .85rem; }
.field { margin-bottom: .25rem; }
form h2 { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.photos, .photo-preview { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.photos img, .photo-preview img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.inline-form { display: flex; gap: .5rem; }
.inline-form select { width: auto; }
tr.urgent td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.card.highlight { border-color: var(--navy-light); box-shadow: 0 0 0 3px var(--navy-tint); }
input[type=date] { min-height: 46px; }
input[type=file] { font-size: 16px; }
.badge.st-awaiting_approval { background: var(--amber-tint); color: var(--amber); }
.badge.st-approved { background: var(--navy-tint); color: var(--navy); }
.badge.st-in_progress { background: #e6f1fb; color: #0b5cad; }
.badge.st-completed { background: var(--green-tint); color: var(--green); }
.badge.st-closed { background: #eceef1; color: var(--muted); }
.badge.st-declined { background: var(--red-tint); color: var(--red); }

/* Attendances and signature */
.grid3 { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.sigpad { position: relative; border: 2px dashed #c4c9d0; border-radius: 10px; background: #fff; height: 190px; margin-top: .5rem; touch-action: none; }
.sigpad canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.sigpad-hint { position: absolute; left: 1rem; bottom: .8rem; color: var(--muted); pointer-events: none; }
.sigpad-hint::before { content: "✕ "; }
.sigpad-clear { position: absolute; right: .5rem; top: .5rem; min-height: 36px; padding: .3rem .8rem; }
.sig-img { max-width: 260px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: .3rem; }
.card.attendance .jobcard-top { margin-bottom: .75rem; }
input[type=time] { min-height: 46px; }

/* Entrance animation (like itsuffolk.com): only when JS is running and motion isn't reduced */
.js-reveal .reveal { opacity: 0; transform: translateY(24px); transition: opacity .55s ease-out, transform .55s cubic-bezier(.22,.8,.3,1); transition-delay: var(--reveal-delay, 0ms); }
.js-reveal .reveal.from-left { transform: translateX(-20px); }
.js-reveal .reveal.revealed { opacity: 1; transform: none; }
.js-reveal tr.reveal { transform: translateY(10px); }
@media (prefers-reduced-motion: reduce) { .js-reveal .reveal { opacity: 1 !important; transform: none !important; transition: none !important; } }
@media print { .js-reveal .reveal { opacity: 1 !important; transform: none !important; } }

/* ---------- Top bar: logo, pill buttons, one primary action (no hidden menus) */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.96); backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; min-height: 68px; display: flex; align-items: center; gap: 1.25rem; }
.topbar .brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--charcoal); flex: none; }
.topbar .brand img { height: 40px; width: auto; }
.brand-name { font-weight: 600; font-size: 1rem; letter-spacing: -.01em; padding-left: .6rem; border-left: 1px solid var(--line); white-space: nowrap; }
.pills { display: flex; align-items: center; gap: .4rem; flex: 1 1 auto; min-width: 0; }
.pills form { margin: 0; display: contents; }
.pill { display: inline-flex; align-items: center; gap: .35rem; height: 36px; padding: 0 .95rem; border-radius: 999px; border: 1px solid transparent;
        background: #f1f3f9; color: var(--navy); font: inherit; font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
        transition: background .15s, color .15s, box-shadow .15s, transform .1s; }
.pill:hover { background: #e3e7f3; }
.pill:active { transform: translateY(1px); }
.pill:focus-visible { outline: 2px solid var(--navy-light); outline-offset: 2px; }
.pill.active { background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(60,70,123,.28); }
.pill.pill-out { background: #fff; border-color: var(--line); color: var(--muted); margin-left: auto; }
.pill.pill-out:hover { color: var(--red); border-color: #f0c4c4; background: var(--red-tint); }
.navcount { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.3em; }
.pill.active .navcount { background: #fff; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: .9rem; flex: none; }
.topbar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.phone-link { display: flex; align-items: center; gap: .4rem; color: var(--navy); text-decoration: none; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.btn.btn-sm { min-height: 38px; padding: .45rem 1rem; font-size: .9rem; font-weight: 600; border-radius: 999px; box-shadow: 0 2px 6px rgba(60,70,123,.25); }
.btn.btn-sm.is-current { background: #2e3765; }

/* Narrower screens: buttons move to their own row and scroll sideways */
@media (max-width: 1040px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 0; padding-top: .55rem; }
  .topbar-right { margin-left: auto; }
  .pills { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
           padding: .55rem 16px .65rem; margin: 0 -16px; scroll-padding: 16px;
           mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
           -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%); }
  .pills::-webkit-scrollbar { display: none; }
  .pill { flex: none; }
  .pill.pill-out { margin-left: .4rem; }
}
@media (max-width: 480px) {
  .phone-link span { display: none; }
  .phone-link { width: 38px; height: 38px; justify-content: center; border-radius: 999px; background: #f1f3f9; }
}
@media (max-width: 360px) { .brand-name { display: none; } }
.js-reveal .topbar { animation: topbar-in .5s cubic-bezier(.22,.8,.3,1) both; }
@keyframes topbar-in { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .js-reveal .topbar { animation: none; } }

/* Date and time pickers: same size as other fields (they open the calendar/clock when tapped) */
input[type=date], input[type=time] { display: block; width: 100%; min-height: 48px; padding: .7rem .8rem; border: 1px solid #c4c9d0; border-radius: 8px;
  font: inherit; font-size: 16px; background: #fff; color: var(--text); -webkit-appearance: none; appearance: none; text-align: left; cursor: pointer; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
input[type=date]::-webkit-calendar-picker-indicator, input[type=time]::-webkit-calendar-picker-indicator { opacity: .7; cursor: pointer; width: 20px; height: 20px; }

/* Searchable customer picker */
.combo { position: relative; }
.combo-input { padding-right: 2.4rem !important; }
.combo-clear { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); background: none; border: 0; font-size: 1.2rem; color: var(--muted); cursor: pointer; padding: .2rem .4rem; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(20,25,50,.14); max-height: 300px; overflow-y: auto; margin: 0; padding: .3rem; list-style: none; }
.combo-list li { padding: .6rem .7rem; border-radius: 7px; cursor: pointer; }
.combo-list li small { display: block; color: var(--muted); }
.combo-list li.active, .combo-list li:hover { background: var(--navy-tint); }
.combo-list li.combo-add { color: var(--navy); font-weight: 600; border-top: 1px solid var(--line); margin-top: .2rem; }
.combo-list li.combo-empty { color: var(--muted); cursor: default; }
.combo-chosen { margin-top: .4rem; font-size: .9rem; color: var(--green); }

/* Clickable list rows */
table.list tr[data-href] { cursor: pointer; transition: background .12s; }
table.list tr[data-href]:hover td { background: #f6f7fb; }
table.list tr[data-href]:focus-visible { outline: 2px solid var(--navy-light); outline-offset: -2px; }
table.list tr[data-href]:active td { background: var(--navy-tint); }
@media (max-width: 640px) {
  table.list tr[data-href] { position: relative; padding-right: 2rem; }
  table.list tr[data-href]::after { content: "›"; position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); font-size: 1.6rem; color: #b6bccb; }
}

/* In-app PDF viewer and photo pop-up */
.viewer-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.viewer-title { flex: 1 1 200px; display: flex; flex-direction: column; min-width: 0; }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title .muted { font-size: .85rem; }
.pdf-pages { display: grid; gap: 1rem; }
.pdf-pages img { width: 100%; max-width: 820px; margin: 0 auto; display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(20,25,50,.08); }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15,18,30,.92); display: flex; align-items: center; justify-content: center; padding: 3.5rem 12px 12px; padding-top: max(3.5rem, env(safe-area-inset-top)); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 1.9rem; line-height: 1; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,.3); }

/* Pull-to-refresh indicator (home-screen app) */
.ptr { position: fixed; left: 50%; top: max(70px, calc(env(safe-area-inset-top) + 64px)); z-index: 70; width: 40px; height: 40px; border-radius: 50%;
       background: #fff; color: var(--navy); box-shadow: 0 4px 14px rgba(20,25,50,.18); display: grid; place-items: center;
       transform: translate(-50%, -50px); opacity: 0; pointer-events: none; transition: background .15s, color .15s; }
.ptr svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ptr.ready { background: var(--navy); color: #fff; }
.ptr.spinning { opacity: 1 !important; animation: ptr-spin .8s linear infinite; background: var(--navy); color: #fff; }
@keyframes ptr-spin { from { rotate: 0deg; } to { rotate: 360deg; } }
html { overscroll-behavior-y: none; }

ul.radio.stack { flex-direction: column; gap: .6rem; }

/* Permanent deletion panel (admins) */
.danger-zone { border-color: #f0c4c4; margin-top: 2rem; }
.danger-zone summary { cursor: pointer; color: var(--red); }
.danger-zone[open] { background: var(--red-tint); }

#id_report_brand { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
#id_report_brand label { font-weight: 400; display: flex; gap: .4rem; align-items: center; margin: 0; }

/* Add-to-home-screen card (customers) */
.install-card { border-color: #cfd5ec; background: linear-gradient(180deg, #f7f8fd 0%, #fff 70%); }
.install-head { display: flex; gap: .9rem; align-items: center; margin-bottom: .6rem; }
.install-icon { width: 56px; height: 56px; border-radius: 13px; box-shadow: 0 2px 8px rgba(20,25,50,.15); flex: none; }
.share-glyph { display: inline-block; width: 14px; height: 17px; vertical-align: -2px; border: 2px solid var(--navy); border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.share-glyph::before { content: ""; position: absolute; left: 50%; top: -7px; width: 2px; height: 12px; background: var(--navy); transform: translateX(-50%); }
.share-glyph::after { content: ""; position: absolute; left: 50%; top: -8px; width: 6px; height: 6px; border-left: 2px solid var(--navy); border-top: 2px solid var(--navy); transform: translateX(-50%) rotate(45deg); }
.textbtn { font: inherit; font-size: .92rem; font-weight: 600; color: var(--muted); background: none; border: 0; padding: .3rem 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.textbtn:hover { color: var(--charcoal); }
