/* =====================================================================
   ENDO IoT  UI
   ・左サイドバー（ダーク）＋ 右コンテンツ（ライト）
   ・社内の勤怠管理アプリとトーンを揃えつつ、余白・ボタンを大きめに
   ===================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* グラフ系（app.js が参照。名称は変更しないこと） */
  --molding: #2563eb;   /* 成形機 */
  --crusher: #f59e0b;   /* 破砕機 */
  --qty:     #16a34a;   /* 製造量（稼働時間の棒に重ねる折れ線。単位が[m]で別ものなので機械とは別色） */
  --night:   #0ea5e9;   /* 夜勤（交替の内訳。日勤は機械の色のまま）
                           ★ 薄い橙では日勤との差が分かりにくいという指摘で青系にした（2026-09-04）。
                             --molding(#2563eb) とは別の青にしてある。成形機の棒と紛れないため。 */
  /* ※ 処理枚数の内訳は色を固定で持たない。機械の色を薄めて作る（app.js の tint()）。
     色あい=機械／濃さ=内訳 にすることで、A系とB系が同じ配色にならないようにしている。 */
  --text:  #1f2937;
  --muted: #6b7280;
  --line:  #e5e7eb;
  --panel: #ffffff;
  --panel2:#f9fafb;
  --accent: var(--primary);

  --sidebar-width: 256px;
  /* 本文の最大幅。ワイドモニタで表やカードが横に間延びするのを防ぐ（2026-08-09 追加）。
     広げたいときはここだけ変える。 */
  --content-max: 1400px;
  --radius: 14px;
  /* 影は「境界線＋影」の二重だと古く見えるので、面は影だけで浮かせる（2026-08-09 変更）。
     境界線は transparent で確保しておき、強調したいときだけ色を付ける。 */
  --shadow:    0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 4px 6px -2px rgba(16,24,40,.05), 0 12px 24px -4px rgba(16,24,40,.10);
}

body {
  font-family: "Segoe UI", "Meiryo", "Yu Gothic", system-ui, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ============ レイアウト ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--gray-700); }
