/* とるんです プロジェクトマネージャー — 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; }

/* 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; }
}
