/* 作業日報 → 原価 デモ ── コンセプト「現場の帳面・工程票」（2026-11-09 第2版）
   方眼の地に、工程票のような罫と枠。検印・赤字は朱のはんこ。工程のアイコンは版画（Higgsfield）、挿絵は版画調（Canva）。
   暗い表示は「青焼き図面」。グラフの 4 色（加工・段取り・検査・手直し）は dataviz の検証を通した並び。 */
:root {
  color-scheme: light;
  --paper: #f3eee1;
  --grid: rgba(31, 48, 71, 0.07);
  --grid-major: rgba(31, 48, 71, 0.12);
  --sheet: #fffcf3;
  --sheet-2: #f7f1e2;
  --ink: #1f3047;
  --ink-2: #44506a;
  --pencil: #625d52;
  --rule: #d8cfb9;
  --rule-ink: rgba(31, 48, 71, 0.55);
  --shu: #c43d27;
  --shu-soft: #fbe7e0;
  --kiiro: #f2c230;
  --kiiro-soft: #fff4cc;
  --fusen: #fff6c9;
  --ok-ink: #2c6b45;
  --k-run: #2b5fa8;
  --k-setup: #e2662d;
  --k-insp: #1f9670;
  --k-rework: #d99b00;
  --cost: #2b5fa8;
  --track: #e3e7ef;
  --icon-filter: none;
  --icon-on: brightness(0) invert(1);
  --shadow: 3px 3px 0 rgba(31, 48, 71, 0.13);
  --f-body: "Zen Kaku Gothic New", "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --f-head: "Dela Gothic One", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --f-hand: "Klee One", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --f-num: "Barlow Condensed", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
}
/* 暗い表示＝青焼き図面 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0f1b2f; --grid: rgba(190, 215, 255, 0.06); --grid-major: rgba(190, 215, 255, 0.11);
    --sheet: #15233b; --sheet-2: #1b2c48; --ink: #e8eef8; --ink-2: #c3cfe2; --pencil: #a9b6cc; --rule: #2b3e5f; --rule-ink: rgba(220, 232, 250, 0.45);
    --shu: #ff7a5c; --shu-soft: #3a2228; --kiiro: #f2c230; --kiiro-soft: #343019; --fusen: #26324a; --ok-ink: #6fd29a;
    --k-run: #4a8ae0; --k-setup: #dc5f2a; --k-insp: #1fa073; --k-rework: #c08200; --cost: #4a8ae0; --track: #22344f;
    --icon-filter: brightness(0) invert(0.92); --icon-on: brightness(0) invert(0.08); --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1b2f; --grid: rgba(190, 215, 255, 0.06); --grid-major: rgba(190, 215, 255, 0.11);
  --sheet: #15233b; --sheet-2: #1b2c48; --ink: #e8eef8; --ink-2: #c3cfe2; --pencil: #a9b6cc; --rule: #2b3e5f; --rule-ink: rgba(220, 232, 250, 0.45);
  --shu: #ff7a5c; --shu-soft: #3a2228; --kiiro: #f2c230; --kiiro-soft: #343019; --fusen: #26324a; --ok-ink: #6fd29a;
  --k-run: #4a8ae0; --k-setup: #dc5f2a; --k-insp: #1fa073; --k-rework: #c08200; --cost: #4a8ae0; --track: #22344f;
  --icon-filter: brightness(0) invert(0.92); --icon-on: brightness(0) invert(0.08); --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.65;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--kiiro); outline-offset: 2px; }
.ic { width: 28px; height: 28px; object-fit: contain; filter: var(--icon-filter); flex: none; }

/* ---- 上の帯 ---- */
.top { position: sticky; top: 0; z-index: 20; background: var(--sheet); border-bottom: 2px solid var(--ink); }
.top-in { max-width: 1160px; margin: 0 auto; padding: 8px 16px 0; display: flex; align-items: center; gap: 14px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; padding-bottom: 8px; }
.brand .logo { width: 42px; height: 42px; border: 2px solid var(--ink); border-radius: 8px; background: #fffcf3; display: grid; place-items: center; flex: none; }
.brand .logo img { width: 34px; height: 34px; }
.brand strong { display: block; font-family: var(--f-head); font-weight: 400; font-size: 18px; letter-spacing: 0.03em; line-height: 1.25; }
.brand strong i { font-style: normal; color: var(--shu); margin: 0 2px; }
.brand small { display: block; color: var(--pencil); font-size: 12px; line-height: 1.3; }
.demo-badge { font-family: var(--f-hand); font-weight: 600; font-size: 12.5px; color: #3a3320; background: #ffe98a; padding: 4px 12px 3px; transform: rotate(-2deg);
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.12); white-space: nowrap; position: relative; margin-bottom: 8px; }
.demo-badge::before { content: ""; position: absolute; left: 50%; top: -6px; width: 34px; height: 10px; margin-left: -17px; background: rgba(255, 255, 255, 0.55); transform: rotate(3deg); }
.tabs { margin-left: auto; display: flex; gap: 2px; align-self: stretch; align-items: flex-end; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 8px 14px 9px; text-decoration: none; color: var(--ink-2); font-weight: 700; border: 2px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; margin-bottom: -2px; }
.tabs a img { width: 26px; height: 26px; filter: var(--icon-filter); opacity: 0.7; }
.tabs a:hover { background: var(--sheet-2); }
.tabs a[aria-current="page"] { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.tabs a[aria-current="page"] img { opacity: 1; }
@media (max-width: 760px) {
  .top-in { padding: 8px 16px; min-height: 0; }
  .brand, .demo-badge { padding-bottom: 0; margin-bottom: 0; }
  .demo-badge { margin-left: auto; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; background: var(--sheet); border-top: 2px solid var(--ink);
    padding: 0 6px env(safe-area-inset-bottom); justify-content: space-around; align-items: stretch; }
  .tabs a { flex-direction: column; gap: 1px; padding: 5px 2px 7px; font-size: 12.5px; flex: 1; min-height: 60px; justify-content: center;
    border: 0; border-radius: 0; margin: 0; border-top: 4px solid transparent; }
  .tabs a[aria-current="page"] { background: var(--paper); border-top-color: var(--shu); }
  .tabs a img { width: 30px; height: 30px; }
  main { padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important; }
}
@media (max-width: 400px) { .brand small { display: none; } .brand strong { font-size: 16px; } }

main { max-width: 1160px; margin: 0 auto; padding: 20px 16px 56px; outline: none; }
.loading { color: var(--pencil); padding: 40px 0; text-align: center; font-family: var(--f-hand); font-weight: 600; }

/* ---- 帳票（カード） ---- */
.card { position: relative; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 6px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card h1, .card h2 { margin: 0; font-family: var(--f-head); font-weight: 400; font-size: 19px; line-height: 1.35; letter-spacing: 0.02em; }
.card h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card .lead { margin: 4px 0 14px; color: var(--pencil); font-size: 13.5px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin: -2px 0 12px; padding-bottom: 10px; border-bottom: 3px double var(--rule-ink); }
.card-head > div { min-width: 0; flex: 1; }
.card-head .lead { margin: 2px 0 0; }
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 3px double var(--rule-ink); flex-wrap: wrap; }
.form-head .day { display: flex; align-items: center; gap: 8px; font-family: var(--f-hand); font-weight: 600; color: var(--ink-2); font-size: 14px; }
.form-head .day input { width: auto; min-height: 42px; padding: 4px 10px; }

button { cursor: pointer; }
.primary, .secondary, .ghost, .warn { border-radius: 8px; border: 2px solid var(--ink); padding: 9px 16px; font-weight: 700; min-height: 48px; }
.primary { background: var(--ink); color: var(--sheet); box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25); }
.primary:hover { filter: brightness(1.12); }
.primary:active, .warn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25); }
.primary:disabled, .warn:disabled, .secondary:disabled { opacity: 0.5; cursor: progress; }
.secondary { background: var(--sheet); color: var(--ink); }
.secondary:hover { background: var(--sheet-2); }
.warn { background: var(--kiiro); color: #1d1d1d; border-color: #1d1d1d; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25); }
.warn img { width: 26px; height: 26px; }
.ghost { background: transparent; color: var(--ink-2); border-color: var(--rule-ink); border-width: 1.5px; font-weight: 700; }
.ghost:hover { background: var(--sheet-2); }
.small { min-height: 44px; padding: 5px 12px; font-size: 14px; border-radius: 6px; }
.big { min-height: 58px; font-size: 18px; }
.danger { color: var(--shu); border-color: var(--shu); background: var(--sheet); }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; font-weight: 700; min-height: 0; }