.sidebar-header h1 { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.sidebar-header .subtitle { font-size: 12px; color: var(--gray-400); margin-top: 3px; }

/* 選択中の物件 */
.sidebar-project {
  padding: 14px 20px;
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid var(--gray-700);
}
.sidebar-project .lbl { font-size: 10px; color: var(--gray-400); letter-spacing: .08em; }
.sidebar-project .nm  { font-size: 14px; font-weight: 700; margin-top: 2px; line-height: 1.35; }
.sidebar-project .cs  { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

.nav-menu { list-style: none; flex: 1; min-height: 0; overflow-y: auto; padding: 10px 0; }
.nav-menu { scrollbar-width: thin; scrollbar-color: var(--gray-700) transparent; }
.nav-menu::-webkit-scrollbar { width: 6px; }
.nav-menu::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 3px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; font-size: 14px; color: #e5e7eb;
  text-decoration: none; cursor: pointer; transition: background .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--gray-700); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; border-left-color: #93c5fd; }
.nav-item.disabled { opacity: .45; cursor: default; }
.nav-item.disabled:hover { background: transparent; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center;
            width: 22px; flex-shrink: 0; opacity: .92; }
.nav-icon .ico { width: 18px; height: 18px; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-soon { margin-left: auto; font-size: 10px; color: var(--gray-400);
            border: 1px solid var(--gray-600); border-radius: 999px; padding: 1px 7px; }

.nav-sep { padding: 14px 20px 6px; font-size: 10px; letter-spacing: .1em;
           color: var(--gray-500); text-transform: uppercase; }

/* ---- 折りたためるグループ（「管理」）--------------------------------
   毎日は使わない項目を普段は隠す。今いるページがグループ内なら開いて描く。 */
.nav-group .nav-toggle {
  width: 100%; background: transparent; border: none;
  font: inherit; font-size: 14px; text-align: left;
}
.nav-caret { margin-left: auto; display: inline-flex; opacity: .55;
             transition: transform .18s ease; }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-sub { list-style: none; display: none; }
.nav-group.open .nav-sub { display: block; }
.nav-sub .nav-item { padding-left: 40px; font-size: 13.5px; }
.nav-sub .nav-icon { width: 20px; }
.nav-sub .nav-icon .ico { width: 16px; height: 16px; }
/* グループ内に現在のページがあることを、閉じていても分かるようにする */
.nav-group:not(.open):has(.nav-item.active) .nav-toggle { color: #fff; font-weight: 600; }
.nav-group:not(.open):has(.nav-item.active) .nav-caret { opacity: 1; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--gray-700); }
.user-box { display: flex; flex-direction: column; gap: 9px; }

/* 自分自身の操作（パスワード変更）はここに置く。
   「管理」グループに入れると、項目が0件になる④⑤には表示されず到達できなくなるため。 */
.user-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; margin: 0 -8px; border-radius: 8px;
  font-size: 13px; color: var(--gray-300); text-decoration: none;
  transition: background .15s, color .15s;
}
.user-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.user-link.active { background: rgba(255,255,255,.10); color: #fff; font-weight: 600; }
.user-link .ico   { vertical-align: 0; opacity: .9; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.4; }
.role-badge { display: inline-block; font-size: 10px; font-weight: 700;
              padding: 2px 9px; border-radius: 999px; }
.role-badge.master { background: #fbbf24; color: #000; }
.role-badge.staff  { background: #60a5fa; color: #000; }
.role-badge.client { background: #86efac; color: #000; }

.main {
  margin-left: var(--sidebar-width);
  flex: 1; min-width: 0;
  /* 横の余白は画面幅に合わせて 20〜40px。狭い画面で詰まりすぎないようにする */
  padding: 28px clamp(20px, 2.6vw, 40px) 64px;
}
/* 本文はここで幅を制限して中央寄せする。ページ側は今までどおり書けばよい */
.main-inner { max-width: var(--content-max); margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h2 { font-size: 23px; font-weight: 700; color: var(--gray-900); }
.page-head .desc { font-size: 13px; color: var(--gray-500); }
.page-head .spacer { margin-left: auto; }

/* タイトル脇の「?」ボタン（説明の開閉）。gap 14px だと離れすぎるので少し詰める */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-left: -7px; margin-bottom: 2px;
  border: 1px solid var(--gray-300); border-radius: 999px;
  background: #fff; color: var(--gray-500);
  font-size: 14px; font-weight: 700; font-family: inherit; line-height: 1;
  cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.help-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.help-btn.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.help-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
/* hidden が効かない指定に負けないようにする保険 */
[hidden] { display: none !important; }

/* ============ アイコン（_icons.php のインラインSVG）============
   絵文字はOSとフォントで見た目が変わるため使わない。色は currentColor。 */
.ico { display: inline-block; vertical-align: -.22em; flex-shrink: 0; }
.btn .ico, .nav-icon .ico, .stat .ico { vertical-align: 0; }

/* ============ カード ============ */
.card {
  background: #fff; border: 1px solid transparent;
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card h2, .card h3.card-title {
  font-size: 15px; font-weight: 700; color: var(--gray-900); margin-bottom: 14px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border: 1px solid transparent; border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.stat .value { font-size: 29px; font-weight: 700; color: var(--gray-900); margin-top: 5px; line-height: 1.15;
               font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--gray-500); font-weight: 500; }
.stat .sub { font-size: 12px; color: var(--gray-500); margin-top: 5px; }

/* ---- 稼働状況の上部KPI（app.js が生成）------------------------------
   機械の色は JS から `style="--kpi-c: #xxxxxx"` で渡す。
   以前は class="kpi" だけでCSSが無く、素のテキストで表示されていた（2026-08-09 修正）。*/
.stat.kpi {
  position: relative; overflow: hidden;
  padding: 22px 20px 16px;
  display: flex; flex-direction: column;
  transition: box-shadow .16s, transform .16s, border-color .16s;
}
.stat.kpi::before {            /* 上端のアクセント。どの機械かを色で示す */
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--kpi-c, var(--gray-300));
}
.stat.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--gray-300); }

.stat.kpi .label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; font-weight: 700; color: var(--gray-700);
}
.stat.kpi .dot { width: 9px; height: 9px; border-radius: 999px; flex-shrink: 0;
                 background: var(--kpi-c, var(--gray-400)); }
.stat.kpi .tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--gray-500); background: var(--gray-100);
  border-radius: 999px; padding: 2px 9px;
}
.stat.kpi .value {
  font-size: 38px; font-weight: 800; letter-spacing: -.02em;
  color: var(--gray-900); margin-top: 10px; line-height: 1.05;
}
.stat.kpi .value small { font-size: 15px; font-weight: 600; color: var(--gray-400); margin-left: 4px; }
.stat.kpi .sub { font-size: 12px; color: var(--gray-500); margin-top: 7px; }
.stat.kpi .sub .sep::before { content: '・'; margin: 0 5px; color: var(--gray-300); }
/* 2行目に足す数字（累計処理枚数など）は、説明文より少し濃くして拾いやすくする */
.stat.kpi .sub b { color: var(--gray-700); font-weight: 700; }
.stat.kpi .spark { display: block; width: 100%; height: 30px; margin-top: auto; padding-top: 12px; }

/* 対象期間のカードは数値ではないので控えめに */
.stat.kpi.meta { --kpi-c: var(--gray-300); }
.stat.kpi.meta .value { font-size: 21px; font-weight: 700; letter-spacing: 0; }
.stat.kpi.meta .value small { font-size: 14px; margin: 0 6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* ★ 横並びのカードには .card + .card の縦余白を効かせない。
   グリッドの中でこれが付くと、2枚目だけが18px下がったうえに
   その分だけ背が低くなり、左右のカードの大きさが揃わなくなる（2026-08-11 修正）。
   カード間の間隔は .grid2 の gap が持っている。*/
.grid2 > .card { margin-top: 0; margin-bottom: 0; }
.chart-wrap { position: relative; height: 300px; }

/* ============ ボタン（大きめ・押しやすく） ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 10px 20px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .15s, transform .08s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn.secondary:hover { background: var(--gray-50); }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }
.btn.danger  { background: var(--danger); }
.btn.ghost   { background: transparent; color: var(--gray-600); box-shadow: none; }
.btn.ghost:hover { background: var(--gray-100); }
.btn.sm { min-height: 34px; padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn.lg { min-height: 50px; padding: 13px 28px; font-size: 15px; }
.btn.block { width: 100%; }

/* ============ フォーム ============ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 18px; margin-bottom: 18px; }
/* 単独で縦に並べたときに間隔が無いと注記と入力欄が重なるため下余白を持たせる。
   form-grid の中では gap が効くので二重にならないよう打ち消す（2026-08-09 修正）。*/
.field { margin-bottom: 16px; }
/* ★ min-width:0 が要る理由: グリッドの項目は既定で min-width:auto のため、
   中身（input[type=date] のような、ブラウザが横幅を決める部品）が広いと
   その列だけ勝手に広がり、隣の列へはみ出す。0 にして枠に収める。*/
.form-grid > .field { margin-bottom: 0; min-width: 0; }
.field input, .field select, .field textarea { max-width: 100%; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.field input, .field select, select, input[type=text], input[type=password], input[type=date], input[type=number] {
  width: 100%; background: #fff; color: var(--gray-800);
  border: 1px solid var(--gray-300); border-radius: 10px;
  padding: 10px 13px; font-size: 14px; font-family: inherit;
  min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
/* ★ 高さを明示して部品の種類で段差が出ないようにする（2026-08-11 修正）。
   min-height だけだと中身の高さで実寸が決まるため、Chrome では
     入力済みの日付欄 43px ／ 空の日付欄 45px ／ プルダウン 43px
   と揃わず、「実施日・次回予定日」だけ他より大きく見えていた。
   （空の日付欄は yyyy/mm/dd の表示部品のぶん背が高くなる）
   line-height も既定の normal のままだと部品ごとに違うため合わせる。
   ファイル選択欄は中のボタンが入らなくなるので対象外。*/
.field input:not([type=file]), .field select, select,
input[type=text], input[type=password], input[type=date], input[type=number] {
  height: 42px;
  line-height: 1.4;
}
/* ★ iPad / iPhone（iOS Safari）対策（2026-08-16 修正）。
   上の height 指定で PC の Chrome は揃ったが、iOS では日付欄だけ崩れていた。
   iOS の Safari は input[type=date] を「値を入れた箱」ではなく独自の部品として描くため、

     ・値の文字が中央寄せになる（他の欄は左寄せなので並びが揃わない）
     ・中身の大きさで実寸が決まり、指定した height:42px を無視して背が高くなる
     ・部品固有の最小幅を持ち、width:100% でもそこまでしか縮まないため
       グリッドの列からはみ出して隣の欄に重なる

   の3つが同時に起きる。「値が入っている実施日だけが大きく、空の次回予定日は
   他と揃って見える」のはこのため（iOS は空の日付欄に何も描かない）。
   appearance を外して枠は自前で描き、値の表示部分（WebKit のシャドウ DOM）にも
   明示的に指定を入れて 42px の枠に収める。PC 側の見た目は変わらない。 */
input[type=date], input[type=month], input[type=time], input[type=datetime-local] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;              /* 部品固有の最小幅で列からはみ出させない */
  text-align: left;
}
/* 42px −(上下 padding 10px×2)−(枠線 1px×2) = 20px。ここに収める。 */
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; line-height: 20px; }
input[type=date]::-webkit-datetime-edit                { padding: 0; line-height: 20px; }
input[type=date]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
.field input:focus, .field select:focus, select:focus, input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field input::placeholder { color: var(--gray-400); }
.req { color: var(--danger); }

.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.controls label { font-size: 13px; font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.controls select { width: auto; min-width: 150px; }
.controls .spacer { margin-left: auto; }

/* ---- 月の選択（年送り＋12か月）--------------------------------------
   プルダウンだと2年ぶんで最新月まで遠かったため置き換えたもの。
   月は常に同じ位置にあるので、目で探さずに押せる。*/
.ym-row { margin-top: -8px; }
.ym-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* 月セレクタは JS 版（稼働状況）が button、PHP 版（入力画面）が a。見た目は同じにする */
.ym-picker button, .ym-picker a.ym-m, .ym-picker a.ym-nav, .ym-picker a.ym-latest, .ym-picker span.ym-m, .ym-picker span.ym-nav {
  /* 中央寄せの flex にして、矢印だけ背が低くならないよう高さを揃える */
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--gray-700); background: #fff;
  border: 1px solid var(--gray-300); border-radius: 8px;
  padding: 5px 11px; line-height: 1.4;
  transition: background .12s, color .12s, border-color .12s;
}
.ym-picker button:hover:not(:disabled),
.ym-picker a:hover { border-color: var(--primary); color: var(--primary); }
.ym-picker a { text-decoration: none; }
.ym-picker button.is-on, .ym-picker a.is-on {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.ym-picker button:disabled { cursor: default; }

.ym-year { display: flex; align-items: center; gap: 2px; }
.ym-year .ym-y { font-size: 13px; font-weight: 700; color: var(--gray-800);
                 min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; }
.ym-nav { padding: 4px 9px !important; font-size: 15px !important; line-height: 1 !important; }
.ym-nav:disabled { color: var(--gray-300); border-color: var(--gray-200); }

/* 12か月は等幅で並べる。押せない月は「無い」ことが分かる程度に薄く */
.ym-months { display: flex; gap: 4px; flex-wrap: wrap; }
.ym-months .ym-m {
  min-width: 34px; padding: 5px 0 !important; text-align: center;
  font-variant-numeric: tabular-nums;
}
.ym-months .ym-m.is-off, .ym-picker .ym-nav.is-off {
  color: var(--gray-300); background: var(--gray-50); border-color: var(--gray-200);
}

.ym-latest { border-style: dashed !important; }
.ym-cur { font-size: 12px; color: var(--gray-500); font-variant-numeric: tabular-nums;
          margin-left: 2px; white-space: nowrap; }

@media (max-width: 640px) {
  /* 12か月を6列×2段にして横スクロールを出さない。
     月の並びを1行ぶん占有させ、「最新月」が月の脇に取り残されないようにする。*/
  .ym-months { flex: 1 0 100%; }
  .ym-months .ym-m { min-width: 0; flex: 1 0 calc(16.666% - 4px); }
}

/* ============ テーブル ============ */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
/* 既定は左寄せ。以前は右寄せが既定で、データ側だけ個別に左寄せしていたため
   「見出しと中身がずれて見える」状態になっていた（2026-08-09 修正）。
   数値の列だけ th と td の両方に class="num" を付けて右寄せにすること。
   ※ 片方だけに付けるとまたずれるので、必ず対で付ける。 */
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th.num, td.num { text-align: right; }
th.center, td.center { text-align: center; }
thead th {
  background: var(--gray-50); color: var(--gray-600); font-weight: 600; font-size: 12.5px;
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody tr:hover { background: var(--gray-50); }
.table-scroll { max-height: 420px; overflow: auto; border: 1px solid var(--gray-200); border-radius: 10px; }
.zero { color: var(--gray-400); }

/* ============ バッジ・メッセージ ============ */
.badge { display: inline-block; font-size: 11px; font-weight: 600;
         border-radius: 999px; padding: 3px 10px; border: 1px solid var(--gray-300); color: var(--gray-500); }
.badge.on { color: var(--success); border-color: #86efac; background: #f0fdf4; }
.badge.off { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

.msg { border-radius: 10px; padding: 13px 16px; margin-bottom: 18px; font-size: 14px; display: flex; gap: 10px; }
.msg .ico { margin-top: 2px; vertical-align: 0; }   /* 1行目の文字と高さを合わせる */
.msg.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.msg.ng { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.info { background: var(--primary-soft); color: #1e40af; border: 1px solid #bfdbfe; }

/* ============ 物件カード（メニュー） ============ */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.proj {
  background: #fff; border: 1px solid transparent; border-radius: var(--radius);
  padding: 20px 22px; text-decoration: none; color: var(--gray-800); display: block;
  box-shadow: var(--shadow); transition: all .16s; position: relative;
}
.proj:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.proj .code { font-size: 11.5px; color: var(--gray-500); font-weight: 600; letter-spacing: .04em; }
.proj .name { font-size: 17px; font-weight: 700; margin: 4px 0 3px; color: var(--gray-900); }
.proj .cust { font-size: 13px; color: var(--gray-600); }
.proj .site { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.chips { margin: 13px 0 14px; display: flex; gap: 7px; flex-wrap: wrap; }
.chip { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 3px 11px;
        border: 1px solid var(--gray-300); color: var(--gray-600); background: var(--gray-50); }
.chip.molding { color: var(--primary); border-color: #bfdbfe; background: var(--primary-soft); }
.chip.crusher { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.proj .stat-row { display: flex; gap: 22px; border-top: 1px solid var(--gray-200); padding-top: 12px; }
.proj .stat-row div { font-size: 11.5px; color: var(--gray-500); }
.proj .stat-row b { display: block; font-size: 18px; color: var(--gray-900); font-weight: 700; margin-top: 1px; }
.hidden-mark { position: absolute; top: 14px; right: 16px; font-size: 10px; font-weight: 700;
               border: 1px solid #fecaca; background: #fef2f2; color: var(--danger);
               border-radius: 999px; padding: 2px 9px; }
.proj.off { opacity: .6; }

/* ============ メンテナンス（カレンダー・記録）============ */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-title { font-size: 17px; font-weight: 700; color: var(--gray-900); margin: 0 4px; }
.cal-head .spacer { margin-left: auto; }

.cal-legend { display: flex; gap: 16px; font-size: 12px; color: var(--gray-500); margin-bottom: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot.done { background: var(--primary); }
.dot.plan { background: var(--warning); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
       background: var(--gray-200); border: 1px solid var(--gray-200);
       border-radius: 10px; overflow: hidden; }
.cal-wd { background: var(--gray-50); text-align: center; padding: 8px 0;
          font-size: 12px; font-weight: 700; color: var(--gray-500); }
.cal-wd.sun { color: #dc2626; }
.cal-wd.sat { color: #2563eb; }

.cal-cell { background: #fff; min-height: 92px; padding: 6px 7px; }
.cal-cell.empty { background: var(--gray-50); }
.cal-cell .d { font-size: 12.5px; font-weight: 700; color: var(--gray-600); margin-bottom: 4px; }
.cal-cell.sun .d { color: #dc2626; }
.cal-cell.sat .d { color: #2563eb; }
.cal-cell.today { background: var(--primary-soft); }
.cal-cell.today .d {
  background: var(--primary); color: #fff; border-radius: 999px;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
}

.cal-item {
  display: flex; align-items: center; gap: 5px; margin-bottom: 3px;
  font-size: 11.5px; line-height: 1.35; text-decoration: none;
  padding: 2px 5px; border-radius: 6px;
}
.cal-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.done { background: var(--primary-soft); color: #1e40af; }
.cal-item.done:hover { background: #dbeafe; }
.cal-item.plan { background: #fffbeb; color: #b45309; }

/* 記録の一覧 */
.mt-row { display: flex; gap: 16px; padding: 16px 0; border-top: 1px solid var(--gray-200); }
.mt-row:first-of-type { border-top: none; }
.mt-date { width: 46px; flex-shrink: 0; text-align: center; }
.mt-date b { display: block; font-size: 24px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.mt-date span { font-size: 11px; color: var(--gray-500); }
.mt-body { flex: 1; min-width: 0; }
.mt-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 14.5px; }
.mt-meta { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.mt-note { font-size: 13px; color: var(--gray-700); margin-top: 8px;
           background: var(--gray-50); border-radius: 8px; padding: 10px 12px; }
.mt-act { flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.mt-act a, .linklike { font-size: 12.5px; font-weight: 600; color: var(--primary);
                       background: none; border: none; cursor: pointer; font-family: inherit;
                       text-decoration: none; padding: 0; }
.linklike.danger { color: var(--danger); }
.mt-act a:hover, .linklike:hover { text-decoration: underline; }

.chip.kind-inspection { color: var(--primary); border-color: #bfdbfe; background: var(--primary-soft); }
.chip.kind-repair     { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.chip.kind-parts      { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.chip.kind-other      { color: var(--gray-600); }

/* 添付ファイル */
.mt-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.filechip { display: inline-flex; align-items: center; border: 1px solid var(--gray-300);
            border-radius: 999px; background: #fff; overflow: hidden; }
.filechip a { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
              font-size: 12.5px; color: var(--gray-700); text-decoration: none; }
.filechip a:hover { background: var(--gray-50); color: var(--primary); }
.filechip em { font-style: normal; font-size: 11px; color: var(--gray-400); }
.filechip .x { border: none; background: none; cursor: pointer; color: var(--gray-400);
               font-size: 15px; padding: 4px 9px 4px 2px; line-height: 1; }
.filechip .x:hover { color: var(--danger); }
.filechip form { display: inline; }

/* ---- メンテナンスの現場写真 ----------------------------------------
   縮小版が無い環境（php-gd 未導入）では原寸が入ってくるので、
   枠のほうで大きさを固定して崩れないようにしている。*/
/* 全期間の一覧では日付欄に年月も出す */
.mt-date em { display: block; font-style: normal; font-size: 11px; font-weight: 600;
              color: var(--gray-400); letter-spacing: .02em; }

/* ---- ページ送り ---------------------------------------------------- */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
         margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 34px; padding: 0 11px;
  border: 1px solid var(--gray-200); border-radius: 8px; background: #fff;
  font-size: 13px; font-weight: 600; color: var(--gray-700); text-decoration: none;
  font-variant-numeric: tabular-nums; transition: all .15s;
}
.pager-btn:hover { border-color: var(--gray-300); background: var(--gray-50); }
.pager-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn.is-off { color: var(--gray-300); border-color: var(--gray-100); cursor: default; }
.pager-btn.is-off:hover { background: #fff; border-color: var(--gray-100); }
.pager-gap { color: var(--gray-400); padding: 0 2px; }
.pager-info { margin-left: auto; font-size: 12px; color: var(--gray-500); }

.mt-photos { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.mt-photos .photo { margin: 0; width: 160px; }
.mt-photos .ph-img { position: relative; width: 100%; aspect-ratio: 1; }
.mt-photos .ph-img > a { display: block; width: 100%; height: 100%; }
.mt-photos .ph-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 10px; background: var(--gray-100);
  border: 1px solid var(--gray-200);
  transition: transform .16s, box-shadow .16s;
}
.mt-photos .ph-img > a:hover img { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mt-photos .ph-img form { position: absolute; top: 4px; right: 4px; }
.mt-photos .ph-img .x {
  border: none; cursor: pointer; line-height: 1;
  font-size: 14px; padding: 2px 7px 4px; border-radius: 999px;
  color: #fff; background: rgba(17,24,39,.55);
}
.mt-photos .ph-img .x:hover { background: var(--danger); }

/* 説明はその場で直せるようにする（保存ボタンは普段は目立たせない） */
.ph-cap { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.ph-cap input[type=text] {
  flex: 1; min-width: 0; font-size: 11.5px; padding: 4px 7px;
  border: 1px solid transparent; border-radius: 7px;
  background: var(--gray-50); color: var(--gray-700); font-family: inherit;
}
.ph-cap input[type=text]:hover { border-color: var(--gray-300); }
.ph-cap input[type=text]:focus { outline: none; background: #fff;
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ph-cap button {
  border: none; background: none; cursor: pointer; color: var(--gray-400);
  padding: 3px 2px; line-height: 1; flex-shrink: 0;
}
.ph-cap button:hover { color: var(--primary); }
.ph-cap-ro { font-size: 11.5px; color: var(--gray-600); margin-top: 6px; line-height: 1.45; }
.mt-photo-note { font-size: 11.5px; color: var(--gray-500); margin-top: 8px; }

/* 登録フォーム側：選んだ写真ごとの説明入力 */
.phcaps { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.phcaps:empty { display: none; }
.phcaps .caprow { display: flex; align-items: center; gap: 10px; }
.phcaps .caprow span {
  flex: 0 0 210px; font-size: 12px; color: var(--gray-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.phcaps .caprow input { flex: 1; min-width: 0; font-size: 13px; padding: 7px 11px;
  border: 1px solid var(--gray-300); border-radius: 9px; font-family: inherit; }
.phcaps .caprow input:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

@media (max-width: 640px) {
  .mt-photos .photo { width: calc(50% - 6px); }
  .phcaps .caprow { flex-direction: column; align-items: stretch; gap: 3px; }
  .phcaps .caprow span { flex: none; }
}

textarea { width: 100%; background: #fff; color: var(--gray-800);
           border: 1px solid var(--gray-300); border-radius: 10px;
           padding: 10px 13px; font-size: 14px; font-family: inherit; resize: vertical; }
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input[type=file] { width: 100%; font-size: 13px; font-family: inherit;
                   border: 1px dashed var(--gray-300); border-radius: 10px; padding: 12px 13px;
                   background: var(--gray-50); }
.hint { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

@media (max-width: 900px) {
  .cal-cell { min-height: 62px; padding: 4px; }
  .cal-item span { display: none; }          /* 狭い画面では点だけ出す */
  .cal-item { justify-content: center; padding: 3px; }
  .mt-row { gap: 12px; }
  .mt-act { flex-direction: row; gap: 14px; }
}

/* ============ 取扱説明書（資料一覧）============ */
.doc-search { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.doc-search-box { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.doc-search-box .ico { position: absolute; left: 13px; color: var(--gray-400); pointer-events: none; }
/* ★ width:100% を明示する理由:
   共通の入力欄スタイルは input[type=text] などを名指ししているが、
   属性セレクタは type が書かれていない input や type="search" には当たらない。
   そのため検索窓だけブラウザ既定の幅（約170px）のままで、
   プレースホルダが途中で切れていた（2026-08-11 修正）。*/
.doc-search-box input {
  width: 100%; min-width: 0;
  background: #fff; color: var(--gray-800);
  border: 1px solid var(--gray-300); border-radius: 10px;
  font-size: 14px; font-family: inherit;
  height: 42px; line-height: 1.4;
  padding: 10px 40px 10px 42px;
  transition: border-color .15s, box-shadow .15s;
}
.doc-search-box input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.doc-search-box .clear { position: absolute; right: 12px; display: inline-flex; color: var(--gray-400); }
.doc-search-box .clear:hover { color: var(--danger); }

/* 検索欄の隣に置くフォルダの絞り込み。幅を決めて検索窓を圧迫しないようにする */
.doc-search select { width: auto; min-width: 190px; max-width: 260px; flex: 0 0 auto; }

/* 絞り込んだ結果が何件かをはっきり出す（資料検索サイトでよくある形） */
.doc-count { margin-top: 14px; font-size: 13px; color: var(--gray-600); }
.doc-count b { color: var(--gray-900); font-size: 15px; font-weight: 800;
               font-variant-numeric: tabular-nums; }
.doc-count a { margin-left: 12px; font-size: 12.5px; color: var(--primary); font-weight: 600; }

/* 件数と表示モードの切替を左右に置く */
.doc-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.doc-foot .doc-count { margin-top: 0; }
.doc-view { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.doc-view > span { font-size: 12px; color: var(--gray-500); margin-right: 2px; }
.doc-view-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--gray-200);
  font-size: 12.5px; font-weight: 600; color: var(--gray-600);
  text-decoration: none; background: #fff; transition: all .15s;
}
.doc-view-btn:hover { border-color: var(--gray-300); background: var(--gray-50); }
.doc-view-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.doc-view-btn em { font-style: normal; font-size: 11.5px; opacity: .75; font-weight: 700; }

/* 「すべての資料」でフォルダごとに区切る見出し */
.doc-group {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 22px 0 12px; font-size: 14px; font-weight: 700; color: var(--gray-800);
}
.doc-group .ico { color: #7c8ac8; }
.doc-group em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--gray-500);
                background: var(--gray-100); border-radius: 999px; padding: 2px 9px; }
.doc-group a { margin-left: 4px; font-size: 12px; font-weight: 600; color: var(--primary);
               text-decoration: none; }
.doc-group a:hover { text-decoration: underline; }
.doc-group:first-of-type { margin-top: 0; }

/* ---- 開閉するカード（普段は畳んでおくフォーム）----------------------
   details/summary で作る。JSが動かなくても必ず開けるようにするため。*/
.panel-toggle { padding: 0; }
.panel-toggle > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px; cursor: pointer; list-style: none;
  border-radius: var(--radius);
}
.panel-toggle > summary::-webkit-details-marker { display: none; }
.panel-toggle > summary:hover { background: var(--gray-50); }
.panel-toggle > summary h2 { margin: 0; border: none; padding: 0; font-size: 15px; }
.panel-toggle > summary .ico-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
}
.panel-toggle > summary .hint-open {
  margin-left: auto; font-size: 12px; color: var(--gray-400); white-space: nowrap;
}
/* 開いているときは「クリックで開閉」の代わりに矢印の向きで示す */
.panel-toggle > summary::after {
  content: '▾'; color: var(--gray-400); font-size: 13px; margin-left: 8px;
  transition: transform .15s;
}
.panel-toggle[open] > summary::after { transform: rotate(180deg); }
.panel-toggle[open] > summary { border-bottom: 1px solid var(--gray-100); border-radius: var(--radius) var(--radius) 0 0; }
.panel-toggle > form, .panel-toggle > p { padding: 0 22px; }
.panel-toggle > form { padding-bottom: 22px; padding-top: 18px; }
/* 中身が複数ブロックになる場合はまとめて余白を持たせる */
.panel-toggle > .panel-body { padding: 18px 22px 22px; }
.panel-toggle > .panel-body > form { padding: 0; }

/* ---- 入力欄が多いフォームのまとまり --------------------------------
   「何を入れるか → どこに置くか → どう見せるか」で区切って、
   一枚の長い入力欄の並びに見えないようにする。*/
.form-sec {
  display: flex; align-items: center; gap: 9px;
  margin: 22px 0 12px; padding-bottom: 9px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px; font-weight: 700; color: var(--gray-700);
}
.form-sec:first-child { margin-top: 0; }
.form-sec span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 999px; flex-shrink: 0;
  background: var(--primary); color: #fff;
  font-size: 11.5px; font-weight: 800;
}

.doc-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
/* ボタンでもリンクと同じ見た目にする（絞り込みを画面上で行う画面用） */
button.doc-tab { font-family: inherit; cursor: pointer; height: auto; line-height: 1.4; }
.doc-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--gray-200);
  font-size: 13px; font-weight: 600; color: var(--gray-600);
  text-decoration: none; background: #fff; transition: all .15s;
}
.doc-tab:hover { border-color: var(--gray-300); background: var(--gray-50); }
.doc-tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.doc-tab em { font-style: normal; font-size: 11.5px; opacity: .75; font-weight: 700; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.doc {
  background: #fff; border: 1px solid transparent; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .16s, transform .16s;
}
.doc:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* サムネイル。縦横比を固定して並びを揃える（用紙なのでA4に近い比率） */
.doc-thumb {
  display: block; aspect-ratio: 4 / 3; background: var(--gray-100);
  overflow: hidden; position: relative;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb .noimg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--gray-300);
}

.doc-body { padding: 14px 16px 15px; display: flex; flex-direction: column; flex: 1; }
.doc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.doc-title {
  font-size: 14.5px; font-weight: 700; color: var(--gray-900); text-decoration: none;
  line-height: 1.45; display: block;
}
.doc-title:hover { color: var(--primary); text-decoration: underline; }
.doc-desc { font-size: 12.5px; color: var(--gray-600); margin-top: 5px; line-height: 1.55; }
.doc-meta { font-size: 11.5px; color: var(--gray-400); margin-top: 8px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-act { display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
           margin-top: auto; padding-top: 12px; }
.doc-act a, .doc-act .linklike {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--primary); text-decoration: none;
}
.doc-act a:hover { text-decoration: underline; }
.doc-act form { display: inline; }

/* ---- 取扱説明書のフォルダ -------------------------------------------
   フォルダのカードは資料のカードと同じ大きさで並べつつ、
   ひと目で「入れ物」だと分かるように地色と枠を変えている。*/
.doc.folder { text-decoration: none; border-color: var(--gray-200); }
.doc.folder .doc-thumb {
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 100%);
}
.doc.folder .doc-thumb .noimg { color: #93a3d8; }
.doc.folder .doc-title { color: var(--gray-900); }
.doc.folder:hover .doc-title { color: var(--primary); }
/* 収録件数はサムネイルの右下にバッジで出す */
.doc.folder .fcount {
  position: absolute; right: 10px; bottom: 10px;
  min-width: 24px; padding: 2px 8px; border-radius: 999px;
  background: rgba(37,99,235,.92); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}
.chip.cat-folder {
  color: #4338ca; border-color: #c7d2fe; background: #eef2ff;
  display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
}
a.chip.cat-folder:hover { border-color: #818cf8; background: #e0e7ff; }

/* フォルダを開いているときのパンくず */
.crumb {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 13.5px; color: var(--gray-600);
}
.crumb a { color: var(--gray-600); text-decoration: none;
           display: inline-flex; align-items: center; gap: 5px; }
.crumb a:hover { color: var(--primary); text-decoration: underline; }
.crumb b { color: var(--gray-900); font-weight: 700;
           display: inline-flex; align-items: center; gap: 6px; }
.crumb .sep { color: var(--gray-300); }
.crumb .spacer { margin-left: auto; }
.crumb-desc { margin: -8px 0 14px; font-size: 12.5px; color: var(--gray-500); }

/* フォルダを選ぶと「どこで見せるか」は効かなくなるので薄くする */
.is-inherited { opacity: .45; }

.chip.cat-manual  { color: var(--primary); border-color: #bfdbfe; background: var(--primary-soft); }
.chip.cat-drawing { color: #6d28d9; border-color: #ddd6fe; background: #f5f3ff; }
.chip.cat-parts   { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.chip.cat-other   { color: var(--gray-600); }

.thumb-now { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.thumb-now img { width: 64px; height: 48px; object-fit: cover;
                 border-radius: 8px; border: 1px solid var(--gray-200); }
.thumb-now span { font-size: 12px; color: var(--gray-500); }

@media (max-width: 900px) {
  .doc-search { flex-wrap: wrap; }
  .doc-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .doc-body { padding: 12px 13px 13px; }
}

/* ============ 準備中ページ ============ */
.soon {
  text-align: center; padding: 70px 20px; color: var(--gray-500);
}
.soon-ico { color: var(--gray-300); line-height: 1; margin-bottom: 2px; }
.soon-ico .ico { vertical-align: 0; }
.soon h3 { font-size: 18px; color: var(--gray-700); margin: 14px 0 8px; }
.soon p { font-size: 13.5px; }

/* ============ ログイン ============ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: linear-gradient(160deg, #1e293b 0%, #111827 100%); padding: 20px; }
.login-box { width: 100%; max-width: 400px; }
.login-box .brand { text-align: center; margin-bottom: 22px; color: #fff; }
.login-box .brand h1 { font-size: 21px; font-weight: 700; }
.login-box .brand p { font-size: 13px; color: var(--gray-400); margin-top: 4px; }
.login-box .card { padding: 28px; border: none; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-box .field { margin-bottom: 16px; }

/* ============ レスポンシブ（スマートフォン・タブレット）============
   900px以下では、サイドバーを画面外に隠した「引き出し（ドロワー）」にし、
   上部のハンバーガーボタンで開閉する。
   以前は上部に横スクロールのタブとして並べていたが、項目が増えると
   画面外に隠れて気づけないため差し替えた（2026-08-09 変更）。 */
.topbar { display: none; }
.scrim  { display: none; }

@media (max-width: 900px) {
  .topbar {
    display: flex; align-items: center; gap: 6px;
    position: sticky; top: 0; z-index: 120;
    height: 56px; padding: 0 8px;
    background: var(--gray-900); color: #fff;
    box-shadow: 0 1px 0 rgba(255,255,255,.08);
  }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;              /* 指で押せる大きさを確保 */
    background: transparent; border: none; color: #fff;
    border-radius: 10px; cursor: pointer; flex-shrink: 0;
  }
  .menu-btn:active { background: rgba(255,255,255,.12); }
  .menu-btn .menu-close { display: none; }
  .menu-btn[aria-expanded="true"] .menu-open  { display: none; }
  .menu-btn[aria-expanded="true"] .menu-close { display: inline-flex; }
  .topbar-title { font-size: 15px; font-weight: 700; letter-spacing: .01em; }

  /* 引き出し本体。上部バーの「下」から出す（バーを覆うと閉じるボタンが隠れるため） */
  .sidebar {
    inset: 56px auto 0 0;
    width: 280px; max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 130;
  }
  .sidebar.open { transform: none; box-shadow: 8px 0 28px rgba(0,0,0,.35); }
  /* サービス名は上部バーに出ているので、引き出し内は省いて項目に幅を使う */
  .sidebar-header { display: none; }

  /* 背面の暗幕。タップで閉じる */
  .scrim { display: block; position: fixed; inset: 56px 0 0 0; z-index: 125;
           background: rgba(0,0,0,.45); }
  body.nav-open { overflow: hidden; }

  .main { margin-left: 0; padding: 18px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }

  /* 指で押しやすいように行を高くする */
  .nav-item { padding: 14px 20px; }
  .nav-sub .nav-item { padding-left: 46px; }
}

/* 端末の回転や小さい画面でも、引き出し内が読めるように */
@media (max-width: 900px) and (max-height: 560px) {
  .sidebar-header { padding: 14px 20px; }
  .nav-item { padding: 11px 20px; }
}

/* ============ 管理画面用の補助クラス ============ */
.card.full { width: 100%; }
section.card + section.card { margin-top: 18px; }

/* 権限バッジ（ID管理） */
.role { display:inline-block; font-size:11px; font-weight:700; border-radius:6px; padding:3px 10px; }
.role.master { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.role.staff  { background:#dbeafe; color:#1e40af; border:1px solid #bfdbfe; }
.role.client { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }

/* 一覧の操作リンク */
td.act a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 13px; margin-right: 12px; }
td.act a:hover { text-decoration: underline; }

/* セクション内の小見出し */
.card h3 { font-size: 13px; color: var(--gray-500); font-weight: 700; margin: 22px 0 10px; }

/* フォーム下のキャンセル等 */
form + h3 { margin-top: 26px; }
.user-comp { font-size: 11px; color: var(--gray-400); margin-top: 1px; }
.role.client_staff { background:#ccfbf1; color:#115e59; border:1px solid #99f6e4; }
.role-badge.client_staff { background:#5eead4; color:#000; }
.role.end_user { background:#ede9fe; color:#5b21b6; border:1px solid #ddd6fe; }
.role-badge.end_user { background:#c4b5fd; color:#000; }

/* 処理枚数カード（KYOKU-003）。見出しの下に出す小さな説明 ----------------- */
.card-note { font-size: 12px; color: var(--muted); margin: -6px 0 6px; }

/* ページ全体の絞り込みバー（機械の選択／月別の年）------------------------ */
.controls-card { padding: 14px 18px; margin-top: 18px; }
.controls-card .controls { margin: 0; flex-wrap: wrap; row-gap: 10px; }
.ctl-note { font-size: 12px; color: var(--muted); }

/* ============ 実績の手入力（input.php）============
   30行を上から順に打っていく画面。見出しと日付が常に見えること、
   いま触っている行がはっきり分かることを優先している。 */
.input-wrap { max-height: min(66vh, 720px); overflow: auto; border-radius: 10px;
              border: 1px solid var(--gray-200); }
.input-tbl { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.input-tbl th, .input-tbl td { border-bottom: 1px solid var(--gray-200); }

/* 見出しは上に貼り付ける。2段目（項目名）は1段目の下に重ねる */
.input-tbl thead th { position: sticky; z-index: 3; background: var(--gray-50);
                      font-size: 12px; color: var(--gray-600); white-space: nowrap; padding: 8px 10px; }
.input-tbl thead tr:first-child th { top: 0; height: 34px; }
.input-tbl thead tr:nth-child(2) th { top: 34px; }
.input-tbl thead th.c-mach { background: var(--gray-100); color: var(--gray-800);
                             font-size: 13px; font-weight: 700; text-align: center;
                             border-left: 2px solid var(--gray-200); }
.input-tbl thead th small { font-weight: 400; color: var(--gray-400); margin-left: 3px; }

/* 日付の列は左に貼り付ける（機械が増えて横に伸びても日が分かるように） */
.input-tbl .c-date { position: sticky; left: 0; z-index: 2; background: #fff;
                     white-space: nowrap; padding: 4px 12px 4px 14px; }
.input-tbl thead .c-date { z-index: 4; background: var(--gray-50); }
.input-tbl td.c-date b { font-size: 15px; font-variant-numeric: tabular-nums; }
.input-tbl td.c-date span { color: var(--gray-400); font-size: 12px; margin-left: 5px; }

.input-tbl tbody tr:hover td { background: #f8fafc; }
.input-tbl tbody tr:hover .c-date { background: #f8fafc; }
.input-tbl tr.sun .c-date b, .input-tbl tr.sun .c-date span { color: #dc2626; }
.input-tbl tr.sat .c-date b, .input-tbl tr.sat .c-date span { color: #2563eb; }
/* 今日の行。左端に印を付けて探さなくても目に入るようにする */
.input-tbl tr.today .c-date { box-shadow: inset 3px 0 0 var(--primary); }
.input-tbl tr.today td { background: var(--primary-soft); }

/* 参考に置く稼働時間。入力欄と間違えないよう薄く小さく */
.input-tbl .c-ref { color: var(--gray-500); font-size: 12.5px;
                    font-variant-numeric: tabular-nums; padding: 4px 10px;
                    border-left: 2px solid var(--gray-200); }
.input-tbl td.num { padding: 5px 8px; }

.input-tbl input[type=number] {
  width: 108px; min-height: 36px; padding: 5px 10px; text-align: right;
  border: 1px solid var(--gray-300); border-radius: 9px;
  font: inherit; font-variant-numeric: tabular-nums; background: #fff;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.input-tbl input[type=number]:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
/* 変えた欄。保存前に「どこを触ったか」が分かるようにする */
.input-tbl input.is-changed { border-color: var(--warning); background: #fffbeb; font-weight: 700; }
/* ほかの人が入れた日。押しても入らないことが見て分かるように */
.input-tbl input[readonly] { background: var(--gray-100); color: var(--gray-500);
  border-style: dashed; cursor: not-allowed; }
/* 数字入力の上下ボタンは誤操作のもとなので消す */
.input-tbl input[type=number]::-webkit-outer-spin-button,
.input-tbl input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-tbl input[type=number] { -moz-appearance: textfield; }

.input-tbl .c-who { white-space: nowrap; padding: 5px 10px; }
.who-tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
           background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200); }
.who-tag.mine { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfdbfe; }
.who-tag.csv  { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* 保存バー。30行スクロールしても押せるよう画面下に貼り付ける */
.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 18px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.save-bar .spacer { margin-left: auto; }
.ctl-note.is-dirty { color: var(--warning); font-weight: 700; }

kbd { font: inherit; font-size: 11px; padding: 1px 6px; border-radius: 5px;
      background: var(--gray-100); border: 1px solid var(--gray-300);
      border-bottom-width: 2px; color: var(--gray-700); }

/* 入力画面をスマートフォンで使うとき ------------------------------------
   機械2台×3項目だと横に並びきらないので、機械は上のセレクタで1台に絞れる。
   そのうえで、狭い画面では参考の稼働時間を隠して入力欄を優先する。 */
@media (max-width: 700px) {
  .input-tbl .c-ref { display: none; }
  .input-tbl input[type=number] { width: 84px; min-height: 40px; }
  .input-tbl .c-date { padding: 4px 8px; }
  .input-tbl td.c-date b { font-size: 16px; }
  .input-tbl thead th, .input-tbl .c-who { padding: 6px 6px; }
  .who-tag { max-width: 88px; overflow: hidden; text-overflow: ellipsis;
             white-space: nowrap; vertical-align: middle; }
  .input-wrap { max-height: none; }          /* スマホは画面ごとスクロールしたほうが自然 */
  /* 折り返したとき spacer が効くと「機械」の見出しだけ右端に飛ぶので効かせない */
  .controls-card .controls .spacer { display: none; }
  .controls-card .controls { row-gap: 6px; }
  .controls-card .controls > label { width: 100%; }
  .save-bar { padding: 10px 14px; }
}
