:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #1d2733; --muted: #66727f; --line: #dfe4ea;
  --primary: #1f5fa8; --primary-ink: #fff; --primary-soft: #e7f0fb;
  --ok: #1e7a46; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fdf2dc;
  --err: #b42318; --err-soft: #fde8e6; --gray-soft: #eef1f4;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }

/* ヘッダー */
.top { background: #16314f; color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; color: #fff; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: #cfdced; padding: 6px 10px; border-radius: 6px; font-size: 14px; white-space: nowrap; }
.nav a:hover, .nav a.on { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 3px; }
.who { font-size: 13px; color: #cfdced; display: flex; gap: 10px; align-items: center; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid rgba(255,255,255,.3); color: #cfdced; padding: 3px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.menu-btn { display: none; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-row h1 { margin: 0; }

/* フラッシュ */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b5dfc5; color: var(--ok); }
.flash.error { background: var(--err-soft); border-color: #f3c1bc; color: var(--err); }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--gray-soft); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #184d8a; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); border-color: #f3c1bc; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 11px 24px; font-size: 15px; }

/* フォーム */
label.f { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
label.f .req { color: var(--err); font-size: 12px; margin-left: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #c9d1da; border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ee; border-color: var(--primary); }
.inline input, .inline select { width: auto; }
.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 14px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* テーブル */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 8px; text-align: left; vertical-align: top; }
.tbl th { background: #f7f9fb; font-weight: 600; font-size: 13px; color: #44505c; white-space: nowrap; }
.tbl tr:hover td { background: #fafcfe; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl td.nowrap { white-space: nowrap; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 状態ラベル */
.st { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-draft { background: var(--gray-soft); color: #55606b; }
.st-submitted { background: var(--primary-soft); color: var(--primary); }
.st-approved { background: var(--ok-soft); color: var(--ok); }
.st-returned { background: var(--err-soft); color: var(--err); }
.st-none { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11px; background: #efe8fb; color: #5b3aa3; }

/* ダッシュボード */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .n { font-size: 26px; font-weight: 700; }
.card .l { font-size: 13px; color: var(--muted); }
.cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: linear-gradient(90deg, #1f5fa8, #2c79c9); color: #fff; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.cta .t { font-size: 17px; font-weight: 700; }
.cta .btn { background: #fff; color: var(--primary); border: 0; font-weight: 700; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border: 1px solid var(--line); border-radius: 6px; padding: 6px 4px; text-align: center; font-size: 12px; background: #fff; display: block; color: var(--ink); }
.day:hover { text-decoration: none; border-color: var(--primary); }
.day .d { font-weight: 700; font-size: 13px; }
.day.off { background: #f6f7f9; color: #a0a8b1; }
.day.miss { border-color: #f0b44c; background: var(--warn-soft); }
.alert { background: var(--warn-soft); border: 1px solid #f0d18e; color: #6d4a00; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.alert.err { background: var(--err-soft); border-color: #f3c1bc; color: var(--err); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }

/* 日報入力 */
.act-table input, .act-table select, .act-table textarea { padding: 6px 7px; font-size: 14px; }
.act-table textarea { min-height: 40px; }
.act-table td { padding: 5px 4px; }
.act-table .w-time { width: 92px; }
.act-table .w-cat { width: 120px; }
.act-table .w-del { width: 36px; }
.act-table .w-content { width: 34%; }
.act-table .w-next { width: 16%; }
.act-table select { min-width: 84px; }
.act-table .w-visit { width: 16%; }
.act-table textarea { max-height: 220px; overflow-y: auto; }
.act-row.cyzen td:first-child { box-shadow: inset 3px 0 0 #7c5cd6; }
.del-row { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.del-row:hover { color: var(--err); }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,249,.96); border-top: 1px solid var(--line); padding: 12px 0; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; z-index: 5; }

.copy-box { padding: 12px 18px; }
.copy-box summary { cursor: pointer; font-weight: 600; color: var(--primary); }

/* 日報表示 */
.kv dt { font-weight: 700; font-size: 13px; color: #44505c; margin-top: 14px; border-left: 3px solid var(--primary); padding-left: 8px; }
.kv dd { margin: 6px 0 0 11px; white-space: pre-wrap; word-break: break-word; }
.kv dd.empty { color: #a0a8b1; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 4px 0 12px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #c6cfd9; }
.timeline li.k-approve::before { background: var(--ok); }
.timeline li.k-return::before { background: var(--err); }
.timeline li.k-submit::before { background: var(--primary); }
.timeline .body { white-space: pre-wrap; margin-top: 2px; }
.meta { font-size: 12px; color: var(--muted); }
.preview { font-size: 13px; color: #44505c; white-space: pre-wrap; max-height: 4.8em; overflow: hidden; }

/* ダッシュボード */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.dash-grid > * { min-width: 0; }
.card small { font-size: 13px; font-weight: 400; color: var(--muted); }
.meter { height: 6px; background: var(--gray-soft); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.meter span.low { background: #e08a00; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 6px; margin-bottom: 6px; border-left: 4px solid; }
.alerts li.al-danger { background: var(--err-soft); border-color: var(--err); }
.alerts li.al-warn { background: var(--warn-soft); border-color: #e08a00; }
.alerts li.al-info { background: var(--primary-soft); border-color: var(--primary); }
.alerts a { color: var(--ink); font-weight: 600; }
.alerts li > div { min-width: 0; overflow-wrap: anywhere; }
.al-kind { flex: none; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; background: #fff; color: #44505c; border: 1px solid var(--line); margin-top: 2px; }
.trend { display: flex; gap: 4px; align-items: flex-end; height: 190px; padding-top: 4px; }
.tcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.tval { font-size: 10px; color: var(--muted); height: 14px; }
.tbar { flex: 1; width: 70%; max-width: 26px; display: flex; align-items: flex-end; background: var(--gray-soft); border-radius: 3px 3px 0 0; }
.tbar span { display: block; width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; }
.tbar span.low { background: #e08a00; }
.tact { height: 34px; width: 70%; max-width: 26px; display: flex; align-items: flex-end; margin-top: 3px; }
.tact span { display: block; width: 100%; background: #9b87d9; border-radius: 2px 2px 0 0; min-height: 1px; }
.tlab { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; transform: rotate(-35deg); transform-origin: center; height: 22px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend .k-rate { background: var(--primary); } .legend .k-act { background: #9b87d9; } .legend .k-low { background: #e08a00; }
.list-plain li.unread > a { font-weight: 700; }

/* フィルタ */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }

/* ログイン */
.login-box { max-width: 380px; margin: 9vh auto; }
.login-box h1 { text-align: center; }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .grid2, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .trend { gap: 2px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 10px 12px; }
  .card .n { font-size: 21px; }
  .top-in { gap: 8px; padding: 8px 16px; }
  .menu-btn { display: inline-block; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: 4px 10px; font-size: 14px; }
  .nav, .who { display: none; width: 100%; }
  .top.open .nav { display: flex; flex-direction: column; }
  .top.open .who { display: flex; padding-bottom: 8px; }
  main { padding: 14px 12px 60px; }
  .panel { padding: 14px; }
  /* 活動記録は1行ずつカード表示 */
  .act-table thead { display: none; }
  .act-table, .act-table tbody, .act-table tr, .act-table td { display: block; width: 100%; }
  .act-table tr { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; background: #fff; position: relative; }
  .act-table td { padding: 3px 0; border: 0; }
  .act-table td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); }
  .act-table .w-time { width: 48%; display: inline-block; }
  .act-table .w-cat, .act-table .w-del { width: 100%; }
  .act-table .w-del { position: absolute; top: 4px; right: 4px; width: auto; }
  .days { grid-template-columns: repeat(4, 1fr); }
}
