/* First On Site "Stencil steel" theme: steel gray, charcoal header, red actions, stencil caps headings */
:root {
  --bg: #d9dcdf;
  --card: #f4f5f6;
  --ink: #1e2226;
  --muted: #5a6168;
  --line: #c3c8cd;
  --brand: #2b2f33;
  --stripe: #c8102e;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --sel: #2b2f33;
  --sel-ink: #ffffff;
  --field: #ffffff;
  --focus: #c8102e;
  --ok: #2b8a3e;
  --warn: #b26a00;
  --danger: #a10d24;
  --chip: #e6e9ec;
  --radius: 4px;
  --head: "Oswald", "Arial Narrow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --body: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16191c; --card: #212529; --ink: #e6e8ea; --muted: #9aa2aa;
    --line: #343a40; --brand: #0f1113; --chip: #2b3035; --field: #16191c;
    --accent: #d61a36; --sel: #cfd4d9; --sel-ink: #16191c; --focus: #e8566b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16191c; --card: #212529; --ink: #e6e8ea; --muted: #9aa2aa;
  --line: #343a40; --brand: #0f1113; --chip: #2b3035; --field: #16191c;
  --accent: #d61a36; --sel: #cfd4d9; --sel-ink: #16191c; --focus: #e8566b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
  border-bottom: 3px solid var(--stripe);
}
.brand { font-family: var(--head); font-weight: 600; display: flex; align-items: center; gap: 12px; font-size: 19px; text-transform: uppercase; letter-spacing: .06em; }
.brand .accent { color: #fff; }
.logo { display: block; width: 52px; height: 52px; border-radius: 3px; flex: none; }
.whoami { position: relative; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.whoami .ghost { color: #fff; background: transparent; border-color: rgba(255,255,255,.35); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden;
}
.menu button { display: block; width: 100%; text-align: left; padding: 12px 14px; background: none; color: var(--ink); border: 0; border-radius: 0; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 600; }
.menu button:hover { background: var(--chip); }

.tabs {
  display: flex; gap: 4px; padding: 8px 16px 0; background: var(--brand); overflow-x: auto;
}
.tabs button {
  border: 0; background: transparent; color: rgba(255,255,255,.75); padding: 10px 14px;
  border-radius: 0; cursor: pointer; white-space: nowrap; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; font-size: 14px; border-bottom: 3px solid transparent;
}
.tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--stripe); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 520px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
h1, h2 { font-family: var(--head); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--field); min-height: 46px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .row.stack-sm { grid-template-columns: 1fr; } }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius); padding: 10px 16px; min-height: 44px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer;
  text-decoration: none; text-transform: uppercase; letter-spacing: .04em; font-size: 15px;
}
button:disabled { opacity: .6; cursor: default; }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.small, .btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.danger { background: var(--danger); color: #fff; }
.block { width: 100%; margin-top: 18px; min-height: 52px; font-size: 17px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 480px) { .seg.five { grid-template-columns: repeat(3, 1fr); } }
.seg { position: relative; }
.seg input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.seg input:checked + label { border-color: var(--sel); background: var(--sel); color: var(--sel-ink); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }

.photo-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-pick .ghost { min-height: 56px; }
.preview { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.preview img { max-width: 96px; max-height: 120px; border-radius: 6px; border: 1px solid var(--line); object-fit: cover; }
.preview .pdf { width: 96px; height: 120px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }

.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } }
.filters label { font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.spacer { flex: 1; }

.totals { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 4px 0 12px; font-size: 14px; }
.totals b { font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--chip); }
.table-scroll { overflow-x: auto; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-submitted { background: #fff3bf; color: #7a5200; }
.st-reviewed { background: #d0ebff; color: #0b4f8a; }
.st-paid { background: #d3f9d8; color: #1f6b2f; }

.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.detail dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.detail dt { color: var(--muted); font-size: 14px; }
.detail dd { margin: 0; word-break: break-word; }

.error { color: var(--danger); font-weight: 600; margin-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--brand); color: #fff; padding: 12px 18px; border-radius: var(--radius); z-index: 50;
  border-left: 4px solid var(--stripe);
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}

dialog.viewer {
  width: min(960px, 100vw - 16px); height: min(92vh, 1200px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
}
dialog.viewer::backdrop { background: rgba(0,0,0,.6); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.viewer-body { height: calc(100% - 58px); overflow: auto; display: flex; justify-content: center; align-items: flex-start; background: #000; }
.viewer-body img { max-width: 100%; height: auto; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none; } }
@media (max-width: 480px) {
  #whoName { display: none; }
  .brand { font-size: 15px; }
  .logo { width: 44px; height: 44px; }
}
