/* 社内スケジュール・設備予約 */
/* 配色は --main / --dark の2つだけを差し替える。
   文字色と背景は固定なので、どの配色を選んでも読みやすさは変わらない。 */
:root {
  --main: #2563eb;
  --dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sun: #fef2f2;
  --sat: #eff6ff;
  --today: #fffbeb;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------- ヘッダー ---------------- */
header {
  background: var(--main);
  color: #fff;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.hrow { display: flex; align-items: center; gap: 12px; min-height: 52px; flex-wrap: wrap; }
.htitle { font-size: 17px; font-weight: 600; margin-right: auto; }
.hme { font-size: 13px; opacity: .95; }
header button {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
header button:hover { background: rgba(255, 255, 255, .3); }

nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
nav a {
  color: #fff;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 6px 6px 0 0;
  font-size: 14px;
  white-space: nowrap;
  opacity: .82;
}
nav a.on { background: var(--bg); color: var(--dark); font-weight: 600; opacity: 1; }
nav a:hover:not(.on) { background: rgba(255, 255, 255, .16); opacity: 1; }

/* ---------------- 本体 ---------------- */
main { padding: 14px; max-width: 1600px; margin: 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.spread { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread .grow { margin-right: auto; }

/* ---------------- 部品 ---------------- */
button, .btn {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
/* <a class="btn"> をボタンと同じ見た目にする（下線と青文字を消す） */
.btn { display: inline-block; text-decoration: none; color: var(--text); }
button:hover, .btn:hover { background: #f8fafc; }
button.primary {
  background: var(--main);
  border-color: var(--main);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--dark); border-color: var(--dark); }
button.danger { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
button.danger:hover { background: #fee2e2; }
button.small, .btn.small { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--main); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }
label.ck { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
label.ck input { margin: 0; }

.field { margin-bottom: 10px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.row2 { display: flex; gap: 10px; flex-wrap: wrap; }
.row2 > * { flex: 1 1 160px; }

.msg { padding: 9px 12px; border-radius: 6px; margin-bottom: 10px; font-size: 13px; }
.msg.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

/* ---------------- 表 ---------------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* ---------------- 週表示 ---------------- */
.weekwrap { overflow-x: auto; }
table.week { table-layout: fixed; min-width: 900px; }
table.week th.who, table.week td.who {
  width: 130px;
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.week td.who { font-weight: 600; }
table.week td.who .dep { display: block; font-weight: normal; font-size: 11px; color: var(--muted); }

/* 設備の週表示は名前が長い（「ノートPC Sueface kt-m01」など）。
   幅を広げ、入りきらないときは折り返して全部見せる */
table.week.facweek th.who, table.week.facweek td.who {
  width: 210px;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
  line-height: 1.35;
}
table.week th.d { width: auto; text-align: center; }
table.week th.d small { display: block; font-weight: normal; color: var(--muted); }
table.week th.sun, table.week td.sun { background: var(--sun); }
table.week th.sat, table.week td.sat { background: var(--sat); }
table.week th.today, table.week td.today { background: var(--today); }
table.week td { height: 46px; cursor: pointer; }
table.week td:hover { outline: 2px solid var(--main); outline-offset: -2px; }
/* 他人の行は空きマスから登録できないので、押せる見た目にしない */
table.week td.noadd { cursor: default; }
table.week td.noadd:hover { outline: none; }
tr.deprow td {
  background: #eef2f7;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 8px;
}
/* 部署の帯。部署名のとなりに外部予定表のボタンを置く */
tr.deprow .dname { margin-right: 10px; color: var(--text); }
tr.deprow .deptlink {
  font-weight: normal;
  padding: 1px 8px;
  font-size: 12px;
  margin-right: 6px;
  vertical-align: 1px;
}
a.btn.deptlink { color: var(--dark); border-color: var(--main); }

/* 外部予定表のリンクを並べる画面 */
.linkrow { gap: 6px; }
.linkrow .handle {
  width: 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  flex: 0 0 auto;
}

.ev {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  border-left: 3px solid #94a3b8;
  background: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev .t { color: var(--muted); font-size: 11px; margin-right: 3px; }
.ev .fac { color: var(--muted); font-size: 11px; }
.ev.k-work { border-left-color: #64748b; background: #f1f5f9; }
.ev.k-visit { border-left-color: #ea580c; background: #fff7ed; }
.ev.k-meeting { border-left-color: #2563eb; background: #eff6ff; }
.ev.k-training { border-left-color: #16a34a; background: #f0fdf4; }
.ev.k-other { border-left-color: #7c3aed; background: #f5f3ff; }
.ev.masked { color: var(--muted); font-style: italic; }
/* 人から共有された予定。自分で入れたものと見分けられるように点線にする */
.ev.shared { border-left-style: dashed; }
.ev .sh {
  display: inline-block;
  font-size: 10px;
  background: var(--main);
  color: #fff;
  border-radius: 3px;
  padding: 0 3px;
  margin-right: 3px;
  vertical-align: 1px;
}

/* 自分の行は少し目立たせる */
table.week tr.merow td.who { background: #fffbeb; }

/* 案件の納期の印。予定と見分けられるよう赤系にする */
.ev.due {
  border-left-color: #dc2626;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 600;
}
.ev.due .t { color: #dc2626; }

/* 部署ごとの書き込み欄（他現場予定・連絡欄。誰でも書ける） */
table.week tr.noterow td { height: auto; vertical-align: top; }
table.week tr.noterow td.who { color: var(--muted); }
/* 他現場予定の行は、連絡欄と見分けられるよう少し色を変える */
table.week tr.siterow td.who { background: #f1f5f9; }
.note {
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 2px;
}
.noteempty { color: #cbd5e1; font-size: 12px; text-align: center; }
tr.noterow td:hover .noteempty { color: var(--main); }
textarea.noteedit {
  width: 100%;
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--main);
  border-radius: 3px;
  resize: vertical;
}

/* 設備の並び替え（▲▼ と 番号の直接入力） */
td.movecell { white-space: nowrap; text-align: center; }
td.movecell button { padding: 1px 6px; line-height: 1.2; }
td.movecell input { display: block; margin-top: 2px; font-size: 12px; padding: 2px 4px; }

/* 直したところが分かるように、保存前の行を色付けする */
tr.dirty > td { background: #fffbeb; }
tr.dirty > td:first-child { box-shadow: inset 3px 0 0 var(--main); }

/* 状態の印 */
.chip.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.chip.ng { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* 管理画面の中の切り替え */
.subnav { gap: 6px; padding: 8px 10px; }
.subnav button { min-width: 110px; }

/* 案件の一覧。行ごと押せる */
tr.clickrow { cursor: pointer; }
tr.clickrow:hover > td { background: #f8fbff; }
.chip.done { background: #f1f5f9; color: #94a3b8; }

/* 進捗のバー */
.bar {
  height: 7px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}
.barfill { height: 100%; background: var(--main); border-radius: 4px; }
label.lbl { display: block; font-size: 12px; color: var(--muted); }

/* 案件のカレンダー（予定ではなく、ただのメモ帳） */
table.month.prjcal td { height: 96px; }
.pnote { margin-top: 2px; }
.pnote .note { white-space: pre-wrap; font-size: 12px; }
.pnote .noteempty { text-align: left; }
/* 納期の日 */
table.month td.duecell { box-shadow: inset 0 0 0 2px #dc2626; }
.duetag {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
}

/* ---------------- 月表示 ---------------- */
table.month { table-layout: fixed; }
table.month th { text-align: center; width: 14.28%; }
table.month td { height: 88px; cursor: pointer; }
table.month td:hover { outline: 2px solid var(--main); outline-offset: -2px; }
table.month td.sun { background: var(--sun); }
table.month td.sat { background: var(--sat); }
table.month td.today { background: var(--today); }
table.month td.blank { background: #f8fafc; cursor: default; }
table.month td.blank:hover { outline: none; }
table.month td.noadd { cursor: default; }
table.month td.noadd:hover { outline: none; }
.dnum { font-size: 12px; font-weight: 600; color: var(--muted); }


/* ---------------- 予定フォームの設備選び（50件近くあるので絞り込む） ---------------- */
.faclist {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fcfdff;
}
.faccat {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin: 6px 0 3px;
}
.faccat:first-child { margin-top: 0; }
label.facpick {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 1px 14px 1px 0;
  font-size: 13px;
  white-space: nowrap;
}
label.facpick small.facspec { color: var(--muted); font-size: 11px; }

/* ---------------- 画面いっぱいの覆い（入力欄） ---------------- */
.back {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.modal h2 { margin-top: 0; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal .foot .grow { margin-right: auto; }

/* ---------------- 配色の見本 ---------------- */
.themes { display: flex; gap: 8px; flex-wrap: wrap; }
.themes label {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px 4px 6px;
  cursor: pointer;
  font-size: 13px;
}
.themes label.on { border-color: var(--main); background: #f8fafc; font-weight: 600; }
.themes .dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.themes input { display: none; }

/* ---------------- ログイン画面 ---------------- */
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #1e3a8a, #2563eb 60%, #0d9488);
  padding: 16px;
}
.loginbox {
  background: #fff;
  border-radius: 12px;
  padding: 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.loginbox h1 { font-size: 19px; margin: 0 0 4px; }
.loginbox .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.loginbox input { width: 100%; padding: 9px 11px; font-size: 15px; }
.loginbox button { width: 100%; margin-top: 12px; padding: 10px; font-size: 15px; }

/* ---------------- 印刷 ---------------- */
@media print {
  header, nav, .noprint, button { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
  table.week { min-width: 0; font-size: 10px; }
}

/* ---------------- 画面が狭いとき ---------------- */
@media (max-width: 700px) {
  main { padding: 8px; }
  .card { padding: 10px; }
  .htitle { font-size: 15px; }
  table.month td { height: 60px; }
}
