/* DLBI Field. Tokens from the DLBI Design System (Timber Gold, Foundation Red, warm concrete neutrals;
   Bitter display, Public Sans UI, IBM Plex Mono figures; near-square corners; the 3px gold rule). */
:root {
  --gold-50: #FAF5EA; --gold-100: #F3E9D3; --gold-200: #E9D8B2; --gold-300: #DCC08A; --gold-500: #C09860; --gold-600: #A97F46; --gold-700: #8C6835; --gold-800: #6B4E27;
  --red-50: #FCEEEC; --red-100: #F6D5D0; --red-500: #B51808; --red-600: #A80000; --red-700: #8C0000; --red-800: #700202;
  --neutral-0: #FFFFFF; --neutral-25: #FBF9F3; --neutral-50: #F6F2E8; --neutral-100: #ECE6D8; --neutral-200: #DDD5C4; --neutral-300: #C2B9A6;
  --neutral-400: #9C917C; --neutral-500: #7A7060; --neutral-600: #5C5346; --neutral-700: #453E34; --neutral-800: #2E2921; --neutral-900: #1F1B15;
  --green-500: #2F7A3D; --green-100: #E1EFE0; --amber-500: #B0740F; --amber-100: #F7EAD2;

  --text-heading: var(--neutral-900); --text-body: var(--neutral-700); --text-muted: var(--neutral-600); --text-brand: var(--red-600);
  --surface-page: var(--neutral-25); --surface-card: var(--neutral-0); --surface-inset: var(--neutral-50); --surface-ink: var(--neutral-900);
  --action-primary: var(--red-600); --action-primary-hover: var(--red-700); --action-primary-active: var(--red-800);
  --accent: var(--gold-500); --border-default: var(--neutral-200); --border-strong: var(--neutral-300);
  --status-success: var(--green-500); --status-success-bg: var(--green-100); --status-warning: var(--amber-500); --status-warning-bg: var(--amber-100);
  --status-danger: var(--red-500); --status-danger-bg: var(--red-50);

  /* Task status: told apart by lightness as well as hue (red dark, amber mid, ink darkest with gold ring, green). */
  --st-open: var(--red-600); --st-progress: var(--amber-500); --st-review: var(--neutral-900); --st-closed: var(--green-500);

  --font-display: "Bitter", Georgia, serif;
  --font-body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  --text-xs: 12px; --text-sm: 14px; --text-md: 16px; --text-lg: 20px; --text-xl: 25px; --text-2xl: 31px;
  --tracking-caps: 0.14em;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-xs: 2px; --radius-sm: 3px; --radius-md: 6px; --radius-lg: 10px; --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(31, 27, 21, 0.08);
  --shadow-md: 0 2px 8px rgba(31, 27, 21, 0.10), 0 1px 2px rgba(31, 27, 21, 0.06);
  --shadow-lg: 0 12px 32px rgba(31, 27, 21, 0.16), 0 2px 6px rgba(31, 27, 21, 0.08);
  --shadow-focus: 0 0 0 3px rgba(192, 152, 96, 0.45);
  --rule-gold: 3px solid var(--gold-500);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --topbar-h: 56px;
  --pnav-h: 48px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { font: 400 var(--text-md)/1.5 var(--font-body); color: var(--text-body); background: var(--surface-page); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--font-display); color: var(--text-heading); line-height: 1.2; margin: 0 0 var(--space-2); font-weight: 700; }
h1 { font-size: var(--text-xl); } h2 { font-size: var(--text-lg); } h3 { font-size: 17px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--red-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-weight: 500; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.late { color: var(--red-600); font-weight: 600; }
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--gold-700); }
.gold-rule { height: 3px; background: var(--gold-500); width: 48px; margin: var(--space-2) 0 var(--space-3); }
.grow { flex: 1; min-width: 0; }

/* ---------- top bar and project nav ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-3);
  padding: 0 max(var(--space-4), env(safe-area-inset-right)) 0 max(var(--space-4), env(safe-area-inset-left)); background: var(--surface-card); border-bottom: var(--rule-gold); }
.topbar .brand { display: flex; align-items: center; gap: var(--space-2); color: var(--text-heading); text-decoration: none; }
.topbar .brand img { height: 32px; width: auto; mix-blend-mode: multiply; }
.topbar .app-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.user-btn { border: 1px solid var(--border-default); background: var(--surface-card); border-radius: var(--radius-full); padding: 5px 14px; font-size: var(--text-sm); font-weight: 600; cursor: pointer; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn:hover { border-color: var(--border-strong); }
.net { border: 0; border-radius: var(--radius-full); padding: 4px 12px; font-size: var(--text-xs); font-weight: 700; background: var(--gold-100); color: var(--gold-800); cursor: pointer; white-space: nowrap; }
.net.off { background: var(--neutral-800); color: var(--neutral-25); }

.pnav { position: sticky; top: var(--topbar-h); z-index: 25; background: var(--surface-card); border-bottom: 1px solid var(--border-default); }
.pnav-inner { display: flex; align-items: center; gap: var(--space-4); max-width: 1280px; margin: 0 auto; padding: 0 var(--space-4); height: var(--pnav-h); }
.pnav-project { font-family: var(--font-display); font-weight: 700; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.pnav-tabs { display: flex; gap: var(--space-1); }
.pnav-tabs a { position: relative; display: flex; align-items: center; gap: 6px; height: var(--pnav-h); padding: 0 var(--space-3); color: var(--text-muted); font-weight: 600; font-size: var(--text-sm); text-decoration: none; border-bottom: 3px solid transparent; }
.pnav-tabs a:hover { color: var(--text-heading); }
.pnav-tabs a.on { color: var(--text-heading); border-bottom-color: var(--red-600); }
.badge { background: var(--red-600); color: #fff; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; }

/* Phones: project name in the bar, tabs fixed at the bottom. */
@media (max-width: 767px) {
  .pnav { position: static; border-bottom: 0; background: transparent; }
  .pnav-inner { height: auto; padding: var(--space-3) var(--space-4) 0; }
  .pnav-project { font-size: var(--text-sm); color: var(--text-muted); max-width: 100%; }
  .pnav-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface-card); border-top: 1px solid var(--border-default);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); justify-content: space-around; gap: 0; }
  .pnav-tabs a { flex: 1; justify-content: center; height: var(--tabbar-h); padding: 0 4px; border-bottom: 0; border-top: 3px solid transparent; font-size: 13px; }
  .pnav-tabs a.on { border-top-color: var(--red-600); border-bottom: 0; }
  body.in-project main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-4)); }
  body.in-project .app-version { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
}

