/* 施工管理 共通スタイル — 屋外の日差しでも読める高コントラスト、片手で押せる大きなボタン */
:root {
  --ink: #14213d;
  --ink-soft: #4a5775;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #ddd8cc;
  --accent: #e8590c;      /* 安全オレンジ */
  --accent-ink: #ffffff;
  --accent-soft: #fff1e6;
  --ok: #1f7a4d;
  --ok-soft: #e3f4ea;
  --warn: #b45309;
  --warn-soft: #fff3d6;
  --bad: #b42318;
  --bad-soft: #fde7e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .08), 0 4px 14px rgba(20, 33, 61, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 1080px; }

/* ヘッダー */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.brand::before { content: ""; width: 10px; height: 26px; background: var(--accent); border-radius: 3px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-soft); letter-spacing: 0; }
.who { font-size: 13px; color: var(--ink-soft); text-align: right; }

/* 部品 */
h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.3; }
h2 { font-size: 17px; margin: 0 0 8px; }
.sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.hidden { display: none !important; }

label.field { display: block; font-weight: 700; font-size: 14px; margin: 0 0 12px; }
label.field > span { display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 12px; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.ghost { border-color: var(--line); font-weight: 600; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.bar { height: 10px; background: #ece8dd; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.done > i { background: var(--ok); }

.notice { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 0 0 12px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

/* 現場カード */
.proj { display: block; text-decoration: none; color: inherit; }
.proj + .proj { margin-top: 12px; }
.proj .name { font-weight: 800; font-size: 18px; line-height: 1.35; }
.proj .addr { color: var(--ink-soft); font-size: 14px; margin: 2px 0 10px; }
.proj .meta { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; color: var(--ink-soft); }

/* 写真チェックリスト */
.req { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fff; }
.req + .req { margin-top: 12px; }
.req.done { border-color: var(--ok); background: #fbfefc; }
.req .head { display: flex; align-items: center; gap: 10px; }
.req .mark { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 15px; background: var(--line); color: var(--ink-soft); }
.req.done .mark { background: var(--ok); color: #fff; }
.req .label { font-weight: 800; flex: 1; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; }
.thumbs button { flex: none; width: 84px; height: 84px; padding: 0; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #eee; cursor: pointer; }
.thumbs a.thumb { flex: none; width: 84px; height: 84px; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #eee; display: block; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shoot { margin-top: 10px; }
.shoot label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.shoot input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ライトボックス・ダイアログ */
.lightbox { position: fixed; inset: 0; background: rgba(10, 16, 32, .92); display: grid; place-items: center; z-index: 50; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox .close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; }
dialog { border: none; border-radius: 16px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(20, 33, 61, .35); color: var(--ink); }
dialog::backdrop { background: rgba(20, 33, 61, .5); }
dialog form, dialog .dlg { padding: 18px; }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

/* 管理画面 */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 2px solid var(--line); }
.tab { padding: 10px 16px; font: inherit; font-weight: 800; background: none; border: none; border-bottom: 4px solid transparent; margin-bottom: -2px; cursor: pointer; color: var(--ink-soft); }
.tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 20px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.money { font-variant-numeric: tabular-nums; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; margin: 10px 0; }
.dl dt { color: var(--ink-soft); }
.dl dd { margin: 0; font-weight: 700; text-align: right; }
.secret { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 18px; letter-spacing: .04em; background: var(--accent-soft); border: 2px dashed var(--accent); border-radius: 10px; padding: 10px 12px; word-break: break-all; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .toast { transition: none; } }
