/* ISL master admin prototype · layout and the few parts tokens.css has no recipe for.
   Font sizes in rem (0.8125rem = 13 px is the floor) so the phone's big-text setting still works. Light only. */

html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body.app { font-size: 0.9375rem; line-height: 1.45; min-height: 100vh; overflow-x: hidden; }
* { box-sizing: border-box; }
h1, h2, h3 { margin: 0; }
small { font-size: 0.8125rem; }
a { color: var(--link); }
.muted { color: var(--muted); }
.en { display: block; font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--bad-text); }
.bad-text { color: var(--bad-text); }
.ok-text { color: var(--ok-text); }
.warn-text { color: var(--warn); }
.grey { color: var(--muted); }
.strike { text-decoration: line-through; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 20; flex-wrap: wrap; row-gap: 4px; min-height: 52px; }
.top .brand { display: inline-flex; align-items: center; min-height: 44px; }
.top .logo { height: var(--logo-h); width: auto; }
.ptitle { font-size: 1.0625rem; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today { font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.viewas { position: relative; }
.asbtn { min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  font: 700 0.875rem/1.2 var(--font); cursor: pointer; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asmenu { position: absolute; right: 0; top: calc(100% + 6px); width: min(360px, 92vw); max-height: 70vh; overflow: auto; z-index: 40; }
.asmenu .grp { padding: 8px 12px 2px; font-size: 0.8125rem; color: var(--muted); font-weight: 700; }
.asmenu [role="menuitem"] { font-size: 0.9375rem; flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 12px; cursor: pointer; }
.asmenu [role="menuitem"] small { color: var(--muted); }
.asmenu [aria-checked="true"] { box-shadow: inset 3px 0 0 var(--in); background: var(--ok-tint); }
.teststrip { background: var(--info-tint); border-bottom: 1px solid var(--info-line); color: var(--info); padding: 5px var(--gutter); font-size: 0.875rem; }
.teststrip b { margin-right: 8px; } .teststrip small { color: var(--info); }
.asbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--info); color: var(--on-colour); padding: 4px var(--gutter); font-size: 0.875rem; }
.asbar[hidden] { display: none; }
.asbar button { min-height: 44px; padding: 4px 14px; border-radius: var(--radius); border: 1px solid var(--on-colour); background: transparent; color: var(--on-colour);
  font: 700 0.875rem var(--font); cursor: pointer; }

.layout { display: flex; align-items: flex-start; max-width: 1480px; }
.sidenav { flex: 0 0 220px; position: sticky; top: 56px; padding: 10px 0; }
.sidenav a, .navitem { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 4px 12px 4px 14px;
  color: var(--ink); text-decoration: none; border-left: 3px solid transparent; font-size: 0.9375rem; font-weight: 700; line-height: 1.2; }
.sidenav a small, .navitem small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
.sidenav a[aria-current="page"] { border-left-color: var(--in); background: var(--soft); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.5rem; padding: 0 6px; border-radius: 999px;
  background: var(--ink); color: var(--on-colour); font-size: 0.8125rem; font-weight: 700; }
.view { flex: 1 1 auto; min-width: 0; max-width: 1240px; padding: 14px 18px 40px; outline: none; }
.bottombar { display: none; }

@media (max-width: 899.98px) {
  .sidenav { display: none; }
  .view { padding: 10px var(--gutter) 90px; }
  .today { font-size: 0.8125rem; }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: 56px; background: var(--card); border-top: 1px solid var(--line); }
  .bottombar.none { display: none; }
  .bottombar a, .bottombar button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    min-height: 56px; padding: calc(1.25rem - 7px) 2px 2px; border: 0; background: none; color: var(--ink); text-decoration: none; font: 700 0.875rem/1.15 var(--font); cursor: pointer; position: relative; }
  .bottombar { height: auto; min-height: 56px; }
  .bottombar span { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
  .bottombar small { display: block; font-size: 0.8125rem; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bottombar [aria-current="page"] { color: var(--ok-text); box-shadow: inset 0 3px 0 var(--in); }
  /* r5 S1: the items get head-room the height of the badge less the 7 px above the bar, so a label starts under the badge */
  .bottombar .badge { position: absolute; top: -7px; right: 2px; min-width: 1.25rem; height: 1.25rem; padding: 0 4px; }
  /* r6: the menu hangs from the (sticky) header, not from the button, so it stays on screen wherever the button wraps to */
  .viewas { position: static; }
  .asmenu { left: 12px; right: 12px; width: auto; max-width: 360px; }
}

/* ---------- drawers, toast ---------- */
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgba(43, 49, 52, .5); overflow: hidden; overscroll-behavior: contain; }
.drawer { border: 1px solid var(--line); border-radius: var(--radius-box); background: var(--card); color: var(--ink); padding: 12px 16px 16px;
  width: min(520px, 94vw); max-height: 88vh; overflow: auto; box-shadow: 0 8px 24px rgba(20, 24, 27, .18); }
