/* セスコ 案件管理 共通スタイル（GAS版の配色・構成を踏襲した簡易版。画面移植時に整備） */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    color: #333;
    background: #f5f6f8;
}

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

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header { padding: 18px 16px; }
.app-title { font-size: 16px; font-weight: bold; }
.nav-menu { flex: 1; }
.menu-list { list-style: none; }
.menu-link {
    display: block;
    padding: 12px 16px;
    color: #ecf0f1;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}
.menu-link:hover { background: #34495e; }
.menu-link.is-disabled { color: #7f8c8d; cursor: not-allowed; }
.accordion-item summary { list-style: none; }
.accordion-item summary::before { content: "▶ "; font-size: 10px; }
.accordion-item details[open] summary::before { content: "▼ "; }
.accordion-content { list-style: none; background: #253544; }
.accordion-content .menu-link { padding-left: 32px; font-size: 13px; }
.sidebar-footer { padding: 16px; }
.sidebar-logout-button {
    width: 100%;
    padding: 10px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}
.sidebar-logout-button:hover { background: #c0392b; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 14px 24px;
    border-bottom: 1px solid #e0e0e0;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title { font-size: 18px; }
.user-info { font-size: 14px; }
.user-role { color: #888; font-size: 12px; }
.content { padding: 24px; }

/* ハンバーガー（PCでは非表示。GAS版 header.html と同じ方式） */
.hamburger {
    display: none;
    font-size: 24px;
    line-height: 1;
    background: none;
    border: none;
    color: #2c3e50;
    cursor: pointer;
    padding: 4px 8px;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 900; }

/* 日付・時刻入力は親幅を超えない（iOS Safari は固有幅を優先して右にはみ出すことがあるため全画面共通で抑止） */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { min-width: 0; max-width: 100%; }

/* ==================== モバイル（GAS版 sidebarStyle.html のスライド式サイドバーを踏襲） ==================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .hamburger { display: inline-block; }
    .app-header {
        position: sticky;
        top: 0;
        z-index: 800;
        padding: 10px 12px;
        gap: 8px;
    }
    .page-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .user-info { font-size: 12px; white-space: nowrap; }
    .user-role { display: none; }
    .content { padding: 12px; }
    .kpi-card { min-width: 0; width: 100%; }
    .form-card { max-width: none; padding: 16px; }
}

/* ==================== ログイン画面 ==================== */
.login-body {
    background: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container { width: 100%; max-width: 380px; padding: 16px; }
.login-card {
    background: #fff;
    border-radius: 8px;
    padding: 32px 28px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.login-title { font-size: 20px; text-align: center; }
.login-subtitle { text-align: center; color: #888; margin: 4px 0 20px; }
.login-error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f5b7b1;
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; margin-bottom: 6px; }
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.form-group input:focus { outline: 2px solid #3498db; border-color: #3498db; }
.login-button {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
}
.login-button:hover { background: #2980b9; }

/* ==================== 共通UI部品 ==================== */
.flash-success {
    background: #eafaf1; border: 1px solid #82e0aa; color: #1e8449;
    border-radius: 4px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}
.flash-error {
    background: #fdecea; border: 1px solid #f5b7b1; color: #c0392b;
    border-radius: 4px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}
.flash-error ul { margin-left: 18px; }
.toolbar { margin-bottom: 16px; }
.btn {
    display: inline-block; padding: 8px 14px; border: 1px solid #ccc; border-radius: 4px;
    background: #fff; color: #333; font-size: 13px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #3498db; border-color: #3498db; color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-danger { color: #c0392b; border-color: #e6b0aa; }
.btn-warn { color: #b9770e; border-color: #f8c471; }
.btn-small { padding: 4px 8px; font-size: 12px; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; white-space: nowrap; }
.data-table thead th { background: #f8f9fa; font-weight: 600; }
.data-table tbody tr:hover { background: #f8fbfd; }
.row-inactive { color: #aaa; background: #fafafa; }
.actions-cell { display: flex; gap: 6px; align-items: center; }
.actions-cell form { display: inline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-green { background: #eafaf1; color: #1e8449; }
.badge-red { background: #fdecea; color: #c0392b; }
.badge-gray { background: #eee; color: #777; }

.form-card { background: #fff; border-radius: 8px; padding: 24px; max-width: 560px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.form-card select {
    width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; background: #fff;
}
.required { color: #c0392b; font-size: 11px; margin-left: 6px; }
.form-hint { font-size: 12px; color: #888; margin-top: 4px; }
.form-hint-block { background: #f8f9fa; border-radius: 4px; padding: 10px 12px; margin-bottom: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.credential-box {
    background: #fef9e7; border: 2px solid #f39c12; border-radius: 8px;
    padding: 16px; margin-bottom: 20px;
}
.credential-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.credential-table { border-collapse: collapse; font-size: 14px; }
.credential-table th { text-align: left; padding: 4px 16px 4px 0; color: #666; font-weight: normal; }
.credential-table td { padding: 4px 0; }
.credential-password {
    font-family: Consolas, Menlo, monospace; font-size: 18px; font-weight: bold;
    letter-spacing: 1px; background: #fff; padding: 2px 10px; border-radius: 4px;
}

/* ==================== ダッシュボード（スタブ） ==================== */
.stub-notice {
    background: #fef9e7;
    border: 1px solid #f7dc6f;
    border-radius: 4px;
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 20px;
}
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 24px;
    min-width: 200px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.kpi-label { font-size: 13px; color: #888; }
.kpi-value { font-size: 28px; font-weight: bold; margin-top: 6px; }
.kpi-unit { font-size: 14px; font-weight: normal; margin-left: 4px; }

/* ==================== マスタ管理（FR-016） ==================== */
.master-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.master-hub-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.master-hub-title { font-size: 15px; font-weight: bold; }
.master-hub-desc { font-size: 12px; color: #666; line-height: 1.6; flex: 1; }
.master-hub-meta { font-size: 12px; color: #888; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.master-hub-actions { margin-top: 4px; }

.master-desc { font-size: 13px; color: #666; margin-bottom: 12px; }
.master-warning {
    background: #fef9e7;
    border: 1px solid #f7dc6f;
    border-radius: 4px;
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.7;
    margin-bottom: 16px;
}
.master-warning-title { font-weight: bold; margin-bottom: 4px; }
.master-warning ul { margin-left: 18px; }
.master-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.order-input { width: 64px; padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.cell-sub { color: #aaa; font-size: 11px; margin-left: 4px; }
.form-readonly { padding: 6px 0; font-size: 14px; color: #555; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.form-card textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px;
    font-size: 14px; font-family: inherit; line-height: 1.6;
}

/* ==================== 現調帳票（FR-015） ==================== */
/* 顧客情報画面のブロック「現調帳票」と、帳票の作成モーダルで使う。
   編集画面（/field-docs）だけで使うクラスは、既存画面の流儀に合わせて
   resources/views/field-docs/index.blade.php の @push('styles') に置いている。 */
.field-docs-group { margin-bottom: 18px; }
.field-docs-group-title { font-size: .9rem; font-weight: 600; color: #34495e; margin-bottom: 6px; }
.field-docs-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.field-docs-table th, .field-docs-table td { border: 1px solid #e0e0e0; padding: 8px 10px; text-align: left; }
.field-docs-table th { background: #f5f7f9; font-weight: 600; white-space: nowrap; }
.field-docs-empty { color: #888; font-size: .9rem; padding: 10px 0; }
.field-docs-error { color: #c0392b; font-size: .9rem; padding: 10px 0; }
.field-docs-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .75rem; }
.field-docs-badge-gray { background: #eceff1; color: #555; }
.field-docs-badge-green { background: #e8f5e9; color: #2e7d32; }
.field-docs-link { color: #2980b9; text-decoration: none; margin-right: 10px; cursor: pointer; }
.field-docs-link:hover { text-decoration: underline; }

/* 帳票を作成するモーダル（顧客情報画面） */
.fd-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.5); z-index: 10001; align-items: center; justify-content: center; }
.fd-modal.open { display: flex; }
.fd-modal-dialog { background: #fff; border-radius: 8px; width: min(480px, 92vw); padding: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.fd-modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 14px; }
.fd-modal-row { margin-bottom: 14px; }
.fd-modal-row label { display: block; font-size: .85rem; color: #666; margin-bottom: 4px; }
.fd-modal-row select { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: .95rem; }
.fd-modal-note { font-size: .8rem; color: #888; line-height: 1.6; }
.fd-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* 施工指示書（床下 AB25-07 ／ 害獣 BB25-01）の入力フォーム（FR-015 WP2c で追加） */
.fd-ins-section { border: 1px solid #e3e7ea; border-radius: 6px; padding: 14px 16px; margin-bottom: 18px; }
.fd-ins-section-title { font-size: 1rem; font-weight: 600; color: #333; margin: 0 0 12px; padding-left: 8px; border-left: 4px solid #3498db; }
.fd-ins-note { font-size: .8rem; color: #777; line-height: 1.6; margin: 6px 0 12px; }
.fd-ins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; }
.fd-ins-grid-wide { grid-template-columns: 1fr; }
.fd-ins-field { display: flex; flex-direction: column; gap: 4px; }
.fd-ins-field > label { font-size: .78rem; color: #666; line-height: 1.4; }
.fd-ins-field input[type="text"], .fd-ins-field input[type="date"], .fd-ins-field input[type="number"],
.fd-ins-field select, .fd-ins-field textarea {
    width: 100%; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: .9rem; background: #fff;
}
.fd-ins-field textarea { resize: vertical; line-height: 1.5; }
.fd-ins-field input:disabled, .fd-ins-field select:disabled, .fd-ins-field textarea:disabled { background: #f2f2f2; color: #999; }
.fd-ins-inline { display: flex; align-items: center; gap: 6px; }
.fd-ins-unit { font-size: .8rem; color: #777; white-space: nowrap; }
.fd-ins-hint { font-size: .72rem; color: #999; line-height: 1.5; }
.fd-ins-auto { padding: 6px 8px; border: 1px dashed #ccc; border-radius: 4px; font-size: .9rem; color: #555; background: #fafafa; min-height: 33px; }
.fd-ins-check { font-size: .85rem; color: #555; display: flex; align-items: center; gap: 6px; }

/* 工事ブロック（×を入れると見出し1行に畳まれる。Q40(a)・ユーザー採用 2026-09-25） */
.fd-ins-block { border: 1px solid #e0e4e7; border-radius: 6px; margin-bottom: 12px; }
.fd-ins-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #f5f7f9; padding: 8px 12px; border-bottom: 1px solid #e0e4e7; border-radius: 6px 6px 0 0; }
.fd-ins-block-title { font-weight: 600; color: #333; font-size: .95rem; }
.fd-ins-block .fd-ins-grid { padding: 12px; }
.fd-ins-skip { font-size: .82rem; color: #c0392b; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.fd-ins-block.is-skipped { background: #fafafa; }
/* ×のブロックは見出しだけ残して本体を畳む（入力欄は無効のまま隠れる。×を外すと元どおり開く） */
.fd-ins-block.is-skipped > :not(.fd-ins-block-head) { display: none; }
.fd-ins-block.is-skipped .fd-ins-block-head { background: #efe3e3; border-bottom: none; border-radius: 6px; }
.fd-ins-block.is-skipped .fd-ins-block-title { color: #888; }
.fd-ins-block.is-skipped .fd-ins-block-title::after { content: '　この工事は行いません（×を外すと入力欄が開きます）'; font-weight: 400; font-size: .78rem; color: #999; }

/* 工事日程の表 */
.fd-ins-schedule { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .85rem; }
.fd-ins-schedule th, .fd-ins-schedule td { border: 1px solid #e0e0e0; padding: 6px 8px; text-align: left; }
.fd-ins-schedule th { background: #f5f7f9; font-weight: 600; white-space: nowrap; }
.fd-ins-schedule input, .fd-ins-schedule select { width: 100%; padding: 5px 6px; border: 1px solid #ccc; border-radius: 4px; font-size: .85rem; }

@media (max-width: 768px) {
    .fd-ins-grid { grid-template-columns: 1fr; }
    .fd-ins-schedule { display: block; overflow-x: auto; }
}

/* 害獣指示書（FR-015 WP3）。チェックを横に並べる箱（施工対象・脚立・必要材料・作業内容） */
.fd-pest-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.fd-pest-checks .fd-ins-check { flex: 0 0 auto; white-space: nowrap; }

/* ==================== 施工指示書の入力画面の作り直し（Q40 (b)(c)・ユーザー承認 2026-09-25） ==================== */
/* 既存の .fd-ins-* の定義は変えない（議事録でも使っているため）。ここでは新しいクラスと、指示書の中だけに効く組み合わせを足す */

/* (b) 「ラベル（幅固定・右寄せ）｜入力欄」の2列を横に2組。.fd-row は display:contents でラベルと入力を格子のセルに直接置く */
.fd-rows { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 8.5em minmax(0, 1fr); gap: 8px 10px; align-items: start; padding: 10px 12px; }
.fd-ins-section > .fd-rows { padding: 2px 0 4px; }
.fd-ins-section > .fd-rows + .fd-rows { margin-top: 8px; }
.fd-row { display: contents; }
/* ラベルは列幅を固定したまま、長いものだけ2行まで折り返す（それ以上は … で切り、title に全文） */
.fd-row-label {
    min-width: 0; text-align: right; font-size: .8rem; color: #555; line-height: 1.35; padding-top: 8px;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.fd-row-input { min-width: 0; }
.fd-row-wide > .fd-row-label { grid-column: 1; }
.fd-row-wide > .fd-row-input { grid-column: 2 / span 3; }
/* 床下指示書は PC でも1列（ラベル｜入力欄を上から下へ）。2026-09-29 ユーザー指示「左右に並んでいる（築年数の隣に坪数）のを縦に」。
   スマホ幅（768px 以下）は元から1列なので PC 幅だけ。害獣指示書・ほかの帳票は2組のまま（.fd-form-part の data-doc-type で絞る） */
@media (min-width: 769px) {
    .fd-form-part[data-doc-type="instruction_underfloor"] .fd-rows { grid-template-columns: 8.5em minmax(0, 36em); }
    .fd-form-part[data-doc-type="instruction_underfloor"] .fd-row-wide > .fd-row-input { grid-column: 2; }
    /* 2組のときに行をそろえるための空きのセルは、1列では要らない */
    .fd-form-part[data-doc-type="instruction_underfloor"] .fd-rows > .fd-row-spacer { display: none; }
}
/* 入力の高さは 34px にそろえる（select も同じ） */
.fd-row-input > input[type="text"], .fd-row-input > input[type="number"], .fd-row-input > input[type="date"],
.fd-row-input > select, .fd-row-inline > input {
    width: 100%; height: 34px; padding: 0 8px; border: 1px solid #ccc; border-radius: 4px; font-size: .9rem; background: #fff; color: #222;
}
.fd-row-input > textarea { width: 100%; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: .9rem; background: #fff; color: #222; resize: vertical; line-height: 1.5; }
.fd-row-input input:disabled, .fd-row-input select:disabled, .fd-row-input textarea:disabled { background: #f2f2f2; color: #999; }
/* 単位は入力欄の右端の中に出す（欄の幅が全部そろう）。数値のスピンボタンと重ならないよう少し内側 */
.fd-row-inline { position: relative; }
.fd-row-inline > input { padding-right: 4.2em; }
.fd-row-unit { position: absolute; right: 24px; top: 0; line-height: 34px; font-size: .78rem; color: #888; pointer-events: none; white-space: nowrap; }
.fd-row-hint { font-size: .72rem; color: #999; line-height: 1.5; margin-top: 3px; }
.fd-row-input > .fd-ins-auto { min-height: 34px; padding: 7px 8px; line-height: 1.35; }
.fd-row-input > .fd-pest-checks { min-height: 34px; align-items: center; }
.fd-row-input > .fd-ins-check { min-height: 34px; }
/* 工事ブロックの見出しに区画見出しと同じ青い縦線 */
.fd-ins-block > .fd-ins-block-head > .fd-ins-block-title { padding-left: 8px; border-left: 4px solid #3498db; line-height: 1.3; }
.fd-ins-block.is-skipped > .fd-ins-block-head > .fd-ins-block-title { border-left-color: #c8c8c8; }

/* (c) 目次（画面上部に固定。スマホ幅では固定ヘッダーの下に付くよう --fd-toc-top を JS が入れる） */
.fd-toc {
    position: sticky; top: var(--fd-toc-top, 0px); z-index: 20; background: #fff; border: 1px solid #d9dee3; border-radius: 8px;
    padding: 8px 12px; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.fd-toc-label { font-size: .75rem; color: #888; margin-right: 2px; }
.fd-toc-sep { color: #ccc; font-size: .8rem; }
.fd-toc-link { font-size: .8rem; line-height: 1.5; padding: 3px 9px; border: 1px solid #d9dee3; border-radius: 999px; background: #f5f7f9; color: #2c3e50; text-decoration: none; }
.fd-toc-link:hover { background: #e8eef3; }
.fd-toc-link.is-skipped { color: #999; text-decoration: line-through; }
.fd-toc-link.is-active { background: #3498db; border-color: #3498db; color: #fff; font-weight: 700; }
/* 飛んだとき目次の下に隠れないように（--fd-toc-space は目次の高さ＋余白。JS が入れる。無いときは 60px） */
.fd-toc-target { scroll-margin-top: calc(var(--fd-toc-top, 0px) + var(--fd-toc-space, 60px)); }

@media (max-width: 768px) {
    .fd-rows { grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; }
    .fd-row-wide > .fd-row-input { grid-column: 2; }
    .fd-row-label { -webkit-line-clamp: 3; font-size: .75rem; }
    .fd-toc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .fd-toc::-webkit-scrollbar { display: none; }
    .fd-toc-label, .fd-toc-sep, .fd-toc-link { white-space: nowrap; flex: 0 0 auto; }
}
