/* 新Genba — 案2 モダン・ミニマル（白基調 / やわらかいティール差し色） */
:root {
  --teal:      #0f9d77;   /* 差し色 */
  --teal-dark: #0b6e54;   /* 文字・濃いめ */
  --teal-soft: #e9f6f0;   /* 薄いティールの面 */
  --teal-line: #bfe3d6;   /* ティールの細線 */
  --navy:      #0b6e54;   /* 旧名を残しティールに統一（地図/ファイル等の既存参照用） */

  --bg:        #f1f5f3;   /* ページ背景（やわらかい） */
  --surface:   #ffffff;
  --line:      #e7ecea;   /* 罫線 */
  --line-soft: #f1f4f2;   /* 薄い区切り線 */

  --text:      #1c2230;
  --text-2:    #5b6477;   /* 補助テキスト */
  --text-3:    #8a93a0;   /* ヒント・薄め */

  --radius:    12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ヘッダー：白地＋下罫線＋ティールのブランド */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { color: var(--teal); text-decoration: none; font-weight: 600; font-size: 18px; letter-spacing: .3px; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--text-2); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--teal); }
.topbar .user { color: var(--text-3); font-size: 13px; }

.container { max-width: 920px; margin: 28px auto; padding: 0 18px; }

/* カード */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.login-card { max-width: 380px; margin: 56px auto; }

h1 { font-size: 21px; font-weight: 600; margin: 0 0 18px; }

label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text-2); }
input[type=text], input[type=password] {
  width: 100%;
  padding: 10px 13px;
  margin-top: 6px;
  border: 1px solid #dfe5e2;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

/* ボタン：主＝ティール塗り */
button, .btn {
  display: inline-block;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--teal-dark); }

.flash {
  max-width: 920px;
  margin: 14px auto 0;
  padding: 0 18px;
  list-style: none;
}
.flash li {
  background: var(--teal-soft);
  border: 1px solid var(--teal-line);
  border-radius: 10px;
  padding: 11px 15px;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--teal-dark);
}

