/* takara. 画面の見た目（土台は tawara. の写し）。
   PC では1行1件の表、スマホでは1件ずつ縦に並ぶ。色は深い緑。
   状況は丸の色で見分ける：未提出＝赤紫、提出済み＝青、修正＝橙、約定＝緑、失注＝灰 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #1a1d21; --sub: #5b636d; --line: #d9dde3; --bg: #eef2ef; --paper: #fff;
  --accent: #1b5e20; --accent-soft: #e8f5e9;
  --ng: #c2185b; --fix: #d97706; --ok: #1b7a3d; --sent: #2563a8; --lost: #8a929b;
}

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px; line-height: 1.5;
}
a { color: var(--accent); }

/* ---------- ヘッダー ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--accent); color: #fff;
}
.appbar h1 { font-size: 18px; margin: 0; font-weight: 700; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.appbar .spacer { flex: 1; }
.appbar .who { font-size: 13px; flex-shrink: 0; white-space: nowrap; }
/* スマホでは会社名を短く切り、名前は「自分」のタブへ回して、ログアウトを必ず見せる */
@media (max-width: 720px) {
  .appbar { gap: 8px; padding: 10px 12px; }
  .appbar h1 { font-size: 15px; flex: 1; }
  .appbar .spacer { display: none; }
  .appbar .who #me { display: none; }
}
.appbar a { color: #fff; text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 14px 40px; }

/* ---------- 入力・ボタン ---------- */
label { font-size: 12px; color: var(--sub); display: block; margin-bottom: 3px; }
input[type=text], input[type=email], input[type=date], input[type=password], select {
  width: 100%; height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px;
  background: #fff; font: inherit; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink);
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--ng); border-color: #e6a5c0; }
.btn:active { transform: translateY(1px); }
.hint { font-size: 12px; color: var(--sub); margin: 8px 0 0; }

/* ---------- 上の操作 ---------- */
.tools { display: grid; grid-template-columns: auto 1fr 170px 190px auto; gap: 10px; align-items: end; margin-bottom: 12px; }
.tools .mt-done { padding-bottom: 9px; white-space: nowrap; }
.tools .mt-done .chk-row { margin: 0; font-size: 14px; }
.tools > div { min-width: 0; }

/* ---------- 一覧 ---------- */
.mt-list { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.mt-head, .mt-row { display: grid; grid-template-columns: 130px 1.4fr 1fr 130px 170px 130px; align-items: center; gap: 8px; padding: 0 14px; }
.mt-head { min-height: 36px; background: #f1f5f2; font-size: 12px; color: var(--sub); border-bottom: 1px solid var(--line); }
.mt-row { min-height: 54px; border-top: 1px solid var(--line); }
.mt-head + div > .mt-row:first-child { border-top: 0; }
.mt-site { font-weight: 700; }
.mt-meta { display: none; }
.mt-lamp { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0 4px 0 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; max-width: 100%; }
.mt-lamp select { width: auto; height: auto; border: none; background: transparent; font-weight: 700; font-size: 15px; padding: 8px 2px; }
.mt-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: #aab1ba; }
.mt-pending { background: var(--ng); }
.mt-revise { background: var(--fix); }
.mt-agreed { background: var(--ok); }
.mt-submitted { background: var(--sent); }
.mt-lost { background: var(--lost); }
.mt-memo { display: block; font-weight: 400; font-size: 13px; color: var(--sub); overflow-wrap: anywhere; }
.mt-row.done .mt-site, .mt-row.done .mt-cust, .mt-row.done .mt-who, .mt-row.done .mt-dl { color: var(--sub); }
.mt-dl { white-space: nowrap; }
.mt-over { color: var(--ng); font-weight: 700; font-size: 13px; margin-left: 6px; }
.mt-soon { color: var(--fix); font-weight: 700; font-size: 13px; margin-left: 6px; }
.mt-none { color: var(--sub); }
.mt-ops { white-space: nowrap; text-align: right; }
.mt-ops .btn { height: 36px; padding: 0 12px; font-size: 14px; }
.mt-empty { color: var(--sub); text-align: center; padding: 22px 8px; }

@media (max-width: 720px) {
  .wrap { padding: 10px 10px 40px; }
  .tools { grid-template-columns: 1fr 1fr; }
  .tools .mt-add, .tools .mt-q, .tools .mt-done { grid-column: 1 / -1; }
  .tools .mt-done { padding-bottom: 0; }
  .tools .btn.primary { width: 100%; }
  .mt-head { display: none; }
  .mt-row { grid-template-columns: 1fr auto; grid-template-areas: "site st" "meta st" "due ops"; gap: 2px 10px; padding: 12px 14px; }
  .mt-row:first-child { border-top: 0; }
  .mt-site { grid-area: site; font-size: 17px; }
  .mt-cust, .mt-who { display: none; }
  .mt-meta { display: block; grid-area: meta; font-size: 13px; color: var(--sub); }
  .mt-dl { grid-area: due; font-size: 14px; align-self: center; }
  .mt-st { grid-area: st; align-self: start; }
  .mt-ops { grid-area: ops; margin-top: 6px; }
}

/* ---------- タブ（一覧／変更の記録） ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 10px 18px; text-decoration: none; color: var(--sub); font-weight: 700; border-radius: 4px 4px 0 0; }
.tabs a.on { background: #fff; color: var(--accent); border: 2px solid var(--line); border-bottom: 2px solid #fff; margin-bottom: -2px; }

/* ---------- 変更の記録 ---------- */
.mt-hist-head, .mt-hist-row { display: grid; grid-template-columns: 130px 130px 110px 1fr; gap: 8px; padding: 8px 14px; font-size: 14px; }
.mt-hist-head { min-height: 36px; align-items: center; background: #f1f5f2; font-size: 12px; color: var(--sub); border-bottom: 1px solid var(--line); }
.mt-hist-row { border-bottom: 1px solid #edf0ee; }
.mt-hist-row:last-child { border-bottom: 0; }
.mt-hist-at { color: var(--sub); white-space: nowrap; }
.mt-hist-by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-hist-act { font-weight: 700; white-space: nowrap; }
.mt-hist-detail { color: var(--sub); }
@media (max-width: 720px) {
  .mt-hist-head { display: none; }
  .mt-hist-row { grid-template-columns: 1fr 1fr; gap: 2px 8px; }
  .mt-hist-detail { grid-column: 1 / -1; }
}

/* ---------- 設定（管理者） ---------- */
.set-card { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 14px; margin-bottom: 14px; }
.set-card h3 { margin: 0 0 6px; font-size: 16px; }
.set-row { display: grid; grid-template-columns: 200px 200px 1fr; gap: 10px; align-items: end; }
.set-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.set-head, .set-line { display: grid; grid-template-columns: 110px 1fr 130px 90px 170px; gap: 8px; align-items: center; padding: 8px 12px; font-size: 14px; }
.set-head.user, .set-line.user { grid-template-columns: 150px 1fr 80px 120px 230px; }
.set-head.pc, .set-line.pc { grid-template-columns: 1fr 120px 110px 140px 80px 80px; }
.set-head { background: #f1f5f2; font-size: 12px; color: var(--sub); border-bottom: 1px solid var(--line); }
.set-line { border-bottom: 1px solid #edf0ee; }
.set-line:last-child { border-bottom: 0; }
.set-line .btn { height: 34px; padding: 0 10px; font-size: 13px; }
.set-name { font-weight: 700; }
.set-mail { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-state.on { color: var(--ok); font-weight: 700; }
.set-state.wait { color: var(--fix); font-weight: 700; }
.set-state.off { color: var(--sub); }
.invite-out { margin-top: 12px; padding: 12px; border: 1px solid #b7d1c1; background: var(--accent-soft); border-radius: 4px; display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: start; }
.invite-qr { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 6px; }
.invite-qr img { display: block; width: 100%; height: auto; }
.invite-body { min-width: 0; }
@media (max-width: 720px) {
  .invite-out { grid-template-columns: 1fr; }
  .invite-qr { width: 200px; margin: 0 auto; }
}
.invite-url { display: flex; gap: 8px; margin-top: 6px; }
.invite-url input { flex: 1; font-family: Consolas, monospace; font-size: 13px; }
@media (max-width: 720px) {
  .set-row { grid-template-columns: 1fr 1fr; }
  .set-row .set-btns { grid-column: 1 / -1; }
  .set-head { display: none; }
  .set-line, .set-line.user, .set-line.pc { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .set-line .mt-ops { grid-column: 1 / -1; text-align: left; }
}

.login-links { margin: 14px 0 0; font-size: 14px; text-align: center; }
.mt-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.mt-foot .hint { margin: 0; }
.mt-foot .btn { height: 36px; padding: 0 12px; font-size: 14px; }
.legal-links { max-width: 1100px; margin: 0 auto; padding: 0 14px 30px; font-size: 12px; color: var(--sub); text-align: center; }
.legal-links a { color: var(--sub); }
@media (max-width: 720px) {
  #p-me .set-row { grid-template-columns: 1fr; }
  #p-me .set-row > div { grid-column: auto !important; }
}
.agree { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 14px; color: var(--ink); }
.agree input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); flex-shrink: 0; }

/* ---------- 追加・変更の箱 ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,32,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: #fff; border-radius: 4px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .row { margin-bottom: 12px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }
.modal .actions .spacer { flex: 1; }
.error { margin-top: 10px; padding: 10px 12px; border-radius: 4px; background: #fde8ee; color: var(--ng); font-size: 14px; }

/* ---------- ログイン ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 26px 24px; }
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-box .lead { margin: 0 0 18px; font-size: 13px; color: var(--sub); }
.login-box .btn { width: 100%; margin-top: 18px; }

.chk-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.chk-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- 知らせ ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 10px 20px; border-radius: 4px; z-index: 200; font-weight: 700; }