.drawer .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 8px; }
.drawer .dtitle { font-size: 1.125rem; margin: 0 0 10px; }
.drawer .dtitle small { display: block; font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.drawer.warn { border-top: 4px solid var(--bad); }
.drawer form { margin: 0; }
.drawer .acts { display: grid; gap: 8px; margin-top: 12px; }
.drawer .linkbtn { background: none; border: 0; color: var(--link); font: 400 0.9375rem var(--font); min-height: 44px; cursor: pointer; text-decoration: underline; }
#morelist a { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 4px 8px;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; line-height: 1.2; }
#morelist a > span:first-child { display: flex; flex-direction: column; }
#morelist a small { display: block; font-weight: 400; color: var(--muted); }
#morelist a .badge { flex: 0 0 auto; }
@media (max-width: 899.98px) {
  .drawer { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: var(--radius-box) var(--radius-box) 0 0; }
}
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 60; background: var(--ink); color: var(--card); border-radius: var(--radius-box);
  padding: 10px 16px; font: 700 0.9375rem var(--font); box-shadow: 0 8px 24px rgba(20, 24, 27, .18); max-width: 92vw; }
.toast small { display: block; font-weight: 400; font-size: 0.8125rem; }
@media (max-width: 899.98px) { .toast { bottom: 70px; } }

/* ---------- page parts ---------- */
.phead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 10px; }
.phead h2 { font-size: 1.25rem; }
.phead h2 .en { display: inline; margin-left: 6px; }
.src { font-size: 0.8125rem; color: var(--muted); margin: 0 0 10px; }
.src.late { color: var(--warn); }
.isl-card { padding: 12px 14px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.card-h h3 { font-size: 1rem; }
.card-h h3 .en { display: inline; margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
@media (max-width: 899.98px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }

.answer { border-radius: var(--radius-box); border: 1px solid var(--line); background: var(--card); padding: 12px 14px; margin: 0 0 12px; font-size: 1.0625rem; font-weight: 700; }
.answer .en { font-size: 0.8125rem; }
.answer.ok { border-color: var(--ok); }
.answer.warn { background: var(--warn-tint); border-color: var(--warn); }
.answer.bad { background: var(--bad-tint); border-color: var(--bad); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
@media (max-width: 899.98px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); } .tiles .tile .fig { font-size: 1.0625rem; } }
.tile .fig small { display: block; font-size: 0.875rem; font-weight: 700; }
.tile { display: block; min-height: 44px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: var(--ink); text-decoration: none; }
.tile:hover { background: var(--soft); }
.tile .lbl { font-size: 0.875rem; font-weight: 700; }
.tile .lbl small { display: block; font-weight: 400; color: var(--muted); }
.tile .fig { font-size: 1.375rem; font-weight: 800; margin: 4px 0 2px; overflow-wrap: anywhere; }
.tile .sub { font-size: 0.8125rem; color: var(--muted); }

.needs { list-style: none; margin: 0; padding: 0; }
.needs li { margin: 0 0 6px; }
.needs a, details.grp > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 48px; padding: 6px 10px; border: 1px solid var(--line);
  border-left: 3px solid var(--rule); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; }