main { flex: 1; width: 100%; }
.page { max-width: 1280px; margin: 0 auto; padding: var(--space-4); }
.page.narrow { max-width: 860px; }
.page-title { font-size: var(--text-2xl); margin: 2px 0 4px; }
.section-title { margin: 0; display: flex; align-items: baseline; gap: var(--space-2); }
.section-title .muted { font: 500 var(--text-sm) var(--font-body); }
.app-version { text-align: center; font-size: 11px; color: var(--neutral-500); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); }
body.viewer-mode .app-version { display: none; }

.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 180px; max-width: 360px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-card); color: var(--text-heading); font-weight: 600; font-size: var(--text-sm); cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.btn:hover { border-color: var(--neutral-400); background: var(--neutral-50); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--action-primary); border-color: var(--action-primary); color: #fff; }
.btn.primary:hover { background: var(--action-primary-hover); border-color: var(--action-primary-hover); }
.btn.primary:active { background: var(--action-primary-active); }
.btn.danger { background: var(--red-700); border-color: var(--red-700); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--neutral-50); border-color: var(--border-default); }
.btn.small { min-height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn.block { width: 100%; }
.danger-text { color: var(--red-600) !important; }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.btn-row.end { justify-content: flex-end; }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 20px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.icon-btn:hover { background: var(--neutral-50); color: var(--text-heading); }

input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-card);
  color: var(--text-heading); font-size: 16px; }
textarea { resize: vertical; line-height: 1.45; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-inset); color: var(--text-body); }
input:focus, select:focus, textarea:focus { border-color: var(--gold-600); }
input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red-600); margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-heading); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); min-height: 32px; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.form-error { color: var(--red-600); font-weight: 600; font-size: var(--text-sm); margin: 0; }

.card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-4); min-width: 0; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--gold-700); margin: 0 0 var(--space-3); }
.sub-head a { letter-spacing: 0; text-transform: none; font-size: var(--text-sm); }
.card > .sub-head:not(:first-child) { margin-top: var(--space-5); }
.alert { padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-inset); margin: var(--space-3) 0; font-size: var(--text-sm); }
.alert.warn { background: var(--status-warning-bg); color: var(--neutral-800); border-left: 0; }
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); }
.empty h3 { color: var(--text-heading); }
.spinner { width: 28px; height: 28px; margin: 64px auto; border: 3px solid var(--gold-200); border-top-color: var(--red-600); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner.small { width: 20px; height: 20px; margin: var(--space-3) 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-full); background: var(--gold-100); color: var(--gold-800); }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: var(--radius-full); white-space: nowrap; line-height: 20px; }
.st-open { background: var(--red-50); color: var(--red-700); }
.st-progress { background: var(--amber-100); color: #7A4F06; }
.st-review { background: var(--neutral-800); color: var(--gold-100); }
.st-closed { background: var(--green-100); color: #22592C; }
.prio { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.prio-1 { color: var(--red-600); }
.due { font-size: 13px; font-weight: 600; color: var(--text-body); white-space: nowrap; }
.due.late { color: var(--red-600); }
.unsynced { font-size: 11px; font-weight: 700; color: var(--gold-800); background: var(--gold-100); padding: 1px 7px; border-radius: var(--radius-full); white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border-default); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border-default); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.table select { min-width: 110px; }
tr.inactive td { opacity: .55; }
.dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px var(--space-3); margin: 0; font-size: var(--text-sm); }
.dl dt { color: var(--text-muted); } .dl dd { margin: 0; color: var(--text-heading); }
details.archived { margin-top: var(--space-5); }
details.archived summary { cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-3); }
details.archived .row { display: flex; gap: var(--space-2); align-items: center; padding: 4px 0; }

