/* ==========================================================================
   タスクボード — 業務指示書（伝票）を下敷きにした画面設計
   ・色だけに頼らない：状態は必ず文字ラベルを持ち、色は補助
   ・赤は「期限超過」だけに使う（判子の赤）
   ========================================================================== */

:root {
  --paper: #f5f4f0;
  --card: #ffffff;
  --ink: #232a33;
  --ink-2: #5f6b7a;
  --ink-3: #8b94a0;
  --rule: #dad8d2;
  --rule-strong: #b9b6ae;

  --stamp: #b8352c;   /* 期限超過のみ */
  --go: #1d6b4f;      /* 完了 */
  --wait: #8a6a16;    /* 確認待ち */
  --free: #2f5d8c;    /* フリータスク */

  --slip: #f0eee7;    /* 伝票地 */
  --focus: #2f5d8c;

  --w: 1180px;
  --r: 3px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium",
    "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

a { color: var(--focus); }
a:focus-visible, button:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------------- ヘッダ */

.topbar {
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--rule-strong);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  flex-wrap: wrap;
}
.topbar .btn { padding: 6px 11px; font-size: 13.5px; min-height: 34px; }
.topbar .storepick { gap: 6px; }
.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.whoami { font-size: 14px; color: #d7dbe1; white-space: nowrap; }
.whoami b { color: #fff; font-weight: 700; }

.storepick { display: flex; align-items: center; gap: 8px; }
.storepick select {
  font-size: 15px;
  padding: 7px 10px;
  border-radius: var(--r);
  border: 1px solid #55606d;
  background: #2f3945;
  color: #fff;
  min-height: 38px;
}

.nav {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
.nav .wrap { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  padding: 13px 13px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 4px solid transparent;
}
.nav a:hover { color: var(--ink); background: var(--slip); }
.nav a.on { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------------------------------------------------------------- 本文 */

main { padding: 26px 0 72px; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: .02em; }
h2 { font-size: 18px; margin: 0; letter-spacing: .02em; }
.lede { margin: 0 0 22px; color: var(--ink-2); font-size: 15px; max-width: 42em; }

.flash, .flash-err {
  padding: 12px 16px;
  border-radius: var(--r);
  margin-bottom: 18px;
  font-size: 15px;
  border: 1px solid var(--rule);
  background: var(--card);
}
.flash { border-left: 6px solid var(--go); }
.flash-err { border-left: 6px solid var(--stamp); }

/* ---------------------------------------------------------------- 次にやること */

.nextup {
  background: var(--card);
  border: 1px solid var(--rule);
  border-top: 5px solid var(--ink);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 30px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.nextup .kicker {
  font-size: 14px;
  color: var(--ink-2);
  margin: 0 0 6px;
}
.nextup .title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 10px;
  max-width: 24em;
}
.nextup .title a { color: var(--ink); text-decoration: none; }
.nextup .title a:hover { text-decoration: underline; }
.nextup .grow { flex: 1 1 380px; }
.nextup .act { display: flex; flex-direction: column; gap: 10px; min-width: 200px; }
.nextup.empty { border-top-color: var(--rule-strong); }
.nextup.empty .title { font-size: 20px; color: var(--ink-2); }

/* ---------------------------------------------------------------- 区分 */

.section { margin-bottom: 34px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--rule-strong);
  margin-bottom: 0;
}
.section-head .count {
  font-size: 15px;
  color: var(--ink-2);
  font-weight: 700;
}
.section-head .note { font-size: 14px; color: var(--ink-3); margin-left: auto; }

/* ---------------------------------------------------------------- タスク行 */

.rows { list-style: none; margin: 0; padding: 0; }

.row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  padding: 15px 18px 15px 14px;
  border-left: 6px solid var(--rule-strong);
}
.row:hover { background: #fbfaf8; }
.row.st-doing { border-left-color: var(--ink); }
.row.st-review { border-left-color: var(--wait); }
.row.st-done { border-left-color: var(--go); }
.row.st-free { border-left-color: var(--free); border-left-style: dashed; }
.row.st-personal { border-left-color: var(--ink-3); border-left-style: dotted; }
.row.overdue { background: #fdf6f5; }

.row .body { flex: 1; min-width: 0; }
.row .name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  margin: 0 0 5px;
}
.row .name a { color: var(--ink); text-decoration: none; }
.row .name a:hover { text-decoration: underline; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 14px;
  color: var(--ink-2);
  margin: 0;
}
.meta b { color: var(--ink); font-weight: 700; }
.meta .sep { color: var(--rule-strong); }

.row .side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- 標識 */

.tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  padding: 2px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  color: var(--ink-2);
  background: var(--slip);
  white-space: nowrap;
}
.tag.status-todo { border-color: var(--rule-strong); color: var(--ink-2); }
.tag.status-doing { border-color: var(--ink); color: var(--ink); background: #fff; border-width: 2px; }
.tag.status-review { border-color: var(--wait); color: var(--wait); background: #fdfaf0; border-width: 2px; }
.tag.status-done { border-color: var(--go); color: var(--go); background: #f2f8f5; }
.tag.type-free { border-color: var(--free); color: var(--free); background: #f2f6fa; border-style: dashed; }
.tag.role { background: #fff; border-color: var(--ink); color: var(--ink); }
.tag.type-personal { border-color: var(--ink-3); color: var(--ink-2); background: #fff; border-style: dotted; }

/* 優先度：色だけでなく丸印の数で示す */
.pri { font-size: 13px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.pri .dots { letter-spacing: 1px; color: var(--ink); }
.pri-high .dots { color: var(--stamp); }

/* 判子：期限超過だけに使う */
.stamp {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--stamp);
  border: 2px solid var(--stamp);
  border-radius: 2px;
  padding: 1px 8px;
  transform: rotate(-3deg);
  white-space: nowrap;
}

.due { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.due.soon { color: var(--stamp); font-weight: 700; }

/* ---------------------------------------------------------------- ボタン */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--r);
  border: 1px solid var(--rule-strong);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--slip); }
.btn-main { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-main:hover { background: #121821; }
.btn-go { background: var(--go); border-color: var(--go); color: #fff; }
.btn-go:hover { background: #175540; }
.btn-warn { border-color: var(--stamp); color: var(--stamp); border-width: 2px; }
.btn-warn:hover { background: #fdf3f2; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- 伝票（詳細） */

.slip {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  margin-bottom: 24px;
}
.slip-head {
  padding: 20px 24px 16px;
  border-bottom: 2px solid var(--rule-strong);
}
.slip-head .name { font-size: 24px; font-weight: 700; line-height: 1.45; margin: 8px 0 0; max-width: 26em; }
.slip-body { padding: 20px 24px; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
}
.fact {
  background: var(--card);
  padding: 12px 14px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.fact .k { font-size: 13px; color: var(--ink-3); margin: 0 0 2px; }
.fact .v { font-size: 16px; font-weight: 700; margin: 0; }

.block { margin-top: 24px; }
.block h3 {
  font-size: 15px;
  margin: 0 0 8px;
  color: var(--ink-2);
  border-left: 4px solid var(--rule-strong);
  padding-left: 9px;
}
.block .text {
  white-space: pre-wrap;
  background: var(--slip);
  border-radius: var(--r);
  padding: 14px 16px;
  max-width: 44em;
  font-size: 15.5px;
}
.block .text.empty { color: var(--ink-3); }

.actions {
  background: var(--slip);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 24px;
}
.actions h3 { margin: 0 0 12px; font-size: 15px; color: var(--ink-2); }

/* ---------------------------------------------------------------- 履歴 */

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule); }
.timeline li { position: relative; padding: 0 0 16px 20px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 9px;
  width: 10px;
  height: 10px;
  background: var(--card);
  border: 2px solid var(--rule-strong);
  border-radius: 50%;
}
.timeline li.reject::before { border-color: var(--stamp); background: var(--stamp); }
.timeline li.approve::before { border-color: var(--go); background: var(--go); }
.timeline .when { font-size: 13px; color: var(--ink-3); }
.timeline .what { font-size: 15px; }
.timeline .what b { font-weight: 700; }
.timeline .cmt {
  margin: 6px 0 0;
  padding: 9px 12px;
  background: var(--slip);
  border-radius: var(--r);
  font-size: 14.5px;
  white-space: pre-wrap;
  max-width: 40em;
}

/* ---------------------------------------------------------------- 表 */

.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); }
table.grid { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.grid th, table.grid td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.grid thead th {
  background: var(--slip);
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 2px solid var(--rule-strong);
  position: sticky;
  top: 0;
}
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tbody tr:hover { background: #fbfaf8; }
table.grid .who { font-weight: 700; }
table.grid .muted { color: var(--ink-3); }
table.grid .warn { color: var(--stamp); font-weight: 700; }

/* 比率バー：数字と併記する（色だけに頼らない） */
.bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar .track { display: block; width: 68px; height: 9px; background: var(--rule); border-radius: 5px; overflow: hidden; }
.bar .fill { display: block; height: 100%; min-width: 2px; background: var(--ink); border-radius: 5px; }
.bar .fill.low { background: var(--stamp); }

/* ---------------------------------------------------------------- 入力 */

.form { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 24px; max-width: 840px; }
.field { margin-bottom: 20px; }
.field > label, .field .lbl {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field .hint { font-size: 13px; color: var(--ink-3); margin: 5px 0 0; }
input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  background: #fff;
  color: var(--ink);
  min-height: 44px;
}
textarea { min-height: 96px; line-height: 1.65; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 20px; }

.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choices label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}
.choices input { accent-color: var(--ink); width: 17px; height: 17px; }
.choices label:has(input:checked) { border-color: var(--ink); border-width: 2px; background: var(--slip); }

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f span { font-size: 13px; color: var(--ink-2); font-weight: 700; }
.filters select, .filters input { min-width: 140px; }

.empty-note {
  background: var(--card);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r);
  padding: 22px;
  color: var(--ink-2);
  font-size: 15px;
}

/* ---------------------------------------------------------------- ログイン */

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--rule); border-top: 6px solid var(--ink); border-radius: var(--r); padding: 34px 32px; width: 100%; max-width: 400px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .lede { margin-bottom: 24px; }

/* ---------------------------------------------------------------- 折りたたみ */

details.panel { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 20px; }
details.panel > summary {
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  list-style: none;
}
details.panel > summary::marker, details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸ "; color: var(--ink-3); }
details.panel[open] > summary::before { content: "▾ "; }
details.panel > summary:hover { background: var(--slip); }
details.panel .inner { padding: 4px 18px 20px; border-top: 1px solid var(--rule); }

/* ---------------------------------------------------------------- 応答 */

@media (max-width: 720px) {
  body { font-size: 15px; }
  .row { flex-direction: column; gap: 10px; }
  .row .side { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nextup .act { width: 100%; }
  .facts { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .nav, .actions, .btn, .filters { display: none !important; }
  body { background: #fff; }
}

/* ==========================================================================
   PC通知
   ========================================================================== */

.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid #55606d;
  border-radius: var(--r);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  min-height: 38px;
  white-space: nowrap;
}
.bell:hover { background: #2f3945; }
.bell { font-size: 13.5px; min-height: 34px; }
.bell-badge[hidden] { display: none; }
.bell-badge {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  background: var(--stamp);
  color: #fff;
  border-radius: 11px;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  font-weight: 700;
}

#toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  max-width: 400px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-left: 7px solid var(--ink);
  border-radius: var(--r);
  box-shadow: 0 6px 20px rgba(35, 42, 51, .22);
  padding: 16px 40px 15px 18px;
}
.toast-urgent { border-left-color: var(--stamp); }

.toast-title { margin: 0 0 5px; font-size: 16px; font-weight: 700; line-height: 1.45; }
.toast-urgent .toast-title { color: var(--stamp); }
.toast-body { margin: 0 0 12px; font-size: 14.5px; color: var(--ink-2); line-height: 1.6; }
.toast-row { display: flex; gap: 9px; }

.toast-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r);
}
.toast-x:hover { background: var(--slip); color: var(--ink); }

/* お知らせ一覧 */
.notes { list-style: none; margin: 0; padding: 0; }
.notes li {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  border-left: 6px solid var(--rule-strong);
  padding: 14px 18px;
}
.notes li.unread { border-left-color: var(--ink); background: #fff; }
.notes li.unread.urgent { border-left-color: var(--stamp); }
.notes li.read { opacity: .62; }
.notes .t { font-size: 16px; font-weight: 700; margin: 0 0 3px; }
.notes .b { font-size: 14.5px; color: var(--ink-2); margin: 0 0 4px; }
.notes .m { font-size: 13px; color: var(--ink-3); margin: 0; }

@media (max-width: 720px) {
  .bell-label { display: none; }
  #toast-stack { right: 10px; left: 10px; bottom: 10px; width: auto; max-width: none; }
}

/* ---------------------------------------------------------------- 添付写真 */

.shots { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.shot { margin: 0; max-width: 220px; }
.shot a { display: block; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--slip); }
.shot img { display: block; width: 100%; height: 150px; object-fit: cover; }
.shot figcaption { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }

input[type="file"] {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r);
  background: var(--slip);
  min-height: 44px;
}