.needs a:hover, details.grp > summary:hover { background: var(--soft); }
.needs a.problem, details.grp.problem > summary { border-left-color: var(--bad); }
.needs a.waiting, details.grp.waiting > summary { border-left-color: var(--warn); }
.needs .txt { flex: 1 1 8rem; min-width: 0; font-size: 0.9375rem; }
.needs .txt .en { font-size: 0.8125rem; }
.needs .cnt { flex: 0 0 auto; margin-left: auto; font-size: 0.875rem; font-weight: 700; white-space: nowrap; }
details.grp > summary { list-style: none; cursor: pointer; }
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::after { content: '▸'; color: var(--muted); flex: 0 0 auto; }
details.grp[open] > summary::after { content: '▾'; }
.needs.sub { margin: 6px 0 0 14px; }
.needs.sub a { min-height: 44px; }

/* Overview (Andrew 28/11): ≥ 1024 px the to-do and feeds sit in a narrow left column beside the tiles and jobs, so the jobs start near the top.
   Below 1024 px one column: answer, the to-do as one line, jobs right after it, then tiles and feeds. */
.ov { display: flex; flex-direction: column; gap: 12px; }
.ov-side, .ov-main { display: contents; }
.ov .answer { order: 0; margin: 0; } .ov .todo { order: 1; } .ov .jobsbox { order: 2; } .ov .tiles { order: 3; margin: 0; } .ov .feedc { order: 4; }
.todo-h { display: flex; align-items: center; gap: 6px; font-size: 0.9375rem; margin: 10px 0 6px; }
.todo-h::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.todo-h.problem::before { background: var(--bad); }
.todo-body > .todo-h:first-child { margin-top: 0; }
.todo-tg { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  color: var(--link); font: 700 0.9375rem/1.2 var(--font); cursor: pointer; }
.todo-tg b { color: var(--link); }
.feedl { list-style: none; margin: 0; padding: 0; }
.feedl li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 6px; min-height: 40px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.feedc .card-h h3 a.lnk { color: var(--ink); text-decoration: underline; }
@media (max-width: 1023.98px) {
  .todo { padding: 4px 6px; }
  .todo.has-prob { border-left: 3px solid var(--bad); }
  .todo > .card-h { margin: 0; }
  .todo > .card-h h3 { display: none; }
  .todo-tg { flex: 1 1 auto; justify-content: flex-start; border: 0; background: none; color: var(--ink); text-align: left; }
  .todo-tg .d { display: none; }
  .todo:not(.open) .todo-body { display: none; }
  .todo.open .todo-body { padding: 4px 6px 6px; }
}
@media (min-width: 1024px) {
  .ov { display: grid; grid-template-columns: 16rem minmax(0, 1fr); align-items: start; }
  .ov .answer { grid-column: 1 / -1; }
  .ov-side, .ov-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .ov-side { grid-column: 1; } .ov-main { grid-column: 2; }
  .ov .todo, .ov .feedc, .ov .tiles, .ov .jobsbox { order: 0; }   /* desktop: DOM order (to-do then feeds; tiles then jobs) */
  .todo { padding: 10px 10px 12px; }
  .todo-tg { padding: 4px 10px; font-size: 0.875rem; }
  .todo-tg .m { display: none; }
  .todo.few .todo-tg { display: none; }
  .todo:not(.open) .needs > li.x { display: none; }
  .todo.open .todo-body { max-height: min(40rem, calc(100vh - 12rem)); overflow-y: auto; padding-right: 4px; }
  .ov .tiles .tile .fig { font-size: 1.25rem; }
}
@media (min-width: 1024px) and (max-width: 1179.98px) { .ov .tiles .tile .fig { font-size: 1.0625rem; } }   /* r5 S1: money stays in its tile */
/* the jobs card turns its rows into cards when its own box is narrow (1024–1100 px beside the to-do column); older browsers scroll it */
.jobsbox { container-type: inline-size; min-width: 0; }
@container (max-width: 739.98px) {
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; padding: 6px 10px; }
  table.cards td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 10px; border: 0; padding: 3px 0; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.8125rem; text-align: left; flex: 0 0 auto; max-width: 55%; }
  table.cards td.head { display: block; text-align: left; font-weight: 700; padding-bottom: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  table.cards td.head::before { content: none; }
  table.cards td .v { min-width: 0; margin-left: auto; max-width: 100%; text-align: right; overflow-wrap: anywhere; }   /* r6 (SCORE_5 L1): a value that cannot fit beside its label drops under it, whole */
  table.cards td.head .v { text-align: left; }
}

