:root {
  --navy: #0F2537;
  --navy-2: #163650;
  --gold: #FFC107;
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --ink: #1B2430;
  --muted: #6B7785;
  --line: #E3E8EE;
  --ok: #1E9E5A;
  --warn: #E5A100;
  --ng: #D6453D;
  --info: #2C6FD1;
  --radius: 14px;
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; color: var(--navy); }
h3 { font-size: .95rem; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
small, .muted { color: var(--muted); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }

/* ── 骨組み ── */
.topbar { display: none; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #fff;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.side nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; }
.side .nav { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #D7DEE7; font-weight: 600; }
.side .nav i { width: 20px; text-align: center; }
.side .nav.on { background: var(--navy-2); color: var(--gold); }
.side .nav:hover { background: var(--navy-2); }
.side-foot { margin-top: auto; font-size: .9rem; color: #C5CEDA; }
.side-foot a { color: var(--gold); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand .mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--gold); color: var(--navy); font-weight: 900; }
.brand.big small { color: #B9C4D0; font-weight: 500; }
.tabs { display: none; }
.main { margin-left: var(--side); padding: 26px 28px 60px; max-width: 1180px; }
.main.solo { margin: 0 auto; max-width: 480px; padding: 40px 16px; }
.badge { margin-left: auto; background: var(--ng); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 700; }

@media (max-width: 899px) {
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
    background: var(--navy); color: #fff; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  }
  .topbar .who { font-size: .85rem; }
  .topbar .role { margin-left: 6px; color: var(--gold); }
  .topbar .logout { color: #C5CEDA; margin-left: 8px; }
  .tabs {
    display: flex; gap: 2px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 54px; z-index: 9; padding: 0 6px; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .nav { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; font-size: .72rem; color: var(--muted); border-bottom: 3px solid transparent; position: relative; }
  .tabs .nav i { font-size: 1.05rem; }
  .tabs .nav.on { color: var(--navy); border-bottom-color: var(--gold); font-weight: 700; }
  .tabs .badge { position: absolute; top: 4px; right: 4px; margin: 0; }
  .main { margin-left: 0; padding: 16px 16px 80px; }
}

/* ── 部品 ── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head-right { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(15,37,55,.06); }
.card.warn { border-left: 5px solid var(--warn); }
.card.ng { border-left: 5px solid var(--ng); }
.card.ok { border-left: 5px solid var(--ok); }
.card.info { border-left: 5px solid var(--info); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.flash { background: #E8F6EE; color: #14603A; border: 1px solid #BFE6CF; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px;
  background: var(--navy); color: #fff; font-weight: 700; border: 0; cursor: pointer; font-size: 1rem; min-height: 46px;
}
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn.ng { background: var(--ng); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: .9rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #E9EEF4; color: var(--navy); white-space: nowrap; }
.pill.ok { background: #E3F5EA; color: #16613A; }
.pill.warn { background: #FFF3D6; color: #7A5500; }
.pill.ng { background: #FBE3E1; color: #8E2520; }
.pill.info { background: #E3ECFB; color: #1F4E9A; }
.pill.gold { background: var(--gold); color: var(--navy); }

/* 今日やることのリスト */
.todo { display: flex; flex-direction: column; gap: 8px; }
.todo a.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
.todo a.item .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #EEF2F6; color: var(--navy); flex: 0 0 auto; }
.todo a.item.ng .ic { background: #FBE3E1; color: var(--ng); }
.todo a.item.warn .ic { background: #FFF3D6; color: #9A6B00; }
.todo a.item.info .ic { background: #E3ECFB; color: var(--info); }
.todo .t { font-weight: 700; }
.todo .d { font-size: .85rem; color: var(--muted); }
.todo .right { margin-left: auto; text-align: right; font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* 表 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; white-space: nowrap; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: #F7F9FB; color: var(--muted); font-weight: 600; font-size: .8rem; position: sticky; top: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.over td { background: #FFF7F6; }
.tbl .mark { font-weight: 700; }

/* フォーム */
form.f { display: flex; flex-direction: column; gap: 12px; }
label.fl { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; color: var(--muted); font-weight: 600; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=month], input[type=number], select, textarea {
  width: 100%; padding: 12px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 1rem; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }
.help { font-size: .82rem; color: var(--muted); margin: 0; }

/* チェックリスト（3択） */
.chk { display: flex; flex-direction: column; gap: 6px; }
.chk .it { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.chk .it .lb { font-weight: 600; font-size: .95rem; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg label { padding: 7px 12px; font-size: .85rem; font-weight: 700; color: var(--muted); cursor: pointer; background: #fff; }
.seg input { display: none; }
.seg input:checked + span { display: block; }
.seg label.done.on { background: #E3F5EA; color: #16613A; }
.seg label.not_done.on { background: #FBE3E1; color: #8E2520; }
.seg label.na.on { background: #E9EEF4; color: var(--navy); }

/* 工程バー */
.stages { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.stages .s { flex: 1 0 auto; min-width: 64px; text-align: center; font-size: .72rem; padding: 6px 4px; border-radius: 8px; background: #EEF2F6; color: var(--muted); font-weight: 700; }
.stages .s.done { background: #DDE8F5; color: var(--navy); }
.stages .s.cur { background: var(--gold); color: var(--navy); }
.stages .s.lost { background: #FBE3E1; color: var(--ng); }

/* 数字 */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: #fff; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.kpi .v { font-size: 1.55rem; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .8rem; color: var(--muted); }
.bar { height: 10px; background: #E9EEF4; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.bar.ok > i { background: var(--ok); }

/* 写真 */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #EEF2F6; position: relative; }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.photos .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15,37,55,.7); color: #fff; font-size: .7rem; padding: 2px 6px; }

/* 履歴 */
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist .h { border-left: 3px solid var(--line); padding-left: 12px; }
.hist .h.approved { border-color: var(--ok); }
.hist .h.returned { border-color: var(--ng); }
.hist .h.pending { border-color: var(--warn); }
.hist .h .m { font-size: .8rem; color: var(--muted); }
.hist .h .q { background: #F7F9FB; border-radius: 8px; padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; }

.login-box { background: #fff; border-radius: 16px; padding: 28px 24px; box-shadow: 0 2px 10px rgba(15,37,55,.08); }
.login-box .brand { justify-content: center; margin-bottom: 18px; font-size: 1.2rem; }
.err { color: var(--ng); font-weight: 600; }
.manual-list li { margin-bottom: 6px; }
.stage-guide { background: #FFF9E6; border: 1px solid #F5E2A0; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }

/* 工程タブ（案件詳細） */
.ptabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); margin-bottom: 14px; scrollbar-width: none; }
.ptabs::-webkit-scrollbar { display: none; }
.ptabs button { flex: 0 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 12px; font-size: .9rem; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.ptabs button.cur { color: var(--navy); border-bottom-color: var(--gold); }
.ptabs button.done { color: var(--navy); }
.ptabs button.now::after { content: '●'; color: var(--gold); font-size: .6rem; margin-left: 4px; vertical-align: middle; }
.ptabs button .cnt { display: inline-block; margin-left: 4px; background: var(--ng); color: #fff; border-radius: 999px; font-size: .68rem; padding: 0 6px; }
.ptab { display: none; }
.ptab.cur { display: block; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 14px; }
.kv > div small { display: block; color: var(--muted); font-size: .78rem; }
.kv > div div { font-weight: 600; }

/* 今日やること（コンパクト） */
.alerts { display: flex; flex-direction: column; }
.alerts a.al { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.alerts a.al:last-child { border-bottom: 0; }
.alerts a.al i { text-align: center; }
.alerts a.al.ng i { color: var(--ng); }
.alerts a.al.warn i { color: var(--warn); }
.alerts a.al.info i { color: var(--info); }
.alerts a.al .who { font-weight: 700; margin-right: 6px; }
.alerts a.al .st { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.alerts a.al.ng .st { color: var(--ng); }
.alerts a.al.warn .st { color: #9A6B00; }
.alerts a.al .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* ブランドロゴ */
.brand img.logo { height: 34px; width: auto; max-width: 140px; border-radius: 6px; background: #fff; padding: 2px 4px; object-fit: contain; }
.login-box .brand img.logo { height: 48px; max-width: 220px; }

/* 今すぐやること */
.hero { border-radius: 16px; padding: 20px 22px; margin-bottom: 14px; color: #fff; background: linear-gradient(135deg, var(--navy), #1E4A6E); position: relative; }
.hero.ng { background: linear-gradient(135deg, #8E2520, #D6453D); }
.hero.warn { background: linear-gradient(135deg, #7A5500, #C98F00); }
.hero.ok { background: linear-gradient(135deg, #14603A, #1E9E5A); }
.hero-l { font-size: .8rem; font-weight: 700; letter-spacing: .08em; opacity: .85; }
.hero-t { font-size: 1.4rem; font-weight: 800; margin: 4px 0 2px; }
.hero-d { opacity: .92; margin-bottom: 12px; }
.hero-m { font-size: .8rem; opacity: .8; margin-top: 8px; }
.hero .btn.gold { box-shadow: 0 2px 8px rgba(0,0,0,.2); }

/* モチベーション */
.quote { font-size: 1.05rem; font-weight: 600; line-height: 1.7; margin: 0; white-space: pre-wrap; }

/* 掲示板 */
.posts { display: flex; flex-direction: column; gap: 10px; }
.post { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.post.pinned { border-color: var(--gold); background: #FFFCF0; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: var(--gold); display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.post-body { white-space: pre-wrap; line-height: 1.6; }
.post-img { max-width: 100%; max-height: 320px; border-radius: 10px; margin-top: 8px; display: block; }
.post-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.post-actions form { margin: 0; }
.comments { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cmt { font-size: .9rem; background: #F7F9FB; border-radius: 8px; padding: 6px 10px; }
.cmt-form { display: flex; gap: 6px; }
.cmt-form input { flex: 1; padding: 8px 10px; }
