:root {
    --navy: #1e3a5f;
    --navy-dark: #16293f;
    --accent: #2f6fb2;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #24303c;
    --muted: #6b7a89;
    --border: #d8e0e8;
    --danger: #b3372f;
    --success: #2e7d4f;
    --paid: #b06a00;
}

* { box-sizing: border-box; }

/* .save-bar.is-stuck::before の 100vw 全幅背景は、スクロールバーが実領域を持つ環境(Windows等)だと
   100vw がスクロールバー分だけ実際のビューポート幅を超え、横スクロールを生んでしまう。
   html/body 両方で横方向のはみ出しを切り捨てて回避する。overflow-x: hidden だと overflow-y が
   auto 扱いになり .save-bar の position: sticky が効かなくなるため、その副作用が無い overflow: clip を使う。 */
html { overflow-x: clip; }

body {
    margin: 0;
    overflow-x: clip;
    font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.site-header {
    background: var(--navy);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    position: relative;
}

.header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.nav-drawer {
    display: contents;
}

.nav-toggle {
    display: none;
    flex-shrink: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    margin-left: auto;
    padding: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 1px;
    background: #fff;
}

.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: .08em;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon { width: 26px; height: 26px; display: block; }

.nav { display: flex; flex-wrap: wrap; gap: 2px; }

.nav a {
    color: #cfe0f2;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: .92rem;
}

.nav a.active, .nav a:hover { background: var(--navy-dark); color: #fff; }

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .85rem;
}

.user-name { color: #cfe0f2; }
.muted-link { color: #9db8d4; text-decoration: none; }
.muted-link:hover { color: #fff; }

.header-user-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #cfe0f2;
    text-decoration: none;
}
.header-user-link:hover .user-name { text-decoration: underline; }
.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    background: #9db8d4;
    flex-shrink: 0;
}
.avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}
/* 管理者マークは右上、オンラインマーク(Facebook等を参考にした緑丸、右下)と場所が被らないようにする */
.avatar-admin-mark {
    position: absolute;
    right: -2px;
    top: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--paid);
    border: 2px solid #fff;
}
.avatar-online-mark {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid #fff;
}
.user-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .78rem;
}

.inline-form { display: inline; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 14px 60px;
}

h1 { font-size: 1.3rem; margin: 8px 0 16px; }
h2 { font-size: 1.05rem; margin: 20px 0 10px; }
.page-subtitle { font-size: 1.15rem; margin: 0 0 16px; color: var(--navy); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 8px;
}

label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92rem; }

textarea, input[type=text], input[type=password], input[type=email], input[type=date],
input[type=time], input[type=number], input[type=month], select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px; /* iOS のズーム防止 */
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

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

.auto-grow { resize: none; overflow-y: hidden; }

/* 顧客ごとの報告とは別枠であることが分かるよう、枠で囲って区別する */
.visit-count-box {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: #f6f8fa;
}
.visit-count-box .hint { margin: 8px 0 0; }
.visit-count-fields { display: flex; gap: 24px; flex-wrap: wrap; }
.visit-count-item { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; }
.visit-count-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--navy);
    color: #fff;
    font-weight: 700;
    font-size: .76rem;
}
.visit-count-unit { color: var(--muted); }
.visit-count-item input[type=number] { width: 70px; text-align: center; }
.visit-count-display { color: var(--muted); font-size: .92rem; margin: 0; }

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

.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 3px; }

