:root {
  --navy: #16324f;
  --navy-2: #1e4368;
  --ink: #1f2937;
  --muted: #5b6675;
  --line: #dfe4ea;
  --bg: #f5f7fa;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-soft: #e6f4f1;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #b42318;
  --red-soft: #fdeceb;
  --blue-soft: #eaf1f8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 15px;
}

h1, h2, h3, h4, p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 10px rgba(9, 20, 33, .18);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 66px;
  padding: 8px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-weight: 700;
  font-size: 20px;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .04em; line-height: 1.3; }
.brand-sub { font-size: 11px; color: #c5d5e4; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 6px; flex: 0 0 auto; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #d7e3ef;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover { background: rgba(255, 255, 255, .08); }
.tab.active { background: #fff; color: var(--navy); }

.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 11px;
  font-weight: 700;
}

.tab.active .tab-count { background: var(--blue-soft); color: var(--navy); }

main { padding: 26px 0 56px; }

/* ---------- generic ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 22px; }

.stack { display: grid; gap: 18px; }

.hero { padding: 30px 26px; }
.hero h2 { font-size: 24px; line-height: 1.45; letter-spacing: .01em; color: var(--navy); }
.hero p { margin-top: 10px; color: var(--muted); max-width: 62em; }
.hero .badges { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--navy-2);
  font-size: 12px;
  font-weight: 600;
}

.badge.teal { background: var(--teal-soft); color: #0b5f59; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.section-title h3 { font-size: 18px; color: var(--navy); letter-spacing: .02em; }
.section-title p { color: var(--muted); font-size: 13px; }

.hint { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

/* ---------- condition form ---------- */
.form-card { overflow: hidden; }

.form-head {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe, #fff);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.form-head h2 { font-size: 18px; color: var(--navy); }

.cond-list { padding: 6px 22px 4px; }

.cond {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 15px 0;
  border-bottom: 1px solid #eef1f5;
}

.cond:last-child { border-bottom: 0; }

.cond-label { padding-top: 6px; font-size: 13px; font-weight: 700; color: var(--navy-2); }
.cond-label span { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 2px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }

.seg button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  transition: background .12s, border-color .12s, color .12s;
}

.seg button:hover { border-color: #b9c6d4; background: #f8fafc; }

.seg button[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #0b5f59;
  box-shadow: inset 0 0 0 1px var(--teal);
}

.form-extra {
  padding: 18px 22px 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field label { display: block; font-size: 12px; font-weight: 700; color: var(--navy-2); margin-bottom: 6px; }
.field label .opt { font-weight: 400; color: var(--muted); }

.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}

.field input:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }

.form-actions {
  padding: 18px 22px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .06s, background .12s, border-color .12s;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #0d6a63; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--navy-2); }
.btn-ghost:hover { border-color: #b9c6d4; background: #f8fafc; }
.btn-danger { background: #fff; border-color: #f0c2bd; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- case ---------- */
.case-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.backlink {
  border: 0;
  background: transparent;
  color: var(--navy-2);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.backlink:hover { text-decoration: underline; }

.case-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.case-head { padding: 22px; }
.case-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.case-head h2 { font-size: 20px; color: var(--navy); line-height: 1.4; }
.case-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.case-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.case-fields {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.2fr 1fr .9fr .9fr;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid #eef1f5;
}

.save-state { font-size: 12px; color: var(--muted); }
.save-state.saved { color: var(--teal); }

/* progress */
.progress-card {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 2fr);
  gap: 20px;
  align-items: center;
}

.progress-num { display: flex; align-items: baseline; gap: 6px; }
.progress-num strong { font-size: 32px; line-height: 1; color: var(--navy); letter-spacing: .02em; }
.progress-num span { color: var(--muted); font-size: 13px; }

.progress-label { font-size: 12px; font-weight: 700; color: var(--navy-2); margin-bottom: 8px; }
.bar { height: 10px; border-radius: 999px; background: #e8edf2; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #2ea394); transition: width .25s ease; }
.progress-sub { margin-top: 7px; color: var(--muted); font-size: 12px; }

/* warnings */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid;
  font-size: 13px;
  align-items: flex-start;
}

.alert + .alert { margin-top: 8px; }
.alert .mark { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.alert strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.alert p { color: inherit; opacity: .9; }
.alert.info { background: var(--blue-soft); border-color: #cddceb; color: #14395c; }
.alert.info .mark { background: #d3e3f2; }
.alert.warn { background: var(--amber-soft); border-color: #f0d8b6; color: #7c3f06; }
.alert.warn .mark { background: #f5e0c3; }
.alert.danger { background: var(--red-soft); border-color: #f1c7c3; color: #8f1d16; }
.alert.danger .mark { background: #f5d6d3; }

.alert-list { display: grid; gap: 8px; }

/* deadline */
.deadline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed #d8dee6;
  background: #fafbfd;
}

.deadline.has-date { border-style: solid; }
.deadline .d-date { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.deadline .d-state { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.d-state.ok { background: var(--teal-soft); color: #0b5f59; }
.d-state.soon { background: var(--amber-soft); color: var(--amber); }
.d-state.over { background: var(--red-soft); color: var(--red); }
.d-state.none { background: #eef1f5; color: var(--muted); }

/* sections */
.section-card { padding: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h3 { font-size: 17px; color: var(--navy); }
.section-head .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.doc-group + .doc-group { margin-top: 18px; }
.doc-group h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--navy-2);
  margin-bottom: 8px;
}
.doc-group h4::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--teal); }

.checklist { display: grid; gap: 8px; }

.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.check:hover { background: #fbfcfe; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

.check .box {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  margin-top: 1px;
  border: 1.5px solid #b9c4d0;
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
  font-weight: 800;
  transition: background .12s, border-color .12s;
}

.check .body { min-width: 0; }
.check .lbl { display: block; font-size: 14px; font-weight: 600; line-height: 1.5; }
.check .note { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.check .note.warn { color: var(--amber); font-weight: 600; }

.check input:checked + .box { background: var(--teal); border-color: var(--teal); color: #fff; }
.check input:checked ~ .body .lbl { text-decoration: line-through; text-decoration-color: #9fb3c4; color: #64748b; }
.check input:checked ~ .body .note { color: #8a97a6; }
.check.checked { background: #fbfdfc; border-color: #d7e5e1; }

.check.caution .box { border-color: #e0b58c; }
.check.caution input:checked + .box { background: var(--amber); border-color: var(--amber); }

.check:focus-within { outline: 2px solid rgba(15, 118, 110, .35); outline-offset: 1px; }

/* timeline */
.timeline { display: grid; gap: 0; margin-top: 4px; }

.tl-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  position: relative;
}

.tl-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 34px;
  bottom: -4px;
  width: 2px;
  background: #e3e8ee;
}

.tl-dot {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #cfd8e2;
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  margin-top: 8px;
}

.tl-item.done .tl-dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.tl-item.done:not(:last-child)::before { background: #bfe0d9; }

.tl-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 4px;
}

.tl-card:hover { background: #fafbfd; }
.tl-main { flex: 1; min-width: 0; }
.tl-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-title { font-size: 14.5px; font-weight: 700; color: #24364a; }
.tl-owner {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--navy-2);
  background: #eef3f8;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.tl-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-item.done .tl-title { color: #64748b; text-decoration: line-through; text-decoration-color: #a9b8c6; }
.tl-check { flex: 0 0 auto; margin-top: 1px; }

/* info grid */
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.info-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
  background: #fff;
}
.info-box h4 { font-size: 13px; color: var(--navy-2); margin-bottom: 7px; }
.info-box p, .info-box li { font-size: 13px; color: #3f4c5c; }
.info-box ul { margin: 0; padding-left: 1.1em; display: grid; gap: 3px; }
.info-box .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--blue-soft); color: var(--navy-2); margin-left: 6px; }

.kv { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; color: #2b3a4b; }

.cost-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cost {
  border: 1px solid #dbe3ea;
  background: #fbfcfe;
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #33475b;
}
.cost span { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }

/* schedule */
.schedule { display: grid; gap: 0; }
.sch-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px dashed #e7ebf0;
}
.sch-row:last-child { border-bottom: 0; }
.sch-date { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.sch-title { font-size: 13px; }
.sch-title small { display: block; color: var(--muted); font-size: 11.5px; }
.sch-state { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.sch-state.future { background: var(--blue-soft); color: var(--navy-2); }
.sch-state.soon { background: var(--amber-soft); color: var(--amber); }
.sch-state.over { background: var(--red-soft); color: var(--red); }
.sch-state.done { background: var(--teal-soft); color: #0b5f59; }

.schedule-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.schedule-head .field { width: 190px; }

.memo textarea { min-height: 96px; resize: vertical; }

/* cases list */
.case-list { display: grid; gap: 12px; }

.case-item {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.case-item h3 { font-size: 16px; color: var(--navy); line-height: 1.4; }
.case-item .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.case-item .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.case-item .chips span { font-size: 11px; background: #f1f5f9; color: #475569; border-radius: 999px; padding: 1px 8px; }
.case-item .mini-progress { min-width: 150px; }
.case-item .mini-progress .bar { height: 8px; }
.case-item .mini-progress p { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.case-item .mini-progress strong { color: var(--navy); }
.case-item .actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.empty {
  padding: 48px 24px;
  text-align: center;
}
.empty h3 { color: var(--navy); font-size: 17px; }
.empty p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.empty .btn { margin-top: 18px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--navy);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .22);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { padding-bottom: 30px; color: #8a96a3; font-size: 11.5px; display: grid; gap: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .case-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-card { grid-template-columns: 1fr; gap: 12px; }
  .case-item { grid-template-columns: 1fr; }
  .case-item .actions { justify-content: flex-start; }
  .form-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 14px; }
  .wrap { width: min(1080px, 100% - 22px); }
  .topbar-inner { min-height: 0; gap: 7px 10px; padding: 8px 0; }
  .brand-sub { display: none; }
  .tabs { margin-left: auto; }
  .brand-title { font-size: 15.5px; }
  .logo { width: 34px; height: 34px; font-size: 18px; }
  .tab { padding: 7px 10px; font-size: 12px; }
  .tab-count { min-width: 18px; height: 18px; }

  main { padding: 16px 0 40px; }
  .hero { padding: 22px 18px; }
  .hero h2 { font-size: 20px; }
  .card-pad, .section-card, .case-head { padding: 18px; }
  .form-head { padding: 16px 18px; }
  .cond-list { padding: 2px 18px; }
  .cond { grid-template-columns: 1fr; gap: 8px; padding: 12px 0; }
  .cond-label { padding-top: 0; }
  .seg button { padding: 8px 11px; font-size: 12.5px; }
  .form-extra { grid-template-columns: 1fr; padding: 14px 18px 0; }
  .form-actions { padding: 16px 18px 20px; }
  .form-actions .btn { width: 100%; }
  .case-fields { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .sch-row { grid-template-columns: 84px minmax(0, 1fr); }
  .sch-row .sch-state { grid-column: 2; justify-self: start; margin-top: -4px; }
  .case-topbar { position: static; }
  .case-actions { width: 100%; }
  .case-actions .btn { flex: 1 1 auto; }
  .progress-card { padding: 16px 18px; }
  .section-head { margin-bottom: 10px; }
}

@media (max-width: 420px) {
  .brand-title { font-size: 14.5px; }
  .tab { padding: 6px 9px; font-size: 11.5px; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .no-print, .topbar, .foot, .toast, .case-actions, .case-topbar .btn, .schedule-head .field { display: none !important; }
  .wrap { width: 100%; }
  main { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .case-fields input { border: 0; padding: 0; }
  .check { break-inside: avoid; }
  .check .box { border-color: #777; }
  .check input:checked + .box { background: #333; border-color: #333; }
  .alert { break-inside: avoid; }
  .tl-item { break-inside: avoid; }
  .section-card { padding: 12px; }
  .case-head { padding: 0 0 10px; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
