/* OGRP Projects: one stylesheet for phone, tablet and desktop. */

:root {
  --bg: #f4f6f8; --card: #fff; --text: #1b1f24; --muted: #5f6b7a; --line: #dde2e8;
  --accent: #1f6feb; --accent-soft: #e8f0fe; --ok: #1a7f37; --okbg: #e9f6ed; --danger: #c62828;
  --radius: 12px; --appbar: 56px; --side: 300px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #181d23; --text: #e6e9ee; --muted: #9aa5b1; --line: #2a3139;
    --accent: #5b9bff; --accent-soft: #17243a; --ok: #3fb950; --okbg: #14241a; --danger: #ff6b6b; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--appbar) + 64px); }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 1.45rem; margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 2px; }
a { color: var(--accent); }
.muted, .meta, .stamp { color: var(--muted); }
.meta, .stamp { font-size: .85rem; margin: 0; }
.small { font-size: .9rem; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.error { color: var(--danger); } .ok { color: var(--ok); }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- App bar ---------- */
.appbar { position: sticky; top: 0; z-index: 20; height: var(--appbar); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; padding-top: env(safe-area-inset-top); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 650; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 16px; font-size: .9rem; min-width: 0; }
.user .who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Two-column layout (desktop) that stacks on phones ---------- */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1320px; margin: 0 auto; }
.side { position: sticky; top: var(--appbar); align-self: start; height: calc(100vh - var(--appbar)); overflow-y: auto;
  padding: 24px 16px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.content { padding: 24px; min-width: 0; }
.contractor .content { max-width: 860px; }

/* ---------- Contractor sidebar ---------- */
.summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.summary h1 { font-size: 1.25rem; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.segmented { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented a { flex: 1; text-align: center; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.segmented a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: .92rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 40px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.jump { display: flex; flex-direction: column; gap: 2px; }
.jump a { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.jump a:hover { background: var(--card); }
.jump a.active { background: var(--accent-soft); }
.j-name { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.j-count { font-size: .8rem; color: var(--muted); }
.j-bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.j-bar i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.jump a.complete .j-name::after { content: " ✓"; color: var(--ok); }

/* ---------- Progress ---------- */
.progress { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.pct { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.progress.big { flex-direction: column; align-items: stretch; gap: 6px; }
.progress.big .bar { flex: none; height: 10px; border-radius: 5px; }

/* ---------- Task groups and cards ---------- */
.group { margin-bottom: 28px; }
.group-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.count { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.task.done { background: var(--okbg); }
.task.done h3 { text-decoration: line-through; color: var(--muted); }
.hide-done .task.done, .hide-done .group.all-done, .hide-done .jump a.complete { display: none; }
.tick { position: relative; flex: none; width: 34px; height: 34px; cursor: pointer; }
.tick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tick span { display: block; width: 34px; height: 34px; border: 2px solid var(--muted); border-radius: 9px; background: var(--card); }
.tick input:checked + span { background: var(--ok); border-color: var(--ok); }
.tick input:checked + span::after { content: ""; position: absolute; left: 12px; top: 6px; width: 8px; height: 16px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.tick input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.tick input:disabled + span { opacity: .5; }
.body { flex: 1; min-width: 0; }
details { margin-top: 4px; font-size: .92rem; }
summary { cursor: pointer; color: var(--accent); width: max-content; }
details p { margin: .4em 0; }
.doc { font-size: .92rem; }

/* ---------- Cards, forms, buttons ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.grid .card { margin: 0; }
.row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.activity { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--line); }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.danger { background: var(--danger); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.inline input { flex: 1 1 180px; width: auto; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; flex-direction: row !important; }
.people { list-style: none; padding: 0; margin: 0 0 8px; }
.people li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.people .inline { margin: 0; }
.inactive { opacity: .6; }
.area-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }

/* ---------- Admin menu and task table ---------- */
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.menu a:hover { background: var(--card); }
.menu a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.admin .side { gap: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.filters input, .filters select { width: auto; flex: 1 1 150px; }
.table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
tr.done td { background: var(--okbg); }
td input[type=checkbox] { width: 22px; height: 22px; }

/* ---------- Sign-in and account ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.auth-card .brand { margin-bottom: 24px; font-size: 1.1rem; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  :root { --side: 250px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* ---------- Phone ---------- */
@media (max-width: 860px) {
  :root { --appbar: 52px; }
  html { scroll-padding-top: calc(var(--appbar) + 60px); }
  .layout { display: block; }
  .side { position: static; height: auto; overflow: visible; padding: 16px 16px 0; gap: 12px; }
  .content { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .user a[href="/account"] { display: none; }
  .brand span { display: none; }
  .admin .brand span, .plain .brand span { display: inline; }

  /* Section chips stick under the app bar so long lists stay easy to move around. */
  .contractor .side { display: contents; }
  .contractor .summary { margin: 16px 16px 12px; }
  .contractor .controls { margin: 0 16px 4px; }
  .jump { position: sticky; top: var(--appbar); z-index: 10; flex-direction: row; overflow-x: auto; gap: 8px;
    margin: 0; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .jump::-webkit-scrollbar { display: none; }
  .jump a { display: flex; flex: none; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
  .jump a.active { border-color: var(--accent); }
  .j-name { max-width: 170px; }
  .j-bar { display: none; }
  .contractor .content { padding-top: 12px; }
  .controls { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .segmented { flex: 1 1 220px; }

  .task { padding: 12px; gap: 12px; }
  .tick, .tick span { width: 38px; height: 38px; }
  .tick input:checked + span::after { left: 14px; top: 7px; width: 9px; height: 17px; }

  /* Admin menu becomes a scrolling tab strip. */
  .admin .side { position: sticky; top: var(--appbar); z-index: 10; padding: 0; background: var(--card); border-bottom: 1px solid var(--line); }
  .menu { flex-direction: row; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; }
  .menu::-webkit-scrollbar { display: none; }
  .menu a { flex: none; padding: 8px 12px; }

  /* Task table becomes a list of cards. */
  .table { border: 0; background: transparent; overflow: visible; }
  table.tasks thead { display: none; }
  table.tasks, table.tasks tbody { display: block; }
  table.tasks tr { display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 10px; padding: 12px; margin-bottom: 8px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
  table.tasks tr.done { background: var(--okbg); }
  table.tasks td { display: block; padding: 0; border: 0; background: transparent !important; grid-column: 2 / 3; font-size: .85rem; color: var(--muted); }
  table.tasks td.c-tick { grid-column: 1; grid-row: 1 / span 5; }
  table.tasks td.c-edit { grid-column: 3; grid-row: 1; }
  table.tasks td.c-task { grid-row: 1; font-size: 1rem; color: var(--text); font-weight: 550; }
  table.tasks td.c-ref { order: 2; }
  table.tasks td[data-label]:not(.c-task)::before { content: attr(data-label) ": "; }

  .two { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .people li { flex-direction: column; }
}