/* ---- AIによる自動分析の結果表示(見出しはあえて小さめに) ---- */
.ai-result {
    font-size: .92rem;
    line-height: 1.7;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
.ai-result:empty { display: none; }
.ai-result-heading {
    font-size: .98rem;
    font-weight: 700;
    color: var(--navy);
    margin: 16px 0 6px;
    padding-left: 8px;
    border-left: 3px solid var(--accent);
}
.ai-result-heading:first-child { margin-top: 0; }
.ai-result p.ai-result-p { margin: 0 0 8px; }
.ai-result ul.ai-result-list { margin: 0 0 8px; padding-left: 1.3em; }
.ai-result ul.ai-result-list li { margin-bottom: 4px; }

/* モダンなチェックボックス (ネイティブ input は透明化し、隣接の .chk-box で見た目を描画する)。
   .chk-wrap は視覚上のサイズより一回り大きく取った上で負のマージンで相殺し、
   レイアウトを変えずにクリック可能な範囲だけ広げている。 */
.chk-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: -7px;
    cursor: pointer;
    vertical-align: middle;
}
.chk-wrap input[type=checkbox] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}
.chk-box {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    pointer-events: none;
    transition: background .15s, border-color .15s;
}
.chk-box::after {
    content: "";
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0;
}
.chk-wrap input:checked ~ .chk-box { background: var(--accent); border-color: var(--accent); }
.chk-wrap input:checked ~ .chk-box::after { opacity: 1; }
.chk-wrap input:focus-visible ~ .chk-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px 22px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { background: #275d96; }
.btn:disabled { background: #b6c2cc; color: #eef1f4; border-color: #b6c2cc; cursor: not-allowed; }
.btn:disabled:hover { background: #b6c2cc; }
.btn-outline:disabled { background: #f2f4f6; color: #a9b3bc; border-color: #d3d9de; }
.btn-outline:disabled:hover { background: #f2f4f6; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: .85rem; border-radius: 6px; }
.btn-outline { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: #eef4fa; }
.btn-outline-success { background: #fff; color: var(--success); border: 1px solid var(--success); }
.btn-outline-success:hover { background: #e6f4ec; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: #fbeeed; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    line-height: 0;
    vertical-align: middle;
}
.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;
}

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: #e6f4ec; color: var(--success); border: 1px solid #bfe3cd; }
.alert-error { background: #fbeeed; color: var(--danger); border: 1px solid #efc9c5; }
.alert-info { background: #fff7e8; color: var(--paid); border: 1px solid #f2ddb4; }
.alert-demo { background: var(--navy); color: #fff; border: 1px solid var(--navy-dark); font-weight: 700; text-align: center; }

/* ---- モーダル (メール送信ログの「詳細を見る」等で使用) ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 45, .5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: var(--card);
    border-radius: 10px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; }
.modal-body { padding: 16px 20px; overflow-y: auto; }

table.list {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-size: .92rem;
}
table.list th, table.list td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}
table.list th { background: #eef2f6; font-size: .85rem; }
table.list tr:last-child td { border-bottom: none; }
table.list td a { color: var(--accent); }
table.list td a:visited { color: var(--accent); }
table.list th .sort-link {
    color: var(--text);
    text-decoration: none;
    display: inline-block;
}
table.list th .sort-link:hover { color: var(--accent); }
table.list th .sort-arrow { color: var(--accent); font-size: .75em; margin-left: 2px; }

.table-wrap { overflow-x: auto; }

/* 横スクロールが発生する幅広テーブルで、操作ボタン列だけ右端に固定表示するための修飾クラス。
   table.list自体のoverflow:hiddenがあるとposition:stickyがtable基準で固定されてしまうため、
   角丸のクリップを実際にスクロールする.table-wrap側に移し、table側はoverflow:visibleにする。 */
.table-wrap.has-sticky-col {
    border: 1px solid var(--border);
    border-radius: 10px;
}
.table-wrap.has-sticky-col table.list {
    border: none;
    border-radius: 0;
    overflow: visible;
}
table.list th.col-sticky, table.list td.col-sticky {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow: -4px 0 6px -4px rgba(0, 0, 0, .18);
}
table.list th.col-sticky { background: #eef2f6; }
table.list td.col-sticky { background: var(--card); }

/* 顧客管理: テキスト入力欄(高さ約44px)に対してチェックボックス・操作ボタンを縦中央に揃える */
#customer-table td { vertical-align: middle; }

/* ---- ドラッグによる表示順変更 (ユーザー管理など) ---- */
table.list tr.dragging { opacity: .4; }
table.list td.drag-handle { user-select: none; font-size: 1.1rem; }

.badge {
    display: inline-block;
    font-size: .75rem;
    border-radius: 99px;
    padding: 1px 9px;
    background: #e4ebf2;
    color: var(--navy);
    white-space: nowrap;
}
.badge-chief { background: var(--navy); color: #fff; }
.badge-admin { background: var(--paid); color: #fff; }
.badge-today { background: var(--accent); color: #fff; margin-left: 6px; vertical-align: middle; }
.badge-paid { background: #fff3df; color: var(--paid); border: 1px solid #ecd3a8; }
.badge-missing { background: #fbeeed; color: var(--danger); }
.badge-ok { background: #e6f4ec; color: var(--success); }
.badge-carried { background: #eaf2fb; color: var(--accent); border: 1px solid #c9dcf1; margin-left: 6px; }
.badge-no-report { background: #eaf2fb; color: var(--accent); border: 1px solid #c9dcf1; }
.badge-substitute-day, .badge-substitute { background: #e6f4f1; color: #1a7a68; border: 1px solid #b7e0d8; }
.badge-report { background: #eaf2fb; color: var(--accent); }
.badge-plan { background: #e6f4ec; color: var(--success); }
.badge-absent { background: #edeff2; color: var(--muted); border: 1px solid var(--border); }

/* ---- カレンダー ---- */
.cal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.cal-title { font-size: 1.15rem; font-weight: 700; }

table.calendar {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    table-layout: fixed;
}
table.calendar th {
    border: 1px solid var(--border);
    background: #eef2f6;
    font-size: .8rem;
    padding: 4px 0;
}
table.calendar th.sun, .cal-day.sun .day-num { color: var(--danger); }
table.calendar th.sat, .cal-day.sat .day-num { color: var(--accent); }
table.calendar td {
    border: 1px solid var(--border);
    height: 74px;
    vertical-align: top;
    padding: 0;
}
.cal-day {
    display: block;
    height: 100%;
    padding: 3px 4px;
    text-decoration: none;
    color: inherit;
    font-size: .78rem;
}
a.cal-day:hover { background: #eef4fa; }
.cal-day.out { opacity: .35; }
.cal-day.sun, .cal-day.sat { background: #f5f7fa; }
.cal-day.closed { background: #f7eded; }
.cal-day.no-report { background: #eaf2fb; }
.cal-day.substitute-day { background: #e6f4f1; }
.cal-day.business-required { background: #eaecf5; }
/* 「本日」は背景色ではなく縁取り+太字にして、報告不要日等の薄い青背景と混同しないようにする */
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.today .day-num { color: var(--accent); font-weight: 800; }
.day-num { font-weight: 600; }
.day-mark { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mark-plan { color: var(--success); }
.mark-paid { color: var(--paid); }
.mark-holiday { color: var(--danger); }
.mark-no-report { color: var(--accent); }
.mark-substitute-day, .mark-substitute { color: #1a7a68; }
.mark-business-required { color: var(--navy); }
.mark-absent { color: var(--muted); }
.mark-jp-holiday { color: var(--muted); }

/* ---- 顧客報告ブロック ---- */
.item-block {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fafcfe;
}
.item-block-report { background: #eff6fc; }
.item-block-plan { background: #eef8f2; }
.item-block-carried { border: 1px dashed var(--accent); background: #f2f7fc; }
.carried-note { margin: 0 24px 8px 0; font-size: .8rem; color: var(--accent); }
.item-head { display: flex; gap: 8px; margin-bottom: 8px; }

/* 削除ボタン: カード内のフォーム要素とは独立させ、右上に半分はみ出す形で配置(使用頻度が低いため誤操作しにくい位置に)。
   色は報告(青)/予定(緑)それぞれのキーカラーに合わせる。 */
.remove-item {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--danger);
    border-radius: 50%;
    background: #fff;
    color: var(--danger);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
}
.remove-item:hover { background: #fbeeed; }
.item-block-report .remove-item { border-color: var(--accent); color: var(--accent); }
.item-block-report .remove-item:hover { background: #eef4fa; }
.item-block-plan .remove-item { border-color: var(--success); color: var(--success); }
.item-block-plan .remove-item:hover { background: #e6f4ec; }

/* 顧客名入力 + 新規企業トグルを1つのグループに見せる */
.customer-field {
    flex: 1;
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.customer-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.customer-field .ac-wrap { flex: 1; }
.customer-field .ac-wrap input[type=text] {
    border: none;
    border-radius: 7px 0 0 7px;
}
.customer-field .ac-wrap input[type=text]:focus { outline: none; }
.new-customer-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px;
    margin-bottom: 0;
    border-left: 1px solid var(--border);
    border-radius: 0 7px 7px 0;
    background: #f4f6f9;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.new-customer-toggle input { width: auto; margin: 0; }
.new-customer-toggle:has(input:checked) {
    background: var(--accent);
    border-left-color: var(--accent);
    color: #fff;
}

/* 顧客名オートコンプリート */
.ac-wrap { position: relative; display: block; }
.ac-wrap input { width: 100%; }
.ac-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 2px 0 0;
    padding: 4px;
    list-style: none;
    max-height: 230px;
    overflow-y: auto;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.ac-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: .92rem; }
.ac-list li:hover { background: #eef4fa; }
.ac-reading { color: var(--muted); font-size: .8rem; }
.customer-new-hint { margin: 4px 0 8px; color: var(--paid); font-size: .78rem; line-height: 1.4; }
.label-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.label-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 4px 12px;
    font-size: .85rem;
    font-weight: normal;
    background: #fff;
    cursor: pointer;
    margin: 0;
    user-select: none;
}
.label-chip:has(input:checked) {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}
.label-chip input { width: auto; margin: 0; accent-color: var(--paid); }
.new-customer-chip { display: inline-flex; margin-bottom: 8px; }
.new-customer-chip:has(input:checked) { background: var(--paid); border-color: var(--paid); }
.badge-new { background: #fff3df; color: var(--paid); border: 1px solid #ecd3a8; }
textarea.item-detail { min-height: 90px; }
.item-headline { font-weight: 600; }
.item-labels .badge { margin-left: 4px; }
.item-bullet { margin-right: 5px; }
.item-bullet.report { color: var(--accent); }
.item-bullet.plan { color: var(--success); }

/* ---- みんなの報告 ---- */
.report-name { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.report-name-avatar { width: 24px; height: 24px; font-size: .72rem; }
/* 訪問件数: テーブルの1行ではなく名前欄の横に表示する。入力欄を思わせる白背景+枠線で軽く装飾する */
.report-name-visit-count {
    font-weight: normal;
    font-size: .82rem;
    color: var(--text);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.report-label { font-size: .8rem; color: var(--muted); margin: 6px 0 2px; }
.report-text { white-space: pre-wrap; margin: 0; font-size: .95rem; }
.report-text.empty { color: var(--danger); }
.report-text.paid { color: var(--paid); font-weight: 600; }
.report-text.absent { color: var(--muted); font-weight: 600; }

/* 顧客に紐づかない備考行を、通常の顧客行とは別枠に見せる */
tr.remark-row td { background: #f7f5ef; }
.remark-text { white-space: pre-wrap; font-size: .95rem; }
.remark-label {
    display: inline-block;
    margin-right: 8px;
    padding: 1px 9px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    vertical-align: middle;
}

/* ---- 報告 / 予定セクションの区別 ---- */
.section-title {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 14px;
    padding-left: 10px;
    border-left: 4px solid var(--accent);
}
.section-title.plan { border-left-color: var(--success); }
.section-title .badge { margin-left: 6px; vertical-align: middle; }

.group-title {
    background: var(--navy);
    color: #fff;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: .98rem;
    margin: 28px 0 8px;
    font-weight: bold;
}

/* ---- ログイン ---- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; }
.login-brand {
    text-align: center;
    color: var(--navy);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: .15em;
    margin-bottom: 18px;
}

.pagination { display: flex; gap: 8px; list-style: none; padding: 0; }
.pagination a, .pagination span {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: var(--accent);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.spacer { flex: 1; }

.day-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.day-nav-title { margin: 0; }

/* ---- 使い方ページ ---- */
.help-steps { font-size: 1.05rem; padding-left: 24px; margin: 0; }
.help-steps li { margin-bottom: 10px; }
.help-steps li:last-child { margin-bottom: 0; }
.help-list { padding-left: 20px; margin: 0; }
.help-list li { margin-bottom: 8px; }
.help-list li:last-child { margin-bottom: 0; }

/* ---- 保存ボタン: 画面外に出る間だけ画面下部に固定し、末尾まで来たら通常表示に戻る ---- */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: 16px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
/* 実際に画面下部へ張り付いている間だけ、他要素と区別する白いバー背景を出す。
   .save-bar 自体は .container の幅に収まっているため、背景だけ疑似要素で画面全幅まではみ出させる。 */
.save-bar.is-stuck::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 100vw;
    margin-left: -50vw;
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .1);
    z-index: -1;
}

@media (max-width: 600px) {
    table.calendar td { height: 64px; }
}

@media (max-width: 760px) {
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
    }
    .header-inner { flex-wrap: nowrap; }
    .nav-toggle { display: flex; }
    .nav-drawer {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        max-height: calc(100vh - 100%);
        overflow-y: auto;
        background: var(--navy);
        padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
        box-shadow: 0 8px 16px rgba(0, 0, 0, .2);
    }
    .nav-drawer.is-open { display: flex; }
    .nav { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
    .nav a { padding: 10px 8px; }
    .header-user {
        margin-left: 0;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, .15);
    }
    .header-user .user-name { display: inline; }
}

@media (max-width: 760px) {
    /* iOSの自動ズームを防ぐため font-size は16px維持のまま、余白と行間だけ詰めて見た目を小さくする */
    textarea, input[type=text], input[type=password], input[type=email], input[type=date],
    input[type=time], input[type=number], input[type=month], select {
        padding: 8px;
        line-height: 1.4;
    }
    /* 「新規訪問」トグルの分だけ顧客名入力欄が狭くなりすぎないようにする */
    .new-customer-toggle { padding: 8px; gap: 3px; font-size: .74rem; }
}

.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    color: var(--muted);
    font-size: .78rem;
}
.site-footer-version {
    font-size: .7rem;
    opacity: .7;
}

/* ---- メールテンプレート編集 (ソース → プレビューの順で縦に並べ、それぞれ横幅いっぱいに表示) ---- */
.mail-template-columns {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.mail-template-editor {
    width: 100%;
    min-height: 320px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.5;
}
.mail-template-preview-subject {
    font-size: .85rem;
    padding: 8px 10px;
    background: #f4f6f9;
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    word-break: break-all;
}
.mail-template-iframe {
    width: 100%;
    height: 720px;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    background: #fff;
}

/* ---- 管理者専用: 動作確認ツール (操作は /admin/diagnostics に集約、有効時のみ右下に小さく表示) ---- */
.admin-testing-indicator {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #ecd3a8;
    background: #fff3df;
    color: var(--paid);
    font-weight: 700;
    font-size: .82rem;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
button.admin-testing-indicator {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    font-family: inherit;
}
.admin-testing-indicator-tag {
    background: var(--paid);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .74rem;
    font-weight: 600;
}
.admin-testing-tool-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}
.admin-testing-time-form { display: flex; align-items: center; gap: 6px; }
.admin-testing-time-form input[type="datetime-local"] { width: auto; padding: 4px 6px; font-size: .85rem; }
.admin-testing-now-label { color: var(--paid); font-weight: 600; white-space: nowrap; }

/* ---- 管理者メニューのカテゴリ分けナビ ---- */
.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.admin-nav-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}
.admin-nav-group-label {
    font-size: .74rem;
    color: var(--muted);
    width: 92px;
    flex-shrink: 0;
}
.admin-nav .btn { background: var(--navy); border-color: var(--navy); }
.admin-nav .btn:hover { background: var(--navy-dark); }
.admin-nav .btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.admin-nav .btn-outline:hover { background: #eaf0f6; }

/* ---- READMEプレビュー (Markdown->HTML) ---- */
.markdown-body h1 { font-size: 1.3rem; margin: 0 0 12px; }
.markdown-body h2 { font-size: 1.1rem; margin: 24px 0 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.markdown-body h3 { font-size: .98rem; margin: 18px 0 8px; }
.markdown-body p, .markdown-body ul, .markdown-body ol { margin: 0 0 10px; line-height: 1.7; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body code {
    background: #f4f6f9;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .85em;
}
.markdown-body pre {
    background: #f4f6f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 0 0 12px;
}
.markdown-body pre code { border: none; padding: 0; background: none; }
.markdown-body table { border-collapse: collapse; margin: 0 0 12px; width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: .9rem; }
.markdown-body th { background: #eef2f6; }
.markdown-body a { color: var(--accent); }
.markdown-body blockquote { margin: 0 0 12px; padding: 4px 12px; border-left: 3px solid var(--border); color: var(--muted); }

/* ---- マイページ: アイコン編集 ---- */
.avatar-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.avatar-edit-preview {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--navy);
    flex-shrink: 0;
}
.avatar-edit-preview-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.6rem;
}
.avatar-edit-actions { display: flex; align-items: center; gap: 8px; }

.mypage-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 760px) {
    .mypage-columns { grid-template-columns: 1fr; }
}

/* ---- レポート分析 (統計ページ) ---- */
.stats-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 760px) {
    .stats-columns { grid-template-columns: 1fr; }
}
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 600px) {
    .stats-summary { grid-template-columns: 1fr; }
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
}
.stat-card-value {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.2;
}
.stat-card-label {
    font-size: .82rem;
    color: var(--muted);
    margin-top: 4px;
}
.stats-chart-wrap { position: relative; height: 280px; }
.stats-scope-tabs { display: flex; gap: 6px; }
.stats-scope-tabs a {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: .85rem;
    text-decoration: none;
}
.stats-scope-tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 200px; }

/* モダンな日付・時刻入力 (ネイティブのままだが、フォーカス時の縁取りをアクセントカラーの光彩に、
   カレンダー/時計アイコンをホバー時だけ強調する形に調整) */
input[type=date], input[type=time], input[type=datetime-local] { cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .55;
    padding: 4px;
    border-radius: 6px;
    transition: opacity .15s, background .15s;
}
input[type=date]::-webkit-calendar-picker-indicator:hover,
input[type=time]::-webkit-calendar-picker-indicator:hover,
input[type=datetime-local]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: var(--bg); }
input[type=date]:focus, input[type=time]:focus, input[type=datetime-local]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 178, .15);
}
.datetime-pair { display: flex; gap: 8px; }
.datetime-pair input[type=date] { flex: 1.3; min-width: 0; }
.datetime-pair input[type=time] { flex: 1; min-width: 0; }

/* モダンなトグルスイッチ (on/off設定用。.chk-wrap は一覧のチェックボックス向けで
   ラベルテキストを横に並べる用途には合わないため別コンポーネントとして用意) */
.switch-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: .92rem;
}
.switch-wrap input[type=checkbox] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--border);
    flex-shrink: 0;
    transition: background .15s;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform .15s;
}
.switch-wrap input:checked ~ .switch-track { background: var(--accent); }
.switch-wrap input:checked ~ .switch-track::after { transform: translateX(18px); }
.switch-wrap input:focus-visible ~ .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* セグメントコントロール (2〜3択のON/OFF的な切り替えをタブ状のボタン列で表現) */
.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label {
    margin: 0;
    padding: 9px 18px;
    font-weight: 600;
    font-size: .88rem;
    color: var(--muted);
    background: #fff;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.segmented label:not(:last-child) { border-right: 1px solid var(--border); }
.segmented input:checked + label { background: var(--accent); color: #fff; }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }

/* アンケートの配信対象ピッカー */
.target-mode-toggle { margin-bottom: 12px; }
.target-filter-bar { flex-wrap: wrap; margin-bottom: 10px; }
.target-filter-bar select { width: auto; min-width: 140px; }
.target-user-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
}
.target-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-weight: normal;
    cursor: pointer;
}
.target-user-row:hover { background: var(--bg); }
.target-user-row[hidden] { display: none; }
.target-user-name { font-weight: 600; }
.target-user-meta { color: var(--muted); font-size: .82rem; }

.survey-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 500;
}
.survey-modal {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}
.survey-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.survey-modal-header h2 { margin: 0 0 6px; }
.survey-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
}
.survey-modal-close:hover { color: var(--text); }
.survey-question .survey-choice {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    margin-bottom: 6px;
}
.survey-question .survey-choice input { width: auto; }
.required-mark { color: var(--danger); }
