/* とるんです プロジェクトマネージャー — site schedule app.
   Layout concept: drafting-sheet. Thin grid lines, dense rows, indigo ink on cool paper,
   one project colour per site used as the left edge of every bar. */
:root {
  --bg: #e9edf3;
  --surface: #ffffff;
  --surface-2: #dde3ec;
  --ink: #070d18;
  --ink-2: #364255;
  --line: #8d99ac;
  --line-soft: #bcc6d4;
  --accent: #14327a;
  --accent-ink: #ffffff;
  --accent-soft: #d3dff7;
  --weekend: #e8ecf2;
  --holiday: #f8dcdc;
  --holiday-ink: #9c1f1c;
  --today: #c42a14;
  --todo: #4a586d;
  --doing: #8f5200;
  --done: #17703f;
  --danger: #a3201d;
  --leave-plan: #d92d20;
  --shadow: 0 8px 28px rgba(18, 28, 45, .16);
  --font-ui: "IBM Plex Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d14; --surface: #121923; --surface-2: #1b2433; --ink: #f6f8fc; --ink-2: #c3cddc;
    --line: #5b6a82; --line-soft: #35425a; --accent: #9dbcf5; --accent-ink: #07101f; --accent-soft: #263a5f;
    --weekend: #0f1520; --holiday: #351b1f; --holiday-ink: #ffa5a1; --today: #ff8a70;
    --todo: #a9b6cb; --doing: #f0b45c; --done: #6fd6a0; --danger: #ffa5a1; --leave-plan: #ff6f61;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num, time { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px; padding: 0 16px; min-height: 52px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.brand span { color: var(--ink-2); font-size: 12px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; min-width: 0; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 15px 12px 13px; border-bottom: 2px solid transparent;
  color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); border-bottom-width: 3px; border-bottom-color: var(--accent); font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--todo); }
.live[data-s="on"] i { background: var(--done); }
.live[data-s="off"] i { background: var(--today); }
.who { display: flex; align-items: center; gap: 8px; }
.who .name { font-weight: 500; white-space: nowrap; }

.btn {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 12px; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: var(--surface); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }

#view { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
main { flex: 1; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input[type="search"], .filters input[type="month"] {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 8px; min-width: 0; max-width: 100%;
}
.filters .grow { flex: 1; }
.chip-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.view-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 18px; font-weight: 700; min-width: 7em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.spacer { flex: 1; }

/* ---------- calendar ---------- */
.cal-wrap { overflow-x: auto; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); }
.cal { min-width: 760px; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.dow div { padding: 6px 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.dow div:first-child { color: var(--holiday-ink); }
.week { position: relative; border-top: 1px solid var(--line-soft); }
.week:first-of-type { border-top: 0; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); min-height: var(--h, 104px); }
.day {
  border-left: 1px solid var(--line-soft); padding: 3px 6px; text-align: left; background: none; border-top: 0; border-right: 0; border-bottom: 0;
  display: flex; gap: 6px; align-items: flex-start; border-radius: 0; min-width: 0;
}
.day:first-child { border-left: 0; }
.day:hover { background: var(--accent-soft); }
.day .d { font-family: var(--font-num); font-size: 13px; font-weight: 500; color: var(--ink); min-width: 1.6em; text-align: center; border-radius: 10px; padding: 0 3px; }
.day .hn { font-size: 11px; font-weight: 600; color: var(--holiday-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 18px; }
.day.out .d { opacity: .5; }
.day.we { background: var(--weekend); }
.day.hol { background: var(--holiday); }
.day.today .d { background: var(--today); color: #fff; font-weight: 600; }
.bars {
  position: absolute; left: 0; right: 0; top: 24px; bottom: 0; display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 38px; gap: 3px 0; pointer-events: none; align-content: start;
}

.bar {
  pointer-events: auto; margin: 0 3px; border: 0; border-left: 5px solid var(--pc, var(--accent)); border-radius: 4px;
  background: color-mix(in srgb, var(--pc, var(--accent)) 26%, var(--surface)); color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc, var(--accent)) 55%, var(--surface));
  text-align: left; padding: 2px 7px; font-size: 12.5px; line-height: 16px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; min-width: 0;
}
.bar .l1 { display: flex; gap: 6px; align-items: center; min-width: 0; }
.bar .l2 { font-size: 11px; line-height: 14px; color: var(--ink-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar:hover { background: color-mix(in srgb, var(--pc, var(--accent)) 40%, var(--surface)); }
.bar.cl { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cr { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar .who-chip { font-weight: 700; flex: none; }
.bar .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-weight: 500; }
.bar .dp { font-family: var(--font-num); font-size: 10px; margin-left: auto; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; line-height: 14px; flex: none; color: var(--ink-2); }
.bar.done .ttl { text-decoration: line-through; color: var(--ink-2); }
.bar.done { opacity: .85; }
.bar.doing .l1::after, .gbar.doing::after { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--doing); margin-left: auto; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- gantt ---------- */
.gscroll { overflow: auto; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); max-height: calc(100dvh - 196px); min-height: 280px; }
.gbody { position: relative; width: max-content; min-width: 100%; }
.grow, .ghdr { display: grid; grid-template-columns: var(--lw, 236px) var(--tw); }
.ghdr { position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line); }
.gcorner { position: sticky; left: 0; z-index: 7; background: var(--surface-2); border-right: 1px solid var(--line); display: flex; align-items: flex-end; padding: 6px 10px; color: var(--ink-2); font-size: 12px; }
.gmonths { display: flex; height: 22px; }
.gdays { position: relative; height: 22px; }
.gmonth { flex: none; height: 22px; border-left: 1px solid var(--line); overflow: clip; }
.gmonth span { position: sticky; left: var(--lw, 236px); display: inline-block; padding: 2px 6px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.gday { position: absolute; top: 0; height: 36px; text-align: center; font-size: 11px; line-height: 1.25; padding-top: 3px; border-left: 1px solid var(--line-soft); color: var(--ink-2); }
.gday b { display: block; font-family: var(--font-num); font-weight: 600; font-size: 12.5px; color: var(--ink); }
.gday.we, .gday.hol { background: var(--weekend); }
.gday.hol { background: var(--holiday); }
.gday.sun b, .gday.hol b { color: var(--holiday-ink); }
.gday.today { background: var(--today); color: #fff; }
.gday.today b { color: #fff; }
.gl {
  position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft);
  padding: 0 10px; display: flex; align-items: center; gap: 8px; min-width: 0; height: 46px; font-size: 14px;
}
.gl .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.gl .a { color: var(--ink-2); font-size: 12.5px; font-weight: 500; flex: 0 1 auto; max-width: 42%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.ghead .gl { background: var(--surface-2); font-weight: 700; }
.ghead .gl, .ghead .gr { height: 40px; }
.ghead .gl button { border: 0; background: none; padding: 0; display: flex; gap: 8px; align-items: center; font-weight: 700; min-width: 0; text-align: left; }
.dot { width: 10px; height: 10px; border-radius: 2px; background: var(--pc, var(--accent)); flex: none; }
.cnt { font-family: var(--font-num); font-size: 11px; color: var(--ink-2); font-weight: 400; }
.gr { position: relative; height: 46px; border-bottom: 1px solid var(--line-soft); overflow: hidden; }
.ghead .gr { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.span-line { position: absolute; top: 17px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--pc) 35%, transparent); }
.shade { position: absolute; top: 0; bottom: 0; background: var(--weekend); z-index: 0; pointer-events: none; }
.shade.hol { background: var(--holiday); }
.todayline { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--today); z-index: 2; pointer-events: none; opacity: .8; }
.glayer { position: absolute; left: var(--lw, 236px); top: 58px; bottom: 0; width: var(--tw); pointer-events: none; z-index: 0; }
.grow { position: relative; z-index: 1; }
.gbar {
  position: absolute; top: 5px; height: 36px; border: 0; border-left: 5px solid var(--pc); border-radius: 5px; padding: 0 10px;
  background: color-mix(in srgb, var(--pc) 30%, var(--surface)); color: var(--ink); font-size: 13.5px; font-weight: 500; line-height: 36px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc) 55%, var(--surface));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; display: flex; align-items: center; gap: 6px;
  cursor: grab; touch-action: none; user-select: none; z-index: 1;
}
.gbar.drag { cursor: grabbing; box-shadow: var(--shadow); z-index: 4; }
.gbar.done { opacity: .65; }
.gbar.done .tx { text-decoration: line-through; }
.gbar .tx { overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.gbar .hd { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
.gbar .hd.l { left: 0; } .gbar .hd.r { right: 0; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-2); }

/* ---------- tables (sites, invoices, staff) ---------- */
.tbl-wrap { overflow-x: auto; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
.rtbl { table-layout: fixed; min-width: 0; width: auto; }
.rtbl td { overflow-wrap: anywhere; }
th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink); background: var(--surface-2); padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
td.r, th.r { text-align: right; }
td .sub { color: var(--ink-2); font-size: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1.5px solid currentColor; white-space: nowrap; }
.pill.todo, .pill.draft, .pill.planned { color: var(--todo); }
.pill.doing, .pill.in_progress, .pill.sent, .pill.on_hold { color: var(--doing); }
.pill.done, .pill.paid, .pill.active { color: var(--done); }
.pill.overdue, .pill.void { color: var(--danger); }
.docs { display: inline-flex; gap: 10px; font-size: 12px; white-space: nowrap; }
.docs span em { font-style: normal; font-family: var(--font-num); margin-left: 2px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; background: var(--pc); margin-right: 6px; }
.note { color: var(--ink-2); font-size: 12px; }
.sum { display: flex; gap: 22px; flex-wrap: wrap; padding: 4px 2px; }
.sum div { display: flex; flex-direction: column; }
.sum b { font-family: var(--font-num); font-size: 16px; font-weight: 600; }
.sum span { font-size: 12px; color: var(--ink-2); }
.banner { border: 1px solid var(--line); border-left: 3px solid var(--doing); background: var(--surface); padding: 8px 12px; border-radius: 6px; font-size: 13px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 26, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); width: min(560px, 100%); }
.modal.wide { width: min(720px, 100%); }
.modal header { display: flex; align-items: center; padding: 14px 18px 10px; gap: 10px; }
.modal h3 { margin: 0; font-size: 16px; flex: 1; }
.modal form { padding: 0 18px 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.modal .f.full { grid-column: 1 / -1; }
.modal label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.modal input, .modal select, .modal textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 7px 9px; width: 100%; min-width: 0; }
.modal input[type="color"] { padding: 2px; height: 36px; }
.modal textarea { min-height: 72px; resize: vertical; }
.modal .actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding-top: 6px; }
.err { grid-column: 1 / -1; color: var(--danger); font-size: 13px; }
.hint { font-size: 12px; color: var(--ink-2); }
.toasts { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 100%; }

