/* スーパーAIサーバー: 画面の見た目（スマホで日報を書くのが中心なので、スマホを先に考える） */
:root {
  --main: #1f5fbf; --main-d: #174a96; --main-l: #eaf1fc;
  --ok: #1e8449; --warn: #d68910; --ng: #c0392b; --gray: #7b8794;
  --line: #dde3ea; --bg: #f3f5f8; --text: #1d2733;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif; }
a { color: var(--main); }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 12px 12px 90px; }
.small { font-size: 12px; color: var(--gray); }
.muted { color: var(--gray); }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* 上の帯 */
.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.brand { display: flex; align-items: center; gap: 6px; font-weight: bold; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand .logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #1f5fbf, #7b3fe4); color: #fff; }
.brand small { display: block; font-size: 10px; color: var(--gray); font-weight: normal; line-height: 1; }
nav.main { display: flex; gap: 2px; flex: 1; }
nav.main a { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; white-space: nowrap; }
nav.main a.on, nav.main a:hover { background: var(--main-l); color: var(--main-d); font-weight: bold; }
details.menu { position: relative; }
details.menu summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu > div { position: absolute; right: 0; top: 38px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 200px; padding: 6px; }
details.menu > div a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
details.menu > div a:hover { background: var(--bg); }
/* スマホ: 下にタブ */
@media (max-width: 760px) {
  .brand > span:last-child { display: none; }
  nav.main { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); justify-content: space-around; padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); z-index: 60; }
  nav.main a { flex-direction: column; gap: 0; font-size: 11px; padding: 4px 6px; }
  nav.main a span { font-size: 20px; }
  nav.main a.pc-only { display: none; }
  .top { justify-content: space-between; }
  .kaizen-fab { display: none; }   /* スマホでは下の「提出する」などと重なるので、上の帯の 🤖 にする */
  .kaizen-top { display: inline-grid !important; }
}

