:root {
  --ink: #1f2a37; --muted: #6b7280; --line: #d6dae0; --bg: #f4f5f7; --card: #fff;
  --accent: #2563eb; --danger: #b42318;
  --red: #fce4d6; --red-strong: #f8cbad; --blue: #ddebf7; --blue-strong: #9dc3e6;
  --count: #e2efda; --none: #ededed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: #eef0f3; padding: 0 .25em; border-radius: 3px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--ink); color: #fff; padding: .6rem 1.2rem; }
header.top a, header.top .linklike { color: #fff; text-decoration: none; }
header.top nav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .01em; }

main { max-width: 1100px; margin: 1.2rem auto; padding: 0 1.2rem; }
main.wide { max-width: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.3rem; margin: 1rem 0; }
.card.narrow { max-width: 460px; margin: 3rem auto; }
.flash { background: #ecfdf3; border: 1px solid #abefc6; padding: .6rem .9rem; border-radius: 6px; }
.error { background: #fef3f2; border: 1px solid #fecdca; color: var(--danger); padding: .6rem .9rem; border-radius: 6px; }
.notice { background: #fffaeb; border: 1px solid #fedf89; padding: .4rem 1rem; border-radius: 6px; margin: 1rem 0; }
.danger-zone { border-color: #fecdca; }

form.stack { display: flex; flex-direction: column; gap: .8rem; }
form.inline { display: inline; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; }
input, select { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { font: inherit; padding: .45rem .9rem; border-radius: 5px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
button.small { padding: .15rem .5rem; font-size: .85rem; }
button.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.secret { font-size: 1.1rem; letter-spacing: .05em; user-select: all; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
ol.steps li { margin-bottom: .6rem; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.projhead h1 { margin-bottom: 0; }
.projhead p { margin: .2rem 0 .6rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .45rem .9rem; text-decoration: none; color: var(--ink); border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; }
.tabs a.on { background: var(--card); border-color: var(--line); margin-bottom: -1px; font-weight: 600; }
.tag { font-size: .75rem; background: #eef0f3; border-radius: 10px; padding: .1rem .5rem; font-weight: 500; }
.tag.bad { background: #fef3f2; color: var(--danger); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
table.list th, table.list td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
table.list td.num, table.list th.num { text-align: right; }
table.list tr.dim td { color: var(--muted); }
table.list tr.warn td { background: #fffaeb; }
table.list .actions { text-align: right; white-space: nowrap; }
table.list .actions form + form { margin-left: .25rem; }
.scroll { overflow-x: auto; }
.team { margin-bottom: 1.5rem; }
.team-red table.list th { background: var(--red); }
.team-blue table.list th { background: var(--blue); }
.team-count table.list th { background: var(--count); }

/* Schedule grid */
.gridhelp { margin: 0 0 .3rem; }
.gridstatus { min-height: 1.2em; margin: 0 0 .4rem; font-size: .85rem; color: var(--muted); }
.gridstatus.bad { color: var(--danger); font-weight: 600; }
.gridwrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); background: var(--card); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: .85rem; }
table.grid th, table.grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; background: var(--card); }
table.grid thead th { position: sticky; z-index: 2; padding: .3rem .45rem; font-weight: 600; text-align: center; white-space: nowrap; }
table.grid thead tr.names th { top: 0; height: 2rem; }
table.grid thead tr.positions th { top: 2rem; height: 1.6rem; font-weight: 500; }
table.grid thead tr.teams th { top: 3.6rem; height: 1.5rem; font-weight: 500; font-size: .75rem; }
table.grid thead a { color: inherit; text-decoration: none; }
table.grid .sticky { position: sticky; z-index: 1; }
table.grid thead .sticky { z-index: 3; }
table.grid .c-date { left: 0; min-width: 4.6rem; width: 4.6rem; padding: .25rem .45rem; text-align: left; font-weight: 600; }
table.grid .c-day { left: 4.6rem; min-width: 3rem; width: 3rem; padding: .25rem .45rem; color: var(--muted); }
table.grid .c-phase { left: 7.6rem; min-width: 8.5rem; width: 8.5rem; }
table.grid .c-note { left: 16.1rem; min-width: 11rem; border-right: 2px solid #9aa3ae; }
table.grid th.team-red { background: var(--red-strong); }
table.grid th.team-blue { background: var(--blue-strong); }
table.grid th.team-count { background: var(--count); }
table.grid th.team-none { background: var(--none); }
table.grid tr.outside .c-date, table.grid tr.outside .c-day { color: #9aa3ae; font-style: italic; }
table.grid tr.weekstart > * { border-top: 3px solid #374151; }
table.grid input, table.grid select { border: 0; border-radius: 0; width: 100%; padding: .3rem .4rem; background: transparent; font-size: .85rem; }
table.grid input.cell { min-width: 10.5rem; text-align: center; }
table.grid input.cell.need { min-width: 3.5rem; }
table.grid input[readonly] { cursor: default; }
table.grid input:focus, table.grid select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
table.grid .saving { background: #fffaeb !important; }
table.grid .saved { background: #ecfdf3 !important; transition: background 1s; }
table.grid .failed { background: #fef3f2 !important; outline: 2px solid var(--danger); }
table.grid .changed { background: #eff8ff !important; transition: background 2s; }

@media (max-width: 700px) {
  header.top { flex-direction: column; align-items: flex-start; }
  .card.narrow { margin: 1rem auto; }
}

/* Project teams: fills come from /projects/{id}/teams.css (.tm<ID>). */
.teamhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .5rem .7rem; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; margin-top: 1.2rem; }
.teamhead h2 { margin: 0; }
.teamedit { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.teamedit .teamname { font-size: 1.1rem; font-weight: 700; background: rgba(255,255,255,.6); min-width: 14rem; }
.teamhead .swatch { flex-direction: row; align-items: center; gap: .35rem; font-weight: 500; font-size: .85rem; color: inherit; }
.teamhead input[type=color] { width: 2.4rem; height: 1.9rem; padding: .1rem; }
.teamtools { display: flex; gap: .3rem; align-items: center; }
.team table.list { border-radius: 0 0 8px 8px; }
.team > .muted { border: 1px solid var(--line); border-top: 0; margin: 0; padding: .6rem .7rem; background: var(--card); border-radius: 0 0 8px 8px; }
table.list thead tr[class^="tm"] th { color: inherit; }
a.button.small { padding: .15rem .5rem; font-size: .85rem; }
form.search { margin: .4rem 0 1rem; }
form.search input[type=search] { min-width: 18rem; }
label.plain { display: inline; font-weight: 400; font-size: inherit; cursor: pointer; }
table.pick td:first-child { width: 2rem; }
[hidden] { display: none !important; }
.inputbtn { display: flex; gap: .3rem; align-items: center; }
.inputbtn input { width: 7rem; }
table.list tr.handsrow td { background: #fafbfc; font-style: italic; }
table.grid td.calc { text-align: center; min-width: 3.6rem; color: var(--muted); font-variant-numeric: tabular-nums; background: #fafbfc; }
table.grid th.calc { font-size: .75rem; min-width: 3.6rem; }
table.grid td.tofill input { width: 3.6rem; min-width: 3.6rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Fill colour menu (app.js): Excel-style theme and standard colours, with OK and Cancel. */
.pickfield { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.teamhead .pickfield { flex-direction: row; align-items: center; gap: .35rem; font-weight: 500; font-size: .85rem; }
.colorpick { position: relative; display: inline-flex; }
.pal-open { width: 2.4rem; height: 1.9rem; padding: 0; border: 1px solid #8a919c; border-radius: 4px; }
.pal-open:focus-visible, .pal-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.palette { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: .6rem; width: max-content; }
.pal-label { font-size: .78rem; font-weight: 600; color: var(--muted); margin: .2rem 0 .3rem; }
.pal-grid { display: grid; grid-template-columns: repeat(10, 1.3rem); gap: 3px; margin-bottom: .5rem; }
.pal-swatch { width: 1.3rem; height: 1.3rem; padding: 0; border: 1px solid rgba(0,0,0,.18); border-radius: 2px; cursor: pointer; }
.pal-swatch:hover { outline: 2px solid #f59e0b; outline-offset: 0; }
.pal-swatch.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.pal-more { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; font-size: .85rem; margin: .1rem 0 .6rem; }
.pal-more input[type=color] { width: 2rem; height: 1.5rem; padding: 0; }
.pal-foot { display: flex; align-items: center; gap: .4rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.pal-now { flex: 1; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Greyed-out crew: the team's colour, greyed (gr<ID> in teams.css), and locked. */
table.list tr.greyed td, table.list tr.greyed td a { color: #5b6470; }
.greyedtag { font-size: .72rem; background: rgba(255,255,255,.6); color: #4b5563; white-space: nowrap; }
table.grid td.greyed input { background: transparent; color: #5b6470; cursor: not-allowed; }
table.grid th.greyed a { color: #5b6470; }
.lockednote { padding: .6rem .8rem; border-radius: 6px; border: 1px solid var(--line); margin: 0; }
.danger-zone h3 { margin: 1rem 0 .3rem; font-size: 1rem; }
.danger-zone h3:first-of-type { margin-top: .4rem; }

/* Several schedule cells selected (Shift-click, Cmd-click). */
table.grid td.sel, table.grid td.sel input { background: #dbe8ff !important; }
table.grid td.sel { box-shadow: inset 0 0 0 1px #2563eb; }

/* Kit days on crew forms and lists. */
fieldset.kitdays { gap: .4rem; }
fieldset.kitdays legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
fieldset.kitdays p { margin: 0; }
.kitdays-list { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* Crew tables: headers that wrap onto several lines are centred. */
table.list.crew th, table.list.crew th.num { text-align: center; vertical-align: middle; }
table.list.crew th .hrs { white-space: nowrap; text-transform: none; }

/* Schedule: Date, Day, Phase and Description headers span the three header rows, text at the top. */
table.grid thead th[rowspan] { vertical-align: top; }

/* Call popup on the schedule: call time and length for the selected cells. */
.callpop { position: fixed; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: .6rem .7rem; width: max-content; max-width: calc(100vw - 16px); }
.callpop .cp-title { font-weight: 600; font-size: .85rem; margin-bottom: .4rem; }
.callpop .cp-fields { display: grid; grid-template-columns: auto auto; gap: .4rem .6rem; align-items: center; margin-bottom: .5rem; }
.callpop .cp-fields > label { font-weight: 500; font-size: .85rem; }
.callpop .cp-mp { display: flex; gap: .8rem; align-items: center; margin-bottom: .55rem; font-size: .85rem; }
.callpop .cp-mp label.check { display: inline-flex; align-items: center; gap: .25rem; font-weight: 600; }
.callpop .cp-fields input { width: 7.5rem; }
.callpop .cp-len { display: inline-flex; align-items: center; gap: .3rem; font-weight: 500; }
.callpop .cp-len input { width: 4.5rem; }
.callpop .cp-buttons { display: flex; gap: .35rem; flex-wrap: wrap; }
.teamedit .teamfield { display: inline-flex; flex-direction: row; align-items: center; gap: .35rem; font-size: .85rem; }
.teamedit .row3 { width: 9rem; background: rgba(255,255,255,.6); }
.othrs { width: 3.5rem; text-align: center; }
.teamedit .othrs { background: rgba(255,255,255,.6); }
.callpop .cp-timebox { display: inline-flex; align-items: center; gap: .35rem; }
.callpop .cp-timebox input { width: 6rem; }
.callpop .cp-ampm { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.callpop .cp-ampm button { border: 0; border-radius: 0; background: #fff; padding: .3rem .5rem; font-size: .8rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.callpop .cp-ampm button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.callpop input.bad { border-color: #d93025; background: #fdecea; }
table.sortable th a { color: inherit; text-decoration: none; display: block; }
table.sortable th a:hover { text-decoration: underline; }
table.sortable th .arrow { font-size: .7rem; }
.search .button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.posorder summary { cursor: pointer; font-weight: 600; }
.orderlist { margin: .5rem 0; padding-left: 1.6rem; max-width: 28rem; }
.orderlist li { display: flex; align-items: center; gap: .4rem; padding: .15rem 0; }
.orderlist li span { flex: 1; }
.pickcell { width: 1.6rem; text-align: center; white-space: nowrap; }
.pickwrap { display: inline-flex; align-items: center; gap: .3rem; }
table.pickable tbody tr[data-id] { cursor: default; user-select: none; }
table.pickable tbody tr.picked td { background: #dbe7ff !important; }
.bulkbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: .5rem .7rem; margin: .5rem 0; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.bulkbar[hidden] { display: none; }
.bulkbar .bulkcount { font-weight: 600; margin-right: .4rem; }
.draghandle { cursor: grab; touch-action: none; font-size: 1rem; line-height: 1; padding: .2rem .45rem; }
tr.dragging td { background: #fff7d6 !important; }
body.dragging-row, body.dragging-row * { cursor: grabbing !important; user-select: none; }
.bulkbools label { min-width: 9rem; }
.bulknames { line-height: 1.6; }
.drhours { display: flex; align-items: flex-end; gap: .5rem; }
.drhours input[name^="day_rate"] { width: 6rem; }
.drhours label.check { margin-bottom: .45rem; white-space: nowrap; }
.gridtools { display: flex; align-items: center; gap: .5rem; margin: 0 0 .3rem; font-size: .85rem; }
.gridzoom { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; margin: 0; }
.gridzoom input[type="range"] { width: 10rem; padding: 0; }
.gridzoom output { min-width: 2.8rem; font-variant-numeric: tabular-nums; }
.colchips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .7rem; }
.colchip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .3rem .15rem .55rem;
  background: #eef4ff; font-size: .82rem; cursor: grab; user-select: none; }
.colchip.unused { background: #fff7d6; border-color: #e6c766; }
.colchip.picked { border-color: var(--accent); }
.colchip .grip { color: var(--muted); }
.colchip select { width: auto; min-width: 0; font-size: .8rem; padding: .1rem 1.4rem .1rem .4rem; border-radius: 999px; }
table.dropping th[data-field] { outline: 2px dashed var(--accent); outline-offset: -3px; }
table.dropping th[data-field].over { background: #dbe7ff; }
body.busy, body.busy * { cursor: progress !important; }
.orderlist li.dragging { background: #fff7d6; border-radius: 6px; }
.orderlist .orderhandle { padding: .1rem .35rem; }
form.changed .orderlist + div::after { content: "Not saved yet"; margin-left: .6rem; color: #b06000; font-size: .85rem; }
.hourlyfield { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.hourlyfield label.check { font-weight: normal; white-space: nowrap; min-height: 2.2rem; display: inline-flex; align-items: center; gap: .3rem; }
.callpop .cp-plus { margin-left: .3rem; font-size: .78rem; font-weight: 600; color: #b06000; background: #fff7d6; border-radius: 999px; padding: .05rem .4rem; }
.callpop .cp-plus[hidden] { display: none; }
.phaselist { max-width: 44rem; }
.phaselist input[name=phase_name] { flex: 1; min-width: 8rem; }
.phaselist label.plain { display: flex; flex-direction: row; align-items: center; gap: .3rem; font-weight: normal; white-space: nowrap; }
.phaselist .phasedays { min-width: 4.5rem; font-size: .85rem; }
label.inline { flex-direction: row; align-items: center; gap: .5rem; align-self: flex-start; }
table.grid td.copied { outline: 2px dashed #2563eb; outline-offset: -2px; }
table.grid input[readonly] { caret-color: transparent; user-select: none; -webkit-user-select: none; }
table.grid input[readonly]::selection { background: transparent; }
table.grid input[data-editing] { cursor: text; outline-color: #16a34a; }
.tsbar { align-items: flex-end; }
.tswrap { display: flex; gap: 1rem; align-items: flex-start; margin: 1rem 0; }
.tspage { position: relative; flex: 1; min-width: 0; max-width: 1200px; border: 1px solid var(--line, #ccc); background: #fff; user-select: none; -webkit-user-select: none; touch-action: none; cursor: default; }
.tspage.inserting, .tspage.inserting .tsbox { cursor: crosshair; }
button[aria-pressed="true"] { background: var(--accent, #2f6fde); color: #fff; border-color: var(--accent, #2f6fde); }
.tspage img { display: block; width: 100%; height: auto; pointer-events: none; }
.tsbox { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; border: 1px solid rgba(37, 99, 235, .8); background: rgba(37, 99, 235, .08); color: #1d4ed8; font-family: Helvetica, Arial, sans-serif; line-height: 1; overflow: hidden; cursor: move; }
.tsbox.blank { border-style: dashed; color: #b06000; }
.tsbox.cover { background: rgba(255, 255, 255, .85); }
.tsbox.on { border: 2px solid #2563eb; background: rgba(37, 99, 235, .16); z-index: 2; }
.tsrow { flex: 1; display: flex; align-items: center; justify-content: inherit; padding: 0 2px; white-space: nowrap; overflow: hidden; min-height: 0; border-bottom: 1px dotted rgba(37, 99, 235, .45); }
.tshandle { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; background: #2563eb; cursor: nwse-resize; }
.tspanel { width: 17rem; flex: none; position: sticky; top: 1rem; }
.sheetlist { margin: .4rem 0 .8rem; padding-left: 1.2rem; }
.tsmarquee { position: absolute; border: 1px dashed #2563eb; background: rgba(37, 99, 235, .06); pointer-events: none; z-index: 3; }
/* The Timesheets tab: a filled timesheet on screen. */
.tsview { cursor: default; }
.tvtext { position: absolute; box-sizing: border-box; display: flex; align-items: center; padding: 0 1.5px; color: #000; font-family: Helvetica, Arial, sans-serif; line-height: 1; white-space: nowrap; overflow: hidden; }
.tvtext.cover { background: #fff; }
.tvcovers { margin: 0; line-height: 1.3; }
.tvcovers .muted { font-size: .85rem; }
fieldset.ts-lineup { gap: .3rem; }
fieldset.ts-lineup legend { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.ts-lineup .lineup2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem; }