/* ---------- toast, dialog, lightbox ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; background: var(--neutral-900); color: var(--neutral-25);
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 600; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
body.in-project .toast { bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { body.in-project .toast { bottom: var(--space-6); } }
.toast.error { background: var(--red-700); }
.dialog-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(31, 27, 21, 0.45); display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.dialog { background: var(--surface-card); border-radius: var(--radius-md); border-top: var(--rule-gold); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; max-height: calc(100dvh - 32px); overflow: auto; padding: var(--space-5); }
.dialog.medium { max-width: 560px; }
.dialog.wide { max-width: 860px; }
.dialog h2 { font-size: var(--text-lg); }
.dialog .body { white-space: pre-line; }
.dialog .actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); flex-wrap: wrap; }
.dialog .field + .field, .dialog .grid2 + .field, .dialog .field + .grid2 { margin-top: var(--space-3); }
.dialog .grid2 > .field { margin-top: 0; }
.dialog-photo { width: 100%; border-radius: var(--radius-sm); }
.menu-form { display: flex; flex-direction: column; gap: var(--space-3); align-items: stretch; }
.menu-form hr { border: 0; border-top: 1px solid var(--border-default); width: 100%; margin: 0; }
.menu-form .btn { justify-content: flex-start; }
@media (max-width: 600px) {
  .dialog-overlay { align-items: flex-end; padding: 0; }
  .dialog { max-width: none !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
}
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(31, 27, 21, 0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-4); }
.lightbox img { max-height: calc(100dvh - 100px); object-fit: contain; }
.bar { height: 6px; background: var(--neutral-100); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--red-600); transition: width 200ms var(--ease); }
.link-box { display: flex; gap: var(--space-2); }
.link-box input { font-family: var(--font-mono); font-size: 13px !important; }
.qr { display: flex; justify-content: center; margin-top: var(--space-4); }
.qr img, .qr canvas { width: 180px; height: 180px; }

/* ---------- auth ---------- */
body.auth-mode .topbar { display: none; }
.auth { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth-card { width: 100%; max-width: 400px; padding: var(--space-6) var(--space-5); }
.auth-logo { display: block; width: 120px; height: auto; mix-blend-mode: multiply; margin-bottom: var(--space-2); }

/* ---------- projects and overview ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.project-card { display: block; color: inherit; text-decoration: none !important; padding-top: 0; transition: box-shadow 120ms var(--ease), border-color 120ms var(--ease); }
.project-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.project-card .gold-rule { width: auto; margin: 0 calc(-1 * var(--space-4)) var(--space-4); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.project-card h3 { margin-top: 4px; }
.counts { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); font-size: var(--text-sm); color: var(--text-muted); }
.counts b { font-family: var(--font-mono); color: var(--text-heading); }
.counts .late b { color: var(--red-600); }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-3); margin-bottom: var(--space-4); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--space-4); background: var(--surface-card); border: 1px solid var(--border-default); border-top: 3px solid var(--neutral-300); border-radius: var(--radius-md); color: var(--text-muted); text-decoration: none !important; font-size: 13px; font-weight: 600; }
.kpi b { font: 600 28px/1.1 var(--font-mono); color: var(--text-heading); }
.kpi:hover { box-shadow: var(--shadow-sm); }
.k-open { border-top-color: var(--st-open); } .k-progress { border-top-color: var(--st-progress); } .k-review { border-top-color: var(--st-review); }
.k-closed { border-top-color: var(--st-closed); } .k-late { border-top-color: var(--red-600); } .k-late b { color: var(--red-600); }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi b { font-size: 22px; } }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: var(--space-4); align-items: start; }
.two-col > * { min-width: 0; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.mini-row { display: flex; align-items: center; gap: var(--space-2); padding: 8px 0; border-bottom: 1px solid var(--border-default); color: var(--text-heading); text-decoration: none !important; font-size: var(--text-sm); }
.mini-row:last-child { border-bottom: 0; }
.mini-row .muted { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .mini-row .muted { display: none; } }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border-default); font-size: var(--text-sm); }
.feed li:last-child { border-bottom: 0; }
.feed a { color: var(--text-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px var(--space-4); }
.companies .actions { width: 1%; }
@media (max-width: 600px) {
  .table.team thead { display: none; }
  .table.team tr { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--space-2); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-default); }
  .table.team tr:last-child { border-bottom: 0; }
  .table.team td { padding: 0; border: 0; }
  .table.team td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; }
  .table.team td.actions .btn { margin: 0 4px 0 0; }
}

/* ---------- sheets ---------- */
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); }
@media (max-width: 480px) { .sheet-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); } }
.sheet-card { display: flex; flex-direction: column; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; color: inherit; text-decoration: none !important; }
.sheet-card:hover { box-shadow: var(--shadow-md); }
.sheet-thumb { aspect-ratio: 4 / 3; background: var(--surface-inset); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border-default); overflow: hidden; }
.sheet-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sheet-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: var(--space-2) var(--space-3); min-height: 54px; }
.sheet-meta b { color: var(--text-heading); }
.sheet-meta .count { margin-left: auto; background: var(--red-600); color: #fff; font: 700 11px/18px var(--font-body); padding: 0 6px; border-radius: var(--radius-full); }
.sheet-title { flex-basis: 100%; font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-wrap { max-height: 55vh; overflow: auto; border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.up-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.up-table th { position: sticky; top: 0; background: var(--surface-inset); text-align: left; padding: 6px; font-size: 12px; z-index: 1; }
.up-table td { padding: 6px; border-top: 1px solid var(--border-default); vertical-align: middle; }
.up-thumb { width: 72px; height: 54px; object-fit: contain; background: #fff; border: 1px solid var(--border-default); display: block; }
.up-no { width: 110px !important; }
.up-state { white-space: nowrap; }

/* ---------- viewer ---------- */
body.viewer-mode main { display: flex; flex-direction: column; }
.viewer { position: relative; display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - var(--pnav-h)); }
.viewer-bar { display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-3); background: var(--surface-card); border-bottom: 1px solid var(--border-default); min-height: 48px; }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
.viewer-title b { color: var(--text-heading); margin-right: 4px; }
.viewer-actions { display: flex; gap: 2px; }
.viewer-stage { position: relative; flex: 1; overflow: hidden; background: var(--neutral-100); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.viewer-stage.placing { cursor: crosshair; box-shadow: inset 0 0 0 3px var(--gold-500); }
.viewer-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: var(--shadow-md); will-change: transform; }
.viewer-canvas img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: auto; }
#compare-img { mix-blend-mode: multiply; }
.pin-layer { position: absolute; inset: 0; pointer-events: none; }
.pin-btn { position: absolute; left: 0; top: 0; margin: -39px 0 0 -15px; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 1px 2px rgba(31, 27, 21, .4)); }
.pin-btn.focus .pin path { stroke: var(--gold-300); stroke-width: 3; }
.pin path { stroke: #fff; stroke-width: 1.5; }
.pin text { fill: #fff; font: 700 13px var(--font-body); }
.pin-open path { fill: var(--st-open); } .pin-progress path { fill: var(--st-progress); }
.pin-review path { fill: var(--st-review); stroke: var(--gold-500); stroke-width: 2.5; } .pin-review text { fill: var(--gold-100); }
.pin-closed path { fill: var(--st-closed); }
.viewer-tools { position: absolute; left: var(--space-3); right: var(--space-3); bottom: var(--space-3); display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-2); pointer-events: none; }
.viewer-tools > * { pointer-events: auto; }
.viewer-tools .btn.primary { min-height: 48px; padding: 0 var(--space-5); font-size: var(--text-md); box-shadow: var(--shadow-md); }
.zoom-btns { display: flex; flex-direction: column; gap: 4px; margin-left: auto; }
.zoom-btns .btn { width: 44px; min-height: 40px; padding: 0; box-shadow: var(--shadow-sm); }
.viewer-hint { position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%); background: var(--neutral-900); color: var(--neutral-25); padding: 6px 6px 6px 14px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 600; display: flex; align-items: center; gap: var(--space-2); box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 2; }
.viewer-hint .btn { color: var(--neutral-25); min-height: 28px; }
.viewer-hint .btn:hover { background: var(--neutral-700); }
.compare-bar { position: absolute; top: var(--space-3); left: var(--space-3); right: var(--space-3); max-width: 480px; margin: 0 auto; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-3); font-size: var(--text-sm); z-index: 2; }
.compare-bar input[type=range] { flex: 1; accent-color: var(--red-600); }
.compare-bar select { width: auto; min-height: 30px; padding: 2px 6px; }
.side-panel { position: absolute; z-index: 5; background: var(--surface-card); box-shadow: var(--shadow-lg); padding: var(--space-4); overflow: auto; border-top: var(--rule-gold); }
.panel-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.panel-head .icon-btn { margin-left: auto; }
.panel-desc { font-size: var(--text-sm); white-space: pre-line; max-height: 8em; overflow: hidden; }
@media (min-width: 1024px) {
  .side-panel { top: 48px; right: 0; bottom: 0; width: 340px; border-top: 0; border-left: var(--rule-gold); }
  .viewer.with-panel .viewer-stage { margin-right: 340px; }
}
@media (max-width: 1023px) {
  .side-panel { left: 0; right: 0; bottom: 0; max-height: 55%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}
@media (max-width: 767px) {
  .viewer { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom)); }
  body.viewer-mode .pnav-inner { display: contents; }
  body.viewer-mode .pnav-project { display: none; }
  body.viewer-mode main { padding-bottom: 0 !important; }
  .side-panel { bottom: 0; }
}