/* ---------- auth ---------- */
.auth { margin: auto; width: min(400px, 100%); padding: 24px 16px; }
.auth .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.auth h1 { margin: 0; font-size: 22px; }
.auth .sub { color: var(--ink-2); margin-top: -8px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .f { display: flex; flex-direction: column; gap: 4px; }
.auth label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.auth input { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 9px 10px; }
.auth .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.auth .msg { font-size: 13px; padding: 8px 10px; border-radius: 6px; background: var(--accent-soft); }
.auth .msg.bad { background: var(--holiday); color: var(--holiday-ink); }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }

@media (max-width: 720px) {
  .top { gap: 8px; padding: 0 12px; flex-wrap: wrap; }
  .brand span, .who .name { display: none; }
  .tabs { order: 3; flex-basis: 100%; }
  .tab { padding: 8px 10px; }
  main { padding: 12px; }
  .modal form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* ---------- resizable columns ---------- */
.rtbl th { position: relative; overflow: hidden; text-overflow: ellipsis; padding-right: 14px; }
.rz { position: absolute; top: 0; right: 0; bottom: 0; width: 9px; cursor: col-resize; touch-action: none; user-select: none; }
.rz::after { content: ""; position: absolute; top: 20%; bottom: 20%; right: 3px; width: 2px; border-radius: 1px; background: var(--line); }
.rz:hover::after, .rz.on::after { background: var(--accent); width: 3px; }
.lrz { position: absolute; top: 0; right: -1px; bottom: 0; width: 9px; cursor: col-resize; touch-action: none; user-select: none; z-index: 8; }
.lrz::after { content: ""; position: absolute; top: 20%; bottom: 20%; right: 3px; width: 2px; border-radius: 1px; background: var(--line); }
.lrz:hover::after { background: var(--accent); width: 3px; }
th.c, td.mc { text-align: center; }
td.mc { padding: 6px 2px; white-space: nowrap; }

/* ---------- paid leave ---------- */
h3.sec { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.lv { display: inline-block; min-width: 22px; padding: 0 5px; margin: 0 1px; border-radius: 4px; font-family: var(--font-num); font-size: 12.5px; font-weight: 600; text-align: center; line-height: 20px; }
.lv.planned { border: 1.5px dashed var(--pc); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 22%, var(--surface)) 0 5px, var(--surface) 5px 10px); color: var(--ink); }
.lv.taken { background: color-mix(in srgb, var(--pc) 60%, var(--surface)); border: 1.5px solid var(--pc); color: var(--ink); }
.bar.leave, .gbar.leave { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 24%, var(--surface)) 0 7px, var(--surface) 7px 14px); }
.bar.leave.planned, .gbar.leave.planned { outline: 1.5px dashed var(--pc); outline-offset: -2px; }
.bar.leave.taken, .gbar.leave.taken { background: color-mix(in srgb, var(--pc) 55%, var(--surface)); }
.bar.leave:hover { background: color-mix(in srgb, var(--pc) 40%, var(--surface)); }
.warn { color: var(--danger); font-weight: 700; flex: none; pointer-events: none; }

.gbar.static { cursor: pointer; touch-action: auto; }
.lgr { cursor: cell; }
.view-head input[type=month] { height: 34px; }

