:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1f2328; --muted: #6a6f76; --line: #e3e1da;
  --accent: #1f6f5c; --accent-soft: #e3f1ec; --warn: #b4232c; --warn-soft: #fbe9ea; --amber: #9a6400; --amber-soft: #fbf1dc;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --card: #1e2125; --ink: #e8e9ea; --muted: #9aa0a6; --line: #30343a;
    --accent: #5cc3a6; --accent-soft: #1d3a32; --warn: #ff7b84; --warn-soft: #3d2023; --amber: #e6b450; --amber-soft: #3a2f17;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--warn); }

header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
header h1 { font-size: 18px; margin: 0; flex: 1; }
header a.logout { font-size: 13px; color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #0d1f1a; } }
button.danger { color: var(--warn); }
button:disabled { opacity: .5; cursor: default; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; }
.stat.alert b { color: var(--warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.toolbar input[type=search] { flex: 1; min-width: 180px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.tabs button { white-space: nowrap; border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.list { display: grid; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: grid; gap: 4px; }
.item:hover { border-color: var(--accent); }
.item .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .title { font-weight: 600; flex: 1; min-width: 200px; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .next { font-size: 14px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.s-waiting, .badge.s-hold { background: var(--amber-soft); color: var(--amber); }
.badge.s-lost, .badge.s-done { background: var(--line); color: var(--muted); }
.badge.cat { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.due-over { color: var(--warn); font-weight: 600; }
.due-soon { color: var(--amber); font-weight: 600; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.dlg-head h2 { font-size: 17px; margin: 0; flex: 1; }
.dlg-body { padding: 16px; display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 15px; }
textarea { min-height: 70px; resize: vertical; }
.full { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline { display: grid; gap: 8px; }
.act { border-left: 3px solid var(--accent-soft); padding: 2px 0 2px 10px; }
.act .when { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.act .when button { padding: 0 6px; font-size: 11px; border: none; color: var(--muted); background: none; }
.act p { margin: 2px 0 0; white-space: pre-wrap; }
.addact { display: grid; grid-template-columns: 130px 130px 1fr; gap: 8px; align-items: end; }
@media (max-width: 560px) { .addact { grid-template-columns: 1fr 1fr; } .addact .grow { grid-column: 1 / -1; } }
h3 { font-size: 14px; margin: 4px 0 0; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login-card { display: grid; gap: 12px; width: min(360px, 100%); }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }
.login-card input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* 体験版 */
.demo-bar { background: var(--amber-soft); color: var(--ink); font-size: 13px; padding: 8px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.demo-bar a { margin-left: 6px; font-weight: 600; }
body.demo main { padding-bottom: 110px; }
.demo-note { margin: 0; font-size: 14px; padding: 10px 12px; border-radius: 8px; background: var(--amber-soft); }
.demo-note a { font-weight: 600; }

/* スマホ：上の帯を1行に収め、案件を見る場所を広く */
@media (max-width: 560px) {
  header { gap: 8px; padding: 10px 12px; }
  header h1 { font-size: 15px; line-height: 1.3; }
  header button.primary { padding: 6px 10px; font-size: 14px; white-space: nowrap; }
  header a.logout { font-size: 12px; white-space: nowrap; }
}