/* 入力の欄（帳票の項目欄） */
.field { display: block; margin: 0 0 18px; }
.lbl, .field > span { display: inline-block; font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 7px; padding: 0 7px; border-left: 4px solid var(--ink); letter-spacing: 0.06em; }
input[type="date"], input[type="time"], input[type="number"], input[type="text"], select, textarea {
  width: 100%; min-height: 50px; border: 1.5px solid var(--rule-ink); border-radius: 6px; background: var(--sheet); padding: 9px 12px; font-size: 16px; }
input[type="time"], input[type="date"] { font-family: var(--f-num); font-size: 21px; font-weight: 600; letter-spacing: 0.03em; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); }
textarea { min-height: 64px; resize: vertical; font-family: var(--f-hand); font-weight: 600; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.hint { display: block; margin-top: 7px; color: var(--ink-2); font-size: 14px; font-family: var(--f-hand); font-weight: 600; line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 50px; padding: 8px 14px; border-radius: 8px; border: 1.5px solid var(--rule-ink); background: var(--sheet); font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; font-size: 15.5px; }
.chip:hover { border-color: var(--ink); }
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2); }
.chip[aria-checked="true"] .ic { filter: var(--icon-on); }
.chip .dot { display: inline-block; width: 7px; align-self: stretch; border-radius: 3px; margin: -2px 2px -2px -6px; }
.chips.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.chip.tile { flex-direction: column; justify-content: center; gap: 2px; min-height: 86px; padding: 8px 4px 6px; font-size: 14.5px; }
.chip.tile .ic { width: 42px; height: 42px; }
.chip.who { font-size: 16.5px; min-width: 78px; justify-content: center; }
.chip.job { flex-direction: column; align-items: flex-start; gap: 0; min-height: 56px; padding: 6px 12px; line-height: 1.3; text-align: left; }
.chip.job b { font-family: var(--f-num); font-size: 17px; font-weight: 600; }
.chip.job small { font-size: 12.5px; font-weight: 500; }
.recent { margin-bottom: 8px; }
.recent-cap { display: block; font-size: 12.5px; color: var(--pencil); margin: 0 0 6px; font-family: var(--f-hand); font-weight: 600; }