/* tags, pills, chips */
.tag { display: inline-block; font-size: 0.8125rem; font-weight: 700; color: var(--info); background: var(--info-tint); border-radius: 8px; padding: 1px 7px; white-space: nowrap; text-decoration: none; }
a.tag { text-decoration: none; }
.isl-pill { font-size: 0.8125rem; display: inline-block; line-height: 1.4; }
.isl-pill.info { color: var(--info); border-color: var(--info); }
.isl-pill.ink { color: var(--ink); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { display: inline-flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--radius-chip);
  background: var(--card); color: var(--ink); font: 400 0.875rem/1.2 var(--font); cursor: pointer; text-decoration: none; text-align: left; }
.chip b { font-weight: 700; }
.chip small { color: var(--muted); }
.chip[aria-pressed="true"], .chip[aria-current="true"] { border: 2px solid var(--in); background: var(--ok-tint); font-weight: 700; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); font: 700 0.9375rem/1.2 var(--font); cursor: pointer; text-decoration: none; flex-wrap: wrap; text-align: center; max-width: 100%; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-colour); }
.btn.in { background: var(--in-strong); border-color: var(--in-strong); color: var(--on-colour); }
.btn.badline { color: var(--bad-text); border-color: var(--bad); background: var(--card); }
.btn:disabled { background: var(--disabled-bg); color: var(--disabled-ink); border-color: var(--disabled-line); cursor: not-allowed; }
.btn small { font-weight: 400; font-size: 0.8125rem; }
.isl-btn { font-size: 0.9375rem; }
.isl-btn small { font-weight: 400; font-size: 0.8125rem; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }

/* links inside tables are row actions: 44 px tall */
a.lnk { display: inline-flex; align-items: center; min-height: 44px; color: var(--link); }
td a.lnk { vertical-align: middle; }
a.tagl { text-decoration: none; }
a.tagl:hover .tag { text-decoration: underline; }

/* tables */
.tbl { overflow-x: auto; max-width: 100%; margin: 0 0 6px; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.t th { text-align: left; font-weight: 700; font-size: 0.8125rem; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
table.t th small { display: block; font-weight: 400; }
table.t td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th.num, table.t td.num { text-align: right; }
table.t tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
table.t tr.sub td { background: var(--soft); font-weight: 700; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: var(--soft); }
table.t tr.dim td { color: var(--muted); }
/* r6 sweep: Payables 按供應商 (two cells per row): the amount drops under the name when it cannot fit beside it (320 px, 150 % text), instead of being cut in the card's own scroll box */
table.bysup, table.bysup tbody { display: block; width: 100%; }
table.bysup tr { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 10px; border-bottom: 1px solid var(--line); }
table.bysup td { border-bottom: 0; min-width: 0; }
table.bysup td:first-child { flex: 1 1 8rem; overflow-wrap: anywhere; }
table.bysup td.num { flex: 0 0 auto; margin-left: auto; }
.bar { height: 4px; background: var(--soft); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--rule); }
.bar i.over { background: var(--bad); }

/* tables that turn into cards under 900 px */
@media (max-width: 899.98px) {
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; padding: 6px 10px; }
  table.cards td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 10px; border: 0; padding: 3px 0; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.8125rem; text-align: left; flex: 0 0 auto; max-width: 55%; }
  table.cards td.head { display: block; text-align: left; font-weight: 700; padding-bottom: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  table.cards td.head::before { content: none; }
  table.cards td .v { min-width: 0; margin-left: auto; max-width: 100%; text-align: right; overflow-wrap: anywhere; }   /* r6 (SCORE_5 L1): a value that cannot fit beside its label drops under it, whole */
  table.cards td.head .v { text-align: left; }
  table.cards td:empty { display: none; }
  table.cards tr.total { border-width: 2px; }
}