/* ---------- task list ---------- */
.filters { margin-bottom: var(--space-3); }
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-2); }
.chip { border: 1px solid var(--border-strong); background: var(--surface-card); border-radius: var(--radius-full); padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-muted); min-height: 32px; }
.chip.on { background: var(--neutral-900); border-color: var(--neutral-900); color: var(--neutral-25); }
.filter-top { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); }
.filter-top input[type=search] { flex: 1; max-width: 420px; }
.filter-toggle { display: none; min-height: 40px; }
.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
@media (max-width: 767px) {
  .filter-toggle { display: inline-flex; }
  .filter-top input[type=search] { max-width: none; }
  .filters:not(.open) .filter-row { display: none; }
}
.filter-row select { flex: 1 1 140px; width: auto; min-height: 36px; font-size: 14px; padding: 4px 8px; }
.task-list { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.task-list .empty { padding: var(--space-6) var(--space-4); }
.task-row { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-default); color: inherit; text-decoration: none !important; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--neutral-25); }
.task-pin { flex: none; display: flex; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-title { color: var(--text-heading); font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px var(--space-3); align-items: center; font-size: 13px; color: var(--text-muted); }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: none; }
@media (max-width: 600px) {
  .task-row { align-items: flex-start; flex-wrap: wrap; }
  .task-side { flex-basis: 100%; flex-direction: row; justify-content: space-between; padding-left: 34px; }
}

