/* 管理アプリ（経費精算・現場管理・従業員台帳）
   見た目は genba-app（現場クラウド）に合わせる：オレンジの差し色、角丸の白いカード、
   PC は左のサイドバー、スマホは上のバー＋下の5タブ。状態は色付きの丸いバッジ。 */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --paper: #f9fafb;
  --hub: #f9fafb;
  --ink: #1f2937;
  --ink-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --primary: #ea580c;        /* orange-600 */
  --primary-ink: #c2410c;    /* orange-700 */
  --primary-soft: #ffedd5;   /* orange-100 */
  --primary-faint: #fff7ed;  /* orange-50 */
  --stamp: #ef4444;          /* 件数バッジ・未読（red-500） */
  --stamp-soft: #fee2e2;
  --match: #16a34a;
  --match-soft: #dcfce7;
  --diff: #b45309;
  --diff-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ai: #0369a1;
  --ai-soft: #e0f2fe;
  --font: "Hiragino Sans", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --display: var(--font);
  --r: 12px;
  --r-sm: 8px;
  --side-w: 224px;
  --bottom-h: 64px;
}
* { box-sizing: border-box; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.6; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
h1 { font-size: 20px; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
strong, b { font-weight: 700; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
img { max-width: 100%; }

/* ---------- 骨格：PC は左サイドバー、スマホは上バー＋下タブ ---------- */
#app-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
#app-header .brand { color: var(--primary); font-weight: 700; font-size: 18px; white-space: nowrap; text-decoration: none; }
#app-header .brand .beta { display: none; }
#app-header .who { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#app-header nav { display: flex; gap: 4px; }
#app-header .nav-link { display: flex; align-items: center; gap: 8px; flex-shrink: 0; border-radius: var(--r-sm); padding: 8px 12px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; }
#app-header .nav-link:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
#app-header .nav-link.on { background: var(--primary-faint); color: var(--primary-ink); }
#app-header .nav-link .ic { width: 20px; text-align: center; }
#app-header .nav-link .nb { margin-left: auto; }
#app-header .nav-sep { height: 1px; background: var(--line-soft); margin: 8px 4px; }
#app-header .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--faint); padding-top: 16px; }
#app-header .side-foot select { font-size: 13px; padding: 5px 8px; max-width: 100%; }
#app-header .side-foot .logout { color: var(--faint); font-size: 12px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font-family: inherit; }
#app-header .side-foot .logout:hover { color: var(--muted); }
#app-header .bell-m { display: none; }
.nb { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--stamp); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

#bottom-nav { display: none; }

@media (min-width: 768px) {
  body { display: flex; min-height: 100vh; }
  #app-header { position: sticky; top: 0; height: 100vh; width: var(--side-w); flex-shrink: 0; display: flex; flex-direction: column; padding: 16px 12px; border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  #app-header .brand-row { margin-bottom: 20px; padding: 0 8px; }
  #app-header .who { margin-top: 4px; }
  #app-header nav { flex-direction: column; }
  main.page { flex: 1; min-width: 0; padding: 32px 32px 64px; }
}
@media (max-width: 767px) {
  #app-header { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: env(safe-area-inset-top) 12px 0; }
  #app-header .brand { font-size: 17px; }
  #app-header .brand-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
  #app-header .who { display: none; }
  #app-header nav, #app-header .nav-sep, #app-header .side-foot { display: none; }
  #app-header .bell-m { display: inline-flex; position: relative; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-size: 18px; text-decoration: none; }
  #app-header .bell-m .nb { position: absolute; top: -4px; right: -4px; }
  main.page { padding: 12px 12px calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom)); }
  #bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255,255,255,.95); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  #bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; }
  #bottom-nav a .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
  #bottom-nav a.on { color: var(--primary); }
  #bottom-nav a.on .ic { filter: none; opacity: 1; }
  #bottom-nav a .nb { position: absolute; top: 4px; left: 50%; margin-left: 8px; }
}

/* ---------- ページ骨格 ---------- */
main.page { max-width: 1100px; padding: 24px 16px 64px; }
main.page.wide { max-width: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); padding: 20px; margin-bottom: 16px; }
.card.tight { padding: 12px 16px; }
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.divider { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }
@media (max-width: 767px) { .card { padding: 16px; border-radius: 16px; } .page-head { margin-bottom: 16px; } }

