@charset "UTF-8";

/*
  現場台帳 — 社内3名用の業務ツール。
  一覧のスキャン性を最優先にして、装飾は住所未入力のマーカーだけに寄せている。
  ビルド工程も外部CDNも使わないので、社内LANだけで完結する。
*/

:root {
  --ink: #22282b;
  --ink-soft: #5d6a6d;
  --bg: #eceee9;
  --surface: #ffffff;
  --line: #d2d6cf;
  --line-strong: #b4bbb2;
  --accent: #0f5257;
  --accent-soft: #e2ecec;
  --alert: #8a5000;
  --alert-soft: #fbf1e0;

  --radius: 3px;
  --gap: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, Meiryo,
    "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* 日付や伝票番号は桁を揃えて読ませる */
.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

a {
  color: var(--accent);
}

/* ---- 全体の骨格 ---------------------------------------------------- */

.masthead {
  background: var(--accent);
  color: #fff;
}

/* 内側コンテナ。.shell と同じ max-width で左右を揃える */
.masthead-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 4px 24px;
}

/* 会社ロゴ + システム名。ロゴは白抜きなので濃色の地にそのまま置ける。 */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  text-decoration: none;
  color: #fff;
}

.brand-logo {
  height: 39px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.35);
}

.brand-system {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.masthead-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: stretch;
}

.masthead-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* デスクトップではバーガーを隠して、nav-items を直接横並びで表示。
   モバイルでは nav-toggle を出して checkbox 状態で nav-items を開閉する。 */
.nav-toggle-input { display: none; }
.nav-toggle       { display: none; }

.nav-items {
  display: flex;
  gap: 4px;
  align-items: stretch;
}

/* ナビの下線位置がロゴの高さで動かないよう、ヘッダー全体の高さに合わせて
   リンクを縦いっぱいに引き伸ばし、テキストは中央で受ける */
.nav-items a {
  display: flex;
  align-items: center;
}

.masthead-name {
  font-size: 13px;
  color: #cfe0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 12ch;
}

.masthead-logout {
  font: inherit;
  font-size: 12px;
  color: #cfe0e0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
}

.masthead-logout:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-items a {
  color: #cfe0e0;
  text-decoration: none;
  padding: 0 14px;
  font-size: 13px;
  border-bottom: 3px solid transparent;
}

.nav-items a:hover {
  color: #fff;
}

.nav-items a.is-current {
  color: #fff;
  border-bottom-color: #a8cfcd;
  font-weight: 700;
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--gap) 20px 64px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: var(--gap);
}

/* 過去の panel-narrow は無効化。全ページで .shell 幅に揃える。
   HTMLから class を消す必要はなく、Blade の書き換えを最小に抑える。 */
.panel-narrow {
  max-width: none;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  font-size: 15px;
  margin: 0;
  letter-spacing: 0.02em;
}

.hint {
  color: var(--ink-soft);
  font-size: 12.5px;
  margin: 0;
}

/* ---- 通知 ---------------------------------------------------------- */

.notice {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: var(--gap);
}

.errors {
  background: #fbeeee;
  border-left: 4px solid #9c3030;
  padding: 10px 14px 10px 32px;
  border-radius: var(--radius);
  margin: 0 0 var(--gap);
  color: #7a2727;
}

.errors li {
  margin: 2px 0;
}

/* ---- 検索 ---------------------------------------------------------- */

