/* 作業完了報告書システム 共通スタイル */
:root {
  --green-900: #1b5e20;
  --green-800: #2e7d32;
  --green-700: #388e3c;
  --green-600: #43a047;
  --green-300: #8bc34a;
  --green-100: #dcedc8;
  --green-50: #f1f8e9;
  --row-a: #e3f0dc;
  --row-b: #f5faf1;
  --teal: #1f6f78;
  --teal-dark: #175359;
  --red: #c62828;
  --amber: #ef6c00;
  --ink: #1f2a1f;
  --muted: #5f6b5f;
  --line: #c8d6c2;
  --bg: #f6f8f4;
  --panel: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(20, 40, 20, 0.12);
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--teal); }
[hidden] { display: none !important; }

/* ---------- レイアウト ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app.user { max-width: 768px; margin: 0 auto; background: var(--panel); box-shadow: var(--shadow); }
.app.admin { max-width: 1600px; margin: 0 auto; background: var(--panel); box-shadow: var(--shadow); }

.topbar {
  background: var(--green-800);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; height: 52px; position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 700; font-size: 18px; letter-spacing: 0.02em; white-space: nowrap; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.topbar .who { font-size: 13px; opacity: 0.9; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { background: transparent; border: 1px solid rgba(255,255,255,0.6); color: #fff; border-radius: 6px; width: 44px; height: 38px; font-size: 22px; line-height: 1; cursor: pointer; }
.menu {
  position: absolute; right: 8px; top: 56px; background: var(--green-900); color: #fff;
  border-radius: 8px; box-shadow: var(--shadow); min-width: 220px; padding: 6px 0; z-index: 30;
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: #fff; padding: 12px 18px; font-size: 16px; cursor: pointer; }
.menu button:hover, .menu button:focus { background: rgba(255,255,255,0.12); }

.main { flex: 1; padding: 16px; }
.admin .main { padding: 16px 24px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 10px; }

/* 同期状態インジケータ */
.sync {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,0.18); white-space: nowrap;
}
.sync.ok { background: #a5d6a7; color: #103d14; }
.sync.pending { background: #ffe082; color: #5d3a00; }
.sync.offline { background: #ef9a9a; color: #5b0d0d; }
.sync.saving { background: #b3e5fc; color: #0b3d5b; }

/* ---------- 管理サイトのナビ ---------- */
.admin-nav { display: flex; gap: 6px; padding: 10px 24px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin-nav button { background: none; border: 0; padding: 10px 14px; font-size: 16px; cursor: pointer; border-bottom: 3px solid transparent; }
.admin-nav button.active { color: var(--red); font-weight: 700; border-bottom-color: var(--red); }

/* ---------- 部品 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.center { text-align: center; }
.login-box { max-width: 380px; margin: 40px auto; background: #eef2ea; border-radius: var(--radius); padding: 24px; }
.login-box h2 { margin: 0 0 16px; font-size: 18px; text-align: center; }

h1.page { font-size: 20px; margin: 0 0 12px; }
h2.sec { font-size: 17px; margin: 18px 0 8px; color: var(--green-900); border-bottom: 2px solid var(--green-100); padding-bottom: 4px; }
.sub { color: var(--muted); font-size: 13px; }
.err { color: var(--red); font-weight: 700; }
.note-red { color: var(--red); font-size: 14px; font-weight: 700; text-align: center; margin: 8px 0; }

.form-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.form-row label.lbl { width: 92px; text-align: right; flex: none; font-size: 15px; }
.form-row .grow { flex: 1; min-width: 140px; }
.form-col { margin: 10px 0; }
.form-col label.lbl { display: block; margin-bottom: 4px; font-size: 15px; }
.req::after { content: "＊"; color: var(--red); margin-left: 2px; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=month], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #9fb59a; border-radius: 8px; background: #fff; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-600); outline-offset: 1px; border-color: var(--green-600); }
textarea { min-height: 120px; resize: vertical; }
input[readonly] { background: #f2f2f2; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.with-mic { display: flex; align-items: stretch; gap: 6px; flex: 1; min-width: 0; }
.with-mic > :first-child { flex: 1; min-width: 0; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 0;
  background: var(--green-700); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.teal { background: var(--teal); }
.btn.gray { background: #757575; }
.btn.red { background: var(--red); }
.btn.outline { background: #fff; color: var(--green-900); border: 2px solid var(--green-700); box-shadow: none; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn.block { display: flex; width: 100%; }
.btn.mic { min-width: 44px; padding: 0 10px; background: #fff; color: var(--teal); border: 1px solid #9fb59a; border-radius: 8px; box-shadow: none; font-size: 20px; }
.btn.mic.listening { background: #ffebee; color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198,40,40,0.4);} 100% { box-shadow: 0 0 0 10px rgba(198,40,40,0);} }

.nav-btns { display: flex; justify-content: center; gap: 24px; margin: 24px 0 8px; flex-wrap: wrap; }
.nav-btn {
  width: 84px; height: 76px; border-radius: 10px; border: 2px solid #444; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 700;
}
.nav-btn .tri { font-size: 26px; color: var(--green-700); line-height: 1; }
.nav-btn.red .tri, .nav-btn.red { color: var(--red); }
.nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ステップ表示 */
.steps { text-align: center; font-size: 14px; margin: 6px 0 10px; line-height: 1.9; }
.steps span { margin: 0 2px; white-space: nowrap; }
.steps span.on { color: var(--red); font-weight: 700; }
.steps + hr, hr.sep { border: 0; border-top: 2px solid var(--teal); margin: 6px 0 14px; }

/* カウンタ行 */
.counter-list { display: flex; flex-direction: column; gap: 6px; }
.counter-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.counter-row:nth-child(odd) { background: var(--row-b); }
.counter-row .name { flex: 1; text-align: right; padding-right: 6px; font-size: 15px; word-break: break-all; }
.counter-row .unit { width: 34px; font-size: 14px; color: var(--muted); }
.counter-row .cnt { width: 44px; text-align: center; font-weight: 700; font-size: 18px; }
.counter-row .cnt.on { color: var(--green-900); background: var(--green-100); border-radius: 6px; }
.cbtn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid #8fa88a; background: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.cbtn:active { background: var(--green-100); }
.link-btn { background: none; border: 0; color: var(--teal); text-decoration: underline; cursor: pointer; padding: 6px; font-size: 14px; }

/* テーブル */
.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
table.tbl th { background: var(--green-600); color: #fff; padding: 8px 6px; text-align: left; font-weight: 700; white-space: nowrap; }
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { background: var(--green-700); }
table.tbl td { padding: 8px 6px; border-bottom: 1px solid #e0e8dc; vertical-align: middle; }
table.tbl tr:nth-child(odd) td { background: var(--row-a); }
table.tbl tr:nth-child(even) td { background: var(--row-b); }
table.tbl td.c, table.tbl th.c { text-align: center; }
table.tbl a.rowlink { color: var(--ink); text-decoration: underline; cursor: pointer; }
table.tbl .dot { display: inline-block; width: 30px; height: 30px; border-radius: 50%; background: var(--green-800); color: #fff; line-height: 30px; text-align: center; cursor: pointer; font-size: 14px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 8px 0; font-size: 14px; }
.pager button { background: none; border: 1px solid var(--line); border-radius: 6px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.pager button:disabled { opacity: 0.3; }
.toolbar { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ダッシュボード */
.dash h3 { margin: 12px 0 4px; font-size: 16px; }
.dash h3::after { content: ""; display: block; border-bottom: 1px dashed #777; }
.dash button.item { display: block; background: none; border: 0; text-align: left; padding: 12px 10px; font-size: 17px; width: 100%; cursor: pointer; border-radius: 8px; }
.dash button.item:hover { background: var(--green-50); }
.dash button.item .sub { display: block; }

/* 測定値グリッド */
.mgrid { display: grid; grid-template-columns: 1.1fr 1.3fr 0.8fr 1fr 1.1fr 36px; gap: 4px; align-items: center; margin-bottom: 4px; }
.mgrid.head { font-size: 12px; color: var(--muted); }
.mgrid input, .mgrid select { padding: 6px 6px; min-height: 40px; font-size: 14px; }
.mgrid .del { background: none; border: 0; color: var(--red); font-size: 18px; cursor: pointer; }
@media (max-width: 540px) { .mgrid { grid-template-columns: 1fr 1fr; } .mgrid.head { display: none; } }

/* チェック */
.chk { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; font-size: 15px; cursor: pointer; }
.chk input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; }

/* サイン */
.sign-frame { border: 2px dashed #555; border-radius: 6px; background: #fff; width: 100%; aspect-ratio: 2 / 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sign-frame img { max-width: 100%; max-height: 100%; }
canvas.sign { width: 100%; height: 100%; touch-action: none; display: block; background: #fff; }
.sign-page .sign-frame { aspect-ratio: 3 / 2; }

/* ダイアログ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 18px; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.dialog.wide { max-width: 900px; }
.dialog .dhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dialog .dhead h3 { margin: 0; font-size: 17px; }
.dialog .close { background: none; border: 0; font-size: 15px; cursor: pointer; }
.dialog .dbtns { display: flex; justify-content: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.pick-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #eee; padding: 12px; font-size: 15px; cursor: pointer; }
.pick-list button:hover { background: var(--green-50); }
.pick-list button.on { background: var(--green-100); }

/* トースト */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #263238; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 200; box-shadow: var(--shadow); font-size: 15px; max-width: 90vw; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green-800); }

/* プレビュー */
.preview-frame { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--line); background: #666; }
.close-line { text-align: right; margin: 4px 0; }

/* 状態バッジ */
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eee; }
.badge.pending { background: #ffe082; }
.badge.done { background: var(--green-100); color: var(--green-900); }

.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.center { text-align: center; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.w-100 { width: 100%; }

@media print {
  .topbar, .nav-btns, .toolbar, .footer { display: none !important; }
}