/* 流れ（経費のトップ）：横並びの小さなカード */
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 20px; counter-reset: step; }
.flow .step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; counter-increment: step; }
.flow .step .t { font-weight: 600; font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.flow .step .t::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 700; flex-shrink: 0; }
.flow .step.ai .t::before { background: var(--ai-soft); color: var(--ai); }
.flow .step.human .t::before { background: var(--primary-soft); color: var(--primary-ink); }
.flow .step .s { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
@media (max-width: 860px) { .flow { grid-template-columns: 1fr 1fr; } }

/* 数字の帯 → KPI カード */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); padding: 14px 16px; text-decoration: none; color: inherit; display: block; min-width: 0; }
a.stat:hover { border-color: #fdba74; text-decoration: none; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.stat.alert { border-left: 4px solid var(--primary); }
.stat.alert .v { color: var(--primary); }
@media (max-width: 800px) { .stats { grid-template-columns: 1fr 1fr; gap: 10px; } }

/* ---------- ボタン・入力 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 12px; border: 1px solid #d1d5db; background: var(--surface); color: var(--ink-2); border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; line-height: 1.4; transition: background .15s, border-color .15s; text-decoration: none; }
.btn:hover { background: var(--paper); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary, .btn.ok { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover, .btn.ok:hover { background: var(--primary-ink); border-color: var(--primary-ink); }
.btn.ai { background: var(--surface); border-color: #bae6fd; color: var(--ai); font-weight: 600; }
.btn.ai:hover { background: var(--ai-soft); }
.btn.ai::before { content: "✦ "; }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.dark { background: #111827; border-color: #111827; color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 12px 20px; font-size: 15px; font-weight: 700; border-radius: 12px; }
.btn.link { border: none; background: none; color: var(--primary-ink); padding: 0; font-weight: 500; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.block { width: 100%; }

input, select, textarea { font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: var(--r-sm); background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #f97316; box-shadow: 0 0 0 3px #fed7aa; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.sm, select.sm { padding: 4px 8px; font-size: 13px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: #4b5563; }
label.field input, label.field select, label.field textarea { font-size: 14px; font-weight: 400; color: var(--ink); }
label.field.ai-filled input, label.field.ai-filled select, label.field.ai-filled textarea { background: var(--ai-soft); border-color: #bae6fd; }
label.field .fl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
input[type=file] { padding: 4px; font-size: 12px; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
input:read-only, textarea:read-only, select:disabled { background: var(--paper); color: var(--ink-2); }
@media (max-width: 767px) { input, select, textarea, label.field input, label.field select, label.field textarea { font-size: 16px; } }

/* 丸いフィルタ（すべて／種類） */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; align-items: center; }
.chip { flex-shrink: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; background: var(--surface); color: #4b5563; border: 1px solid var(--line); cursor: pointer; font-family: inherit; text-decoration: none; }
.chip:hover { text-decoration: none; }
.chip.on { background: #111827; color: #fff; border-color: #111827; }

/* ---------- タブ ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button, .tabs a { flex-shrink: 0; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; border: none; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--ink-2); text-decoration: none; }
.tabs button.on, .tabs a.on { color: var(--primary-ink); border-bottom-color: var(--primary); }
.tabs button .cnt { color: var(--faint); font-size: 11px; margin-left: 5px; font-variant-numeric: tabular-nums; }
.tabs button.on .cnt { color: var(--primary); }

/* ---------- 表 ---------- */
table { border-collapse: collapse; width: 100%; font-size: 14px; background: transparent; }
th, td { border-bottom: 1px solid var(--line-soft); padding: 8px 12px; text-align: left; vertical-align: middle; }
thead th { font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; background: var(--paper); border-bottom: 1px solid var(--line); }
tbody tr:hover td { background: var(--paper); }
tbody tr.click { cursor: pointer; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
td input, td select { width: 100%; padding: 4px 8px; font-size: 13px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll table { min-width: 560px; }
td.main, th.main { min-width: 200px; }
@media (max-width: 960px) { .opt { display: none; } }
table.kv th { color: var(--muted); font-weight: 400; width: 10em; background: none; font-size: 13px; border-bottom-color: var(--line-soft); }
table.kv td { font-variant-numeric: tabular-nums; }
.sub-row td { background: var(--paper) !important; padding: 8px 12px 12px 28px; }
td .amount { font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- 状態バッジ（genba-app の StatusBadge と同じ色） ---------- */
.tag, .st { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap; background: var(--line-soft); color: var(--ink-2); }
.tag.ai { background: var(--ai-soft); color: var(--ai); }
.tag.warn { background: var(--diff-soft); color: #92400e; }
.tag.ok { background: var(--match-soft); color: #15803d; }
.tag.err { background: var(--danger-soft); color: #b91c1c; }
/* 状態の文字で色を決める（statusBadge() が data-st に入れる） */
[data-st="見積中"], [data-st="下書き"] { background: #f3f4f6; color: #374151; }
[data-st="失注"] { background: #e5e7eb; color: #4b5563; }
[data-st="着工前"], [data-st="承認済"], [data-st="送付済"], [data-st="現調予約"], [data-st="提出済"] { background: #e0f2fe; color: #0369a1; }
[data-st="施工中"] { background: #ffedd5; color: #c2410c; }
[data-st="完了"], [data-st="支払済"], [data-st="入金済"], [data-st="契約"], [data-st="受注"], [data-st="承認"], [data-st="対応済"] { background: #dcfce7; color: #15803d; }
[data-st="請求済"], [data-st="見積提出"] { background: #ede9fe; color: #6d28d9; }
[data-st="未処理"], [data-st="申請中"], [data-st="新規"], [data-st="未対応"] { background: #fef3c7; color: #92400e; }
[data-st="差戻し"], [data-st="却下"] { background: #fee2e2; color: #b91c1c; }
[data-st="現調済"] { background: #e0e7ff; color: #4338ca; }
/* 経費の状態（statusTag） */
.st.draft { background: #f3f4f6; color: #374151; }
.st.submitted { background: #fef3c7; color: #92400e; }
.st.approved { background: #e0f2fe; color: #0369a1; }
.st.returned { background: #fee2e2; color: #b91c1c; }
.st.paid, .st.matched { background: #dcfce7; color: #15803d; }
.st.unmatched { background: #fef3c7; color: #92400e; }
.st.ignored { background: #f3f4f6; color: #6b7280; }
.st.lg { font-size: 14px; padding: 4px 12px; }
@keyframes pop { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.st.just { animation: pop .25s ease-out; }
@media (prefers-reduced-motion: reduce) { .st.just { animation: none; } }

.wmark { display: inline-flex; gap: 3px; vertical-align: middle; }
.wmark i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.wmark i.warn { background: #f59e0b; } .wmark i.error { background: var(--danger); } .wmark i.info { background: var(--ai); }

.empty { color: var(--faint); padding: 32px 16px; text-align: center; font-size: 14px; line-height: 1.7; }
.empty b { color: var(--ink); }
.loading { color: var(--faint); padding: 12px 0; font-size: 13px; }
.notice { background: var(--diff-soft); border-left: 4px solid #f59e0b; padding: 9px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin: 10px 0; font-size: 13px; line-height: 1.6; }
.notice.ai { background: var(--ai-soft); border-color: var(--ai); }
.notice.ok { background: var(--match-soft); border-color: var(--match); }
.notice.err { background: var(--danger-soft); border-color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 14px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 6px; }
details > summary::before { content: "▸"; font-size: 11px; color: var(--faint); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary::-webkit-details-marker { display: none; }
ul.plain { margin: 4px 0 0; padding-left: 1.2em; } ul.plain li { margin: 2px 0; }
ul.warns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.warns li { font-size: 13px; padding: 6px 10px 6px 26px; border-radius: var(--r-sm); position: relative; line-height: 1.55; }
ul.warns li::before { content: ""; position: absolute; left: 10px; top: 12px; width: 8px; height: 8px; border-radius: 50%; }
ul.warns li.error { background: var(--danger-soft); } ul.warns li.error::before { background: var(--danger); }
ul.warns li.warn { background: var(--diff-soft); } ul.warns li.warn::before { background: #f59e0b; }
ul.warns li.info { background: var(--ai-soft); } ul.warns li.info::before { background: var(--ai); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(16px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 86vw; font-size: 14px; box-shadow: 0 10px 20px rgba(0,0,0,.15); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--danger); } #toast.ok { background: #111827; }
@media (max-width: 767px) { #toast { bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); } }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; padding: 20px; border-radius: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal p { white-space: pre-line; line-height: 1.7; }
.modal textarea { width: 100%; }
.modal h3 { font-size: 17px; font-weight: 700; }
@media (max-width: 639px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 24px 24px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: #d1d5db; margin: -4px auto 12px; }
}

/* ---------- 領収書の投入 ---------- */
.drop { border: 2px dashed #d1d5db; background: var(--surface); border-radius: var(--r); padding: 32px 20px 28px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-faint); }
.drop .big { font-size: 18px; font-weight: 700; }
.drop .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.drop input { display: none; }
.drop .btns { margin-top: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.progress { font-size: 13px; }
.progress:not(:empty) { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.progress .item { display: flex; gap: 10px; align-items: center; padding: 5px 0; }
.progress .item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
#upload-card { padding: 0; border: 0; background: transparent; box-shadow: none; }

/* ---------- 申請ページ ---------- */
.exp-layout { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .exp-layout { grid-template-columns: 1fr; } }
.receipt-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
@media (min-width: 901px) { .receipt-box { position: sticky; top: 16px; } }
@media (max-width: 900px) { .receipt-box .view { max-height: 46vh; min-height: 180px; } }
.receipt-box .view { background: #e5e7eb; border-radius: var(--r-sm); min-height: 260px; display: flex; align-items: center; justify-content: center; overflow: auto; max-height: 72vh; }
.receipt-box .view img { max-width: 100%; height: auto; display: block; cursor: zoom-in; transform-origin: top left; }
.receipt-box .view img.zoom { max-width: none; width: 200%; cursor: zoom-out; }
.receipt-box .view iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.receipt-box .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.exp-form .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px 14px; }
.exp-form .c2 { grid-column: span 2; } .exp-form .c3 { grid-column: span 3; } .exp-form .c4 { grid-column: span 4; } .exp-form .c6 { grid-column: span 6; }
@media (max-width: 640px) { .exp-form .grid { grid-template-columns: 1fr 1fr; } .exp-form .c3, .exp-form .c4, .exp-form .c6 { grid-column: span 2; } }
.exp-form input.amount { font-size: 22px; font-weight: 700; padding: 6px 12px; }
.status-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.status-bar .who { font-size: 12px; color: var(--muted); }
.status-bar strong { font-size: 18px; font-weight: 700; }
.status-bar .yen { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.ai-box { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-box .conf { display: inline-block; height: 5px; width: 72px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.ai-box .conf i { display: block; height: 100%; background: var(--ai); }
.act-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.act-list li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; }
.act-list li .t { color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-list li .a { color: var(--ink-2); white-space: nowrap; }

/* ---------- カード明細 ---------- */
.cand { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #fff; margin: 6px 0; font-size: 13px; }
.cand .score { font-weight: 700; color: var(--ink); min-width: 3.4em; font-size: 15px; }
.cand .reasons { color: var(--muted); font-size: 12px; flex: 1; min-width: 160px; }

/* ---------- ホーム ---------- */
.code { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--stamp); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.home-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 960px) { .home-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .home-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.tile { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; min-height: 92px; }
.tile:hover { border-color: #fdba74; text-decoration: none; }
.tile .ic { font-size: 22px; line-height: 1; margin-bottom: 6px; }
.tile .sub { font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.5; }
.tile .badge { position: absolute; top: 10px; right: 10px; }
.hero { display: block; border-radius: 24px; background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; padding: 16px; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.06); margin-bottom: 16px; }
.hero:hover { text-decoration: none; }
.hero .hl { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; opacity: .92; }
.hero .hn { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.hero .hn b { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero .pill { display: inline-block; margin-left: 8px; border-radius: 999px; background: rgba(255,255,255,.25); padding: 2px 8px; font-weight: 600; font-size: 12px; }
.hero ul { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hero li { background: rgba(255,255,255,.15); border-radius: 12px; padding: 8px 12px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); padding: 14px 16px; color: inherit; text-decoration: none; }
.kpi:hover { border-color: #fdba74; text-decoration: none; }
.kpi.alert { border-left: 4px solid var(--primary); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { margin-top: 4px; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.site-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; margin-bottom: 12px; }
.site-card > a.main { display: block; padding: 16px; color: inherit; text-decoration: none; }
.site-card .ttl { font-weight: 700; font-size: 15px; }
.site-card .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.site-card .acts { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line-soft); text-align: center; font-size: 12px; font-weight: 500; }
.site-card .acts a, .site-card .acts span { display: block; padding: 10px 0; color: inherit; text-decoration: none; border-left: 1px solid var(--line-soft); }
.site-card .acts > :first-child { border-left: 0; }
.site-card .acts span { color: #d1d5db; }
.site-card .acts .ic { display: block; font-size: 20px; line-height: 1.2; }
.list-card { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list-card > li { border-bottom: 1px solid var(--line-soft); }
.list-card > li:last-child { border-bottom: 0; }
.list-card > li > a, .list-card > li > .in { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: inherit; text-decoration: none; }
.list-card > li > a:hover { background: var(--paper); text-decoration: none; }
.list-card .chev { color: #d1d5db; font-size: 18px; }
.sec-title { font-size: 13px; font-weight: 700; color: #4b5563; margin: 0 0 8px; padding: 0 4px; }

/* ---------- 工程カード（未着手／作業中／完了の3ボタン） ---------- */
.task-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 8px; color: inherit; }
.task-card.mine { border-color: #fdba74; box-shadow: 0 0 0 1px #fdba74; }
.task-card .th { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.task-card .th b { font-size: 15px; font-weight: 600; }
.task-card .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
a.task-card:hover { border-color: #fdba74; text-decoration: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-width: 240px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 10px; border: 0; border-radius: 10px; background: var(--line-soft); color: #4b5563; cursor: pointer; line-height: 1.4; }
.seg button:hover { background: var(--line); }
.seg button.on, .seg button.on.done { background: var(--primary); color: #fff; }
@media (max-width: 480px) { .task-card .row.between { flex-direction: column; align-items: stretch; } .seg { min-width: 0; } }

/* ---------- 工程表（ガント） ---------- */
.gantt { --g-label: 220px; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); font-size: 14px; }
@media (max-width: 600px) { .gantt { --g-label: 124px; } .g-label .s { display: none; } }
.g-head { display: flex; position: sticky; top: 0; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 2; }
.g-label { flex: 0 0 var(--g-label); width: var(--g-label); padding: 6px 12px; position: sticky; left: 0; background: inherit; z-index: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.g-head .g-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.g-label a { color: var(--ink); text-decoration: none; }
.g-label a:hover { text-decoration: underline; }
.g-label .s { font-size: 11px; color: var(--faint); }
.g-day { flex: 0 0 28px; width: 28px; text-align: center; font-size: 10px; line-height: 1.3; padding: 4px 0; color: var(--muted); }
.g-day.sat { color: #0ea5e9; } .g-day.sun { color: #ef4444; }
.g-day.today { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.g-row { display: flex; align-items: stretch; min-height: 40px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.g-row:last-child { border-bottom: 0; }
.g-group { background: var(--paper); min-height: 26px; font-size: 12px; font-weight: 600; color: #4b5563; }
.g-group span { position: sticky; left: 0; padding: 3px 12px; white-space: nowrap; }
.g-row .g-label { display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.g-track { position: relative; flex: 0 0 auto; }
.g-today { position: absolute; top: 0; bottom: 0; background: #ffedd580; }
.g-bar { position: absolute; top: 50%; transform: translateY(-50%); height: 20px; background: #fed7aa; border-radius: 4px; overflow: hidden; }
.g-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #f97316; }
.g-bar .pct { position: absolute; inset: 0; padding: 0 4px; font-size: 10px; line-height: 20px; color: #111827; }

/* ---------- 案件ページの頭 ---------- */
.pj-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.pj-sub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.pj-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.pj-actions a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); text-decoration: none; font-size: 12px; font-weight: 600; }
.pj-actions a:hover { border-color: #fdba74; text-decoration: none; }
.pj-actions a .ic { font-size: 24px; line-height: 1; }
.pj-actions .badge { position: absolute; top: 6px; right: 6px; font-size: 10px; min-width: 18px; height: 18px; }
@media (min-width: 768px) { .pj-actions { display: none; } }
.item-dl { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; font-size: 14px; margin: 0; }
.item-dl dt { font-size: 12px; color: var(--muted); }
.item-dl dd { margin: 2px 0 0; }
@media (max-width: 560px) { .item-dl { grid-template-columns: 1fr; } }

/* ---------- 写真 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-grid > a, .photo-grid > div { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--line-soft); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; background: rgba(17,24,39,.6); color: #fff; font-size: 11px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-grid .cap:empty { display: none; }

/* ---------- 日報 ---------- */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.04); padding: 16px; margin-bottom: 12px; }
.report .rh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.report .rh b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.report .rb { white-space: pre-wrap; line-height: 1.7; margin: 0; font-size: 14px; }

/* ---------- チャット（LINE 風） ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; min-height: 200px; overflow-y: auto; padding: 6px 2px; }
.chat .m { max-width: 78%; align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.chat .m.me { align-self: flex-end; align-items: flex-end; }
.chat .who { font-size: 11px; color: var(--muted); }
.chat .m.me .who { display: none; }
.chat .b { background: var(--line-soft); border-radius: 16px 16px 16px 4px; padding: 8px 12px; white-space: pre-wrap; line-height: 1.6; font-size: 14px; }
.chat .m.me .b { background: var(--primary); color: #fff; border-radius: 16px 16px 4px 16px; }
.chat img { max-width: 240px; max-height: 240px; border-radius: 12px; display: block; }
.chat .t { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chat .empty { align-self: stretch; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.chat-form textarea { flex: 1; resize: none; border-radius: 16px; }

/* ---------- お知らせ ---------- */
ul.notif { list-style: none; margin: 0; padding: 0; }
ul.notif li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
ul.notif li:last-child { border-bottom: 0; }
ul.notif li.empty { display: block; }
ul.notif .ic { font-size: 20px; line-height: 1.2; text-align: center; }
ul.notif .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--primary); }
ul.notif li.read .dot { background: transparent; }
ul.notif .nt { font-weight: 700; font-size: 14px; }
ul.notif li.read .nt { color: var(--ink-2); font-weight: 400; }
ul.notif .nt a { color: inherit; }
ul.notif .nbody { font-size: 13px; color: var(--muted); white-space: pre-wrap; line-height: 1.5; }
ul.notif .nd { font-size: 11px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- タスク（やること） ---------- */
ul.todo-list { list-style: none; margin: 0; padding: 0; }
ul.todo-list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
ul.todo-list li:last-child { border-bottom: 0; }
ul.todo-list li.done .ti { text-decoration: line-through; color: var(--faint); }
ul.todo-list .ti { flex: 1; min-width: 160px; font-size: 14px; font-weight: 500; }
ul.todo-list .ti a { color: inherit; text-decoration: none; } ul.todo-list .ti a:hover { text-decoration: underline; }
ul.todo-list .meta { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
ul.todo-list .due.over { color: var(--danger); font-weight: 700; }
.tick { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #d1d5db; background: none; color: transparent; cursor: pointer; flex-shrink: 0; font-size: 14px; transition: .15s; font-family: inherit; }
.tick:hover { border-color: #22c55e; color: #22c55e; }
.kind { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 500; background: #f3f4f6; color: #374151; }
.kind.k-工程 { background: #ffedd5; color: #c2410c; }
.kind.k-図面 { background: #fee2e2; color: #b91c1c; }
.kind.k-問い合わせ { background: #e0f2fe; color: #0369a1; }
.kind.k-請求書, .kind.k-経費 { background: #ede9fe; color: #6d28d9; }
.kind.k-休暇 { background: #dcfce7; color: #15803d; }
.kind.k-勤怠 { background: #fef3c7; color: #92400e; }
.grp-h { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 6px; padding: 0 4px; }
.grp-h.overdue { color: var(--danger); } .grp-h.today { color: var(--primary); }
.fab { position: fixed; right: 16px; bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)); z-index: 35; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 30px; border: 0; box-shadow: 0 10px 20px rgba(234,88,12,.35); cursor: pointer; display: none; align-items: center; justify-content: center; }
@media (max-width: 767px) { .fab { display: flex; } .pc-only { display: none !important; } }
@media (min-width: 768px) { .m-only { display: none !important; } }
.undo-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 55; display: flex; align-items: center; gap: 12px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 10px 20px rgba(0,0,0,.2); }
.undo-bar button { background: none; border: 0; color: #fdba74; font: inherit; font-weight: 700; cursor: pointer; }
@media (max-width: 767px) { .undo-bar { bottom: calc(var(--bottom-h) + 80px + env(safe-area-inset-bottom)); } }

/* ---------- 印刷 ---------- */
#print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 11pt; color: #000; display: block; }
  #app-header, #bottom-nav, #toast, .fab, .no-print { display: none !important; }
  main.page { max-width: none; padding: 0; margin: 0; }
  body:has(#print-sheet) main.page > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block; }
  #print-sheet h1 { text-align: center; font-size: 18pt; letter-spacing: .3em; margin: 0 0 12pt; }
  #print-sheet .ph { display: flex; justify-content: space-between; align-items: flex-end; gap: 20pt; margin-bottom: 10pt; font-size: 10.5pt; }
  #print-sheet .total-box { border: 2px solid #000; padding: 6pt 12pt; margin: 8pt 0 12pt; display: flex; justify-content: space-between; align-items: baseline; }
  #print-sheet .total-box b { font-size: 16pt; }
  #print-sheet table { font-size: 9.5pt; }
  #print-sheet th, #print-sheet td { border: 1px solid #555; padding: 3pt 5pt; background: #fff !important; }
  #print-sheet thead th { background: #eee !important; color: #000; }
  #print-sheet tr { page-break-inside: avoid; }
  #print-sheet .sign { display: flex; gap: 10pt; justify-content: flex-end; margin-top: 16pt; }
  #print-sheet .sign div { border: 1px solid #000; width: 60pt; height: 60pt; font-size: 8pt; padding: 2pt; }
  #print-sheet .foot { margin-top: 10pt; font-size: 9pt; color: #333; }
  body:not(:has(#print-sheet)) .btn, body:not(:has(#print-sheet)) form, body:not(:has(#print-sheet)) .tabs, body:not(:has(#print-sheet)) .pj-actions, body:not(:has(#print-sheet)) .chat-form, body:not(:has(#print-sheet)) .chips { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; }
  .gantt { overflow: visible; border: 0; } .g-head { position: static; } .g-label { position: static; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