/* ---------- task page ---------- */
.task-page { max-width: 1100px; margin: 0 auto; padding: var(--space-4); }
.task-head { display: flex; align-items: center; gap: var(--space-2); }
.task-no { font-size: var(--text-lg); color: var(--text-heading); font-weight: 600; }
.title-input { font: 700 var(--text-xl)/1.25 var(--font-display) !important; color: var(--text-heading); border: 1px solid transparent !important; background: transparent !important; padding: 4px 6px !important; margin: 0 -6px var(--space-3); resize: none; overflow: hidden; min-height: 0 !important; }
.title-input:hover { border-color: var(--border-default) !important; }
.title-input:focus { border-color: var(--gold-600) !important; background: var(--surface-card) !important; }
.segmented { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--space-3); background: var(--surface-card); }
.seg { flex: 1; border: 0; border-right: 1px solid var(--border-default); background: transparent; padding: 10px 4px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-muted); min-height: 44px; }
.seg:last-child { border-right: 0; }
.seg:disabled { cursor: default; }
.seg:not(:disabled):hover { background: var(--neutral-50); }
.seg.on[data-set-status="Open"] { background: var(--st-open); color: #fff; }
.seg.on[data-set-status="In progress"] { background: var(--st-progress); color: #fff; }
.seg.on[data-set-status="For review"] { background: var(--st-review); color: var(--gold-100); }
.seg.on[data-set-status="Closed"] { background: var(--st-closed); color: #fff; }
.review-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--neutral-900); color: var(--neutral-50); border-radius: var(--radius-md); margin-bottom: var(--space-3); border-left: 0; }
.review-box b { color: #fff; }
.review-box .btn-row { margin: 0; }
.review-box .btn.ghost { color: var(--neutral-25); border-color: var(--neutral-600); }
.review-box .btn.ghost:hover { background: var(--neutral-800); }
.task-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 860px) { .task-grid { grid-template-columns: 1fr; } }
.task-grid .card > .field { margin-top: var(--space-3); }
.checklist { margin-top: var(--space-4); }
.check-item { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-default); }
.check-item .check { flex: 1; min-height: 40px; }
.check-item input:checked + span { text-decoration: line-through; color: var(--text-muted); }
.inline-add { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.crop { position: relative; display: block; max-width: 100%; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background-color: #fff; background-repeat: no-repeat; overflow: hidden; padding: 0; cursor: pointer; }
.crop-link { display: block; text-decoration: none !important; }
.crop-pin { position: absolute; margin: -34px 0 0 -13px; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(31, 27, 21, .4)); }
.crop-dot { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; background: var(--red-600); box-shadow: 0 0 0 2px var(--red-600), var(--shadow-md); pointer-events: none; }
.crop-label { position: absolute; left: 6px; bottom: 6px; background: rgba(31, 27, 21, .8); color: #fff; font: 600 11px var(--font-mono); padding: 1px 6px; border-radius: var(--radius-xs); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--space-2); }
.photo-grid.small { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); margin: var(--space-2) 0; }
.thumb { position: relative; aspect-ratio: 1; border: 1px solid var(--border-default); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-inset); padding: 0; cursor: pointer; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.add { font-size: 28px; color: var(--text-muted); border-style: dashed; border-color: var(--border-strong); }
.thumb.add:hover { color: var(--red-600); border-color: var(--red-600); }
.thumb-tag { position: absolute; left: 4px; top: 4px; background: var(--neutral-900); color: var(--gold-100); font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: var(--radius-xs); }
.thumb-wait { position: absolute; right: 5px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold-500); border: 2px solid #fff; }
.activity { margin-top: var(--space-4); }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: var(--space-2) 0; border-bottom: 1px solid var(--border-default); font-size: var(--text-sm); }
.events li:last-child { border-bottom: 0; }
.events .ev { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px var(--space-3); color: var(--text-muted); }
.events .ev p { flex-basis: 100%; margin: 4px 0 0; color: var(--text-heading); }
.events .ev.fix p, .events .ev.sendback p { padding: 6px 10px; background: var(--surface-inset); border-radius: var(--radius-sm); }
.events time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.events .comment p { margin: 4px 0 0; color: var(--text-heading); white-space: pre-line; }
.ev-head { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.comment-form { display: flex; gap: var(--space-2); align-items: flex-end; margin-top: var(--space-3); }

/* ---------- report ---------- */
.report { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-5); }
.report-head { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-4); align-items: center; border-bottom: var(--rule-gold); padding-bottom: var(--space-4); margin-bottom: var(--space-4); }
.report-head img { mix-blend-mode: multiply; }
.report-head h1 { margin: 2px 0; }
.report-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; color: var(--text-muted); text-align: right; }
.report-meta b { color: var(--text-heading); font-size: var(--text-md); }
.r-task { display: grid; grid-template-columns: 1fr 262px; gap: var(--space-4); padding: var(--space-4) 0; border-bottom: 1px solid var(--border-default); break-inside: avoid; }
.r-task:last-child { border-bottom: 0; }
.r-title { display: flex; flex-wrap: wrap; gap: 4px var(--space-2); align-items: center; margin-bottom: var(--space-2); color: var(--text-heading); }
.r-dl { display: grid; grid-template-columns: 70px 1fr; gap: 2px var(--space-3); margin: 0 0 var(--space-2); font-size: 13px; }
.r-dl dt { color: var(--text-muted); } .r-dl dd { margin: 0; }
.r-desc, .r-note { font-size: 13px; white-space: pre-line; margin: var(--space-2) 0 0; }
.r-note { color: var(--text-muted); }
.r-check { list-style: none; padding: 0; margin: var(--space-2) 0 0; font: 13px var(--font-mono); }
.r-check .done { color: var(--text-muted); }
.r-media .crop { width: 260px !important; }
.r-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.r-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-xs); border: 1px solid var(--border-default); }
@media (max-width: 700px) {
  .report { padding: var(--space-3); }
  .report-head { grid-template-columns: auto 1fr; }
  .report-meta { grid-column: 1 / -1; align-items: flex-start; text-align: left; }
  .r-task { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; display: block; }
  .topbar, .pnav, .no-print, .app-version, .toast { display: none !important; }
  .page { padding: 0; max-width: none; }
  main { padding: 0 !important; }
  .report { border: 0; padding: 0; }
  .r-task { grid-template-columns: 1fr 262px !important; }
  .crop, .pill, .crop-label { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- subcontractor page ---------- */
body.sub-mode .topbar .brand { pointer-events: none; }
.sub-hero { margin-bottom: var(--space-4); }
.sub-task h3 { margin: var(--space-2) 0; }
.sub-task-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sub-media { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; margin: var(--space-3) 0; }
.sub-media .photo-grid { flex: 1; min-width: 140px; margin: 0; }
.sheet-box { padding: 0; justify-content: flex-start; }
.sheet-scroll { flex: 1; width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-wrap { position: relative; width: max(1600px, 100%); }
.sheet-wrap img { width: 100%; max-height: none; display: block; background: #fff; }
.sheet-box > .btn { margin: var(--space-3) 0 calc(var(--space-3) + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0.01ms !important; } }

/* Google sign-in: DLBI-styled button (Google's guidelines: white fill, standard G mark, "Sign in with Google"). */
.gsignin { display: flex; align-items: center; justify-content: center; gap: var(--space-3); width: 100%; height: 48px; margin: var(--space-4) 0 var(--space-3);
  background: var(--surface-card); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: 600 15px var(--font-body);
  color: var(--text-heading); cursor: pointer; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.gsignin svg { flex: none; }
.gsignin:hover { background: var(--neutral-50); border-color: var(--neutral-400); }
.gsignin:active { background: var(--neutral-100); }
.gsignin:disabled { cursor: default; color: var(--text-muted); }
.gsignin:disabled svg { opacity: .5; }
.auth-foot { margin: var(--space-4) 0 0; font-size: var(--text-xs); color: var(--text-muted); }

.top-link { font-size: var(--text-sm); font-weight: 600; color: var(--text-heading); padding: 5px 10px; border-radius: var(--radius-sm); }
.top-link:hover { background: var(--neutral-50); text-decoration: none; }
.home-kpis .kpi { cursor: default; }

/* ======================= 1.2: forms, RFIs, submittals, markups, notifications, motion ======================= */
:root { --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1); }
html { -webkit-tap-highlight-color: transparent; }
.pre { white-space: pre-line; }
.link-btn { border: 0; background: none; padding: 0; color: var(--red-600); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- motion: gentle entrances, sheet-style dialogs ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
#view > .page, #view > .task-page, #view > .empty, #view > .auth { animation: enter 260ms var(--ease-out) both; }
.task-row, .project-card, .sheet-card, .kpi, .mini-row, .inbox-row, .more-item { animation: enter 280ms var(--ease-out) both; }
.task-row:nth-child(2), .project-card:nth-child(2), .sheet-card:nth-child(2), .kpi:nth-child(2) { animation-delay: 25ms; }
.task-row:nth-child(3), .project-card:nth-child(3), .sheet-card:nth-child(3), .kpi:nth-child(3) { animation-delay: 50ms; }
.task-row:nth-child(4), .project-card:nth-child(4), .sheet-card:nth-child(4), .kpi:nth-child(4) { animation-delay: 75ms; }
.task-row:nth-child(5), .project-card:nth-child(5), .sheet-card:nth-child(5), .kpi:nth-child(5) { animation-delay: 100ms; }
.task-row:nth-child(n+6), .sheet-card:nth-child(n+6) { animation-delay: 120ms; }
.dialog-overlay { animation: fade 180ms ease both; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.dialog { animation: rise 240ms var(--ease-out) both; }
.toast { animation: toast-in 260ms var(--ease-out) both; }
.lightbox { animation: fade 180ms ease both; }
.card, .kpi, .sheet-card, .project-card, .btn, .chip, .seg, .insp-b, .mk-tool { transition: background-color 160ms var(--ease), border-color 160ms var(--ease), box-shadow 200ms var(--ease), color 160ms var(--ease), transform 200ms var(--ease-out); }
.kpi:hover, .project-card:hover, .sheet-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.bar span { transition: width 500ms var(--ease-out); }
@media (max-width: 600px) {
  .dialog { animation: sheet-up 320ms var(--ease-sheet) both; padding-top: var(--space-6); position: relative; }
  .dialog::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--neutral-200); }
  .dialog .actions { position: sticky; bottom: calc(-1 * var(--space-5) - env(safe-area-inset-bottom)); background: var(--surface-card); padding: var(--space-3) 0 var(--space-2); margin-top: var(--space-4); }
  .dialog .actions .btn { flex: 1; min-height: 48px; }
}

/* ---------- top bar: bell, frosted bars ---------- */
.topbar { background: rgba(255, 255, 255, .88); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.bell { position: relative; border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; color: var(--text-heading); cursor: pointer; display: grid; place-items: center; }
.bell:hover { background: var(--neutral-50); }
.bell-badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red-600); color: #fff; font: 700 11px/18px var(--font-body); text-align: center; box-shadow: 0 0 0 2px #fff; animation: rise 300ms var(--ease-out) both; }

/* ---------- project nav: icons + More on phones ---------- */
.pnav-tabs svg { display: none; }
.tab-more { display: none; }
.pnav-tabs { overflow-x: auto; scrollbar-width: none; }
.pnav-tabs::-webkit-scrollbar { display: none; }
@media (max-width: 767px) {
  .pnav-tabs { background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); overflow: visible; }
  .pnav-tabs a, .tab-more { flex-direction: column; gap: 2px; font-size: 11px; font-weight: 600; position: relative; }
  .pnav-tabs svg { display: block; }
  .pnav-tabs .tab-extra { display: none; }
  .tab-more { display: flex; flex: 1; align-items: center; justify-content: center; border: 0; border-top: 3px solid transparent; background: none; color: var(--text-muted); cursor: pointer; height: var(--tabbar-h); font-family: var(--font-body); }
  .tab-more.on { color: var(--text-heading); border-top-color: var(--red-600); }
  .pnav-tabs .badge, .tab-more .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
}
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.more-item { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 56px; padding: var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); color: var(--text-heading) !important; font: 600 15px var(--font-body); text-decoration: none !important; cursor: pointer; text-align: center; }
.more-item:hover, .more-item.on { border-color: var(--gold-500); background: var(--gold-50); }

/* + button on phones (inside a project) */
.fab { display: none; }
@media (max-width: 767px) {
  .fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); z-index: 45; width: 56px; height: 56px; border-radius: 50%; border: 0;
    background: var(--red-600); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(168, 0, 0, .35), var(--shadow-md); cursor: pointer; animation: rise 300ms var(--ease-out) both; }
  .fab:active { background: var(--red-700); }
  .fab[hidden] { display: none !important; }
  body.in-project .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px); }
  body.in-project main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 88px); }
}