/* テーブル：罫線控えめ・横線だけ */
.tbl { width: 100%; border-collapse: collapse; margin-top: 14px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line-soft); padding: 12px 10px; text-align: left; font-size: 14px; }
.tbl thead th { color: var(--text-3); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.tbl td a { color: var(--teal); text-decoration: none; }
.tbl td a:hover { text-decoration: underline; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot th { border-top: 1px solid var(--line); }

/* カードの見出し行（タイトル＋右にボタン） */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h1 { margin: 0; }

h2.sub { font-size: 16px; font-weight: 600; margin: 26px 0 8px; }
.hint { font-size: 13px; color: var(--text-3); margin: 4px 0 12px; }

textarea {
  width: 100%;
  padding: 10px 13px;
  margin-top: 6px;
  border: 1px solid #dfe5e2;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
select {
  width: 100%;
  padding: 10px 13px;
  margin-top: 6px;
  border: 1px solid #dfe5e2;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
}

/* 状態バッジ：パステルの丸ピル（状態ごとに色分け） */
.badge {
  display: inline-block;
  background: #eef1f0;
  color: var(--text-2);
  border-radius: 999px;
  padding: 3px 13px;
  font-size: 12.5px;
  white-space: nowrap;
}
.badge.b-uketu  { background: #dde7f6; color: #1f3b7a; }
.badge.b-sekou  { background: #fde8cf; color: #8a5a12; }
.badge.b-kanryo { background: #d6efe2; color: #0b6e54; }
.badge.b-seikyu { background: #e7ddf6; color: #5a3b8a; }
.badge.b-paid   { background: #e8eaed; color: #555f6b; }

/* 明細テーブルの入力欄は枠いっぱいに */
.tbl.items input, .tbl.items select { margin-top: 0; padding: 7px 9px; font-size: 14px; }
.unit-cell { text-align: center; color: var(--text-2); font-weight: 600; font-size: 14px; }
.row-del {
  background: #fff; color: #c0392b; border: 1px solid #ead7d4;
  border-radius: 8px; padding: 5px 9px; font-size: 13px; cursor: pointer;
}
.row-del:hover { background: #fceae8; }

/* 操作ボタン群 */
.actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.btn-light {
  display: inline-block;
  background: #fff; color: var(--teal-dark);
  border: 1px solid var(--teal-line);
  border-radius: 10px; padding: 9px 17px; font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn-light:hover { background: var(--teal-soft); }
.btn-sm { padding: 5px 13px; font-size: 13px; }

/* 詳細の項目テーブル */
.kv { border-collapse: collapse; margin-top: 8px; }
.kv th, .kv td { padding: 8px 10px; text-align: left; font-size: 14px; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.kv th { color: var(--text-3); width: 130px; font-weight: 500; }

.head-btns { display: flex; gap: 10px; align-items: center; }
.pick-form { margin-bottom: 8px; max-width: 380px; }

/* フォームの2カラム */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

/* ============================================================
   カレンダー（施工予定）
   ============================================================ */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cal-head h1 { margin: 0; }
.cal-head-right { display: flex; gap: 8px; }

.cal { width: 100%; border-collapse: separate; border-spacing: 5px; table-layout: fixed; }
.cal th { background: transparent; padding: 4px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.cal th.wd-sun { color: #c0392b; }
.cal th.wd-sat { color: #2a5db0; }
.cal-cell { border: 1px solid var(--line); border-radius: 10px; vertical-align: top; height: 92px; padding: 6px; overflow: hidden; background: #fff; }
.cal-out { background: #f7f9f8; }
.cal-out .cal-date { color: #c2c9d2; }
.cal-today { background: var(--teal-soft); border-color: var(--teal-line); }
.cal-date { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }

.cal-ev {
  display: block;
  font-size: 12px;
  padding: 2px 7px;
  margin-bottom: 3px;
  border-radius: 6px;
  background: #e7eefc;
  color: #1f2d52;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-ev:hover { filter: brightness(0.97); }
/* 状態で色分け */
.ev-uketu  { background: #dde7f6; color: #1f3b7a; }
.ev-sekou  { background: #fde8cf; color: #8a5a12; }
.ev-kanryo { background: #d6efe2; color: #0b6e54; }
.ev-seikyu { background: #e7ddf6; color: #5a3b8a; }
.ev-paid   { background: #e8eaed; color: #555f6b; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.cal-legend .cal-ev { display: inline-block; white-space: nowrap; }

/* ============================================================
   請求書シート（見本PDFに寄せる）
   ============================================================ */
:root { --inv-navy: #16284d; --inv-gold: #c98a2b; --inv-red: #d8443a; }

.inv-toolbar { max-width: 800px; margin: 0 auto 12px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.btn-danger {
  background: #fff; color: #c0392b; border: 1px solid #e2b6b1;
  border-radius: 8px; padding: 9px 16px; font-size: 15px; cursor: pointer;
}
.btn-danger:hover { background: #fceae8; }

/* 入金バー（請求書の上・印刷では隠す） */
.inv-paybar {
  max-width: 800px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.pay-done { color: #1c7c3a; font-weight: 700; }
.pay-none { color: #b23; font-weight: 700; }
.pay-form { display: flex; align-items: center; gap: 12px; margin: 0; }
.pay-label { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pay-label input { margin-top: 0; width: auto; }

.invoice-sheet {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 48px 52px;
  color: #233;
  font-size: 14px;
}

/* ヘッダー */
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; }
.inv-logo { display: flex; align-items: center; gap: 8px; }
.inv-logo-text { color: var(--inv-navy); font-weight: 800; line-height: 1.05; font-size: 18px; }
.inv-logo-img { height: 56px; width: auto; display: block; margin-left: -6px; }
.inv-title { font-size: 30px; font-weight: 800; color: var(--inv-navy); margin-top: 28px; letter-spacing: 2px; }
.inv-title-en { font-size: 11px; letter-spacing: 3px; color: var(--inv-gold); border-top: 2px solid var(--inv-gold); display: inline-block; padding-top: 4px; margin-top: 2px; }
.inv-meta { border-collapse: collapse; }
.inv-meta th { text-align: left; color: #667; font-weight: 500; padding: 3px 14px 3px 0; font-size: 13px; }
.inv-meta td { text-align: right; font-weight: 700; color: var(--inv-navy); padding: 3px 0; font-size: 14px; }
.inv-meta td.due { color: var(--inv-red); }

/* 請求先ボックス */
.inv-client { display: flex; gap: 32px; background: #f1f3f7; border-radius: 10px; padding: 14px 22px; margin: 16px 0 12px; }
.inv-client-col { flex: 1; border-left: 3px solid #c9d0de; padding-left: 16px; }
.inv-client-col:first-child { border-left: none; padding-left: 0; }
.inv-label { font-size: 11px; color: #667; font-weight: 700; letter-spacing: .5px; margin-bottom: 10px; }
.inv-client-name { font-size: 20px; font-weight: 800; color: var(--inv-navy); }
.inv-client-name .onchu { font-size: 13px; font-weight: 500; }
.inv-subject { font-size: 18px; font-weight: 700; color: var(--inv-navy); }

.inv-lead { margin: 0 0 8px; font-size: 13px; }

/* 明細 */
.inv-items { width: 100%; border-collapse: collapse; }
.inv-items thead th { font-size: 12px; color: #556; font-weight: 700; border-bottom: 2px solid #d3d9e4; padding: 6px 6px; text-align: left; }
.inv-items thead th.r, .inv-items td.r { text-align: right; }
.inv-items tbody td { padding: 6px 6px; border-bottom: 1px solid #eef0f4; vertical-align: top; font-size: 13px; }
.inv-items td.date { color: #667; }
.inv-items td.content { font-weight: 700; color: #1f2a44; }
.inv-items td.site { color: #445; }
.inv-items td.unit { color: #667; font-weight: 600; white-space: nowrap; padding-right: 18px; }
.inv-items td.amount { font-weight: 800; color: var(--inv-navy); }

/* 合計 */
.inv-totals { margin-top: 14px; margin-left: auto; width: 320px; }
.inv-total-row { display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid #eef0f4; font-size: 14px; }
.inv-total-box { display: flex; justify-content: space-between; align-items: center; background: #fff; color: var(--inv-navy); border: 2px solid var(--inv-navy); border-radius: 8px; padding: 14px 18px; margin-top: 10px; }
.inv-total-label { font-size: 10px; letter-spacing: 1px; opacity: .7; line-height: 1.5; }
.inv-total-label .jp { font-size: 14px; font-weight: 700; opacity: 1; }
.inv-total-amount { font-size: 26px; font-weight: 800; color: var(--inv-navy); }

.inv-note { margin-top: 18px; font-size: 13px; white-space: pre-wrap; color: #445; }

/* 備考の囲い（見出し付き・フッター左下に配置） */
.inv-remark { border: 1px solid #e3e7ee; border-radius: 10px; padding: 12px 16px; width: 340px; }
.inv-remark-head { font-size: 12px; font-weight: 700; color: var(--inv-navy); letter-spacing: .5px; margin-bottom: 6px; }
.inv-remark-body { font-size: 13px; color: #445; white-space: pre-wrap; line-height: 1.6; }

/* フッター */
.inv-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 24px; gap: 24px; }
.inv-bank { border: 1px solid #e3e7ee; border-radius: 10px; padding: 12px 16px; width: 320px; }
.inv-bank-head { font-weight: 700; color: var(--inv-navy); margin-bottom: 10px; font-size: 14px; }
.inv-bank table { width: 100%; border-collapse: collapse; }
.inv-bank th { text-align: left; color: #889; font-weight: 500; font-size: 12px; padding: 3px 0; }
.inv-bank td { text-align: right; font-weight: 700; font-size: 13px; padding: 3px 0; }
.inv-fee { font-size: 11px; color: #889; margin: 10px 0 0; }
.inv-from { text-align: right; }
.inv-from-name { font-size: 18px; font-weight: 800; color: var(--inv-navy); }
.inv-from-person { font-size: 14px; font-weight: 700; color: var(--inv-navy); margin-bottom: 8px; }
.inv-from-line { font-size: 12px; color: #556; }

/* 印刷時：画面の余計なものを隠してシートだけ出す */
@page { size: A4; margin: 14mm; }

@media print {
  .topbar, .flash, .inv-toolbar, .inv-paybar { display: none !important; }
  html, body { background: #fff; }
  .container { margin: 0; max-width: none; padding: 0; }
  .invoice-sheet { border: none; border-radius: 0; max-width: none; padding: 0; }

  /* 背景色・色を印刷でもそのまま出す（紺の合計ボックス・グレーの請求先・金のライン） */
  body, .invoice-sheet, .invoice-sheet * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 変な所で改ページしない */
  .inv-head, .inv-client, .inv-totals, .inv-foot { break-inside: avoid; }
  .inv-items tr { break-inside: avoid; }
}

/* ============================================================
   スマホ対応（幅600px以下のときだけ効く・PC表示とPDF/印刷には影響しない）
   ============================================================ */
@media (max-width: 600px) {
  /* ナビ：折り返して全部見えるように */
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar nav { width: 100%; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
  .topbar nav a { margin-left: 0; font-size: 14px; }
  .topbar .user { margin-left: 0; width: 100%; font-size: 13px; }

  /* 全体の余白を少し詰める */
  .container { margin: 14px auto; padding: 0 12px; }
  .card { padding: 16px; }
  .flash { padding: 0 12px; }

  /* 一覧・明細の表は横スクロールで全列見られるように */
  .tbl { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* 見出し行・操作ボタンは折り返す */
  .card-head, .actions, .head-btns, .cal-head { flex-wrap: wrap; }

  /* 請求書/見積書 view：スマホ幅に収める（PDFはA4幅なので影響なし） */
  .inv-toolbar, .inv-paybar { flex-wrap: wrap; justify-content: flex-start; }
  .invoice-sheet { padding: 20px 16px; font-size: 13px; }
  .inv-head { flex-direction: column; gap: 14px; }
  .inv-title { margin-top: 10px; }
  .inv-client { flex-direction: column; gap: 14px; }
  .inv-client-col { border-left: none; padding-left: 0; }
  .inv-items { display: block; overflow-x: auto; white-space: nowrap; }
  .inv-totals { width: 100%; }
  .inv-foot { flex-direction: column; align-items: stretch; gap: 18px; }
  .inv-bank, .inv-remark { width: 100%; }
  .inv-from { text-align: left; }

  /* カレンダー：マスと文字を少し小さく */
  .cal th { padding: 4px 2px; font-size: 12px; }
  .cal-cell { height: 64px; padding: 4px; }
  .cal-date { font-size: 11px; }
  .cal-ev { font-size: 11px; padding: 1px 5px; }
  .av-chip { font-size: 10px; padding: 0 4px; }
}

/* ============================================================
   勤務可能日（カレンダーに重ねる）
   ============================================================ */
.cal-edit-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 12px; }
.cal-edit-label { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.cal-edit-label select { width: auto; margin-top: 0; padding: 6px 10px; }
.cal-edit-hint { font-size: 13px; color: #1c7c3a; font-weight: 600; }

.av-chips { margin-top: 3px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.av-chip {
  display: inline-block;
  font-size: 11px; line-height: 1.5;
  padding: 0 6px; border-radius: 999px;
  background: #dcf2e0; color: #1c6b33; white-space: nowrap;
}
.av-chip.av-chip-off { background: #fbe1de; color: #a3352d; }
.av-note { font-size: 10px; color: #5b6477; line-height: 1.3; word-break: break-word; }

/* 勤務可能日のタップ入力パネル */
.av-editor { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.av-editor[hidden] { display: none; }
.av-editor-box { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.av-editor-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.av-editor-btns { display: flex; gap: 8px; margin-bottom: 14px; }
.av-pick { flex: 1; background: #fff; border: 1px solid #dfe5e2; border-radius: 10px; padding: 10px 0; font-size: 14px; color: var(--text-2); cursor: pointer; }
.av-pick:hover { background: #f1f5f3; }
.av-pick[data-v="work"].on { background: var(--teal); border-color: var(--teal); color: #fff; }
.av-pick[data-v="off"].on { background: #d8443a; border-color: #d8443a; color: #fff; }
.av-pick[data-v="clear"].on { background: #6b7280; border-color: #6b7280; color: #fff; }
.av-editor-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 16px; }
.av-editor-label input { width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid #dfe5e2; border-radius: 10px; font-size: 14px; }
.av-editor-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 編集モード：日をタップできることを示す */
.cal.cal-editing .cal-cell[data-editable] { cursor: pointer; }
.cal.cal-editing .cal-cell[data-editable]:hover { background: #eefbf0; }
.cal-cell.av-sel { box-shadow: inset 0 0 0 2px #1c7c3a; }
.cal-cell.av-busy { opacity: .55; }

/* 地図リンク（住所→Googleマップ） */
.map-link { color: var(--teal-dark); text-decoration: none; font-size: 13px; margin-left: 8px; white-space: nowrap; }
.map-link:hover { text-decoration: underline; }

/* ユーザー管理の操作ボタン群 */
.user-ops { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* 外注共有リンクのURL欄 */
.share-row { display: flex; gap: 8px; align-items: center; }
.share-row .btn { white-space: nowrap; }
.share-url { flex: 1; min-width: 0; font-size: 13px; font-family: ui-monospace, monospace; background: #f7f8fb; }

/* 完了処理のチェック項目 */
.chk { display: flex; align-items: center; gap: 12px; font-size: 16px; margin-bottom: 16px; cursor: pointer; }
.chk input { width: 20px; height: 20px; margin: 0; flex: none; }

/* 写真・ファイル添付 */
.file-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.file-item { position: relative; width: 120px; }
.file-item img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.file-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 120px; height: 120px; border-radius: 8px; border: 1px solid var(--line); background: #f7f8fb; text-decoration: none; color: var(--teal-dark); padding: 8px; gap: 6px; }
.file-doc-ic { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #889; }
.file-doc-name { font-size: 11px; text-align: center; word-break: break-all; max-height: 48px; overflow: hidden; }
.file-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; }
.file-del:hover { background: rgba(0,0,0,.75); }
.file-up { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