/* ---- はじめての方への案内（付箋） ---- */
.guide { position: relative; background: var(--fusen); border: 1px solid rgba(31, 48, 71, 0.2); padding: 16px 18px 14px; margin-bottom: 16px; box-shadow: 2px 3px 0 rgba(31, 48, 71, 0.12); transform: rotate(-0.3deg); }
.guide::before { content: ""; position: absolute; left: 50%; top: -8px; width: 70px; height: 16px; margin-left: -35px; background: rgba(255, 255, 255, 0.6); transform: rotate(-2deg); }
.guide h2 { margin: 0 0 8px; font-family: var(--f-head); font-weight: 400; font-size: 17px; }
.guide ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.guide li { display: flex; gap: 10px; align-items: baseline; font-family: var(--f-hand); font-weight: 600; font-size: 15.5px; }
.guide li b { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--shu); color: var(--shu); font-family: var(--f-num); font-size: 15px; }
.guide .g-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.guide .g-note { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
@media (max-width: 760px) { .guide { padding: 12px 14px 10px; } .guide h2 { font-size: 15px; } .guide li { font-size: 14.5px; } .guide .g-note { display: none; } .guide .g-actions { margin-top: 6px; } }

/* ---- 日報の入力 ---- */
.input-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .input-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } .input-grid .card + .card { margin-top: 0; } .today-card { position: sticky; top: 84px; } }
.time-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.time-row span { color: var(--pencil); font-weight: 700; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qty-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: grid; grid-template-columns: 50px 1fr 50px; border: 1.5px solid var(--rule-ink); border-radius: 6px; overflow: hidden; background: var(--sheet); }
.stepper button { border: 0; background: var(--sheet-2); font-size: 22px; font-weight: 700; color: var(--ink); min-height: 50px; }
.stepper input { border: 0; border-radius: 0; text-align: center; min-height: 50px; padding: 0 4px; font-family: var(--f-num); font-size: 22px; font-weight: 600; }
.plus10 { margin-top: 6px; width: 100%; }
.cost-preview { margin: 4px 0 14px; padding: 10px 14px; background: var(--kiiro-soft); border: 1.5px dashed var(--rule-ink); border-radius: 6px; font-size: 14.5px; color: var(--ink-2); }
.cost-preview b { color: var(--ink); font-family: var(--f-num); font-size: 22px; font-weight: 700; }
.cost-preview .note2 { display: block; font-size: 13px; font-family: var(--f-hand); font-weight: 600; color: var(--shu); }
.cost-preview.err { background: var(--shu-soft); color: var(--ink); border-color: var(--shu); }
.actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 520px) { .actions { grid-template-columns: 2fr 1fr; } }
.actions.one { grid-template-columns: 1fr !important; }
.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: -4px 0 14px; background: var(--kiiro-soft); border: 2px solid var(--kiiro); border-radius: 6px; font-weight: 700; }
@media (max-width: 760px) {
  .submit-bar { position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 5; margin: 0 -18px -18px; padding: 10px 18px 14px;
    background: var(--sheet); border-top: 3px double var(--rule-ink); border-radius: 0 0 6px 6px; }
  .submit-bar .cost-preview { margin: 0 0 8px; padding: 6px 12px; font-size: 13.5px; }
  .submit-bar .cost-preview b { font-size: 19px; }
  .submit-bar .cost-preview .detail { display: none; }
  .submit-bar .actions { grid-template-columns: 3fr 2fr; }
  .submit-bar .big { min-height: 54px; font-size: 17px; padding: 6px 8px; }
  .submit-bar .warn img { width: 22px; height: 22px; }
  .submit-bar #a-timer img { display: none; }
}

