:root {
  --ink: #1c2422; --muted: #66716e; --line: #dfe5e3; --paper: #f6f8f7; --card: #fff;
  --brand: #1f6f5c; --brand-ink: #fff; --danger: #a8322a; --warn: #b4530a;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .4rem; }
h4 { font-size: .95rem; margin: .6rem 0 .2rem; }
p { margin: .5rem 0; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.warn { color: var(--warn); font-weight: 600; }
.pre { white-space: pre-wrap; }
.loading, .empty { color: var(--muted); padding: 1.5rem 0; text-align: center; }

/* ── frame ── */
.top { background: var(--card); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem; padding: .6rem 1rem; position: sticky; top: 0; z-index: 1000; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: .25rem; overflow-x: auto; }
.top nav a { padding: .4rem .7rem; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.top nav a.on { background: var(--brand); color: var(--brand-ink); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.bar h1, .bar h2 { margin-right: auto; }
.bar > div:first-child { margin-right: auto; }
.group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem; }

/* ── controls ── */
.btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 2.5rem; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .25rem .6rem; min-height: 2rem; font-size: .85rem; }
.icon { font: inherit; font-size: 1.4rem; line-height: 1; border: 0; background: none; color: var(--muted); cursor: pointer; padding: .2rem .5rem; }
.linkish { font: inherit; border: 0; background: none; color: var(--brand); text-decoration: underline; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 2.5rem; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=search] { max-width: 16rem; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field { display: block; margin: .7rem 0; }
.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.field > small { display: block; color: var(--muted); margin-top: .2rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0 .8rem; }
.inline { display: flex; gap: .5rem; }
.inline .btn { white-space: nowrap; }
.stack { display: grid; gap: .5rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
.checks label, .check { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.check { display: flex; margin: .4rem 0; }
.nested { border-left: 3px solid var(--line); padding-left: .8rem; }
.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); margin-left: .4rem; white-space: nowrap; }
.maplinks { display: inline-flex; gap: .4rem; flex-wrap: wrap; }

/* ── cards and lists ── */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.list .card { margin: 0; }
.rowcard { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; text-decoration: none; color: inherit; }
.rowcard > span:first-child { display: grid; }
.rowcard small { color: var(--muted); }
.rowcard.off { opacity: .6; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0 1rem; }
.attach { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .7rem 0; }
.invite { background: var(--card); border: 1px solid var(--brand); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }

/* ── calendar ── */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dow { background: var(--card); text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); padding: .35rem 0; text-transform: uppercase; }
.day { background: var(--card); min-height: 6.5rem; padding: .25rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day.can-add { cursor: pointer; }
.day.can-add:hover { background: #fbfdfc; }
.day.other { background: #fafbfb; }
.day.other .num { color: #b7c0bd; }
.day .num { font-size: .8rem; color: var(--muted); align-self: flex-end; padding: 0 .25rem; }
.day.today .num { background: var(--brand); color: #fff; border-radius: 999px; min-width: 1.5rem; text-align: center; }
.chip { font: inherit; font-size: .75rem; text-align: left; border: 0; border-radius: 5px; padding: .15rem .35rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.agenda-day.today h3 { color: var(--brand); }
.agenda-row { font: inherit; color: inherit; text-align: left; width: 100%; display: grid; grid-template-columns: 6.2rem 1fr auto; align-items: center; gap: .8rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .4rem; cursor: pointer; }
.agenda-row:hover { border-color: var(--muted); }
.agenda-row span { display: grid; min-width: 0; }
.agenda-row small { color: var(--muted); }
.agenda-row small.warn { color: var(--warn); }

/* ── hours ── */
.clock { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; background: #e7f3ef; border: 1px solid var(--brand); border-radius: 10px; padding: .5rem .8rem; margin-bottom: .9rem; }
.clock small { flex-basis: 100%; color: var(--muted); }
.scroll { overflow-x: auto; }
.times { width: 100%; border-collapse: collapse; font-size: .92rem; }
.times th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .3rem .6rem; }
.times td { padding: .45rem .6rem; border-top: 1px solid var(--line); white-space: nowrap; }
.times td:nth-last-child(2) { white-space: normal; min-width: 8rem; }

/* ── map ── */
.map { height: min(68vh, 640px); border: 1px solid var(--line); border-radius: 12px; margin-bottom: .8rem; z-index: 0; }
.map.mini { height: 220px; }
.popup { display: grid; gap: .3rem; font-size: .9rem; }

/* ── scope of work ── */
.scope-row { display: grid; grid-template-columns: 1fr 2fr 9rem auto auto; gap: .4rem; padding-bottom: .6rem; margin-bottom: .6rem; border-bottom: 1px solid var(--line); }
.scope-row input[type=date] { width: 9.5rem; }
.scope-row .task-note { grid-column: 1 / -1; font-size: .9rem; }
.scope-read li small { display: block; color: var(--muted); }
.scope-read ul { margin: 0; padding-left: 1.2rem; }
.scope-read li { margin: .15rem 0; }

/* ── dialogs ── */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); box-shadow: 0 20px 60px rgb(0 0 0 / .25); color: var(--ink); }
.dialog::backdrop { background: rgb(20 30 28 / .45); }
.dialog > header { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.dialog > header h2 { margin: 0; }
.dialog .body { padding: .6rem 1rem 1rem; }
.dialog footer { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.when { font-weight: 600; }
.results { margin: .3rem 0; }

/* ── signing in ── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: min(26rem, 100%); }
.auth .btn { width: 100%; margin-top: .4rem; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 1rem); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s; z-index: 3000; max-width: calc(100vw - 2rem); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); border-radius: 12px; }

@media (max-width: 760px) {
  main { padding: .75rem; }
  .day { min-height: 4.2rem; }
  .chip b { display: none; }
  .scope-row { grid-template-columns: 1fr auto; }
  .scope-row input, .scope-row select, .scope-row input[type=date] { grid-column: 1; width: 100%; }
  .scope-row .icon { grid-column: 2; grid-row: 1; }
  .agenda-row { grid-template-columns: 5.6rem 1fr; }
  .agenda-row > small:last-child { grid-column: 2; }
}
