:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e1e5ea;
  --accent: #2f5fd0;
  --accent-dark: #2449a8;
  --done: #1e9e5a;
  --done-bg: #e3f6ea;
  --overdue: #d6383a;
  --overdue-bg: #fde8e8;
  --soon: #c77700;
  --soon-bg: #fff2d6;
  --todo: #2f5fd0;
  --todo-bg: #e8eefc;
  --nodate: #7b8794;
  --nodate-bg: #eef0f3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
form h2 { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
form h2:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: normal; margin-left: 8px; }
p.hint { margin: 0 0 12px; }
.nowrap { white-space: nowrap; }
.error-text { color: var(--overdue); font-size: 12.5px; }

/* ---- ヘッダー ---- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: #1f2a44; color: #fff; padding: 10px 24px;
}
.topbar a { color: #d5dcec; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 15px;
}
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.on { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.topbar .me { display: flex; gap: 14px; font-size: 13.5px; }

.container { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }

/* ---- 部品 ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 16px;
}
.card.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.btn {
  display: inline-block; padding: 7px 14px; border: 1px solid #c9d0d9; border-radius: 7px;
  background: #fff; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f1f3f6; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--overdue); border-color: #efb9ba; }
.btn-danger:hover { background: var(--overdue-bg); }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; padding: 10px; margin-top: 8px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--todo-bg); color: var(--todo); vertical-align: middle; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash-ok { background: var(--done-bg); color: #14693b; }
.flash-error { background: var(--overdue-bg); color: #a12527; }

label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 12px; }
.field-title { font-weight: 600; font-size: 13.5px; margin: 4px 0 8px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid #c9d0d9; border-radius: 7px; background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a9c0f5; border-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; cursor: pointer; }
label.check input { width: 17px; height: 17px; margin: 0; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 160px; }
.row > input { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-project { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2, .grid-project { grid-template-columns: 1fr; } }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12.5px; color: var(--muted); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-sm td { font-size: 13px; }
.code { background: #1f2a44; color: #e6ebf5; padding: 10px 12px; border-radius: 7px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }

/* ---- ログイン ---- */
.login-box { max-width: 380px; margin: 9vh auto 0; padding: 28px; }
.login-box h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 19px; }

/* ---- 一覧 ---- */
.tabs { display: flex; align-items: center; gap: 4px; background: #e6e9ee; padding: 3px; border-radius: 8px; }
.tabs a { padding: 4px 12px; border-radius: 6px; color: var(--muted); font-size: 13.5px; }
.tabs a.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs a:hover { text-decoration: none; }
.tabs .sep { width: 1px; height: 18px; background: #c9d0d9; margin: 0 4px; }

.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12.5px; margin-bottom: 14px; }
.dot { width: 11px; height: 11px; border-radius: 50%; margin-left: 10px; background: var(--c); }
.dot:first-child { margin-left: 0; }

.is-done { --c: var(--done); --cb: var(--done-bg); }
.is-overdue { --c: var(--overdue); --cb: var(--overdue-bg); }
.is-soon { --c: var(--soon); --cb: var(--soon-bg); }
.is-todo { --c: var(--todo); --cb: var(--todo-bg); }
.is-nodate { --c: var(--nodate); --cb: var(--nodate-bg); }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 700;
  background: var(--cb); color: var(--c); white-space: nowrap;
}

.alert-card { border-left: 4px solid var(--overdue); }
.alert-card .count { margin-left: 8px; background: var(--overdue); color: #fff; border-radius: 10px; padding: 0 8px; font-size: 12.5px; }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.alert-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.alert-list li.is-struck { opacity: .45; text-decoration: line-through; }
.alert-date { width: 4.6em; color: var(--muted); }

.project-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.project-head h2 { margin: 0; }
.project-title { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.project-title a { font-size: 17px; font-weight: 700; color: var(--text); }
.assignee { font-size: 13px; background: #eef0f3; padding: 2px 10px; border-radius: 12px; }
.assignee.none { color: var(--muted); }
.progress { width: 150px; height: 8px; background: #e6e9ee; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--done); transition: width .25s; }
.progress-text { font-size: 13px; color: var(--muted); min-width: 3.6em; }
.progress-text b { color: var(--text); font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: grid; grid-template-columns: auto 1fr; column-gap: 7px; align-items: center; text-align: left;
  padding: 5px 12px 5px 8px; border: 1.5px solid var(--c); border-radius: 9px;
  background: var(--cb); color: var(--text); font: inherit; cursor: pointer; transition: transform .08s;
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.chip-check {
  grid-row: span 2; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--c); background: #fff; display: grid; place-items: center;
}
.chip-name { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.chip-date { font-size: 11.5px; color: var(--c); font-weight: 700; line-height: 1.25; }
.chip.is-done { background: var(--done); border-color: var(--done); color: #fff; }
.chip.is-done .chip-date { color: #d9f5e4; }
.chip.is-done .chip-check, .step.is-done .check-btn { background: #fff; }
.chip.is-done .chip-check::after, .step.is-done .check-btn::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2.5px solid var(--done); border-bottom: 2.5px solid var(--done); transform: rotate(-45deg);
}
.chip.is-nodate { border-style: dashed; }

/* ---- 案件ページ ---- */
.steps { list-style: none; margin: 0 0 14px; padding: 0; }
.step {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 6px;
  border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 8px; background: #fff;
  transition: background .3s;
}
.step.is-done { background: var(--done-bg); }
.step.is-overdue { background: #fff7f7; }
.step.saved { background: #eaf1ff; }
.check-btn {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--c);
  background: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.check-btn:hover { background: var(--cb); }
.step.is-done .check-btn { background: var(--done); }
.step.is-done .check-btn::after { border-color: #fff; width: 11px; height: 6px; }
.step input { margin: 0; }
.step .step-name { flex: 1; min-width: 120px; border-color: transparent; background: transparent; font-weight: 600; }
.step .step-name:hover { border-color: #c9d0d9; }
.step .step-name:focus { background: #fff; }
.step.is-done .step-name { text-decoration: line-through; color: var(--muted); }
.step input[type=date] { width: 158px; flex: none; }
.step .badge { min-width: 6.8em; text-align: center; }
.step-tools { display: flex; gap: 2px; }
.icon-btn {
  width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: #e6e9ee; color: var(--text); }
.icon-btn.danger:hover { background: var(--overdue-bg); color: var(--overdue); }
.add-step { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 14px; border-top: 1px dashed var(--line); }
.add-step input { margin: 0; }
.add-step input[type=text] { flex: 1; min-width: 180px; }
.add-step input[type=date] { width: 158px; }
.step-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 8px; }
.step-picks label { margin: 0; font-size: 13.5px; }
@media (max-width: 640px) {
  .step { flex-wrap: wrap; }
  .container { padding: 14px; }
}