/* sum slips (− + =) */
.slip { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.slip h3 { font-size: 1rem; margin: 0 0 6px; }
.slip h3 .en { display: inline; margin-left: 6px; }
.slip .ln { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; padding: 3px 0; font-size: 0.875rem; }   /* r5 S1: a figure that does not fit drops under its label */
.slip .ln .op { display: inline-block; width: 1.1em; color: var(--muted); }
.slip .ln > span:first-child small { display: block; padding-left: 1.1em; }
.slip .ln.eq > span:first-child small { font-weight: 400; }
.slip .ln > :last-child { text-align: right; margin-left: auto; }
.slip .ln.eq { border-top: 1px solid var(--ink); margin-top: 3px; padding-top: 5px; font-weight: 800; font-size: 1rem; }
.slip .note { font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }
.slip .note.bad-text { color: var(--bad-text); }
.bigfig { font-size: 1.75rem; font-size: min(1.75rem, 10vw); font-weight: 800; }   /* r5 S1: with large text on a 320 px phone the one big figure stays on the screen */
.unrel { color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 12px; overflow-x: auto; }
.tabs [role="tab"] { min-height: 44px; padding: 6px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink); font: 700 0.9375rem/1.2 var(--font);
  cursor: pointer; white-space: nowrap; }
.tabs [role="tab"] small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
.tabs [role="tab"][aria-selected="true"] { border-bottom-color: var(--in); background: var(--soft); }

/* states */
.ph { height: 2.6rem; border-radius: var(--radius); background: var(--soft); margin: 0 0 8px; }
.loading .msg { color: var(--muted); margin: 0 0 8px; }
.empty { color: var(--muted); padding: 8px 0; margin: 0; }
.notallowed { max-width: 520px; }

/* clock-in */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
@media (max-width: 359.98px) { .sites { grid-template-columns: minmax(0, 1fr); } }
.site h3 { font-size: 1rem; }
.counts { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.875rem; margin: 4px 0 6px; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; border-top: 1px solid var(--line); font-size: 0.875rem; }
.prow.notin { color: var(--muted); }
.prow .times { display: flex; gap: 10px; white-space: nowrap; }
.tin { color: var(--in-text); font-weight: 700; }
.tout { color: var(--out-text); font-weight: 700; }
.grp-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.9375rem; font-weight: 700; margin: 10px 0 4px; }
table.t tr.site-row td { background: var(--soft); }
table.t tr.site-row .grp-h { margin: 2px 0; }
details.day { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; padding: 0 10px; background: var(--card); }
details.day > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 48px; cursor: pointer; font-size: 0.9375rem; }
details.day > summary { list-style: none; }
details.day > summary::-webkit-details-marker { display: none; }
details.day > summary::before { content: '▸'; color: var(--muted); width: 1em; }
details.day[open] > summary::before { content: '▾'; }
details.day[open] > summary { border-bottom: 1px solid var(--line); }
details.day > summary .muted { font-size: 0.875rem; }
.tick { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.tick input { width: 24px; height: 24px; accent-color: var(--in); margin: 0; }

/* timesheet grid: scrolls inside its own box */
.grid-box { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.ts { border-collapse: collapse; font-size: 0.8125rem; }
table.ts th, table.ts td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: center; min-width: 2.6rem; }
table.ts th { color: var(--muted); font-weight: 700; padding: 4px 2px; }
table.ts th.who, table.ts td.who { position: sticky; left: 0; background: var(--card); text-align: left; min-width: 9rem; padding: 2px 6px; z-index: 1; }
table.ts td.tot, table.ts th.tot { position: sticky; right: 0; background: var(--card); border-left: 2px solid var(--line); z-index: 1;
  padding: 2px 8px; white-space: nowrap; font-weight: 700; text-align: right; }
table.ts th.tot small { display: block; font-weight: 400; }
table.ts td.tot .en { font-weight: 400; }
table.ts button.cell { width: 100%; min-height: 44px; border: 0; background: none; font: 700 0.8125rem var(--font); color: var(--ink); cursor: pointer; padding: 0; }
table.ts button.cell.pending { background: var(--warn-tint); }
table.ts button.cell.open { background: var(--ok-tint); }
table.ts button.cell.rejected { color: var(--muted); text-decoration: line-through; }
table.ts button.cell.problem { box-shadow: inset 0 0 0 2px var(--bad); color: var(--bad-text); }
table.ts tr.coltot td { font-weight: 700; padding: 4px 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8125rem; color: var(--muted); margin: 6px 0; }
.legend i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }
.legend i.pending { background: var(--warn-tint); } .legend i.open { background: var(--ok-tint); } .legend i.problem { box-shadow: inset 0 0 0 2px var(--bad); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0 0 10px; }
.filters label { display: flex; flex-direction: column; font-size: 0.8125rem; color: var(--muted); gap: 2px; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.filters select { width: 100%; }
.filters select, .filters input, .drawer input, .drawer select { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  color: var(--ink); font: 400 1rem var(--font); max-width: 100%; }
.drawer label { display: block; font-size: 0.8125rem; color: var(--muted); margin: 8px 0 2px; }
.drawer input, .drawer select { width: 100%; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 0.9375rem; margin: 0; align-items: baseline; }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 479.98px) { .facts { grid-template-columns: minmax(0, 1fr); } .facts dd { margin-bottom: 6px; } }
.strip { display: flex; flex-wrap: wrap; gap: 4px; }
.strip .day { width: 2.6rem; text-align: center; font-size: 0.8125rem; border: 1px solid var(--line); border-radius: 4px; padding: 2px 0; background: var(--card); }
.strip .day b { display: block; font-size: 0.875rem; }
.strip .day.pending { background: var(--warn-tint); } .strip .day.open { background: var(--ok-tint); } .strip .day.problem { box-shadow: inset 0 0 0 2px var(--bad); }
.strip .day.none { color: var(--muted); }

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