/* 計っている間：安全標識の黄と黒の縞 */
.timer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin: -4px 0 16px; background: var(--kiiro-soft);
  border: 7px solid transparent; border-image: repeating-linear-gradient(-45deg, #1d1d1d 0 10px, #f2c230 10px 20px) 7; }
.timer img { width: 42px; height: 42px; filter: var(--icon-filter); animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .timer img { animation: none; } }
.timer .t-main { flex: 1; min-width: 170px; }
.timer .t-main b { font-family: var(--f-num); font-size: 32px; font-weight: 700; line-height: 1.1; }
.timer .t-main small { display: block; color: var(--ink-2); font-size: 13px; }
.timer.stale .t-main b { color: var(--shu); font-size: 22px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--rule); }
.rows li:first-child { border-top: 0; }
.rows li.mine { background: linear-gradient(90deg, var(--kiiro-soft), transparent 70%); }
.rows li.editing { outline: 2px solid var(--kiiro); outline-offset: -2px; }
.rows .time { font-family: var(--f-num); font-weight: 600; font-size: 17px; white-space: nowrap; line-height: 1.2; }
.rows .time small { display: block; font-family: var(--f-body); font-size: 12px; color: var(--pencil); font-weight: 500; }
.rows .what { min-width: 0; font-size: 14.5px; }
.rows .what b { font-family: var(--f-num); font-size: 16px; font-weight: 600; margin-right: 4px; }
.rows .what small { display: block; color: var(--pencil); font-size: 13px; overflow-wrap: anywhere; }
.rows .right { text-align: right; font-family: var(--f-num); font-weight: 600; font-size: 17px; white-space: nowrap; line-height: 1.2; }
.rows .right small { display: block; color: var(--pencil); font-size: 13px; font-weight: 500; }
.rows .note { font-family: var(--f-hand); font-weight: 600; color: var(--ink-2); }
.rows .acts { display: flex; gap: 6px; }
.icon-btn { border: 1.5px solid var(--rule-ink); background: var(--sheet); border-radius: 6px; min-width: 44px; min-height: 44px; color: var(--ink-2); font-size: 14px; font-weight: 700; padding: 0 8px; }
.icon-btn:hover { background: var(--sheet-2); color: var(--ink); }
.icon-btn.del:hover { background: var(--shu-soft); color: var(--shu); border-color: var(--shu); }
.seed-tag { font-family: var(--f-hand); font-weight: 600; font-size: 11.5px; color: var(--pencil); border: 1px dashed var(--rule-ink); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.kind-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.kind-tag i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.totals { display: flex; justify-content: space-between; gap: 10px; padding-top: 8px; margin-top: 6px; border-top: 3px double var(--ink); font-weight: 700; font-family: var(--f-num); font-size: 19px; }
.totals span:first-child { font-family: var(--f-body); font-size: 15px; }
.empty { color: var(--pencil); padding: 8px 0 4px; text-align: center; font-size: 14.5px; font-family: var(--f-hand); font-weight: 600; }
.empty img { display: block; width: 100%; max-width: 460px; margin: 0 auto 10px; border-radius: 4px; border: 1.5px solid var(--rule-ink); }

/* 記録した瞬間の朱のはんこ */
.stamp-pop { position: fixed; left: 50%; top: 42%; z-index: 70; pointer-events: none; width: 170px; height: 170px; margin: -85px 0 0 -85px; border-radius: 50%;
  border: 6px solid var(--shu); color: var(--shu); display: grid; place-items: center; text-align: center;
  font-family: var(--f-head); font-size: 36px; line-height: 1.05; background: rgba(255, 252, 243, 0.86); animation: stamp 1.2s cubic-bezier(.2, .9, .3, 1.2) forwards; }
.stamp-pop::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 2px solid var(--shu); }
.stamp-pop small { display: block; font-family: var(--f-num); font-size: 19px; margin-top: 4px; letter-spacing: 0.04em; }
@keyframes stamp { 0% { transform: scale(1.9) rotate(-18deg); opacity: 0; } 18% { transform: scale(0.95) rotate(-12deg); opacity: 1; } 26% { transform: scale(1) rotate(-12deg); } 78% { opacity: 1; } 100% { transform: scale(1) rotate(-12deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .stamp-pop { display: none; } }

/* ---- はんこ・札 ---- */
.hanko { display: inline-grid; place-items: center; font-family: var(--f-body); font-weight: 700; font-size: 12.5px; line-height: 1; color: var(--shu); border: 2px solid var(--shu); border-radius: 5px;
  padding: 4px 6px 3px; transform: rotate(-6deg); letter-spacing: 0.05em; white-space: nowrap; }
.hanko.grey { color: var(--pencil); border-color: var(--pencil); transform: rotate(4deg); }
.hanko.ink { color: var(--ink); border-color: var(--ink); transform: rotate(-3deg); }
.badge-grey { display: inline-flex; font-size: 12px; font-weight: 700; color: var(--ink-2); border: 1.5px solid var(--rule-ink); border-radius: 4px; padding: 0 6px; white-space: nowrap; }

/* ---- 集計 ---- */
.sum-hero { position: relative; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; background: #f1e9d6; }
.sum-hero img { display: block; width: 100%; height: 250px; object-fit: cover; object-position: center 64%; }
.sum-hero .over { position: absolute; left: 22px; top: 16px; right: 22px; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
/* 見出しは絵の上に貼った帳票の札（絵と重なっても読めるように） */
.sum-hero h1 { margin: 0 auto 0 0; font-family: var(--f-head); font-weight: 400; font-size: 26px; color: #1f3047; line-height: 1.2; background: #fffcf3; border: 2px solid #1f3047; border-radius: 4px;
  padding: 8px 14px 8px; box-shadow: 3px 3px 0 rgba(31, 48, 71, 0.25); transform: rotate(-1deg); }
.sum-hero h1 small { display: block; font-family: var(--f-hand); font-weight: 600; font-size: 14px; color: #2f3a4e; margin-top: 2px; }
@media (max-width: 640px) { .sum-hero img { height: 190px; object-position: center 70%; } .sum-hero h1 { font-size: 18px; padding: 6px 10px; } .sum-hero h1 small { font-size: 12px; } .sum-hero .over { left: 10px; right: 10px; top: 10px; } .month-nav strong { font-size: 18px; } .month-nav button { min-width: 40px; } }
.month-nav { display: flex; align-items: center; gap: 2px; background: #fffcf3; border: 2px solid #1f3047; border-radius: 8px; padding: 2px; color: #1f3047; box-shadow: 2px 2px 0 rgba(31, 48, 71, 0.2); }
.month-nav button { border: 0; background: transparent; min-width: 44px; min-height: 44px; border-radius: 6px; font-size: 20px; font-weight: 700; color: #1f3047; }
.month-nav button:disabled { opacity: 0.25; cursor: default; }
.month-nav button:not(:disabled):hover { background: #f1e9d6; }
.month-nav strong { padding: 0 6px; font-family: var(--f-num); font-size: 21px; font-weight: 600; white-space: nowrap; }
.grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
.grid2 .card + .card { margin-top: 0; }
@media (min-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.kpis { display: grid; gap: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.kpis .kpi:first-child { grid-column: 1 / -1; }
@media (min-width: 900px) { .kpis { grid-template-columns: 1.5fr repeat(4, minmax(0, 1fr)); } .kpis .kpi:first-child { grid-column: auto; } }
.kpi { padding: 12px 16px 14px; min-width: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); position: relative; }
.kpi .k-label { font-size: 13px; color: var(--ink-2); font-weight: 700; letter-spacing: 0.04em; }
.kpi .k-value { font-family: var(--f-num); font-size: 40px; font-weight: 700; line-height: 1.1; margin-top: 4px; overflow-wrap: anywhere; }
.kpi .k-value small { font-family: var(--f-body); font-size: 14px; font-weight: 700; margin-left: 3px; color: var(--ink-2); }
.kpi .k-sub { font-size: 13px; color: var(--pencil); }
.kpi.alert .k-value { color: var(--shu); }
.kpi.main { background: var(--sheet-2); }
.kpi.main .k-value { font-size: 46px; }
.kpi .k-value .hanko { margin-left: 10px; vertical-align: 8px; font-size: 13px; }

.insight-card { margin-bottom: 18px; }
.insights { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); } .insights li:first-child { grid-column: 1 / -1; } }
.insights li { position: relative; background: var(--fusen); border: 1px solid rgba(31, 48, 71, 0.18); padding: 14px 16px 14px 58px; font-family: var(--f-hand); font-weight: 600; font-size: 15.5px; line-height: 1.75;
  box-shadow: 2px 3px 0 rgba(31, 48, 71, 0.1); }
.insights li:nth-child(2n) { transform: rotate(0.35deg); } .insights li:nth-child(2n+1) { transform: rotate(-0.25deg); }
.insights li b { font-family: var(--f-body); font-weight: 700; }
.insights li::before { content: ""; position: absolute; left: 50%; top: -7px; width: 60px; height: 14px; margin-left: -30px; background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(0, 0, 0, 0.05); transform: rotate(-2deg); }
.insights .ic2 { position: absolute; left: 13px; top: 15px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-body); font-weight: 700; font-size: 15px; }
.insights .ic2.bad { color: var(--shu); border: 2px solid var(--shu); transform: rotate(-8deg); }
.insights .ic2.info { color: var(--ink); border: 2px solid var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); margin: 0 0 10px; padding: 0; list-style: none; font-weight: 700; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.legend i.tick { width: 3px; height: 15px; border-radius: 1px; background: var(--ink); }

.hbars { display: grid; gap: 0; }
.hbar { display: grid; grid-template-columns: var(--lw, 96px) minmax(0, 1fr) var(--vw, 96px); gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--rule); cursor: default; }
.hbar:last-child { border-bottom: 0; }
.hbar:hover, .hbar.on { background: var(--sheet-2); }
.hbar.click { cursor: pointer; }
.hbar .lab { font-size: 14px; min-width: 0; line-height: 1.35; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hbar .lab > span { min-width: 0; }
.hbar .lab b { font-family: var(--f-num); font-size: 16px; font-weight: 600; }
.hbar .lab small { display: block; color: var(--pencil); font-size: 12px; font-weight: 500; }
.hbar .val { text-align: right; white-space: nowrap; color: var(--ink-2); font-family: var(--f-num); font-size: 16px; font-weight: 600; }
.hbar .val b { color: var(--ink); font-weight: 700; }
.hbar .val small { font-family: var(--f-body); font-size: 12px; font-weight: 500; }
.track { position: relative; height: 20px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; display: flex; gap: 2px; }
.track .seg { height: 100%; min-width: 1px; }
.track .seg:last-child { border-radius: 0 4px 4px 0; }
.track .tick { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 1px; }
.jobs-chart .hbar { --lw: 230px; --vw: 150px; }
.jobs-sub { display: flex; align-items: baseline; gap: 10px; margin: 16px 0 4px; padding: 6px 0; border-bottom: 2px solid var(--ink); }
.jobs-sub:first-of-type { margin-top: 4px; }
.jobs-sub h3 { margin: 0; font-family: var(--f-head); font-weight: 400; font-size: 16px; }
.jobs-sub small { color: var(--pencil); font-size: 12.5px; }
#proc-bars .hbar { --lw: 132px; }
#work-bars .hbar { --lw: 96px; }
@media (max-width: 640px) {
  .hbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lab val" "bar bar"; gap: 4px 10px; }
  .hbar .lab { grid-area: lab; } .hbar .val { grid-area: val; } .hbar .track, .hbar .meter-track { grid-area: bar; }
}
.over { color: var(--shu); font-weight: 700; }

.meter-track { position: relative; height: 18px; border-radius: 3px; background: var(--track); overflow: hidden;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(31, 48, 71, 0.18) calc(10% - 1px) 10%); }
.meter-track .fill { position: absolute; inset: 0 auto 0 0; background: var(--cost); border-radius: 0 3px 3px 0; }

.cols-wrap { position: relative; }
.cols-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.cols-wrap .grid line { stroke: var(--rule); stroke-width: 1; }
.cols-wrap .base { stroke: var(--ink); stroke-width: 1.5; }
.cols-wrap text { fill: var(--ink-2); font-size: 12px; font-family: var(--f-num); font-weight: 600; }
.cols-wrap .unit { font-family: var(--f-body); font-weight: 500; font-size: 11px; }
.cols-wrap .hatch-line { stroke: var(--rule); stroke-width: 1.5; }
.cols-wrap .hit { fill: transparent; }

.more { margin-top: 10px; }
.table-wrap { overflow-x: auto; margin-top: 12px; border: 1.5px solid var(--ink); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); text-align: left; white-space: nowrap; background: var(--sheet); }
th { background: var(--sheet-2); font-weight: 700; color: var(--ink); position: sticky; top: 0; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--rule); }
th:first-child { z-index: 2; }
td.n, th.n { text-align: right; font-family: var(--f-num); font-size: 15px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.csv-card .actions { grid-template-columns: 1fr; }
@media (min-width: 640px) { .csv-card .actions { grid-template-columns: 1fr 1fr; } }
.csv-card a.secondary { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.csv-card a.secondary img { width: 28px; height: 28px; filter: var(--icon-filter); }

/* ---- 品番の工程票（重ねて開く） ---- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(12, 18, 30, 0.5); display: grid; place-items: end center; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--sheet); width: min(820px, 100%); max-height: 88vh; overflow: auto; border: 2px solid var(--ink); border-radius: 10px 10px 0 0; padding: 18px; box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.25); }
@media (min-width: 760px) { .modal-back { place-items: center; } .modal { border-radius: 8px; } }
.modal .m-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 3px double var(--rule-ink); }
.modal .m-head h2 { margin: 0; font-family: var(--f-head); font-weight: 400; font-size: 20px; }
.modal .m-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--ink-2); margin: 0 0 10px; }
.modal .m-facts b { font-family: var(--f-num); font-size: 18px; color: var(--ink); }

/* ---- 明細・設定 ---- */
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
@media (min-width: 760px) { .filters { grid-template-columns: 1fr 1fr 2fr; } }
.filters .field { margin: 0; }
.sum-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); margin: 0 0 6px; padding: 8px 12px; background: var(--sheet-2); border-radius: 4px; }
.sum-line b { color: var(--ink); font-family: var(--f-num); font-size: 18px; }
.rate-grid { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 10px; align-items: center; padding-bottom: 8px; border-bottom: 1px dashed var(--rule); }
.rate-row label { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.yen-input { position: relative; }
.yen-input input { padding-right: 52px; text-align: right; font-family: var(--f-num); font-size: 21px; font-weight: 600; }
.yen-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--pencil); font-size: 13px; pointer-events: none; }
.form2 { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.form2 .wide { grid-column: 1 / -1; }
.about p, .about li { font-size: 15px; color: var(--ink-2); }
.about ul { padding-left: 1.2em; }
.about h3 { font-size: 15.5px; margin: 18px 0 6px; font-family: var(--f-head); font-weight: 400; }
.about .scene { display: block; width: 100%; border-radius: 4px; border: 1.5px solid var(--rule-ink); margin: 6px 0 12px; }
.credit { font-size: 12.5px; color: var(--pencil); }

/* ---- お知らせとツールチップ（付箋） ---- */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 75;
  background: var(--ink); color: var(--sheet); padding: 12px 16px; border-left: 8px solid var(--kiiro); border-radius: 4px; font-weight: 700; font-size: 15px; max-width: calc(100vw - 24px); width: max-content;
  transition: opacity 0.2s, transform 0.2s; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.show.has-actions { pointer-events: auto; }
#toast.err { background: var(--shu); color: #fff; border-left-color: #1d1d1d; }
#toast .t-btn { background: transparent; color: inherit; border: 1.5px solid currentColor; border-radius: 6px; padding: 6px 12px; min-height: 40px; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 760px) { #toast { top: 66px; bottom: auto; transform: translate(-50%, -20px); } #toast.show { transform: translate(-50%, 0); } }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--fusen); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 3px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.55; box-shadow: 4px 4px 0 rgba(31, 48, 71, 0.18); max-width: 320px; }
.tip b { font-size: 14.5px; }
.tip table { font-size: 13.5px; margin-top: 4px; width: auto; }
.tip td { padding: 1px 0; border: 0; background: transparent; position: static; box-shadow: none; }
.tip td + td { padding-left: 14px; text-align: right; font-family: var(--f-num); font-size: 15.5px; font-weight: 600; }
.tip i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (forced-colors: active) { .seg, .meter-track .fill, .legend i, .chip .dot { forced-color-adjust: none; } }
/* 作業者は 5 人を 1 行に（スマホでも） */
#f-worker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#f-worker .chip.who { min-width: 0; padding: 8px 4px; justify-content: center; }
/* スマホの記録の行：直す・✕ は 2 行目の右へ（金額が欠けないように） */
@media (max-width: 520px) { .rows li { grid-template-columns: auto minmax(0, 1fr) auto; } .rows .acts { grid-column: 2 / -1; justify-self: end; } }

/* スマホの計測中の帯：経過時間を 1 行に */
@media (max-width: 520px) { .timer .t-main b { font-size: 24px; } .timer img { width: 34px; height: 34px; } .timer { gap: 10px; } }
