@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-400.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-500.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-600.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-700.woff2) format("woff2"); }

:root {
  --navy: #0f2d52; --brand: #1d5fa8; --brand-dark: #164b86; --brand-soft: #e8f0fa; --red: #c8102e;
  --bg: #f3f5f8; --card: #fff; --ink: #18212d; --ink-2: #445163; --muted: #6b7889; --line: #dde2e9; --field: #fbfcfd;
  --good: #157347; --bad: #b42318; --warn-bg: #fff6e0; --warn-ink: #7a4b00;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 32, 56, .05), 0 1px 3px rgba(16, 32, 56, .06);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
a { color: var(--brand); }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.center { text-align: center; }
.sub-text { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.error { color: var(--bad); font-weight: 500; font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }
.banner { background: var(--brand-soft); color: var(--navy); border-radius: 10px; padding: 11px 14px; font-size: 14px; margin: 0 0 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 15px; letter-spacing: .04em; }

/* ---------- form controls ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 0 0 14px; }
input, textarea, select { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px; color: var(--ink);
  padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--field);
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #a3adba; }
input:focus, textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(29, 95, 168, .15); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 400; color: var(--ink-2); margin: 2px 0 16px; cursor: pointer; }
label.check.tight { margin-bottom: 10px; }
label.check input { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); -webkit-appearance: checkbox; appearance: auto; }

button { font: inherit; font-size: 15px; font-weight: 500; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 16px; min-height: 44px; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #f6f8fa; }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-dark); }
button.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
button.link { background: none; border: none; padding: 6px 4px; min-height: 0; color: var(--brand); font-weight: 500; }
button.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
button.danger { color: var(--bad); }
button.block { display: block; width: 100%; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1.4fr 110px; gap: 0 16px; }
.form-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- sign in ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px;
  background: linear-gradient(180deg, #fff 0, var(--bg) 60%); }
.auth-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 24px 22px; box-shadow: 0 8px 30px rgba(16, 32, 56, .08); }
.auth-logo { display: block; width: 190px; height: auto; margin: 0 0 22px; }
.auth-card .lead { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-card .primary { margin-top: 4px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.faceid-note { font-size: 12.5px; margin: 8px 2px 0; text-align: center; }
.fine { color: var(--muted); font-size: 12.5px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 840px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 34px; width: auto; }
.brand span { font-size: 13px; font-weight: 600; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.tabs { max-width: 840px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted);
  padding: 10px 10px 9px; min-height: 0; font-size: 14px; font-weight: 500; white-space: nowrap; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.view { max-width: 840px; margin: 0 auto; padding: 18px 16px 120px; }

/* ---------- cards / sections ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 6px;
  margin: 0 0 16px; box-shadow: var(--shadow); }
div.card, form.card { padding-bottom: 18px; }
fieldset.card { min-width: 0; padding-top: 0; }
legend { float: left; width: 100%; display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--ink);
  padding: 16px 0 14px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
legend + * { clear: both; }
.num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--navy);
  color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.sub { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 8px; }

/* tick options */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip { margin: 0; font-size: 14px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.chip span { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; min-height: 40px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: #fff; font-weight: 500; user-select: none; -webkit-user-select: none; cursor: pointer;
  transition: background .12s, border-color .12s; }
.chip span::before { content: ""; width: 16px; height: 16px; flex: none; border: 1.5px solid #b6c0cc; border-radius: 4px; background: #fff center / 12px no-repeat; }
.chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--navy); }
.chip input:checked + span::before { background-color: var(--brand); border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(29, 95, 168, .25); }

/* yes / no */
.yesno { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; margin: 0 0 4px;
  border-top: 1px solid var(--line); }
.yn-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: none; border-radius: 0; min-width: 68px; min-height: 38px; padding: 6px 14px; font-size: 14px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on[data-v=yes] { background: var(--good); color: #fff; font-weight: 600; }
.seg button.on[data-v=no] { background: var(--bad); color: #fff; font-weight: 600; }

/* time sheet / materials */
.row { display: grid; gap: 10px 10px; align-items: end; padding: 0 0 14px; margin: 0 0 14px; border-bottom: 1px dashed var(--line); }
.row label { margin: 0; font-size: 12px; min-width: 0; }
.row input { margin-top: 4px; padding: 8px 10px; font-size: 15px; min-width: 0; }
.row.time { grid-template-columns: 1fr 1.3fr 1fr 1fr; }          /* 2 lines: date/name/arrive/depart, then travel/OOH */
.row.time .del { justify-self: end; }
.row.mat { grid-template-columns: 2.2fr 1fr .6fr 56px; }
.dur { display: flex; gap: 6px; margin-top: 4px; }
.dur select { flex: 1; min-width: 0; margin: 0; padding: 8px 18px 8px 8px; font-size: 14px; min-height: 40px;
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7889' stroke-width='1.5'/%3E%3C/svg%3E") right 6px center / 8px no-repeat; }
.dur .colon { align-self: center; font-weight: 600; color: var(--ink-2); }
.row .del { border: none; background: none; color: var(--muted); font-size: 12.5px; padding: 0 2px; min-height: 40px; }
.row .del:hover { color: var(--bad); }
#add-time, #add-material { margin: 0 0 16px; font-size: 14px; }

/* signatures */
.sigbox { margin: 4px 0 8px; }
.sig-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.sigpad { display: block; width: 100%; height: 160px; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff linear-gradient(to right, transparent 20px, #cfd6df 20px, #cfd6df calc(100% - 20px), transparent calc(100% - 20px))
  0 120px / 100% 1px no-repeat; touch-action: none; cursor: crosshair; }
.sigbox .hint { margin: 6px 0 0; font-size: 12px; }
.engineer-line { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 10px 0 16px; }
.engineer-line strong { color: var(--ink); }

/* bottom bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.actionbar-inner { max-width: 808px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.actionbar .error { flex: 1; margin: 0; text-align: center; }
.actionbar .primary { min-width: 150px; margin-left: auto; }

/* admin tables */
.table-wrap { overflow-x: auto; margin: 6px -4px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: normal; text-align: right; }
td.actions button { margin: 2px 4px 2px 0; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); margin-left: 4px; }
.pill.amber { background: var(--warn-bg); color: var(--warn-ink); }
.msg { font-size: 14px; color: var(--good); font-weight: 500; } .msg.err { color: var(--bad); }
ul.plain { list-style: none; padding: 0; margin: 0 0 14px; border-top: 1px solid var(--line); }
ul.plain li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
ul.plain li .hint { display: block; font-size: 12px; }

/* dialogs */
dialog { border: none; border-radius: 16px; padding: 26px 22px 18px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(10, 20, 35, .25); }
dialog::backdrop { background: rgba(10, 20, 35, .5); }
dialog h2 { font-size: 19px; margin-bottom: 6px; }
.dlg-actions { display: grid; gap: 10px; margin: 18px 0 8px; }
.keep-preview { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 4px 0 6px; text-align: center; }
.keep-preview img { display: block; max-width: 100%; max-height: 90px; margin: 0 auto 8px; }
.keep-preview strong { font-size: 14px; }
.dlg-foot { display: flex; justify-content: space-between; margin-top: 6px; }
.done-icon { width: 48px; height: 48px; border-radius: 50%; background: #e6f4ec; color: var(--good); display: grid; place-items: center;
  font-size: 24px; font-weight: 700; margin-bottom: 14px; }
.filename { font-size: 13px; color: var(--ink-2); background: var(--bg); border-radius: 6px; padding: 6px 10px; display: inline-block;
  margin: 0 0 10px; word-break: break-all; }

/* saved sites */
.site-find { position: relative; margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.site-find label { margin-bottom: 0; }
.site-find .msg { margin: 6px 0 0; min-height: 0; }
.site-results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 0 8px 24px rgba(16, 32, 56, .10); }
.site-results li + li { border-top: 1px solid var(--line); }
.site-results button { display: block; width: 100%; text-align: left; border: none; border-radius: 0; padding: 10px 12px; min-height: 0; }
.site-results button:hover, .site-results button:focus-visible { background: var(--brand-soft); outline: none; }
.site-results strong { display: block; font-size: 15px; }
.site-results span { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.site-results .none { padding: 10px 12px; font-size: 14px; color: var(--muted); }
#admin-site-q { margin: 0 0 10px; }
#sites-table td.addr { white-space: normal; min-width: 160px; color: var(--ink-2); }

/* server link status */
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.link-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--muted); margin: -10px 0 18px; }
.link-status.compact { margin: 0; font-size: 12px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 12px; white-space: nowrap; }
.link-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #b6c0cc; flex: none; }
.link-status.good .dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.link-status.slow .dot { background: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, .18); }
.link-status.down .dot { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.link-status.good { color: var(--good); } .link-status.slow { color: #92400e; } .link-status.down { color: var(--bad); }

/* maintenance */
.maint-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--warn-bg); color: var(--warn-ink);
  display: grid; place-items: center; margin-bottom: 14px; }
.maint-note { font-size: 13.5px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 0 0 18px; }
.maint-banner { background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; font-weight: 500; text-align: center;
  padding: 9px 16px; border-bottom: 1px solid #f1dfb0; }
.maint-banner .link { color: var(--warn-ink); text-decoration: underline; padding: 0 4px; }
.maint-state { font-weight: 600; margin: 0 0 12px; }
.maint-state.on { color: var(--warn-ink); } .maint-state.off { color: var(--good); }
button.primary.warn { background: #b45309; border-color: #b45309; }

/* pull down to refresh (home-screen app, where the iPhone doesn't do it itself) */
.ptr { position: fixed; top: 0; left: 50%; z-index: 50; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(16, 32, 56, .15);
  font-size: 13px; font-weight: 500; color: var(--ink-2); transform: translate(-50%, -60px); opacity: 0; pointer-events: none;
  margin-top: env(safe-area-inset-top); }
.ptr.moving { transition: none; }
.ptr:not(.moving) { transition: transform .2s, opacity .2s; }
.ptr .ptr-arrow { display: inline-block; transition: transform .15s; color: var(--brand); font-weight: 700; }
.ptr.ready .ptr-arrow { transform: rotate(180deg); }

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding-left: 16px; padding-right: 16px; border-radius: 10px; }
  .view { padding: 14px 12px 120px; }
  .brand img { height: 26px; }
  .brand span { font-size: 12px; padding-left: 10px; }
  .brand span { display: none; }               /* room for the link status on a phone */
  .row.time { grid-template-columns: 1fr 1fr; }
  .row.time .del { grid-column: 2; justify-self: end; }
  .row.mat { grid-template-columns: 1fr 1fr 60px; }
  .row.mat label:first-child { grid-column: 1 / -1; }
  .actionbar .primary { min-width: 0; flex: 1; }
  .actionbar .error:empty { display: none; }
}
td.actions button { white-space: nowrap; }