/* Overview: jobs table keeps the job name readable */
.jobs td.head { min-width: 9rem; }
.jobs th { white-space: nowrap; }
@media (min-width: 900px) { table.jobs td, table.jobs th { padding-left: 4px; padding-right: 4px; } table.jobs { font-size: 0.8125rem; } }
td.num .en { white-space: normal; }
td.num .en.nowrap { white-space: nowrap; }
/* Cost list (eight columns at 1280): 13 px like the Overview jobs table, second figures on one line, the job keeps a readable width */
@media (min-width: 900px) {
  table.costtbl { font-size: 0.8125rem; }
  table.costtbl td.num .en { white-space: nowrap; }
  table.costtbl td.mg .en { white-space: normal; }
}
.jn { display: block; font-weight: 700; }
@media (min-width: 1100px) {
  .tiles.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tiles.five .tile .fig { font-size: 1.125rem; }
  table.costtbl td.head { min-width: 8.5rem; }
}
.pmchip { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-chip); background: var(--card); font-size: 0.875rem; }
/* Payables: the by-supplier list sits below the table (side by side never fits: .view is capped at 1240px and the table needs ~1000px) */
.gridside { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.paytbl td:first-child { min-width: 8rem; }
@media (min-width: 900px) { table.paytbl td, table.paytbl th, table.costtbl td, table.costtbl th { padding-left: 6px; padding-right: 6px; } }
td .btn, .btnrow .btn { white-space: nowrap; }
.stickybar { position: sticky; bottom: 0; padding: 8px 0; background: var(--card); }
@media (max-width: 899.98px) { .stickybar { bottom: 56px; } }
/* People & roles on a phone (S1): three lines a person */
.m-only { display: none; }
@media (max-width: 899.98px) { .m-only { display: inline; } table.cards td.opt { display: none; } }
/* Items tab (S7): the item name keeps one line at 1280 */
table.itemtbl td.head { min-width: 9rem; }
table.itemtbl .split { display: block; font-size: 0.8125rem; color: var(--muted); }
tr[hidden], .empty[hidden] { display: none !important; }
.facts dd .isl-pill { white-space: normal; max-width: 100%; }
@media (min-width: 900px) {
  table.itemtbl { font-size: 0.8125rem; }
  table.itemtbl td, table.itemtbl th { padding-left: 5px; padding-right: 5px; }
  table.itemtbl td.flags .v { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
}
/* invoice page (S3): the two columns only from 1100 px; below, the 計入何處 card goes under the facts */
@media (max-width: 1099.98px) { .invgrid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- round 4: the A / B link, A's jobs cap, Overview variant B (PLAN 9.7) ---------- */
.ablink { font-size: 0.875rem; font-weight: 700; white-space: nowrap; }
.card-h .ablink { margin: -10px 0; }          /* 44 px to tap, without making A's card head taller */
.jobs-more { width: 100%; margin-top: 6px; }
@media (min-width: 1024px) {
  .ovb .jobsbox { grid-column: 1 / -1; }
  .ovb .ov-side:empty { display: none; } .ovb .ov-side:empty + .ov-main { grid-column: 1 / -1; }   /* nothing to do and no feeds: the tiles take the width */
}
.jbcard { margin: 0; }
.jb-h { align-items: center; gap: 6px 12px; }
.jb-h .tabs { margin: 0; border-bottom: 0; }
.jb-h .chip { margin: 0; }
.jb-h .ablink { margin: 0 0 0 auto; }
@media (max-width: 899.98px) {
  .jbcard:not(.none) .jb-h h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .jb-h .tabs { flex: 1 1 100%; border-bottom: 1px solid var(--line); }
  .jb-h .tabs [role="tab"] { flex: 1 1 0; padding: 4px 6px; }
}
/* the job cell: P-code, name (may end in …) and status on one line; 「主 PM A · 副 PM B」 under it. The cell is the row's one link. */
.jl { display: flex; flex-direction: column; justify-content: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.jl:hover .jn1, .jl:focus-visible .jn1 { text-decoration: underline; }
.j1 { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 18rem; }
.j1 .tag, .j1 .isl-pill { flex: 0 0 auto; }
.jn1 { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.j2 { font-size: 0.8125rem; color: var(--muted); }
table.jb { font-size: 0.8125rem; }
table.jb th, table.jb td { padding: 3px 6px; }
table.jb th { white-space: nowrap; }
table.jb td.num .en { white-space: nowrap; }
table.jb td.warn { white-space: nowrap; }
table.jb .w { display: block; font-size: 0.8125rem; }
/* r6 (Q3): the cash view's group heads 向客戶 / 向供應商 over their columns, one 13 px line */
table.jb tr.grp th { font-size: 0.8125rem; font-weight: 700; padding: 2px 6px 0; border-bottom: 2px solid var(--line); white-space: nowrap; text-align: center; }
table.jb tr.grp th small { display: inline; margin-left: 4px; }
table.jb tr.grp td { border: 0; padding: 0; }
/* cards when the jobs box is too narrow for the cost view's seven columns; two to a line from a 640 px box */
@container (max-width: 979.98px) {
  table.t.jb, table.t.jb tbody { display: block; }
  table.t.jb thead { display: none; }
  table.t.jb tbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  table.t.jb tr { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 4px 8px; align-content: start;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; }
  table.t.jb td { display: block; border: 0; padding: 0; text-align: left; min-width: 0; white-space: normal; }
  table.t.jb td.head, table.t.jb td.warn, table.t.jb td.wide { grid-column: 1 / -1; }
  table.t.jb td.head { border-bottom: 1px solid var(--line); padding-bottom: 2px; }
  table.t.jb td.wide { order: 1; } table.t.jb td.warn { order: 2; }
  table.t.jb td.num::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
  table.t.jb td.num .v { text-align: left; font-size: 0.9375rem; font-weight: 700; line-height: 1.3; }
  table.t.jb td.num .v .en { white-space: normal; font-weight: 400; line-height: 1.3; }
  table.t.jb td.warn:empty { display: none; }
  table.t.jb .j1 { max-width: none; }
  table.t.jb-cost td.warn { grid-column: auto; align-self: end; }   /* five figures: the 問題 lines take the free cell beside 預計毛利 */
  table.t.jb td.span { grid-column: 1 / -1; }   /* r6 (Q17): 應收 takes the card's width, then 已申請 | 已收, then 未付 | 逾期 */
  table.t.jb thead tr.grp { display: none; }
}
@container (min-width: 640px) and (max-width: 979.98px) { table.t.jb tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* r6: a 980–1019 px box (e.g. 1236 wide) is too narrow for the cash view's five figure columns beside a one-line name: the name takes its
   own line under the P-code and the pill, whole, so the table needs no sideways scroll. From 1020 px (1280 wide: 1024) the job cell is as round 5 */
@container (min-width: 980px) and (max-width: 1019.98px) {
  table.t.jb .j1 { flex-wrap: wrap; max-width: 13rem; }
  table.t.jb .jn1 { flex: 1 1 100%; order: 3; white-space: normal; overflow: visible; }
}
/* r5 S3: a narrow card (large text on a phone): the name takes its own line under the P-code and the pill and may wrap, never cut to 「測…」 */
@container (max-width: 15.99rem) {
  table.t.jb .j1 { flex-wrap: wrap; }
  table.t.jb .jn1 { flex: 1 1 100%; order: 3; white-space: normal; overflow: visible; }
}

/* ---------- round 6 (PLAN 11.6) ---------- */
.tag small { font-weight: 400; margin-left: 4px; }                 /* Q22: 付款條例：適用 · Security of Payment Ordinance */
.phead .tag.navy { align-self: center; white-space: normal; }
.slip hr.hair { border: 0; border-top: 1px solid var(--line); margin: 8px 0 4px; }   /* SCORE_5 N3: money in starts under its own line */
details.ledger { margin: 8px 0 0; }
details.ledger > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; font-size: 0.875rem; font-weight: 700; color: var(--info); }
details.ledger > summary small { font-weight: 400; color: var(--muted); }
details.ledger .tbl { margin-top: 4px; }
/* the claims ledger sits inside the narrow Cash slip: its rows are cards at every width (one claim = one card) */
.slip table.cards, .slip table.cards tbody, .slip table.cards tr, .slip table.cards td { display: block; width: 100%; }
.slip table.cards thead { display: none; }
.slip table.cards tr { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 6px; padding: 4px 8px; }
.slip table.cards td { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 10px; border: 0; padding: 2px 0; font-size: 0.8125rem; text-align: right; }
.slip table.cards td::before { content: attr(data-label); color: var(--muted); text-align: left; }
.slip table.cards td.head { display: block; text-align: left; font-weight: 700; border-bottom: 1px solid var(--line); }
.slip table.cards td.head::before { content: none; }
.slip table.cards td .v { margin-left: auto; max-width: 100%; }
ul.settings { margin: 0; padding: 0 0 0 1.1em; }
ul.settings li { margin: 0 0 6px; font-size: 0.875rem; }
ul.settings li small { display: block; color: var(--muted); font-size: 0.8125rem; }
.btn.sm { min-height: 44px; padding: 4px 10px; font-size: 0.8125rem; }

/* r7 (PLAN 12.6): the PM switches card on 資料來源; the 「已隱藏」 line (PLAN 12.4) */
.off-line { display: block; font-size: 0.8125rem; color: var(--ink); margin-top: 2px; }
.sw-mark { display: block; font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }
table.switches .btn { min-width: 88px; }
.src.hid { color: var(--ink); margin: 8px 0 0; }
/* r7 P2: the 「更改工數」 choices; P3: a refused save's message inside the drawer */
.drawer fieldset.hd { border: 0; padding: 0; margin: 8px 0 0; min-width: 0; }
.drawer fieldset.hd legend { font-size: 0.8125rem; color: var(--muted); padding: 0; margin: 0 0 2px; }
.drawer label.pick { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-size: 1rem; color: var(--ink); cursor: pointer; }
.drawer label.pick input { width: 24px; height: 24px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--in); }
.drawer .dmsg { margin: 12px 0 0; }
.drawer .dmsg small { display: block; }
