/* MIRAIZ 業務アプリ — LINE WORKS に合わせた緑基調 (アクセント #00C73C)。スマホ 360px 基準、PC は最大 960px */
:root {
  --green: #00c73c;
  --green-dark: #00a232;
  --green-bg: #eafbef;
  --red: #d93025;
  --red-bg: #fdecea;
  --amber: #b26a00;
  --amber-bg: #fff4e0;
  --ink: #1b1b1b;
  --muted: #6b6b6b;
  --line: #e3e6e3;
  --bg: #f4f7f4;
  --card: #ffffff;
  --tab-h: 58px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
a { color: var(--green-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.red { color: var(--red); font-weight: 700; }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* 上部バー */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--green); color: #fff; box-shadow: var(--shadow); }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: #fff; font-weight: 800; letter-spacing: 0.04em; font-size: 16px; }
.who { font-size: 13px; opacity: 0.95; }

/* 本文 */
.view { max-width: 960px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.card.clickable { cursor: pointer; }
.card.clickable:active { background: #f7f9f7; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid #cfe9d6; border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* タイル (ホーム) */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; color: var(--ink); border-left: 5px solid var(--green); }
.tile .tile-label { font-size: 13px; color: var(--muted); }
.tile .tile-value { font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.tile .tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.warn { border-left-color: var(--red); }
.tile.warn .tile-value { color: var(--red); }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; min-height: 42px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.btn.primary:active { background: var(--green-dark); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.active { background: var(--green-bg); border-color: var(--green); color: var(--green-dark); font-weight: 700; }
.btn-group { display: inline-flex; border-radius: 10px; overflow: hidden; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1; }

/* フォーム */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field label .req { color: var(--red); margin-left: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 42px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.field input[readonly] { background: #f3f4f3; color: var(--muted); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; min-height: 0; }
.field-error:empty { display: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check input { width: 20px; height: 20px; }
.form-error { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.form-error:empty { display: none; }

/* 検索候補 */
.suggest { border: 1px solid var(--line); border-radius: 10px; background: #fff; max-height: 220px; overflow: auto; margin-top: -8px; margin-bottom: 12px; }
.suggest button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover { background: var(--green-bg); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--green-bg); color: var(--green-dark); padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.chip button { border: 0; background: transparent; cursor: pointer; color: inherit; font-size: 16px; line-height: 1; padding: 0; }

/* バッジ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: #eee; color: #444; }
.s-get { background: var(--green); color: #fff; }
.s-mikomi { background: #e3f2fd; color: #0d47a1; }
.s-50 { background: #fff8e1; color: #8d6e00; }
.s-60 { background: #ffe0b2; color: #8a4b00; }
.s-hard { background: #f3e5f5; color: #6a1b9a; }
.s-hold { background: #eceff1; color: #455a64; }
.s-ng { background: #fdecea; color: var(--red); }
.s-ng-month { background: #fbe9e7; color: #bf360c; }
.s-draft { background: #eceff1; color: #455a64; }
.s-pending { background: #fff8e1; color: #8d6e00; }
.s-approved { background: var(--green-bg); color: var(--green-dark); }
.s-rejected { background: var(--red-bg); color: var(--red); }
.s-type { background: #e8f5e9; color: #1b5e20; }

/* 表・一覧 */
.list .item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.list .item.overdue { background: var(--red-bg); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.list .item .main { flex: 1; min-width: 0; }
.list .item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .sub { font-size: 12px; color: var(--muted); }
.list .item .num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfa; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.short td { color: var(--red); font-weight: 700; }
tr.overdue td { background: var(--red-bg); }
tr.clickable { cursor: pointer; }

/* 週表示 */
.week { display: grid; grid-template-columns: 90px repeat(7, minmax(110px, 1fr)); font-size: 12px; min-width: 860px; }
.week > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; min-height: 44px; }
.week .head { background: #fafbfa; font-weight: 600; color: var(--muted); text-align: center; }
.week .head.today { color: var(--green-dark); background: var(--green-bg); }
.week .name { font-weight: 600; background: #fafbfa; }
.week .appt { display: block; background: var(--green-bg); border-left: 3px solid var(--green); border-radius: 4px; padding: 3px 6px; margin-bottom: 4px; color: var(--ink); }
.week .appt .time { font-weight: 700; margin-right: 4px; }

/* タイムライン */
.timeline .entry { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline .entry::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.timeline .entry.kind-bot_post::before { background: #0d47a1; }
.timeline .entry.kind-status_change::before { background: var(--amber); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; word-break: break-word; }

/* 写真 */
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photo { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; background: #eee; border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .del { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; }
.photo.large { width: 100%; height: auto; max-height: 70vh; }
.photo.large img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; background: #222; }
.camera-overlay { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.camera-overlay video { flex: 1; width: 100%; object-fit: cover; }
.camera-overlay .actions { padding: 12px; background: #000; margin: 0; }
.camera-overlay .actions .btn { background: #fff; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.photo-log { font-size: 11px; color: var(--muted); white-space: pre-wrap; }

/* 進捗バー・グラフ */
.progress { height: 12px; background: #e6efe8; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 999px; }
.progress.over > div { background: var(--green-dark); }
.chart { width: 100%; height: auto; display: block; }
.kpi { font-size: 32px; font-weight: 800; line-height: 1.1; }
.kpi small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; background: var(--c); }

/* 下部タブ */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; z-index: 10; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); padding-top: 6px; }
.tabs a.active { color: var(--green-dark); font-weight: 700; }
.tabs a .ico { font-size: 20px; line-height: 1; }
.tabs:empty { display: none; }

/* トースト */
.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 100; font-size: 14px; max-width: 90vw; }
.toast.show { opacity: 0.95; }
.toast.error { background: var(--red); }

/* お知らせ */
.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.error { background: var(--red-bg); color: var(--red); }
.notice.ok { background: var(--green-bg); color: var(--green-dark); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .field { margin: 0; }
@media (min-width: 640px) { .filters { grid-template-columns: repeat(4, 1fr); } }