/* ---------- overview: setup steps, today ---------- */
.setup { border-top: var(--rule-gold); }
.setup .bar { margin-bottom: var(--space-3); }
.setup-steps { list-style: none; margin: 0 0 var(--space-2); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2); }
.setup-steps a { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); color: var(--text-heading); text-decoration: none !important; height: 100%; }
.setup-steps a:hover { border-color: var(--gold-500); background: var(--gold-50); }
.setup-steps small { display: block; color: var(--text-muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.check-dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.setup-steps .done .check-dot { background: var(--green-500); border-color: var(--green-500); }
.setup-steps .done b { color: var(--text-muted); text-decoration: line-through; }
.today-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 10px 0; border-bottom: 1px solid var(--border-default); color: var(--text-heading); text-decoration: none !important; font-size: var(--text-sm); }
.today-row:last-child { border-bottom: 0; }
.today-row b { font-family: var(--font-mono); }
.home-kpis { margin-bottom: var(--space-5); }

/* ---------- markups ---------- */
.mk-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.viewer-stage.marking { cursor: crosshair; box-shadow: inset 0 0 0 3px var(--red-600); }
.viewer-stage.marking[data-tool="erase"] { cursor: pointer; }
.viewer-stage.marking[data-tool="erase"] .mk-layer [data-mk] { pointer-events: visibleStroke; }
.viewer-stage.marking[data-tool="erase"] .mk-layer text[data-mk] { pointer-events: auto; }
.viewer-tools.hide { opacity: 0; pointer-events: none; transform: translateY(8px); }
.viewer-tools { transition: opacity 180ms var(--ease), transform 220ms var(--ease-out); }
.tool-pair { display: flex; gap: var(--space-2); }
.tool-pair .btn:not(.primary) { min-height: 48px; box-shadow: var(--shadow-md); }
.mk-bar { position: absolute; left: 12px; right: 12px; margin: 0 auto; width: fit-content; bottom: var(--space-3); z-index: 3; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 24px); padding: 6px 8px; background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise 240ms var(--ease-out) both; }
.mk-tools, .mk-colors { display: flex; gap: 2px; }
.mk-tool { width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-body); display: grid; place-items: center; cursor: pointer; }
.mk-tool:hover { background: var(--neutral-50); }
.mk-tool.on { background: var(--neutral-900); color: #fff; }
.mk-color { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; margin: 0 2px; }
.mk-color.on { box-shadow: 0 0 0 2px var(--neutral-900); }
#mk-toggle.on { color: var(--red-600); }
@media (max-width: 600px) {
  .mk-bar { bottom: 8px; left: 8px; right: 8px; width: auto; gap: 6px 4px; padding: 6px; }
  .mk-tools { width: 100%; justify-content: space-between; }
  .mk-tool { width: 40px; height: 40px; }
  .mk-colors { flex: 1; }
  .mk-color { width: 26px; height: 26px; }
}

/* ---------- forms ---------- */
.form-ico { flex: none; width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; font: 700 12px var(--font-mono); color: #fff; background: var(--gold-600); }
.form-ico.inspection { background: var(--neutral-800); }
.form-ico.rfi { background: #1E5BD8; font-size: 16px; }
.form-ico.sub { background: var(--green-500); }
.form-title-row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.form-title-row .title-input { flex: 1 1 260px; margin-bottom: 0; }
.date-field { width: 180px; }
.form-page .card { margin-top: var(--space-3); }
.form-page .card .sub-head { margin-bottom: var(--space-2); }
.mp-rows { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
.mp-row { display: grid; grid-template-columns: 1fr 84px 84px 32px; gap: var(--space-2); align-items: end; }
.mini { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
@media (max-width: 480px) { .mp-row { grid-template-columns: 1fr 70px 70px 28px; } }
.insp-summary { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin: var(--space-3) 0; position: sticky; top: calc(var(--topbar-h) + var(--pnav-h)); z-index: 5; background: var(--surface-page); padding: 6px 0; }
@media (max-width: 767px) { .insp-summary { top: var(--topbar-h); } }
.insp { padding: 0; overflow: hidden; }
.insp-head { padding: var(--space-3) var(--space-4) var(--space-2); font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--gold-700); background: var(--surface-inset); }
.insp-item { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-default); display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-3); align-items: center; }
.insp-item.fail { background: var(--red-50); }
.insp-q { color: var(--text-heading); font-weight: 500; }
.insp-btns { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.insp-b { border: 0; border-right: 1px solid var(--border-default); background: var(--surface-card); min-width: 56px; min-height: 40px; font: 600 13px var(--font-body); color: var(--text-muted); cursor: pointer; }
.insp-b:last-child { border-right: 0; }
.insp-b.pass.on { background: var(--green-500); color: #fff; }
.insp-b.fail.on { background: var(--red-600); color: #fff; }
.insp-b.na.on { background: var(--neutral-600); color: #fff; }
.insp-more { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--space-2); }
@media (max-width: 520px) { .insp-item { grid-template-columns: 1fr; } .insp-btns { width: 100%; } .insp-b { flex: 1; min-height: 44px; } }

/* ---------- RFIs and submittals ---------- */
.file-list { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.file-list .thumb { width: 72px; }
.file-chip { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; padding: 6px 10px 6px 6px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--surface-card); color: var(--text-heading) !important; text-decoration: none !important; font-size: 13px; }
.file-chip:hover { border-color: var(--gold-500); }
.file-ext { flex: none; font: 700 10px var(--font-mono); background: var(--red-600); color: #fff; padding: 3px 5px; border-radius: var(--radius-xs); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rev-group { margin-bottom: var(--space-3); }
.rev-label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.answer-card.answered { border-color: var(--gold-300); background: var(--gold-50); }
.answer { color: var(--text-heading); font-size: var(--text-md); }

/* ---------- inbox ---------- */
.inbox { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--space-5)); max-height: 60vh; overflow: auto; }
.inbox-row { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-default); color: var(--text-body); text-decoration: none !important; }
.inbox-row:hover { background: var(--neutral-25); }
.inbox-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: transparent; }
.inbox-row.new .inbox-dot { background: var(--red-600); }
.inbox-row.new b { color: var(--text-heading); }
.inbox-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--text-sm); }
.inbox-main b { font-weight: 600; color: var(--text-body); }
.inbox-main time { font-size: 12px; color: var(--text-muted); }
.push-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); margin-bottom: var(--space-3); }
.dot.on { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }
.empty.small { padding: var(--space-5) var(--space-4); font-size: var(--text-sm); }

/* ---------- phone sizing ---------- */
@media (max-width: 600px) {
  .page, .task-page { padding: var(--space-3) var(--space-3) var(--space-5); }
  .page-title { font-size: 26px; }
  .toolbar { gap: var(--space-2); margin-bottom: var(--space-3); }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .card { padding: var(--space-3); border-radius: var(--radius-md); }
  .task-row { padding: var(--space-3); }
  .status-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--space-3)) var(--space-2); padding: 0 var(--space-3); }
  .status-chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .segmented .seg { font-size: 12px; padding: 8px 2px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; }
  .viewer-bar .btn.small { min-height: 34px; padding: 0 8px; }
  .viewer-title span { display: none; }
}
.task-head { flex-wrap: wrap; row-gap: 6px; }
.task-no, .tag, .pill { white-space: nowrap; }