/* ---------- printed invoice (A4) ---------- */
#print { display: none; }
.sheet { color: #000; background: #fff; font: 12px/1.6 var(--font-ui); width: 100%; }
.sheet h1 { text-align: center; font-size: 24px; letter-spacing: .6em; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid #000; }
.sheet .meta { text-align: right; font-size: 11.5px; }
.sheet .top { display: flex; gap: 24px; justify-content: space-between; margin: 10px 0 14px; }
.sheet .to { flex: 1.1; } .sheet .from { flex: .9; font-size: 11.5px; }
.sheet .toname { font-size: 17px; font-weight: 700; border-bottom: 1px solid #000; padding-bottom: 2px; }
.sheet .subj { margin: 8px 0 2px; } .sheet .subj span, .sheet .due span { font-weight: 700; margin-right: 6px; }
.sheet .amt { margin: 8px 0; padding: 6px 10px; border: 2px solid #000; display: flex; justify-content: space-between; align-items: baseline; }
.sheet .amt b { font-size: 21px; font-family: var(--font-num); }
.sheet .co { font-size: 15px; font-weight: 700; }
.sheet table { border-collapse: collapse; width: 100%; min-width: 0; table-layout: auto; }
.sheet th, .sheet td { border: 1px solid #000; padding: 4px 8px; background: none; color: #000; font-size: 12px; white-space: normal; }
.sheet .items th { background: #e8e8e8; text-align: center; }
.sheet .items tr.b td { height: 26px; }
.sheet .r { text-align: right; font-family: var(--font-num); } .sheet .c { text-align: center; }
.sheet .items th:nth-child(1) { width: 46%; }
.sheet .detail { break-before: page; page-break-before: always; margin-top: 18px; }
.sheet .detail h2 { font-size: 15px; margin: 0 0 8px; } .sheet .detail small { font-size: 12px; font-weight: 400; }
.sheet .dt th:nth-child(1) { width: 15%; } .sheet .dt th:nth-child(2) { width: 40%; } .sheet .dt th:nth-child(5) { width: 9%; }
.sheet .dt tr { break-inside: avoid; } .sheet .dt thead { display: table-header-group; } .sheet .dt tr.tt td { font-weight: 700; }
.sheet .sum2 { width: 46%; margin: 8px 0 0 auto; }
.sheet .sum2 th { background: #e8e8e8; text-align: left; width: 45%; } .sheet .sum2 td { text-align: right; font-family: var(--font-num); }
.sheet .sum2 .tot td, .sheet .sum2 .tot th { font-weight: 700; font-size: 14px; }
.sheet .taxnote { font-size: 10.5px; text-align: right; margin-top: 4px; }
.sheet .box { border: 1px solid #000; margin-top: 10px; padding: 6px 10px; min-height: 60px; }
.sheet .box b { display: block; border-bottom: 1px solid #999; margin-bottom: 4px; font-size: 11.5px; }
@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #fff !important; height: auto; }
  #app, #modal, #toasts { display: none !important; }
  #print { display: block !important; }
}

/* ---------- dashboard, personal schedule ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; }
.tile b { font-family: var(--font-num); font-size: 28px; line-height: 1.2; }
.tile span { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.tile.warn { border-color: var(--danger); } .tile.warn b { color: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; align-items: start; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
table.plain { width: 100%; min-width: 0; }
.card .tbl-wrap { border: 0; border-radius: 0; }
.chip { display: inline-block; margin: 2px 6px 2px 0; padding: 2px 8px; border: 0; border-left: 4px solid var(--pc); border-radius: 4px; background: color-mix(in srgb, var(--pc) 24%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc) 50%, var(--surface)); font-size: 12.5px; text-align: left; max-width: 100%; }
.chip em { font-style: normal; font-size: 11px; color: var(--ink-2); border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; }
.chip.leave { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 24%, var(--surface)) 0 7px, var(--surface) 7px 14px); }
.chip.leave.taken { background: color-mix(in srgb, var(--pc) 55%, var(--surface)); }
.chip.ev { background: var(--surface-2); }
.prog { margin-bottom: 10px; } .prog .pn { display: flex; gap: 8px; align-items: center; } .prog .pn .num { margin-left: auto; font-size: 12.5px; }
.pbar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 4px; } .pbar i { display: block; height: 100%; background: var(--pc); }
.plist { border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.prow { display: grid; grid-template-columns: 64px 1fr 36px; align-items: center; min-height: 42px; border-bottom: 1px solid var(--line-soft); }
.prow:last-child { border-bottom: 0; }
.prow.we { background: var(--weekend); } .prow.hol { background: var(--holiday); }
.prow.today { box-shadow: inset 4px 0 0 var(--today); }
.prow .pd { display: flex; gap: 6px; align-items: baseline; justify-content: center; font-size: 12px; color: var(--ink-2); }
.prow .pd b { font-family: var(--font-num); font-size: 15px; color: var(--ink); }
.prow.today .pd b { color: var(--today); }
.prow .pi { padding: 3px 4px; min-width: 0; } .prow .hn { color: var(--holiday-ink); font-weight: 600; font-size: 12px; margin-right: 8px; }
table.plain td:first-child { white-space: nowrap; width: 1%; }
.top { gap: 12px; } .tab { padding-left: 9px; padding-right: 9px; font-size: 13.5px; }

.ms { border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface); }
.ms summary { cursor: pointer; padding: 6px 10px; list-style: none; display: flex; justify-content: space-between; gap: 8px; min-height: 34px; align-items: center; }
.ms summary::-webkit-details-marker { display: none; }
.ms summary::after { content: "▾"; color: var(--ink-2); }
.ms[open] summary { border-bottom: 1px solid var(--line-soft); }
.ms-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; padding: 6px 10px; }
.ms-list label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-weight: 500; }
.ms-list input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- avatars ---------- */
.av { width: var(--s, 18px); height: var(--s, 18px); border-radius: 50%; object-fit: cover; flex: none; vertical-align: middle; pointer-events: none; }
.av.ph { display: inline-grid; place-items: center; background: var(--pc); color: #fff; font-size: calc(var(--s) * .5); font-weight: 700; line-height: 1; }
.who-chip { display: inline-flex; align-items: center; gap: 4px; }
.gl .a { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.gl .t { display: inline-flex; align-items: center; gap: 5px; }
.mem { display: inline-flex; align-items: center; gap: 5px; margin: 1px 10px 1px 0; white-space: nowrap; font-weight: 500; }
.photo-f { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gbar .av { margin-left: -2px; }

/* ---------- compact calendar and timeline ---------- */
.gl { height: 32px; padding: 0 8px; font-size: 13px; }
.gr { height: 32px; }
.ghead .gl, .ghead .gr { height: 30px; }
.gl .a { font-size: 12px; }
.span-line { top: 12px; }
.gbar { top: 4px; height: 24px; line-height: 24px; font-size: 12.5px; padding: 0 8px; }
.brand b { font-size: 15px; white-space: nowrap; } .tab { padding-left: 7px; padding-right: 7px; white-space: nowrap; }

/* ---------- ISO inspection sheets ---------- */
.iso-head { display: grid; grid-template-columns: 1fr 2.4fr 1.2fr 1.6fr; gap: 0; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.iso-head > div { padding: 8px 12px; border-left: 1px solid var(--line-soft); min-width: 0; } .iso-head > div:first-child { border-left: 0; }
.iso-head span { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-2); } .iso-head b { display: block; overflow-wrap: anywhere; }
@media (max-width: 720px) { .iso-head { grid-template-columns: 1fr 1fr; } .iso-head > div { border-top: 1px solid var(--line-soft); } }
.rtbl td input, .rtbl td select { width: 100%; min-width: 0; padding: 3px 6px; }
tr.dim td { color: var(--ink-2); background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
td.c, th.c { text-align: center; }
input.late, b.late { color: var(--danger); border-color: var(--danger); }
.guide { background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 14px; }
.guide summary { cursor: pointer; font-weight: 700; }
.guide h4 { margin: 12px 0 2px; font-size: 13.5px; } .guide p { margin: 0; color: var(--ink-2); line-height: 1.7; }
table[data-tbl=iso] td { padding: 4px 8px; vertical-align: middle; } table[data-tbl=iso] td input, table[data-tbl=iso] td select { height: 30px; }

.gbar .av { margin-left: -2px; }

/* ---------- groups, two-column leave page ---------- */
select.grp { font-weight: 700; border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 4px 8px; min-height: 32px; }
.grp-h { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-top: 10px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; align-items: start; }
.two.eq { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.two .col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 1100px) { .two, .two.eq { grid-template-columns: minmax(0, 1fr); } }
.bar.ev, .gbar.ev { background: color-mix(in srgb, var(--pc) 14%, var(--surface-2)); }
.bar.ev { box-shadow: inset 0 0 0 1px var(--line); }
.gbar.ev { box-shadow: inset 0 0 0 1px var(--line); }

th.c { padding-left: 4px; padding-right: 14px; }
@media (max-width: 1560px) { .top { flex-wrap: wrap; row-gap: 0; padding-top: 6px; } .tabs { order: 5; flex: 1 0 100%; } .top-right { margin-left: auto; } .brand { margin-right: 6px; } }
.gscroll { max-height: calc(100dvh - 232px); }

.iso-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.iso-main { min-width: 0; }
.guide.side { position: sticky; top: 8px; max-height: calc(100dvh - 120px); overflow: auto; padding: 10px 14px; }
.guide.side h3 { margin: 0 0 4px; font-size: 14px; }
@media (max-width: 1280px) { .iso-split { grid-template-columns: minmax(0, 1fr); } .guide.side { position: static; max-height: none; } }

.gbody.fluid { width: 100%; }
.gbody.fluid .glayer { width: auto; right: 0; }
.leave-split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.leave-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.leave-aside { position: sticky; top: 8px; }
.hol-side { display: flex; flex-direction: column; gap: 8px; }
.hol-btns { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1100px) { .leave-split { grid-template-columns: minmax(0, 1fr); } .leave-aside { position: static; } }
.iso-split { align-items: stretch; }
.guide.side { position: static; max-height: none; }

.who-chip.pt { margin-left: 2px; }
.chip .who-chip { margin-left: 4px; font-weight: 600; }
.sheet .dt small { font-size: 10px; }
.sheet .dt th:nth-child(2) { width: 17%; }

.about h4 { margin: 12px 0 4px; font-size: 14px; } .about p { margin: 4px 0; line-height: 1.7; } .about ul.lic { margin: 6px 0; padding-left: 18px; } .about ul.lic li { margin: 8px 0; line-height: 1.6; }
.about a { color: var(--accent, #24468a); }
.about { padding: 4px 18px 16px; max-height: 78dvh; overflow: auto; }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 8px; }
.lg-t { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-right: 2px; }
.lg { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font: inherit; font-size: 12.5px; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; }
.lg i { width: 12px; height: 12px; border-radius: 3px; background: var(--pc, #888); flex: none; }
.lg.on { border-color: var(--pc); box-shadow: inset 0 0 0 1px var(--pc); font-weight: 700; }
.lg.clear { color: var(--ink-2); }
.legend ~ .gscroll { max-height: calc(100dvh - 276px); }
td.who { white-space: nowrap; } td.who .av { margin-right: 6px; }
.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; margin-top: 12px; }
.dcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 1000px) { .dash { grid-template-columns: minmax(0, 1fr); } }
.iso-win { background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.iso-win > summary { cursor: pointer; padding: 8px 12px; display: flex; align-items: center; gap: 8px; font-size: 14px; border-left: 6px solid var(--line); background: var(--surface-2, #f3f5fa); }
.iso-win .cnt { font-family: var(--font-num); font-size: 12px; background: var(--ink); color: var(--surface); border-radius: 999px; padding: 0 8px; }
.iso-win.w-creating > summary { border-left-color: #d97706; } .iso-win.w-done > summary { border-left-color: #15803d; } .iso-win.w-na > summary { border-left-color: #64748b; } .iso-win.w-unset > summary { border-left-color: #94a3b8; }
.iso-win .tbl-wrap { border: 0; border-radius: 0; border-top: 1.5px solid var(--line); }
.iso-seg button { padding: 3px 9px; font-size: 12.5px; }
.iso-seg button.s-creating[aria-pressed=true] { background: #d97706; color: #fff; } .iso-seg button.s-done[aria-pressed=true] { background: #15803d; color: #fff; } .iso-seg button.s-na[aria-pressed=true] { background: #64748b; color: #fff; }

@media print {
  #print .pv, #print .pv * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print .pv .view-head { margin-bottom: 6px; }
  #print .pv .gscroll, #print .pv .cal-wrap { max-height: none !important; overflow: visible !important; }
  #print .pv .ghdr, #print .pv .gcorner, #print .pv .gl, #print .pv .gmonth span { position: static !important; }
  #print .pv .gr, #print .pv .week, #print .pv .grow { break-inside: avoid; }
}

h4.sec.sub { margin: 10px 0 4px; font-size: 13px; color: var(--muted, #667); } h4.sec.sub .cnt { font-weight: 400; }

.sitecat { padding: 0; margin: 0 0 14px; overflow: hidden; }
.sitecat .cat-h { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.sitecat .cat-h:hover { background: var(--hover, rgba(128,128,128,.08)); }
.sitecat .car { width: 14px; color: var(--muted, #667); }
.sitecat tr.subrow td { background: var(--surface2, rgba(128,128,128,.10)); font-size: 12.5px; padding: 5px 10px; border-top: 1px solid var(--line); }
.isotypes .itr { display: flex; gap: 8px; margin: 0 0 6px; } .isotypes .itr input { flex: 1; min-width: 0; }
.isotypes { max-height: 70vh; overflow: auto; padding: 4px 2px; }
.rpt textarea { width: 100%; resize: vertical; }
.top .btn.small[data-act=report] { font-weight: 600; }
.modal .rpt { padding: 0 18px 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal .rpt .form-grid { display: contents; }
.modal .rpt .err { grid-column: 1 / -1; }
.modal .rpt textarea { min-height: 64px; }
.modal .rpt .actions { flex-wrap: wrap; }
@media (max-width: 640px) { .modal .rpt { grid-template-columns: 1fr; } }

/* Studio edition — screen-only presentation; schedule geometry and print sheets remain original. */
@media screen {
:root { --bg:#f2efe7; --surface:#fffdf7; --surface-2:#eae7de; --ink:#252f3b; --ink-2:#52606b; --line:#9babae; --line-soft:#d4d9d5; --accent:#243b63; --accent-ink:#fffdf7; --accent-soft:#e0e7ef; --weekend:#eeeee8; --holiday:#f7e9e1; --holiday-ink:#9a3f2c; --today:#b94a35; --done:#267568; --doing:#8a5b26; --danger:#a4382a; --shadow:0 12px 36px #243b6314; }
:root[data-theme="dark"] { --bg:#1c2328; --surface:#252e34; --surface-2:#303c43; --ink:#f2eee4; --ink-2:#bac7cc; --line:#6b7f86; --line-soft:#45535a; --accent:#b3c9f1; --accent-ink:#17263c; --accent-soft:#35465c; --weekend:#2b363b; --holiday:#433332; --holiday-ink:#ffc0a8; --today:#ff997e; --done:#8fd5be; --doing:#e6be85; --danger:#ffac98; color-scheme:dark; }
:root[data-theme="light"] {color-scheme:light;}
body { background-image:linear-gradient(#738a9510 1px,transparent 1px),linear-gradient(90deg,#738a9510 1px,transparent 1px); background-size:24px 24px; }
.top { gap:14px; padding:12px 24px 0; border-bottom:1px solid var(--line-soft); box-shadow:0 4px 20px #16273708; }
.brand {align-items:center;gap:12px;}
.brand b {font-family:"Yu Mincho","Hiragino Mincho ProN",serif;font-size:20px;letter-spacing:.06em;}
.studio-logo {width:34px;height:34px;flex:none;color:var(--accent);}
.tabs {order:5;flex:1 0 100%;gap:6px;}
.tab {padding:11px 15px;font-size:13px;border-radius:7px 7px 0 0;}
.tab[aria-current="page"] {background:var(--accent-soft);}
main {padding:22px 24px 32px;gap:18px;}
#view {gap:16px;}
.view-head h2 {font-family:"Yu Mincho","Hiragino Mincho ProN",serif;font-size:23px;letter-spacing:.04em;}
.btn {border-width:1px;border-radius:7px;padding:7px 12px;transition:background .16s,box-shadow .16s;}
.btn.primary {box-shadow:0 3px 8px #243b631a;}
.btn:hover {box-shadow:0 2px 8px #243b6314;}
.filters {background:var(--surface);padding:12px;border:1px solid var(--line-soft);border-radius:9px;}
.card,.tbl-wrap,.cal-wrap,.gscroll,.plist,.iso-win,.leave-aside {border-color:var(--line-soft);box-shadow:0 3px 0 #738a9508,0 10px 24px #243b6306;}
.card {padding:16px;border-width:1px;border-radius:10px;}
.card h3 {font-size:15px;padding-bottom:10px;border-bottom:1px solid var(--line-soft);}
.tile {border:1px solid var(--line-soft);border-top:3px solid var(--accent);padding:14px 16px;gap:5px;}
.tile b {font-size:27px;}
.tile.warn {border-color:var(--line-soft);border-top-color:var(--danger);}
.pill {border-radius:4px;font-weight:600;}
.bar,.gbar {border-radius:4px;box-shadow:0 2px 3px #243b6312;}
.bar .l2 {color:var(--ink-2);}
.day.today .d {border-radius:50%;background:var(--today);color:var(--surface);padding:0 5px;}
.todayline {box-shadow:0 0 0 2px #b94a3512;}
.ghdr,.ghead,.dow {font-weight:600;}
.modal {border:1px solid var(--line-soft);border-radius:12px;box-shadow:var(--shadow);}
input,textarea,select {accent-color:var(--accent);}
.empty {margin:12px 0;padding:44px 20px;background:var(--surface);border:1px dashed var(--line);border-radius:10px;}
.empty:before {content:"";display:block;width:84px;height:60px;margin:0 auto 18px;background:linear-gradient(90deg,transparent 24%,var(--line-soft) 24%,var(--line-soft) 25%,transparent 25%,transparent 74%,var(--line-soft) 74%,var(--line-soft) 75%,transparent 75%),linear-gradient(transparent 49%,var(--line-soft) 49%,var(--line-soft) 51%,transparent 51%);border:1px solid var(--accent);box-shadow:6px 6px 0 var(--surface-2);transform:rotate(-3deg);}
.project-deck {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr));gap:14px;}
.project-summary {text-align:left;background:var(--surface);border:1px solid var(--line-soft);border-top:4px solid var(--pc);border-radius:9px;padding:18px;display:flex;flex-direction:column;gap:12px;box-shadow:0 5px 16px #243b6307;min-width:0;}
.project-summary:hover {border-bottom-color:var(--accent);}
.project-summary h3 {margin:0;font-size:17px;overflow-wrap:anywhere;}
.project-meta {display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--ink-2);}
.project-progress {width:100%;height:5px;border:0;border-radius:4px;overflow:hidden;appearance:none;background:var(--surface-2);}
.project-progress::-webkit-progress-bar {background:var(--surface-2);}
.project-progress::-webkit-progress-value {background:var(--pc);}
.project-progress::-moz-progress-bar {background:var(--pc);}
.availability {display:inline-block;padding:3px 8px;border:1px solid var(--line-soft);border-radius:4px;font-size:12px;margin:0 5px 4px 0;color:var(--ink-2);}
.availability.leave {color:var(--danger);border-color:var(--danger);}
@media(max-width:720px) { .top {padding:10px 12px 0;gap:8px;position:relative;} .brand b{font-size:16px;} .studio-logo{width:27px;height:27px;} .top-right{flex-wrap:wrap;gap:6px;max-width:100%;margin-left:0;} .who{flex-wrap:wrap;} main{padding:16px 10px;} .tiles{grid-template-columns:repeat(2,minmax(0,1fr));} .tab{padding:12px 10px;} .filters .btn{min-height:36px;} .view-head h2{font-size:20px;} }
@media(prefers-reduced-motion:reduce) { *,*:before,*:after {transition:none!important;animation:none!important;scroll-behavior:auto!important;} }
}

@media screen { .nav-icon {width:16px;height:16px;vertical-align:-3px;margin-right:7px;} :root {--todo:#52606b;--leave-plan:#b94a35;} :root[data-theme="dark"] {--todo:#b8c6ce;--leave-plan:#ff997e;} .gday.today,.gday.today b {color:var(--accent-ink);background:var(--accent);} }

@media screen {.gbar.done {opacity:1;} .schedule-status {flex:none;font-size:11px;padding:1px 4px;border:1px solid var(--line-soft);border-radius:3px;} }

.leave-main tr.subrow td { background: var(--surface-2, rgba(128,128,128,.10)); padding: 0; border-top: 1px solid var(--line); }
.leave-main tr.subrow .cat-h { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 7px 10px; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.leave-main tr.subrow .car { width: 14px; }
.leave-main tr.subrow.lvmem td { background: transparent; }
.leave-main tr.lvrow td.who { display: table-cell; vertical-align: middle; padding-left: 32px; }
.leave-main tr.lvrow td.who .av { margin-right: 8px; vertical-align: middle; }
.leave-main tr.lvrow td.who b { vertical-align: middle; }   /* names line up with the member header above */

/* header layout fix (desktop): brand + actions on row 1, tabs on row 2, at every width */
@media screen {
  .top { flex-wrap: wrap; align-items: center; row-gap: 0; }
  .top .brand { flex: none; margin-right: 6px; }
  .top .brand b { white-space: nowrap; }
  .top .grp { flex: none; }
  .top .top-right { flex: none; margin-left: auto; flex-wrap: nowrap; white-space: nowrap; }
  .top .top-right .btn, .top .top-right .who, .top .top-right .name { white-space: nowrap; flex: none; writing-mode: horizontal-tb; }
  .top .tabs { order: 5; flex: 1 0 100%; overflow-x: auto; }
  .top .tab { white-space: nowrap; flex: none; }
}

/* login: theme / language buttons on their own row, title never squeezed (mobile) */
.auth-tools { display: flex; justify-content: flex-end; gap: 8px; margin: -6px 0 -4px; }
.auth-tools .btn { white-space: nowrap; flex: none; }
.auth h1 { line-height: 1.3; text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .auth { width: 100%; padding: 12px 12px 12vh; margin: auto; }   /* centred in the screen, nudged up a little so the keyboard does not cover it */
  .auth .panel { padding: 18px 16px; }
  .auth input { font-size: 16px; min-height: 44px; }   /* 16px stops iOS zooming in on focus */
  .auth .btn.primary { min-height: 46px; font-size: 16px; }
  .auth .row .linkbtn { min-height: 40px; }
}

/* files (Supabase Storage) */
.files .fhint { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; }
.files .fbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.files .fstat { font-size: 13px; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.files .fstat.bad { color: var(--holiday-ink); background: var(--holiday); padding: 4px 8px; border-radius: 6px; }
.files .flist { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.files .file { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.files .file .fname { text-align: left; font-weight: 600; overflow-wrap: anywhere; justify-self: start; }
.files .file .fmeta { grid-column: 2 / 3; font-size: 12px; color: var(--ink-2); }
.files .file .btn { grid-column: 3; grid-row: 1 / span 2; }
.filebtn { white-space: nowrap; }
@media (max-width: 720px) { .files .file { grid-template-columns: auto 1fr; } .files .file .btn { grid-column: 2; grid-row: auto; justify-self: end; } }
.modal .files { padding: 14px 18px 16px; }
.files .actions { margin-top: 12px; }

/* ---- kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 12px; align-items: start; padding: 4px 0 16px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line-soft); border-top: 4px solid var(--todo); border-radius: 10px; min-height: 160px; padding: 8px; }
.kcol.doing { border-top-color: var(--doing); } .kcol.done { border-top-color: var(--done); }
.kcol.over { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }
.kcol h3 { display: flex; justify-content: space-between; align-items: center; margin: 2px 4px 8px; font-size: 14px; }
.klist { display: grid; gap: 8px; }
.kcard { position: relative; background: var(--surface); border: 1px solid var(--line-soft); border-left: 5px solid var(--pc); border-radius: 8px; box-shadow: 0 1px 3px rgba(18,28,45,.12); cursor: grab; }
.kcard.dragging { opacity: .45; }
.kmain { all: unset; display: grid; gap: 3px; box-sizing: border-box; width: 100%; padding: 9px 56px 9px 10px; cursor: pointer; }
.kmain:focus-visible { outline: 2px solid var(--accent); border-radius: 6px; }
.ksite { font-size: 11px; color: var(--ink-2); } .kttl { font-size: 14px; line-height: 1.35; word-break: break-word; }
.kmeta { font-family: var(--font-num); font-size: 11px; color: var(--ink-2); } .kmeta.late { color: var(--danger); font-weight: 600; }
.kwho { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.kcol.done .kttl { text-decoration: line-through; color: var(--ink-2); }
.kmv { position: absolute; top: 6px; right: 6px; display: flex; gap: 3px; }
.kempty { text-align: center; color: var(--ink-2); font-size: 12px; padding: 18px 0; }
@media (max-width: 760px) { .kanban { grid-template-columns: 1fr; } }

/* ---- share links + download all ---- */
.share { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.share h4 { margin: 0 0 4px; font-size: 14px; }
.shd { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.slist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.slist li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }
.slist input { min-width: 0; width: 100%; font-family: var(--font-num); font-size: 12px; padding: 7px 8px; }
@media (max-width: 700px) { .slist li { grid-template-columns: 1fr auto; } .slist .fmeta { grid-column: 1 / -1; order: 3; } }

/* ---- public download view ---- */
.pub { max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; }
.pub h1 { font-size: 14px; color: var(--ink-2); margin: 8px 0 2px; font-weight: 600; }
.pub-site { font-size: 20px; font-weight: 700; word-break: break-word; }
.pub-sub { color: var(--ink-2); font-size: 13px; }
.pub-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.pub-bar .btn, .pub-row .btn { min-height: 44px; }
.pub-msg { color: var(--ink-2); font-size: 13px; } .pub-msg.bad { color: var(--danger); }
.pub-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; margin-top: 16px; overflow: hidden; }
.pub-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.pub-row:last-child { border-bottom: 0; }
.pub-nm { flex: 1; min-width: 0; word-break: break-all; } .pub-sz { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.pub-c { text-align: center; padding: 60px 16px; }

/* ---- 工程表 (schedule PDF) ---- */
.modal.pdfm { width: min(1100px, 100%); }
.filebtn.has { background: var(--accent-soft); border-color: var(--accent); }
.schips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.schip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px 4px 3px 12px; background: var(--surface); max-width: 100%; }
.schip.on { border-color: var(--accent); background: var(--accent-soft); }
.schip .linkbtn { max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdfview { height: min(68vh, 760px); overflow: auto; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px; -webkit-overflow-scrolling: touch; }
.pdfpage { display: block; margin: 0 auto 10px; background: #fff; box-shadow: 0 1px 4px rgba(18,28,45,.25); max-width: none; }
.pdfview .note { padding: 24px; text-align: center; }

/* ISO import preview */
.isoprev { max-height: 40vh; overflow: auto; border: 1px solid var(--line, #d9dee4); border-radius: 8px; margin-top: 6px; }
.isoprev table { width: 100%; border-collapse: collapse; font-size: 13px; }
.isoprev th, .isoprev td { padding: 5px 8px; border-bottom: 1px solid var(--line, #e4e8ec); text-align: left; }
.isoprev th { position: sticky; top: 0; background: var(--panel, #f4f6f8); }
.isoprev tr.dim td { opacity: .55; }

/* modal title with a second line (e.g. the site under the ISO import title) */
.modal header .mt { min-width: 0; flex: 1; }
.modal header .msub { margin-top: 2px; font-size: 16px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.files .actions { justify-content: flex-end; }

/* every dialog: the button row (保存 / キャンセル / 閉じる ...) sits on the right */
.modal .actions { justify-content: flex-end; }

/* header: two rows on the right (actions / status + account) */
.top-right { flex-direction: column; align-items: flex-end; gap: 6px; }
.top-right .tr1, .top-right .tr2 { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* bulk invoice PDF dialog */
.modal .invpdf { display: flex; flex-direction: column; gap: 12px; padding: 4px 18px 16px; }
.invpdf .ipf { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; align-items: end; }
.modal .invpdf .fld { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.modal .invpdf .fld > span { font-size: 12px; font-weight: 600; }
.invpdf .iplist { max-height: 46vh; overflow: auto; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface); }
.modal .invpdf .ipr { display: grid; grid-template-columns: 22px minmax(0, 1fr) 76px 100px auto; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink); }
.invpdf .iplist .ipr + .ipr { border-top: 1px solid var(--line-soft); }
.invpdf .ipn { font-weight: 600; overflow-wrap: anywhere; }
.modal .invpdf .ipall { grid-template-columns: 22px auto 1fr; padding: 0 4px; }
.invpdf .ipall .note { text-align: left; }
.invpdf .ipr .r { text-align: right; }
.modal .invpdf input[type=checkbox] { width: 18px; height: 18px; margin: 0; padding: 0; }
.modal .invpdf .actions { grid-column: auto; padding-top: 4px; }
@media (max-width: 720px) { .invpdf .ipf { grid-template-columns: 1fr; } .modal .invpdf .ipr { grid-template-columns: 22px minmax(0, 1fr) auto; } .invpdf .ipr .num:not(.r) { display: none; } }

/* invoice print: hand-paginated A4 pages with their own "n/N" footer (no browser header/footer) */
.pg { width: 210mm; height: 296mm; box-sizing: border-box; padding: 12mm 14mm 0; position: relative; overflow: hidden; break-after: page; page-break-after: always; background: #fff; }
.pg:last-child { break-after: auto; page-break-after: auto; }
.pg .sheet .detail { break-before: auto; page-break-before: auto; margin-top: 0; }
.pg .pgno { position: absolute; left: 0; right: 0; bottom: 9mm; text-align: center; font: 11px var(--font-num, monospace); color: #000; }
@media print { #print { margin: 0; padding: 0; } }

/* ---- 依頼フロー (support requests) ---- */
.rq-chip { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12.5px; font-weight: 600; border: 1.5px solid currentColor; white-space: nowrap; }
.rq-chip.warn { color: var(--danger); } .rq-chip.wait { color: var(--doing); } .rq-chip.doing { color: var(--doing); } .rq-chip.done { color: var(--done); } .rq-chip.todo { color: var(--todo); }
.tile.warn { border-color: var(--danger); } .tile.warn b { color: var(--danger); }
button.tile.rq-tile { cursor: pointer; text-align: left; font: inherit; color: inherit; }
.rq-modal { display: flex; flex-direction: column; gap: 10px; padding: 6px 18px 16px; }
.rq-modal .actions { flex-wrap: wrap; }
.rq-st { display: flex; gap: 8px; align-items: center; }
.rq-items { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.rq-it { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.rq-it input { width: auto; }
.rq-quote { background: var(--bg-2, var(--bg)); border-left: 3px solid var(--line); padding: 6px 10px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.rq-lbl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.rq-d summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.rq-hist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.rq-tbl td, .rq-tbl th { padding: 8px 10px; }
.rq-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rq-inv { margin-bottom: 14px; } .rq-inv h3 { margin: 0 0 8px; font-size: 15px; }
.rq-inv-act { white-space: nowrap; text-align: right; } .rq-inv-act .btn { margin-left: 4px; }
.view-head .btn.primary { margin-left: auto; }
@media (max-width: 560px) { .rq-dates { grid-template-columns: 1fr; } }
.modal form.rq-modal { display: flex; flex-direction: column; gap: 10px; grid-template-columns: none; }
.rq-dates .rq-lbl input { min-width: 0; width: 100%; }
.rq-work { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 14px; }
.rq-work th { text-align: left; font-size: 12px; color: var(--muted, #6b7280); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line, #d9d6cc); }
.rq-work td { padding: 4px 6px; border-bottom: 1px solid var(--line, #e6e3da); vertical-align: middle; }
.rq-work tr.dim td:first-child { opacity: .55; }
.rq-work select, .rq-work input[type=date] { width: 100%; min-width: 0; }
.rq-work { table-layout: fixed; }
.rq-work th:nth-child(1) { width: 30%; } .rq-work th:nth-child(2) { width: 25%; } .rq-work th:nth-child(3) { width: 29%; } .rq-work th:nth-child(4) { width: 16%; }
.rq-work select, .rq-work input[type=date] { padding: 4px 4px; font-size: 13px; }
.rq-modal .rq-work { display: table; width: 100%; min-width: 0; max-width: 100%; }
.rq-modal .rq-work th, .rq-modal .rq-work td { min-width: 0; overflow: hidden; }
/* 写真整理 tab: the name field and the 追加 button share one height */
.ps-add { display: flex; align-items: stretch; gap: 8px; margin: 10px 0 12px; }
.ps-add input { flex: 1; max-width: 420px; min-width: 0; height: 38px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font: inherit; color: var(--ink); }
.ps-add .btn { height: 38px; box-sizing: border-box; padding: 0 16px; display: inline-flex; align-items: center; white-space: nowrap; }

/* 編集中 notice (presence) */
.being-edited { outline: 2px solid #d99a00; outline-offset: -2px; }
.edbadge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #fff3cf; color: #6b4a00; border: 1px solid #e3b341; font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle; align-self: flex-start; width: fit-content; max-width: 100%; }
.editing-note { margin: 0 16px 8px; padding: 8px 12px; border-radius: 8px; background: #fff3cf; color: #6b4a00; border: 1px solid #e3b341; font-size: 13px; font-weight: 600; }
:root[data-theme="dark"] .edbadge, :root[data-theme="dark"] .editing-note { background: #4a3a10; color: #ffe29a; border-color: #8a6a1a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .edbadge, :root:not([data-theme="light"]) .editing-note { background: #4a3a10; color: #ffe29a; border-color: #8a6a1a; } }

/* Photo folders and bulk file selection */
.ps-add { flex-wrap: wrap; }
.files .file .fi, .file-select-all { display: inline-flex; align-items: center; gap: 10px; }
.files input.file-pick, .file-select-all input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); cursor: pointer; }
@media (max-width: 600px) { .ps-add input { flex: 1 1 100%; max-width: none; } }

/* Existing-folder dropdown, placed before file name */
.ps-add { align-items: flex-end; }
.ps-add-field { display: flex; flex: 1; max-width: 420px; min-width: 0; flex-direction: column; gap: 5px; }
.ps-add-field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ps-folder-picker { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ps-folder-picker select { width: 100%; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; }
.ps-add-field input { width: 100%; flex: none; max-width: none; }
.ps-folder-picker input[hidden] { display: none !important; }
.ps-folder-heading td { background: var(--surface); font-weight: 700; padding: 12px 10px; border-top: 2px solid var(--line); }
@media (max-width: 600px) { .ps-add-field { flex: 1 1 100%; max-width: none; } }

/* Collapsible photo folders: native buttons support touch and keyboard. */
.ps-folder-heading td { padding: 0; }
.ps-folder-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; background: transparent; color: var(--ink); text-align: left; font: inherit; font-weight: 700; cursor: pointer; }
.ps-folder-toggle:hover { background: var(--line); }
.ps-folder-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.ps-folder-arrow { width: 14px; flex: 0 0 14px; }
tr[data-ps-folder-key][hidden] { display: none !important; }

/* Bulk photo folders and touch-friendly ordering handles */
.bulk-folder { list-style: none; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 10px; }
.bulk-folder summary { display: flex; align-items: center; justify-content: flex-start; gap: 8px; list-style: none; cursor: pointer; min-height: 36px; font-weight: 700; }
.bulk-folder summary::-webkit-details-marker { display: none; }
.bulk-folder summary::before { content: "▸"; flex: 0 0 14px; }
.bulk-folder details[open] > summary::before, details.bulk-folder[open] > summary::before { content: "▾"; }
.bulk-folder summary label { display: inline-flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; margin: 0; cursor: pointer; overflow-wrap: anywhere; }
.bulk-folder input[type=checkbox], .pub-nm input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; padding: 0; accent-color: var(--primary); cursor: pointer; }
.ps-folder-bar { display: flex; align-items: center; }
.ps-folder-toggle[data-ps-order-handle], .ps-reorder-number { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ps-reorder-number { min-width: 32px; min-height: 32px; padding: 0 4px; border: 0; border-radius: 5px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.ps-reorder-number:focus-visible { outline: 2px solid currentColor; }
.ps-dragging, .ps-dragging * { cursor: grabbing !important; user-select: none !important; }
tr.ps-drag-source > td { background: var(--line); }
tr.ps-drop-before > td { border-top: 3px solid #2563eb !important; }
tr.ps-drop-after > td { border-bottom: 3px solid #2563eb !important; }
.pub-nm { display: flex; align-items: center; gap: 8px; }

/* Keep the row number beside its drag handle and align all row controls. */
table[data-tbl="psort"] tr[data-ps-order-row] > td { vertical-align: middle; padding: 6px 8px; }
.ps-number-cell { white-space: nowrap; overflow-wrap: normal !important; }
.ps-row-number { display: inline-flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 4px; min-height: 32px; white-space: nowrap; }
table[data-tbl="psort"] tr[data-ps-order-row] .ps-folder-picker select { height: 32px; }

/* Calendar PDF: print completed task titles without strikethrough. */
@media print {
  #print .pv.cal .bar.done .ttl { text-decoration: none !important; }
}

/* Gantt PDF: print completed task titles without strikethrough. */
@media print {
  #print .pv.gantt .gbar.done .tx { text-decoration: none !important; }
}

/* Schedule PDF mouse-wheel navigation */
.pdfview { overscroll-behavior: contain; }
.pdfview.pdf-panning, .pdfview.pdf-panning * { cursor: grabbing; user-select: none; }

/* Floating staff chat: one office team room and one room per construction site. */
.chat-launch { position: fixed; right: 22px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 45; width: 54px; height: 54px; border: 0; border-radius: 50%; background: #1238b4; color: #fff; box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; padding: 0; }
.chat-total { position: absolute; right: -3px; top: -4px; min-width: 23px; padding: 3px 5px; border-radius: 20px; background: #b42318; color: white; font-size: 12px; font-weight: 700; }
.chat-total[hidden] { display: none; }
.team-chat { position: fixed; z-index: 46; right: 22px; bottom: max(85px, calc(env(safe-area-inset-bottom) + 65px)); width: min(440px, calc(100vw - 24px)); height: min(650px, calc(100dvh - 120px)); display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.chat-header > div { flex: 1; min-width: 0; }
.chat-header strong { display: block; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-live { font-size: 11px; color: var(--ink-2); }
.chat-live[data-live="on"] { color: var(--done); }
.chat-icon { background: transparent; border: 0; color: var(--ink-2); font: inherit; font-size: 20px; min-width: 34px; min-height: 34px; border-radius: 6px; cursor: pointer; }
.chat-icon:hover { background: var(--surface-2); }
.chat-room-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.chat-room-bar label { font-size: 11px; flex: 0 0 auto; color: var(--ink-2); }
.chat-room-bar select { width: 100%; flex: 1; min-width: 0; font: inherit; font-size: 12px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 8px; }
.chat-unread { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.chat-unread[hidden] { display: none; }
.chat-unread-label { font-size: 11px; font-weight: 700; color: #b3261e; }
.chat-unread-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font: inherit; font-size: 12px; border: 1px solid #b3261e; background: #fff4f3; color: #5a1410; border-radius: 999px; padding: 3px 4px 3px 10px; cursor: pointer; }
.chat-unread-chip .chat-unread-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.chat-unread-chip b { background: #b3261e; color: #fff; border-radius: 999px; min-width: 20px; padding: 1px 6px; text-align: center; font-size: 11px; }
.chat-unread-chip:hover { background: #ffe5e2; }
.chat-unread-chip:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.chat-scope { font-size: 12px; font-weight: 600; padding: 8px 14px; color: var(--accent); background: var(--accent-soft); overflow-wrap: anywhere; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { margin: auto; text-align: center; font-size: 13px; color: var(--ink-2); line-height: 1.8; }
.chat-message { flex: 0 0 auto; max-width: 90%; align-self: flex-start; min-width: 100px; }
.chat-message.mine { align-self: flex-end; }
.chat-message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; font-size: 11px; color: var(--ink-2); }
.chat-message-meta time { font-size: 10px; }
.chat-message p { margin: 0; padding: 10px 12px; font-size: 13px; line-height: 1.7; border-radius: 2px 12px 12px 12px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.mine p { background: var(--accent-soft); border-radius: 12px 2px 12px 12px; }
.chat-older { flex: 0 0 auto; align-self: center; border: 0; padding: 6px 8px; border-radius: 6px; font: inherit; font-size: 12px; color: var(--accent); background: var(--accent-soft); cursor: pointer; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; border-top: 1px solid var(--line-soft); padding: 12px; }
.chat-compose textarea { min-width: 0; flex: 1; resize: vertical; max-height: 140px; min-height: 44px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--bg); color: var(--ink); padding: 10px; font: inherit; font-size: 13px; }
.chat-compose .btn { flex: 0 0 auto; min-height: 44px; }
.chat-error { font-size: 12px; color: var(--danger); padding: 0 12px; overflow-wrap: anywhere; }
.chat-footer { font-size: 10px; color: var(--ink-2); padding: 0 12px 10px; }
.team-chat .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 600px) { .team-chat { right: 12px; bottom: max(77px, calc(env(safe-area-inset-bottom) + 65px)); height: min(620px, calc(100dvh - 100px)); } .chat-launch { right: 14px; } .chat-compose textarea { font-size: 16px; } }
@media print { #teamChatRoot { display: none !important; } }

.chat-bubble-icon { display: block; width: 27px; height: 27px; pointer-events: none; }
.chat-launch:hover { background: #0d2b91; }
.chat-launch:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

:root[data-theme="dark"] .chat-unread-chip { background: #3a1f1d; color: #ffe1de; border-color: #e57a72; }
:root[data-theme="dark"] .chat-unread-label { color: #ff9c94; }

/* USER MANUAL dialog (dashboard button) */
.modal.manual { width: min(920px, 100%); }
.tm-open { margin-left: auto; }
.tm { padding: 0 20px 16px; }
.tm-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.tm-fig.narrow img { max-width: 480px; }
.tm-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tm-body h4 { font-size: 14px; margin: 16px 0 6px; }
.tm-body p, .tm-body li { font-size: 13.5px; line-height: 1.75; }
.tm-body ol, .tm-body ul { margin: 6px 0 8px 1.3em; padding: 0; }
.tm-fig { margin: 10px 0; }
.tm-fig img { display: block; width: 100%; height: auto; border: 1px solid var(--line-soft); border-radius: 8px; }
.tm-fig figcaption { font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.6; }
.tm-note { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.tm-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tm-tbl th, .tm-tbl td { border-bottom: 1px solid var(--line-soft); text-align: left; padding: 7px 8px; vertical-align: top; }
.tm-tbl th { background: var(--surface-2); }

/* chat: attachments, edit, delete */
.chat-attach { align-self: flex-end; min-height: 44px; font-size: 18px; }
.chat-pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; border-top: 1px solid var(--line-soft); }
.chat-pending[hidden] { display: none; }
.chat-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--line-soft); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 12px; background: var(--surface-2); }
.chat-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.chat-chip small { color: var(--ink-2); }
.chat-chip button { border: 0; background: transparent; color: var(--ink-2); font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; }
.chat-chip button:hover { background: var(--line-soft); }
.chat-chip.busy { padding-right: 10px; color: var(--ink-2); }
.chat-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chat-message.mine .chat-atts { justify-content: flex-end; }
.chat-img { border: 1px solid var(--line-soft); background: var(--surface-2); padding: 0; border-radius: 8px; overflow: hidden; cursor: zoom-in; line-height: 0; }
.chat-img img { display: block; max-width: 220px; max-height: 180px; min-width: 60px; min-height: 60px; object-fit: cover; }
.chat-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--line-soft); background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.chat-file span { overflow-wrap: anywhere; }
.chat-file small { color: var(--ink-2); white-space: nowrap; }
.chat-file:hover, .chat-img:hover { border-color: var(--accent); }
.chat-edited { font-size: 10px; color: var(--ink-2); }
.chat-message p.chat-deleted { font-style: italic; color: var(--ink-2); background: transparent; border: 1px dashed var(--line-soft); }
.chat-actions { display: flex; gap: 10px; margin-top: 3px; font-size: 11px; opacity: .55; transition: opacity .12s; }
.chat-message.mine .chat-actions { justify-content: flex-end; }
.chat-message:hover .chat-actions, .chat-actions:focus-within { opacity: 1; }
.chat-actions button { border: 0; background: transparent; padding: 2px 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.chat-actions button.armed { color: var(--danger); font-weight: 700; opacity: 1; }
@media (hover: none) { .chat-actions { opacity: 1; } }
.chat-edit textarea { width: 100%; min-width: 200px; box-sizing: border-box; resize: vertical; border: 1px solid var(--accent); border-radius: 9px; background: var(--bg); color: var(--ink); padding: 8px 10px; font: inherit; font-size: 13px; }
.chat-edit-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }

.rpt-progs { display: grid; gap: 6px; }
.rpt-prow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.rpt-prow input { min-width: 0; }
.rpt-prow .btn { min-width: 34px; padding: 4px 8px; font-weight: 700; }
.rpt-prow .rpt-st { width: 170px; }
@media (max-width: 640px) { .rpt-prow { grid-template-columns: minmax(0, 1fr) 110px auto; } .rpt-prow .rpt-st { width: 100%; } }
.chat-message { display: flex; gap: 8px; align-items: flex-start; }
.chat-message.mine { flex-direction: row-reverse; }
.chat-av { flex: none; padding-top: 2px; }
.chat-av img.av { display: block; }
.chat-av .av.ph { display: grid; }
.chat-body { min-width: 0; flex: 0 1 auto; }
.chat-message.mine .chat-message-meta { justify-content: flex-end; }

/* collapsed Gantt site row: one bar per member and run of consecutive days, with the member's photo */
.ghead .gr { position: relative; }
.crewbar { position: absolute; height: 20px; border-radius: 4px; display: flex; align-items: center; padding-left: 2px; overflow: hidden; z-index: 2; background: color-mix(in srgb, var(--pc) 22%, var(--surface)); border-left: 3px solid var(--pc); box-shadow: 0 1px 2px #243b6312; }
.crewbar .av { display: block; }
.gmonth span[data-act] { cursor: pointer; border-radius: 4px; } .gmonth span[data-act]:hover { background: var(--surface-2); text-decoration: underline; }
.gmsel input { border: 0; background: transparent; font: inherit; font-size: 13px; padding: 4px 6px; color: inherit; }

.gmonth { position: relative; }
.gmrz { position: absolute; right: 0; top: 0; bottom: 0; width: 9px; cursor: col-resize; z-index: 3; touch-action: none; background: linear-gradient(90deg, transparent 4px, color-mix(in srgb, var(--accent, #243b63) 35%, transparent) 4px 6px, transparent 6px); }
.gmrz:hover { background: color-mix(in srgb, var(--accent, #243b63) 25%, transparent); }
.kanban.kx { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kcol.kx-lv { border-top-color: var(--leave-plan); } .kcol.kx-pe { border-top-color: #64748b; }
.kcard.static { cursor: pointer; }

/* change history */
.au-ch { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.5; }
.au-old { text-decoration: line-through; color: var(--ink-2); }
.pill.ins { color: var(--done); } .pill.upd { color: var(--doing); } .pill.del { color: var(--danger); }