/* 箱・表 */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card > h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.list th { background: #f7f9fb; font-size: 12px; color: #556; font-weight: bold; white-space: nowrap; }
table.list tr:hover td { background: #fafcff; }
table.list tfoot td { font-weight: bold; background: #f7f9fb; }
.scroll { overflow-x: auto; }
.flash { background: #e8f6ee; border: 1px solid #9fd5b4; color: #185c34; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.warnbox { background: #fff6e5; border: 1px solid #f0c36d; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 22px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: bold; background: #eef1f5; color: #445; white-space: nowrap; }
.tag.ok { background: #e3f4ea; color: var(--ok); }
.tag.warn { background: #fdf0da; color: #9a5d00; }
.tag.ng { background: #fbe4e1; color: var(--ng); }
.tag.blue { background: var(--main-l); color: var(--main-d); }

/* 入力 */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #c5ced8; border-radius: 8px; background: #fff; width: 100%; max-width: 100%;
}
input[type=number] { text-align: right; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0f5; border-color: var(--main); }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12px; color: #556; font-weight: bold; margin-bottom: 2px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.btn, button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 16px; border-radius: 8px; border: 1px solid #c5ced8; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { background: #f5f7fa; }
.btn.main, button.main { background: var(--main); border-color: var(--main); color: #fff; font-weight: bold; }
.btn.main:hover, button.main:hover { background: var(--main-d); }
.btn.ok, button.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: bold; }
.btn.ng, button.ng { color: var(--ng); border-color: #e7b4ad; }
.btn.small, button.small { padding: 3px 10px; font-size: 13px; }
.btn.big, button.big { padding: 12px 22px; font-size: 16px; width: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: 1px solid #c5ced8; border-radius: 999px; cursor: pointer; background: #fff; }
.checks label:has(input:checked) { background: var(--main-l); border-color: var(--main); color: var(--main-d); font-weight: bold; }

/* 予定表（週） */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); min-height: 140px; display: flex; flex-direction: column; }
.day.today { border-color: var(--main); box-shadow: 0 0 0 2px #cfe0fa; }
.day.sun .dh { color: var(--ng); } .day.sat .dh { color: var(--main); }
.day .dh { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; font-weight: bold; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.day .dh a { text-decoration: none; font-weight: normal; font-size: 18px; line-height: 1; }
.job { display: block; margin: 5px; padding: 6px 7px; border-radius: 8px; background: var(--main-l); border-left: 4px solid var(--main); color: var(--text); text-decoration: none; font-size: 13px; line-height: 1.4; }
.job:hover { filter: brightness(.97); }
.job .t { font-size: 11px; color: #556; }
.job .c { font-weight: bold; }
.job .who { font-size: 11px; color: var(--main-d); }
.job.done { background: #eaf6ef; border-left-color: var(--ok); }
.job.cancel { background: #f1f1f1; border-left-color: #bbb; text-decoration: line-through; color: #999; }
@media (max-width: 760px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
}

/* 日報 */
.line-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fcfdff; }
.line-card .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.items { width: 100%; border-collapse: collapse; }
.items td { padding: 2px 3px; }
.photos { display: flex; flex-wrap: wrap; gap: 6px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 760px) {   /* スマホ: 材料・経費は 1 件ずつの箱に（名前を広く） */
  table.items, table.items tbody { display: block; }
  table.items tr.it { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 4px; align-items: center; margin-bottom: 6px; padding: 6px; border: 1px dashed #c5ced8; border-radius: 8px; background: #fff; }
  table.items tr.it td { width: auto !important; padding: 0; }
  table.items tr.it td:first-child { grid-column: 1 / -1; }
}
.stamp { display: inline-grid; place-items: center; width: 54px; height: 54px; border: 2px solid var(--ng); color: var(--ng); border-radius: 50%; font-size: 11px; font-weight: bold; line-height: 1.2; text-align: center; transform: rotate(-8deg); }

/* AI相談 */
.chat { display: grid; grid-template-columns: 240px 1fr; gap: 12px; height: calc(100vh - 110px); }
.chat .side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-y: auto; padding: 8px; }
.chat .side a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .side a.on, .chat .side a:hover { background: var(--main-l); }
.chat .pane { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 14px; }
.msg { max-width: 820px; margin: 0 auto 14px; display: flex; gap: 10px; }
.msg .who { flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #eef1f5; }
.msg.ai .who { background: linear-gradient(135deg, #1f5fbf, #7b3fe4); color: #fff; }
.msg .body { flex: 1; min-width: 0; white-space: pre-wrap; word-wrap: break-word; }
.msg.me .body { background: var(--main-l); padding: 8px 12px; border-radius: 12px; }
.msg .body code { background: #f2f4f7; padding: 1px 4px; border-radius: 4px; }
.msg .body pre { background: #1e1e1e; color: #eee; padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre; }
.chat form.send { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat form.send textarea { min-height: 48px; max-height: 200px; }
.privacy { font-size: 12px; color: var(--gray); text-align: center; padding: 0 10px 8px; }
@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat .side { max-height: 130px; }
  .chat .pane { height: calc(100vh - 290px); }
}

/* AIに改善を頼むボタン */
.kaizen-top { display: none; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #1f5fbf, #7b3fe4); text-decoration: none; font-size: 18px; }
.kaizen-fab { position: fixed; right: 14px; bottom: 14px; z-index: 40; padding: 9px 14px; border-radius: 999px; background: linear-gradient(135deg, #1f5fbf, #7b3fe4); color: #fff; font-weight: bold; font-size: 13px; text-decoration: none; box-shadow: 0 3px 10px rgba(0,0,0,.25); opacity: .92; }
.kaizen-fab:hover { opacity: 1; }

/* ログイン */
.login { max-width: 380px; margin: 8vh auto; }
.login .brand { justify-content: center; font-size: 22px; margin-bottom: 16px; }
.login .brand .logo { width: 44px; height: 44px; font-size: 24px; border-radius: 12px; }

/* 請求書（印刷） */
@media print {
  .top, .kaizen-fab, .noprint, nav.main { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; }
  .card { border: none; }
}

/* 予定表: 注意事項・休み・あき・緊急 */
.job .caution { color: var(--ng); font-size: 11px; font-weight: bold; }
.job.urgent { box-shadow: inset 0 0 0 2px var(--ng); }
.day .holi { font-size: 11px; padding: 3px 8px; background: #fff6e5; color: #8a5a00; border-bottom: 1px solid var(--line); }
.day .holi button.x { border: none; background: none; padding: 0 2px; color: #b07a00; cursor: pointer; font-size: 11px; }
.day .free { margin-top: auto; padding: 5px 8px; font-size: 11px; color: #1e6b3a; background: #f1faf4; border-top: 1px dashed #bfe3cb; border-radius: 0 0 var(--radius) var(--radius); }
h3.sec { font-size: 13px; color: var(--main-d); border-bottom: 1px solid var(--line); padding-bottom: 3px; margin: 12px 0 8px; }

/* 案件のページ */
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { width: 90px; text-align: left; font-size: 12px; color: #556; font-weight: bold; padding: 5px 6px 5px 0; vertical-align: top; white-space: nowrap; }
table.kv td { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.instr { margin-top: 8px; background: #f6f9fc; border-left: 3px solid var(--main); padding: 8px 10px; border-radius: 6px; }

/* 印刷する紙（作業指示書・作業報告書） */
.sheet { max-width: 800px; margin: auto; padding: 30px 36px; }
.sheet-title { text-align: center; font-size: 24px; letter-spacing: 8px; margin-bottom: 12px; font-weight: bold; }
table.sheet-t { width: 100%; border-collapse: collapse; margin: 10px 0; }
table.sheet-t th, table.sheet-t td { border: 1px solid #555; padding: 6px 8px; text-align: left; }
table.sheet-t th { background: #f0f0f0; width: 90px; white-space: nowrap; font-size: 13px; }
.sheet-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.sheet-photos figure { margin: 0; border: 1px solid #ccc; padding: 4px; break-inside: avoid; }
.sheet-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.sheet-photos figcaption { text-align: center; font-size: 13px; padding: 3px; }
@media print { .sheet { padding: 0; } }
details.jobinfo { background: #f6f9fc; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; font-size: 13px; }
details.jobinfo summary { cursor: pointer; color: var(--main-d); font-weight: bold; }
.caution-box { color: var(--ng); font-weight: bold; margin: 6px 0; }
.nw { white-space: nowrap; }

/* 経営のグラフ（色: 売上=青 #2a78d6、粗利=オレンジ #eb6834。文字は文字の色で） */
.viz { --series-1: #2a78d6; --series-2: #eb6834; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: #e7eaee; stroke-width: 1; }
svg.chart .base { stroke: #9aa3ad; stroke-width: 1; }
svg.chart .ax { font-size: 11px; fill: #6b7580; }
svg.chart .s1 { fill: var(--series-1); } svg.chart .s2 { fill: var(--series-2); }
svg.chart path:hover { opacity: .8; }
.legend { font-size: 12px; font-weight: normal; color: #52514e; display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; } .legend i.s1 { background: var(--series-1); } .legend i.s2 { background: var(--series-2); }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hb { display: grid; grid-template-columns: 110px 1fr 92px; align-items: center; gap: 8px; font-size: 13px; cursor: default; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-bar { height: 16px; background: #f1f3f5; border-radius: 4px; overflow: hidden; }
.hb-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hb:hover .hb-bar i { opacity: .8; }
.hb-v { text-align: right; font-variant-numeric: tabular-nums; color: #1d2733; } .hb-v small { color: #6b7580; }
.tip { position: fixed; z-index: 100; background: #1d2733; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: pre-line; pointer-events: none; box-shadow: 0 3px 10px rgba(0,0,0,.2); }
a.notice { display: block; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--main); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; color: var(--text); text-decoration: none; }
a.notice.unread { border-left-color: var(--ng); background: #fffafa; }

/* 予定表の「表」: 縦に日ごとの現場、横に社員（kksw と同じ見かた） */
.board-wrap { overflow: auto; max-height: calc(100vh - 150px); }
table.board { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; background: #fff; }
table.board th, table.board td { border-bottom: 1px solid var(--line); border-right: 1px solid #eef1f4; padding: 5px 6px; vertical-align: top; }
table.board thead th { position: sticky; top: 0; z-index: 3; background: #f7f9fb; font-size: 12px; color: #445; white-space: nowrap; }
table.board th.b-p { width: 34px; padding: 4px 2px; vertical-align: bottom; }
table.board th.b-p span { writing-mode: vertical-rl; letter-spacing: 1px; }
table.board td.b-date { position: sticky; left: 0; z-index: 2; background: #fafbfc; font-weight: bold; white-space: nowrap; border-right: 1px solid var(--line); }
table.board th.b-date { position: sticky; left: 0; z-index: 4; }
table.board .b-job { min-width: 220px; }
table.board .b-job a { color: var(--text); text-decoration: none; } table.board .b-job a:hover { text-decoration: underline; }
table.board tbody.b-day { border-top: 2px solid #c9d2dc; }
table.board tbody.b-day tr:first-child td { border-top: 2px solid #c9d2dc; }
table.board tbody.today td.b-date { background: var(--main-l); color: var(--main-d); }
table.board tbody.sun td.b-date { color: var(--ng); } table.board tbody.sat td.b-date { color: var(--main); }
table.board td.b-c { width: 34px; text-align: center; vertical-align: middle; padding: 0; font-weight: bold; }
table.board td.b-c[data-job] { cursor: pointer; }
table.board td.b-c[data-job]:hover { background: #eef4fd; }
table.board td.b-c.on { background: var(--main); color: #fff; }
table.board td.b-c.on:hover { background: var(--main-d); }
table.board td.b-c.hol { background: #eceff2; color: #8a939c; font-weight: normal; font-size: 11px; }
table.board td.b-c.clash { background: var(--ng); color: #fff; }
table.board td.b-c.free { background: #eaf7ee; color: #1e6b3a; font-size: 10px; font-weight: normal; }
table.board tr.b-sum td { background: #fbfcfd; font-size: 11px; }
table.board tr.b-cancel td:not(.b-date) { color: #aaa; text-decoration: line-through; }
table.board tr.b-done td.b-job { box-shadow: inset 3px 0 0 var(--ok); }
table.board td.b-need.short { color: var(--ng); font-weight: bold; }
table.who-today th { width: 90px; text-align: left; font-weight: bold; background: none; font-size: 13px; color: var(--text); }
table.who-today tr.me th { color: var(--main-d); }
a.who-job { display: inline-block; margin: 2px 6px 2px 0; padding: 3px 9px; border-radius: 999px; background: var(--main-l); color: var(--text); text-decoration: none; font-size: 13px; }
a.who-job.urgent { box-shadow: inset 0 0 0 2px var(--ng); }
a.who-job:hover { background: #d7e5fa; }
@media (max-width: 760px) {   /* スマホ: 表の現場の列をせまくして、人の列が見えるように */
  table.board .sm-hide { display: none; }
  table.board .b-job { min-width: 130px; font-size: 12px; }
  table.board td.b-date { font-size: 11px; padding: 4px; }
  table.board td.b-c, table.board th.b-p { width: 28px; }
  table.board tr.b-sum td[colspan] { font-size: 10px; }
}

/* 稟議のハンコの列 */
.ringi-route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.ringi-route .rr { text-align: center; }
.stamp small { font-size: 9px; font-weight: normal; }
.stamp.gray { border-color: #999; color: #777; }
.stamp.empty { border: 2px dashed #bbb; color: #999; transform: none; font-weight: normal; }

/* お客様の声 */
.stars { color: #e0a800; letter-spacing: 1px; white-space: nowrap; }
.big-choice label { padding: 8px 14px; font-size: 15px; }
.claim-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.claim-steps span { padding: 3px 10px; border-radius: 999px; background: #eef1f5; color: #667; font-size: 12px; }
.claim-steps span.ok { background: #e3f4ea; color: var(--ok); font-weight: bold; }

/* アンケート */
.survey .q { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.survey .ql { font-weight: bold; margin-bottom: 6px; }
.checks.scale label small { color: var(--gray); font-weight: normal; }
ul.answers { margin: 0; padding-left: 18px; } ul.answers li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.praise { background: #fffbea; border-left: 3px solid #e0a800; padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; }
.md .md-h { font-weight: bold; color: var(--main-d); margin-top: 8px; }
.md .md-sp { height: 4px; }

/* お試し版（AIで改善）を見ているときの帯 */
.trialbar { background: #6c4f9c; color: #fff; padding: 6px 12px; font-size: 13px; text-align: center; }
.trialbar a { color: #fff; background: rgba(255,255,255,.2); padding: 2px 10px; border-radius: 999px; margin-left: 6px; text-decoration: none; white-space: nowrap; }