.search {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.search-wide {
  grid-column: span 2;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span {
  font-size: 12px;
  color: var(--ink-soft);
}

input[type="text"],
input[type="date"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 9px;
  width: 100%;
}

/* select と input の高さを揃える。padding の効き方がタイプ別に違うので
   height を固定し、縦 padding は 0 にして自前で中央寄せする。
   textarea と file は例外 (可変・OS描画)。 */
input[type="text"],
input[type="date"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  height: 34px;
  padding: 0 9px;
  line-height: 1.2;
}

textarea {
  resize: vertical;
  min-height: 68px;
}

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

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.search-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.search-actions .spacer {
  margin-left: auto;
}

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

.btn {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  background: #f2f4f1;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover {
  background: #0c4247;
}

.btn-danger {
  color: #8a2b2b;
  border-color: #d8bcbc;
}

.btn-danger:hover {
  background: #fbeeee;
}

.btn-small {
  padding: 4px 9px;
  font-size: 12px;
}

/* ---- 一覧表 -------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table.ledger {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

table.ledger th,
table.ledger td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

/* 折り返す列 (住所など) は上揃えのまま。行が高くなっても左肩基準で読める */
table.ledger td.wrap {
  vertical-align: top;
}

table.ledger thead th {
  position: sticky;
  top: 0;
  background: #e4e8e2;
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
  z-index: 1;
}

table.ledger tbody tr:hover {
  background: #f5f7f4;
}

table.ledger td.wrap {
  white-space: normal;
  min-width: 200px;
  vertical-align: top;
}

.row-actions {
  text-align: right;
}

/* 住所が入っていない行は左端に印を出す。ここが唯一の強い視覚要素。 */
tr.no-address td:first-child {
  box-shadow: inset 3px 0 0 var(--alert);
}

.tag-missing {
  display: inline-block;
  background: var(--alert-soft);
  color: var(--alert);
  border-radius: var(--radius);
  padding: 1px 7px;
  font-size: 12px;
  white-space: nowrap;
}

.dup {
  color: var(--alert);
  font-size: 12px;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.summary strong {
  font-size: 15px;
}

.summary a {
  font-size: 13px;
}

/* ---- フォーム ------------------------------------------------------ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.staff-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-actions .spacer {
  margin-left: auto;
}

.error-text {
  color: #9c3030;
  font-size: 12px;
}

/* ---- ページ送り ---------------------------------------------------- */

.pager {
  margin-top: 14px;
}

.pager .pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pager .pagination li span,
.pager .pagination li a {
  display: inline-block;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  font-size: 13px;
}

.pager .pagination li.active span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager .pagination li.disabled span {
  color: #a6aea6;
}

/* ---- マスタ画面 ---------------------------------------------------- */

.master-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--gap);
  align-items: start;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input[type="text"] {
  width: auto;
  flex: 1 1 140px;
  min-width: 120px;
}

.inline-form select {
  width: auto;
  flex: 1 1 140px;
}

@media (max-width: 720px) {
  .masthead-inner {
    /* 縦方向にも余白を入れる。バーガー展開時や 3 行折り返し時に
       最下段 (通常はナビ or ユーザー) が濃緑バーの下端に張り付くのを防ぐ */
    padding: 6px 12px 10px;
  }

  /* --- ナビをバーガーに切り替える。
     デスクトップ用の横並び ('.nav-items { display:flex }') を上書きして
     checkbox 状態で開閉するドロップダウンにする。項目は縦積み・44px 以上。 */
  .masthead-nav {
    display: block;
    width: 100%;
    margin-left: 0;
    align-items: initial;
  }

  .nav-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #fff;
    background: rgba(0, 0, 0, 0.18);
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
    min-height: 44px;
  }

  .nav-toggle-icon {
    font-size: 22px;
    line-height: 1;
  }

  .nav-items {
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 4px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: var(--radius);
    padding: 4px 0;
  }

  .nav-toggle-input:checked ~ .nav-items {
    display: flex;
  }

  .nav-items a {
    padding: 12px 16px;
    font-size: 15px;
    min-height: 44px;
    border-bottom: none;
  }

  .nav-items a.is-current {
    background: rgba(255, 255, 255, 0.14);
    border-bottom: none;
  }

  .shell {
    padding: 12px 12px 48px;
  }

  /* パネル自体を薄くしてコンテンツ幅を稼ぐ */
  .panel {
    padding: 14px;
  }

  /* 見出しと説明が横並び固定だと h2 が 30〜40px に潰れ 1 文字ずつ改行するので
     狭い時は縦積みに切り替える */
  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  /* 検索と入力フォームは 1 列固定。auto-fit の minmax(150/220px) は
     狭い画面で「収まらないので溢れる」動きになる */
  .search {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-wide {
    grid-column: span 1;
  }

  /* grid item の min-width: auto (= min-content) が iOS date input の
     内在幅で 200px+ になり列を押し広げるのを防ぐ */
  .field {
    min-width: 0;
  }

  /* 念のため入力の絶対上限を親幅に */
  input, select, textarea {
    max-width: 100%;
  }

  /* iOS Safari の <input type="date"> は width:100% + max-width:100% でも
     内在幅 (「年/月/日」プレースホルダ ≈ 200px) で親コンテナを押し広げる。
     -webkit-appearance を切ると内在サイズが解除されて任意サイズに縮む。
     値表示の疑似要素にも min-width:0 と左寄せを指定して余白を殺す。 */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
  }
  input[type="date"]::-webkit-date-and-time-value,
  input[type="time"]::-webkit-date-and-time-value,
  input[type="datetime-local"]::-webkit-date-and-time-value {
    min-width: 0;
    text-align: left;
  }

  /* master-columns は minmax(340px, 1fr) を持ち、340px 未満のビューポート
     でも 340px を強制して数 px 溢れる。モバイルは 1 列固定に */
  .master-columns {
    grid-template-columns: 1fr;
  }

  /* 顧客・担当者の行を 4 項目 (名前/件数/保存/削除) 横 1 行に収める。
     デフォルトの flex 1 1 140px + min 120px は広すぎて折り返しが起きる */
  .inline-form input[type="text"] {
    flex: 1 1 80px;
    min-width: 60px;
  }
}

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

/* ---- ログイン・パスワード設定 --------------------------------------- */

.auth-body {
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 64px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ロゴは白抜きなので、濃色の帯の上に置く */
.auth-card-head {
  background: var(--accent);
  padding: 26px 24px 22px;
  text-align: center;
}

.auth-logo {
  width: 190px;
  max-width: 100%;
  height: auto;
  display: inline-block;
}

.auth-system {
  margin: 14px 0 0;
  color: #cfe0e0;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.auth-card-body {
  padding: 24px;
}

.auth-card-body .notice,
.auth-card-body .errors {
  margin-bottom: 18px;
}

.auth-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-block {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
}

.auth-link {
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
}

.auth-link:hover {
  color: var(--accent);
}

input[readonly] {
  background: #f2f4f1;
  color: var(--ink-soft);
}

@media (max-width: 720px) {
  .masthead-user {
    padding-left: 0;
    border-left: none;
    margin-left: auto;
  }

  .brand-logo {
    height: 32px;
  }

  /* ---- 現場向けのタップ領域 (施工部が現場からスマホで住所を入れる) --------
     iOS のガイドラインは 44pt、Android Material は 48dp。
     デスクトップの 34px 固定だと現場で誤タップが起きやすい。
     入力欄の font-size を 16px にしないと iOS がフォーカス時に拡大する。 */
  input[type="text"],
  input[type="date"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select {
    height: 44px;
    padding: 0 12px;
    font-size: 16px;
    line-height: 1.2;
  }

  input[type="file"] {
    padding: 11px 12px;
    font-size: 16px;
  }

  textarea {
    min-height: 96px;
    padding: 10px 12px;
    font-size: 16px;
  }

  .btn {
    padding: 11px 18px;
    font-size: 14px;
    min-height: 44px;
  }

  .btn-small {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
  }

  .masthead-logout {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
  }

  /* ボタン内テキストを縦中央に (min-height 指定時) */
  .btn, .btn-small, .masthead-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* チェックボックスも指で押しやすく */
  .check input {
    width: 22px;
    height: 22px;
  }

  .staff-picker {
    gap: 10px 20px;
    padding: 12px;
  }

  /* 一覧の左端インジケータが行内容全体に見えるよう、
     縦位置を先頭固定に (行が高くなっても目立つ) */
  tr.no-address td:first-child {
    box-shadow: inset 4px 0 0 var(--alert);
  }

  /* ---- 表の縦積みカード化 (.stack が付いた表だけ) --------------------
     users・顧客・担当者の表は列数が多く、横スクロールでは氏名列が 1 文字
     しか見えないので、狭い画面では表を諦めて 1 行 1 カードに組み直す。 */
  table.ledger.stack,
  table.ledger.stack thead,
  table.ledger.stack tbody,
  table.ledger.stack tr,
  table.ledger.stack td {
    display: block;
    width: 100%;
  }

  table.ledger.stack thead {
    display: none;
  }

  table.ledger.stack tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 10px 12px;
    margin: 0 0 10px;
  }

  table.ledger.stack td {
    border-bottom: none;
    padding: 4px 0;
    white-space: normal;
    min-width: 0;
  }

  table.ledger.stack td[colspan] {
    padding: 0;
  }

  table.ledger.stack .row-actions {
    text-align: left;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* stack 表のラッパは枠と背景を消してカード同士の境目だけを見せる */
  .table-wrap:has(> table.stack) {
    overflow: visible;
    border: none;
    background: transparent;
  }
}
