:root {
  --navy: #1e3a5f;
  --navy-dark: #152a47;
  --accent: #f0a500;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --info: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ホーム画面から開いたとき（standalone）の安全領域: 画面下のホームバーや上の切り欠きと重ならないようにする */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
  .container { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--navy); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand { display: flex; flex: 1; align-items: center; gap: 12px; white-space: nowrap; min-width: 0; }
.brand-logo { display: block; height: 44px; width: auto; flex-shrink: 0; }
.brand-sub {
  font-size: 12px; font-weight: 600; opacity: .9;
  border-left: 1px solid rgba(255,255,255,.35); padding-left: 12px; line-height: 1.2;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub:empty { display: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* ---------- アイコン ---------- */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.btn .icon { width: 1.1em; height: 1.1em; }
.lightbox-close .icon { width: 22px; height: 22px; }
.photo .del .icon { width: 16px; height: 16px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--navy-dark); }
.btn-primary:hover { background: #ffb81c; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2f7; color: var(--text); }

/* ---------- カード・共通 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
/* 画面直下にカードを縦に並べるとき（ユーザー管理など）は間隔を空ける */
#app > .card + .card { margin-top: 16px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.6;
}
.badge-planning { background: #e0e7ff; color: #3730a3; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-onhold { background: #fef3c7; color: #92400e; }
.badge-completed { background: #e5e7eb; color: #374151; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* 進捗バー */
.progress { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--info); border-radius: 999px; transition: width .3s; }
.progress.lg { height: 16px; }
.progress > span.done { background: var(--ok); }

/* ---------- ダッシュボード ---------- */
.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.quick-link { display: flex; align-items: center; gap: 14px; padding: 14px 16px; transition: transform .12s, box-shadow .12s; }
.quick-link:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.09); }
.ql-badge {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 12px; background: var(--navy); color: #fff;
}
.ql-badge .icon { width: 22px; height: 22px; }
.ql-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.ql-text strong { font-size: 16px; }
.ql-text .muted { font-size: 12px; }
.ql-arrow { color: var(--muted); width: 20px; height: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.project-stats { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.project-card { display: flex; flex-direction: column; gap: 10px; transition: transform .12s, box-shadow .12s; }
.project-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.09); }
.project-card .title { font-size: 17px; font-weight: 700; margin: 0; }
.project-card .meta { font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.project-card .pct { font-weight: 800; font-size: 20px; }
.project-card .foot { font-size: 12px; color: var(--muted); display: flex; gap: 6px 12px; flex-wrap: wrap; }
.project-card .foot span { white-space: nowrap; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- 詳細 ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.detail-head { display: flex; flex-direction: column; gap: 12px; }
.detail-head .title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; font-size: 14px; }
.info-grid dt { color: var(--muted); font-size: 12px; }
.info-grid dd { margin: 0; font-weight: 600; }
.big-progress { display: flex; align-items: center; gap: 14px; }
.big-progress .pct { font-size: 32px; font-weight: 900; min-width: 90px; text-align: right; }
.big-progress .progress { flex: 1; }
select.status-select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin: 18px 0 14px; }
.tab {
  padding: 10px 16px; border: none; background: none; cursor: pointer;
  font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab.active { color: var(--navy); border-bottom-color: var(--accent); }
.tab .count { margin-left: 4px; font-size: 12px; background: #eef2f7; padding: 1px 7px; border-radius: 999px; }

/* 工程（チェックリスト） */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.check-item.done { background: #f8fafc; }
.check-label { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; position: relative; }
.check-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.check-box {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid #8a94a6; background: #fff;
  color: #fff; transition: background .12s, border-color .12s;
}
.check-box .icon { width: 16px; height: 16px; opacity: 0; stroke-width: 3; }
.check-input:checked + .check-box { background: var(--ok); border-color: var(--ok); }
.check-input:checked + .check-box .icon { opacity: 1; }
.check-input:focus-visible + .check-box { outline: 2px solid rgba(37,99,235,.45); outline-offset: 2px; }
.check-input:disabled + .check-box { opacity: .5; }
.check-text { display: grid; gap: 2px; min-width: 0; }
.check-name { font-weight: 700; overflow-wrap: anywhere; }
.check-item.done .check-name { text-decoration: line-through; color: var(--muted); font-weight: 600; }
.check-meta { font-size: 12px; color: var(--muted); }
.check-item .edit-item { color: var(--muted); }
.check-item .edit-item:hover { color: var(--text); }
.check-item.editing { background: #fffbeb; border-color: #fcd34d; }
.check-box.static { color: #fff; }
.check-box.static.on { background: var(--ok); border-color: var(--ok); }
.check-box.static.on .icon { opacity: 1; }

/* 名前の編集フォーム（大枠・チェック項目で共通） */
.edit-form { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; flex-wrap: wrap; }
.edit-form input { flex: 1; min-width: 160px; padding: 7px 10px; font-size: 14px; }

/* 大枠の工程 */
.phase-divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.phase { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.phase.done { border-color: #bbf7d0; background: #f0fdf4; }
.phase-head { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.phase-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.phase-title strong { font-size: 15px; overflow-wrap: anywhere; }
.phase-pct { font-weight: 800; font-size: 16px; min-width: 44px; text-align: right; }
.phase .checklist { margin-top: 10px; }
.phase .check-item { padding: 8px 10px; }
.phase-empty { font-size: 13px; margin-top: 10px; }
.phase .inline-form { margin-top: 24px; }
.phase .phase-divider { margin-top: 28px; }
.phase .item-form input { font-size: 14px; padding: 7px 10px; }
.phase .item-form .btn { padding: 7px 12px; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; }
#task-form { margin-top: 24px; }
#task-form + .phase-divider { margin-top: 28px; }

/* 写真 */
.upload-box {
  border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 16px;
  background: #fff; display: grid; gap: 10px; margin-bottom: 14px;
}
.upload-box .file-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-box input[type=file] { flex: 1; min-width: 180px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; }
.photo { background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); position: relative; }
.photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: zoom-in; background: #eee; }
.photo .cap { padding: 8px 10px; font-size: 12px; }
.photo .cap .date { color: var(--muted); font-size: 11px; }
.photo .del {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.preview-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.preview-strip img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* メモ */
.log-form { display: grid; gap: 8px; margin-bottom: 14px; }
.timeline { display: grid; gap: 10px; }
.log { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.log .head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.log .body { white-space: pre-wrap; font-size: 14px; }

/* 写真とメモの共有・添付 */
.media-fields { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 14px; }
.media-fields:disabled { opacity: .65; }
.media-label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.media-fields small, .media-author { font-size: 12px; }
.media-files { display: grid; gap: 8px; min-width: 0; }
.media-files .file-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.media-file-status { font-size: 12px; }
.media-preview { position: relative; padding: 5px 5px 0 0; }
.media-preview button { position: absolute; right: 0; top: 0; border: 0; border-radius: 50%; width: 24px; height: 24px; background: #334155; color: white; cursor: pointer; }
.media-error { color: var(--danger); font-size: 13px; white-space: pre-wrap; }
.media-error:empty, .photo-memos:empty { display: none; }
.media-image-button { display: block; border: 0; padding: 0; background: #eee; width: 100%; cursor: zoom-in; }
.media-image-button img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.photo .cap { display: grid; gap: 8px; overflow-wrap: anywhere; }
.photo:focus, .log:focus { outline: 3px solid var(--accent); outline-offset: 3px; }
.photo-memos { display: grid; gap: 6px; }
.photo-memo-link { display: flex; gap: 6px; text-align: left; border: 0; background: #f1f5f9; border-radius: 6px; padding: 8px; color: var(--navy); cursor: pointer; font-size: 12px; overflow-wrap: anywhere; }
.photo-memo-link .icon { flex-shrink: 0; width: 15px; height: 15px; }
.log .head { flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.log .body { overflow-wrap: anywhere; }
.log-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 12px; margin-top: 14px; }
.log-photos > div { min-width: 0; max-width: 220px; }
.log-photos .media-image-button { border-radius: 8px; overflow: hidden; }
.media-photo-link { display: flex; gap: 4px; align-items: center; margin-top: 6px; border: 0; padding: 4px 0; background: none; color: var(--navy); font-size: 12px; cursor: pointer; }
.media-photo-link .icon { width: 14px; height: 14px; }
.media-choices { border-top: 1px solid var(--border); padding-top: 14px; }
.media-choices summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.media-photo-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 8px; margin-top: 10px; max-height: 300px; overflow: auto; padding: 3px; }
.media-photo-choice { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; min-width: 0; }
.media-photo-choice:has(input:checked) { background: #fff8e7; border-color: var(--accent); }
.media-photo-choice img { width: 52px; height: 52px; object-fit: cover; border-radius: 4px; }
.media-photo-choice span { font-size: 12px; overflow-wrap: anywhere; min-width: 0; }
.media-photo-choice small, .media-log-choices small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.media-modal-card { max-width: 680px; }
.media-link-photo { display: block; width: 100%; max-height: 180px; object-fit: contain; margin: 12px 0; background: #f1f5f9; border-radius: 8px; }
.media-log-choices { display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.media-log-choices label { display: flex; gap: 10px; align-items: start; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 13px; cursor: pointer; }
.media-log-choices span { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.media-new-log { margin-top: 20px; width: 100%; }

/* ---------- フォーム ---------- */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.form .req { font-size: 11px; color: var(--danger); font-weight: 700; margin-left: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input:not([type]), input[type=date], input[type=time], input[type=month], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
  font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--info); }
textarea { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- モーダル・ライトボックス・トースト ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 560px;
  max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px;
}
.lightbox img { max-height: 85vh; max-width: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-caption { color: #fff; margin-top: 10px; font-size: 14px; text-align: center; }
.lightbox-close {
  position: absolute; top: 12px; right: 16px; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.error { background: var(--danger); }

/* ---------- スマホ ---------- */
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .brand { gap: 8px; }
  .brand-logo { height: 30px; }
  .brand-sub { padding-left: 8px; font-size: 11px; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  #btn-new { padding: 8px 10px; font-size: 13px; }
  .big-progress .pct { font-size: 26px; min-width: 70px; }
  .tab { padding: 10px 10px; font-size: 14px; }
}

/* ---------- ヘッダー右側・アカウントメニュー ---------- */
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }
.btn-user {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.btn-user:hover { background: rgba(255,255,255,.22); }
.popover {
  position: fixed; top: 58px; right: 12px; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 230px; padding: 6px;
}
.popover-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: #f1f5f9; }
.menu-item.danger { color: var(--danger); }
body:not(.is-admin) .admin-only { display: none !important; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-staff { background: #e0f2fe; color: #075985; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #e5e7eb; color: #374151; }

/* ---------- ホーム・スケジュール ---------- */
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-heading h1 { font-size: 24px; margin: 0; }
.page-heading p { margin: 6px 0 0; font-size: 14px; }
.home-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-module { display: flex; align-items: center; gap: 16px; min-height: 115px; transition: border-color .15s; }
.home-module:hover { border-color: var(--accent); }
.home-module > span:nth-child(2) { flex: 1; min-width: 0; }
.home-module strong { display: block; font-size: 18px; color: var(--navy); }
.home-module small { display: block; color: var(--muted); margin-top: 6px; }
.home-module-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; color: var(--navy); background: #eef2f8; flex-shrink: 0; }
.home-module-icon .icon { width: 24px; height: 24px; }
.home-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.home-panel h2 { font-size: 17px; margin: 0; }
.home-panel .row { gap: 10px; flex-wrap: wrap; }
.home-list { padding: 0; margin: 14px 0; list-style: none; }
.home-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.home-list li > div, .home-list li > a:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.home-list small { display: block; font-size: 12px; margin-top: 4px; }
.home-more { color: var(--navy); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin-top: 12px; }
.home-empty { padding: 18px 0; font-size: 14px; }
.project-schedule-link { margin: 0 0 20px; }
.schedule-today { margin-bottom: 18px; }
.schedule-today-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.schedule-today small { display: block; font-size: 12px; margin-top: 3px; }
.schedule-today-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 20px 0 0; }
.schedule-today-stats > div { padding: 4px 12px; text-align: center; }
.schedule-today-stats > div + div { border-left: 1px solid var(--border); }
.schedule-today-stats dt { font-size: 13px; color: var(--muted); }
.schedule-today-stats dd { margin: 6px 0 0; font-size: 14px; }
.schedule-today-stats b { color: var(--navy); font-size: 28px; margin-right: 6px; }
.schedule-toolbar { display: grid; grid-template-columns: auto minmax(0, auto) auto; justify-content: center; align-items: center; gap: 12px; }
.schedule-toolbar h2 { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; font-size: 17px; margin: 0; text-align: center; }
.schedule-toolbar h2 span { white-space: nowrap; }
.schedule-week-nav { display: flex; gap: 6px; }
.schedule-filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 20px; }
.schedule-filters > label { display: grid; gap: 5px; font-size: 12px; flex: 1; min-width: 140px; }
#schedule-user, #schedule-project {
  appearance: none; -webkit-appearance: none; padding-right: 38px; line-height: 1.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px 16px;
}
.schedule-help { font-size: 12px; line-height: 1.7; margin: 14px 0; }
.schedule-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.schedule-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1050px; table-layout: fixed; font-size: 13px; }
.schedule-table caption { text-align: left; }
.schedule-table th, .schedule-table td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: top; padding: 10px 8px; }
.schedule-table th:last-child, .schedule-table td:last-child { border-right: 0; }
.schedule-table tr:last-child td, .schedule-table tbody tr:last-child th { border-bottom: 0; }
.schedule-table thead th { background: #f1f5f9; color: var(--navy); text-align: center; }
.schedule-table thead th span { display: block; font-size: 18px; }
.schedule-table th small { display: block; font-weight: 400; font-size: 11px; margin-top: 4px; overflow-wrap: anywhere; }
.schedule-table .schedule-person { width: 136px; position: sticky; left: 0; z-index: 2; text-align: left; background: #f8fafc; overflow-wrap: anywhere; }
.schedule-person .badge { margin-top: 8px; }
.schedule-table .is-today { background: #fffcf2; }
.schedule-table thead .is-today { background: #fff2cb; color: #845800; }
.schedule-table .is-weekend:not(.is-today) { color: #64748b; }
.schedule-entry { background: #eef4fb; border: 1px solid #d8e3f1; padding: 8px; border-radius: 7px; margin-bottom: 8px; overflow-wrap: anywhere; }
.schedule-entry.cancelled { background: #f3f4f6; border-color: #d1d5db; color: var(--muted); }
.schedule-entry.cancelled .schedule-project-link { text-decoration: line-through; }
.schedule-entry-time { font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.schedule-entry-time .badge { margin-top: 5px; }
.schedule-project-link { font-weight: 700; color: var(--navy); display: block; }
.schedule-project-link:hover { text-decoration: underline; }
.schedule-entry p { font-size: 12px; margin: 8px 0; white-space: pre-wrap; }
.schedule-entry-user { display: block; font-size: 10px; color: var(--muted); margin: 8px 0; }
.schedule-warning { display: block; color: #92400e; margin-top: 6px; }
.schedule-edit { width: 100%; background: #fff; padding: 3px 6px; font-size: 11px; }
.schedule-checkin { display: block; font-size: 11px; font-weight: 700; color: var(--navy); margin-top: 8px; }
.schedule-add-cell { width: 100%; border: 1px dashed #d1d5db; border-radius: 6px; background: transparent; color: #64748b; cursor: pointer; padding: 6px; }
.schedule-add-cell:hover { background: #e8edf5; color: var(--navy); }
.schedule-unassigned { display: block; font-size: 11px; color: #9ca3af; margin: 8px 0 12px; text-align: center; }
.schedule-people { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; }
.schedule-people legend { font-size: 13px; font-weight: 600; }
.schedule-people > div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-height: 180px; overflow-y: auto; }
.schedule-people label { display: flex; align-items: center; gap: 8px; }
.schedule-people small { display: block; font-size: 11px; font-weight: 400; }
.schedule-people legend small { display: inline; }
.schedule-form-actions { flex-wrap: wrap; }
.schedule-form-actions .btn-danger { margin-right: auto; }
.schedule-history-modal { max-width: 780px; }
.schedule-history-modal h2 { font-size: 20px; margin: 0; }
.schedule-history-period { display: grid; gap: 6px; margin-top: 20px; font-size: 13px; font-weight: 600; }
.schedule-history-count { font-size: 12px; }
.schedule-history-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 0; }
.schedule-history-item time, .schedule-history-author { font-size: 12px; }
.schedule-history-summary { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; margin: 10px 0 4px; }
.schedule-history-author { margin: 4px 0 12px; }
.schedule-history-create, .schedule-history-restore { color: #166534; background: #f0fdf4; }
.schedule-history-update { color: #1e40af; background: #eff6ff; }
.schedule-history-cancel { color: #991b1b; background: #fef2f2; }
.schedule-history-diff { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.schedule-history-diff th, .schedule-history-diff td { padding: 8px; border: 1px solid var(--border); text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.schedule-history-diff th { background: #f8fafc; font-weight: 600; }
.schedule-history-diff th:first-child { width: 76px; }
.schedule-history-item button { margin-top: 12px; white-space: normal; }
.schedule-history-more { width: 100%; margin-top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 640px) {
  .home-modules, .home-overview { grid-template-columns: 1fr; }
  .home-module { min-height: 96px; }
  .home-module strong { font-size: 16px; }
  .schedule-card { padding: 14px 10px; }
  .schedule-table .schedule-person { width: 106px; }
  .schedule-toolbar { gap: 6px; }
  .schedule-toolbar h2 { font-size: 13px; }
  .schedule-people > div { grid-template-columns: 1fr; }
}

/* ---------- 出勤・日給集計 ---------- */
.attendance-entry { margin-bottom: 16px; }
.attendance-heading h1 { margin: 0; font-size: 24px; }
.attendance-heading p { margin: 6px 0 18px; }
.attendance-card { margin-bottom: 18px; }
.attendance-card h2 { font-size: 18px; margin: 0 0 16px; }
.attendance-card h2 small { font-size: 13px; font-weight: 400; margin-left: 8px; }
.attendance-help { font-size: 13px; line-height: 1.7; margin: 4px 0 12px; }
.attendance-notice { background: #f1f5f9; padding: 12px 14px; border-radius: 8px; line-height: 1.8; font-size: 14px; }
.attendance-toolbar, .attendance-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.attendance-toolbar label { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.attendance-toolbar input { width: auto; }
.attendance-actions { justify-content: flex-start; margin: 16px 0 10px; }
.attendance-record-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.attendance-deleted { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 8px; }
.attendance-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px 0; }
.attendance-amount { font-size: 26px !important; overflow-wrap: anywhere; }
.attendance-table-wrap { overflow-x: auto; }
.attendance-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.attendance-table th, .attendance-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.attendance-table th { background: #f8fafc; font-size: 12px; white-space: nowrap; }
.attendance-table td { min-width: 90px; }
.attendance-table td small { display: block; margin-top: 4px; }
.attendance-pending { background: #fef3c7; color: #92400e; }
.attendance-approved { background: #dcfce7; color: #166534; }
.attendance-rejected { background: #e5e7eb; color: #374151; }
.attendance-within { color: #166534; }
.attendance-warning { color: #92400e; }
.attendance-card summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.attendance-evidence { font-size: 12px; min-width: 160px; }
.attendance-evidence ul { padding-left: 18px; }
.attendance-evidence li { margin-bottom: 8px; overflow-wrap: anywhere; }
.attendance-settings + .attendance-settings { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 6px; }
.attendance-settings .form { margin-top: 10px; }
@media (max-width: 640px) {
  .attendance-stats { grid-template-columns: 1fr 1fr; }
  .attendance-stats .stat:last-child { grid-column: 1 / -1; }
}

/* ---------- ログイン画面 ---------- */
body.auth-open { overflow: hidden; }
.auth {
  position: fixed; inset: 0; z-index: 100;
  background: var(--navy);
  background-image: radial-gradient(circle at 20% 10%, rgba(240,165,0,.25), transparent 40%), radial-gradient(circle at 80% 90%, rgba(255,255,255,.08), transparent 45%);
  display: flex; align-items: flex-start; justify-content: center; padding: 16px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.auth-card { margin: auto; }
.auth-card {
  background: #fff; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); display: grid; gap: 12px;
}
.auth-brand { display: grid; justify-items: center; gap: 2px; }
.auth-logo { display: block; width: 230px; max-width: 100%; height: auto; }
.auth-brand small { font-size: 13px; font-weight: 700; color: var(--navy); letter-spacing: .08em; }
.auth-card h2 { margin: 6px 0 0; }
.auth-card p { margin: 0; font-size: 13px; }
.auth-card label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.form-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; margin-top: 4px; }

/* ---------- テーブル（ユーザー管理） ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 700; }
.table tr.is-disabled td { color: var(--muted); }
.table .ops { display: flex; gap: 6px; flex-wrap: wrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; }

@media (max-width: 640px) {
  .btn-user { max-width: 120px; padding: 8px 10px; font-size: 13px; }
  .popover { right: 8px; left: 8px; min-width: 0; }
}

/* ユーザー名ボタンは左寄せで省略記号に（中央寄せだと両端が切れる） */
.btn-user { justify-content: flex-start; }
#me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 案内モーダル */
.info-body { font-size: 14px; line-height: 1.7; }
.info-body ol { padding-left: 1.4em; margin: 6px 0 10px; }
.info-body li { margin: 4px 0; }
.info-body p { margin: 8px 0 0; font-size: 13px; }

/* スマホ: 入力欄の文字を 16px 以上にする（iOS は 16px 未満の入力欄をタップすると画面を自動で拡大してしまう） */
@media (max-width: 640px) {
  input, select, textarea, button, .btn { font-size: 16px !important; }
  input[type=checkbox], input[type=radio], input[type=file] { font-size: inherit !important; }
  .btn-sm, .chip, .pct-btn { font-size: 14px !important; }
}
html { -webkit-text-size-adjust: 100%; }
