﻿:root {
    --page-bg: #f3f5f7;
    --surface: #ffffff;
    --primary: #154b78;
    --primary-action: #1769aa;
    --text: #263238;
    --muted: #667784;
    --border: #d5dde4;
    --danger: #b3261e;
    --content-max: 1100px;
}

/*
 * 日報Webは外出先のスマートフォン利用を主用途とするため、
 * すべての要素をborder-boxで計算し、入力欄のpaddingが画面幅を押し広げないようにします。
 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Yu Gothic UI", "Meiryo", sans-serif;
    line-height: 1.5;
}

/* ===== 共通ヘッダー ===== */
header {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px 10px;
    background: var(--primary);
    color: #fff;
}

header strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
}

header nav {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

header a,
header button {
    color: #fff;
}

header a {
    display: inline-flex;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
}

header a:hover,
header a:focus-visible {
    background: rgba(255, 255, 255, .14);
}

.logout,
.inline {
    margin: 0;
}

.logout button {
    width: 100%;
    min-height: 44px;
    padding: 8px 6px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .8);
}

/* ===== ページ本体 ===== */
main {
    width: 100%;
    max-width: var(--content-max);
    min-width: 0;
    margin: 12px auto;
    padding: 0 8px;
}

.card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 0 14px;
    padding: 14px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid #e2e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.card h1,
.card h2 {
    margin-top: 0;
    overflow-wrap: anywhere;
}

h1 {
    font-size: 1.35rem;
}

h2 {
    font-size: 1.15rem;
}

/*
 * ログイン画面は狭い端末でも左右余白を必ず残します。
 * max-widthはPC向けの上限にだけ使い、スマートフォンでは親幅100%からはみ出させません。
 */
.login {
    width: 100%;
    max-width: 430px;
    margin: 18px auto;
}

.login form {
    display: grid;
    min-width: 0;
    gap: 14px;
}

.login p {
    overflow-wrap: anywhere;
}

.login button[type="submit"] {
    width: 100%;
}

/* ===== ログイン画面 サイト更新情報 =====
 * システム更新日はログイン操作そのものではなく、現在公開されているサイトの版を
 * 利用者が確認するための補足情報なので、ログインカードの外側へ控えめに表示します。
 */
.login-status {
    margin-top: 10px;
    color: var(--muted);
    font-size: .85rem;
    line-height: 1.5;
    text-align: center;
}

/* ===== フォーム共通 ===== */
label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
}

input,
select,
textarea,
button,
.button {
    max-width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #aeb8c2;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    min-width: 0;
}

input[readonly] {
    background: #eef1f3;
    color: #49565f;
}

textarea {
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .32);
    outline-offset: 2px;
}

.primary {
    background: var(--primary-action);
    border-color: var(--primary-action);
    color: #fff;
}

.button {
    background: #fff;
}

.form-actions {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
}

.form-actions > * {
    width: 100%;
}

.grid,
.search {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

.wide {
    grid-column: auto;
}

.checks {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    margin: 18px 0;
}

.checks label {
    display: inline-flex;
    min-height: 44px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.checks input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
    margin: 0;
}

.message {
    margin-bottom: 12px;
    padding: 12px;
    overflow-wrap: anywhere;
    background: #e5f4e8;
    border: 1px solid #85bd90;
    border-radius: 6px;
}

.validation-summary,
.field-validation-error {
    max-width: 100%;
    color: var(--danger);
    overflow-wrap: anywhere;
}

.validation-summary ul {
    margin: 6px 0 0;
    padding-left: 1.25rem;
}

/* ===== 作業日報入力 ===== */
.page-title-row,
.day-summary-header {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.page-title-row h1,
.day-summary-header h2 {
    margin-bottom: 4px;
}

.page-title-row > .button,
.date-navigation {
    margin-top: 0;
    flex: 0 0 auto;
}

.page-note {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
    overflow-wrap: anywhere;
}

.report-form-grid {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
    margin-top: 16px;
}

.form-field,
.staff-field,
.date-field,
.workday-type-field,
.project-code-field,
.project-name-field,
.destination-field,
.miscellaneous-field,
.break-field,
.time-fieldset,
.work-description-field {
    min-width: 0;
    grid-column: auto;
}

.form-field small,
.workday-type-field small {
    display: block;
    max-width: 100%;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
    overflow-wrap: anywhere;
}

.date-with-weekday {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 5px;
}

/*
 * iOSではdate/time inputへ直接paddingを付けると親幅を超える場合があるため、
 * 外枠側にpaddingを持たせ、input本体はpadding 0で描画します。
 */
.date-input-frame,
.time-input-frame {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 9px 11px;
    overflow: hidden;
    border: 1px solid #aeb8c2;
    border-radius: 6px;
    background: #fff;
}

.date-input-frame input,
.time-input-frame input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 24px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.weekday-label {
    min-width: 0;
    font-weight: 700;
    white-space: normal;
}

.time-fieldset {
    width: 100%;
    margin: 0;
    padding: 10px 12px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.time-fieldset legend {
    max-width: 100%;
    padding: 0 5px;
    font-weight: 600;
}

.time-range {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
}

.time-range > span {
    text-align: center;
}

.time-errors {
    margin-top: 5px;
}

.checkbox-row {
    display: flex;
    min-width: 0;
    min-height: 44px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.checkbox-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.checkbox-row input[type="checkbox"] {
    width: 22px;
    min-height: 22px;
    margin: 0;
    flex: 0 0 auto;
}

.compact-button,
.row-button {
    min-height: 38px;
    padding: 7px 11px;
}

.date-navigation {
    display: grid;
    width: auto;
    min-width: 0;
    grid-template-columns: repeat(2, 44px);
    justify-content: end;
    gap: 6px;
}

.arrow-button {
    width: 44px !important;
    min-width: 44px;
    padding: 7px 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.date-navigation .button {
    width: 100%;
    padding-right: 5px;
    padding-left: 5px;
}

.danger-button {
    color: var(--danger);
    border-color: #d6a19d;
    background: #fff;
}

/* スマートフォンでは登録操作を画面下部に残し、長い明細を確認した後でも戻らず操作できるようにします。 */
.sticky-mobile-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 18px -14px -14px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--border);
}

/* ===== 一覧 ===== */
.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #dde3e8;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

th {
    background: #f6f8fa;
    white-space: nowrap;
}

/* 狭い画面では表をカード化し、横スクロールを基本操作にしません。 */
.responsive-table {
    min-width: 0;
}

.responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.responsive-table,
.responsive-table tbody,
.responsive-table tr,
.responsive-table td {
    display: block;
    width: 100%;
    min-width: 0;
}

.responsive-table tr {
    margin-bottom: 10px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.responsive-table td {
    display: grid;
    grid-template-columns: 6.2em minmax(0, 1fr);
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid #edf0f2;
}

.responsive-table td:last-child {
    border-bottom: 0;
}

.responsive-table td::before {
    content: attr(data-label);
    min-width: 0;
    color: var(--muted);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.responsive-table .empty-row {
    display: block;
}

.responsive-table .empty-row::before {
    content: none;
}

.row-actions {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.row-actions form {
    min-width: 0;
    margin: 0;
}

.row-actions .button,
.row-actions button {
    width: 100%;
}

/* ===== タブレット縦以上 ===== */
@media (min-width: 480px) {
    main {
        margin: 16px auto;
        padding: 0 12px;
    }

    .card {
        padding: 16px;
    }

    .login {
        margin: 30px auto;
    }

    .date-with-weekday {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
    }

    .weekday-label {
        white-space: nowrap;
    }

    .time-range {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 8px;
    }

    .form-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .checks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== タブレット ===== */
@media (min-width: 721px) {
    header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        min-height: 60px;
        padding: 10px max(16px, calc((100% - var(--content-max)) / 2));
    }

    header strong {
        white-space: nowrap;
        font-size: 1.05rem;
    }

    header nav {
        display: flex;
        width: auto;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
    }

    header a {
        padding: 8px 12px;
    }

    .logout button {
        width: auto;
    }

    main {
        margin: 22px auto;
        padding: 0 16px;
    }

    .card {
        margin-bottom: 18px;
        padding: 20px;
        border-radius: 10px;
    }

    .login {
        margin: 52px auto;
    }

    .page-title-row,
    .day-summary-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
    }

    .page-title-row > .button,
    .date-navigation {
        margin-top: 0;
    }

    .date-navigation {
        display: flex;
        width: auto;
        flex-wrap: wrap;
        gap: 7px;
    }

    .date-navigation .button {
        width: auto;
        padding-right: 11px;
        padding-left: 11px;
    }

    .report-form-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        gap: 14px 16px;
        margin-top: 18px;
    }

    .staff-field,
    .project-name-field,
    .destination-field,
    .time-fieldset,
    .work-description-field {
        grid-column: span 12;
    }

    .date-field,
    .workday-type-field,
    .project-code-field,
    .miscellaneous-field,
    .break-field {
        grid-column: span 6;
    }

    .search {
        grid-template-columns: minmax(150px, 220px) minmax(150px, 220px) auto;
        align-items: end;
    }

    .search button {
        width: auto;
    }

    .sticky-mobile-actions {
        position: static;
        margin: 18px 0 0;
        padding: 0;
        background: transparent;
        border-top: 0;
    }

    .form-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .form-actions > * {
        width: auto;
    }

    .responsive-table {
        display: table;
        min-width: 760px;
    }

    .report-items-table {
        min-width: 980px;
    }

    .responsive-table thead {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }

    .responsive-table tbody {
        display: table-row-group;
        width: auto;
    }

    .responsive-table tr {
        display: table-row;
        width: auto;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .responsive-table th {
        display: table-cell;
    }

    .responsive-table td {
        display: table-cell;
        width: auto;
        padding: 10px;
        border-bottom: 1px solid #dde3e8;
    }

    .responsive-table td::before {
        content: none;
    }

    .responsive-table .empty-row {
        display: table-cell;
    }

    .row-actions {
        display: flex;
        width: auto;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .row-actions .button,
    .row-actions button {
        width: auto;
    }
}

/* ===== PC / タブレット横 ===== */
@media (min-width: 1024px) {
    .staff-field { grid-column: span 6; }
    .date-field { grid-column: span 4; }
    .workday-type-field { grid-column: span 2; }
    .project-code-field { grid-column: span 4; }
    .project-name-field { grid-column: span 8; }
    .destination-field { grid-column: span 6; }
    .miscellaneous-field { grid-column: span 3; }
    .break-field { grid-column: span 3; align-self: end; }
    .time-fieldset { grid-column: span 6; }
    .work-description-field { grid-column: span 12; }
}

/* ===== fixed14: 日報入力のコンパクト横並び行 =====
 * スマートフォンで縦方向を使いすぎないよう、関連項目を一つの行として扱います。
 * 320px幅でも折り返さないことを優先し、各入力の余白と最小幅を個別に調整します。
 */
.compact-entry-row {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-column: auto;
    align-items: center;
    gap: 5px;
}

.inline-field-label {
    display: block;
    min-width: 0;
    margin: 0;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.date-status-row {
    grid-template-columns: auto minmax(112px, 1fr) auto 66px;
}

.compact-date-input,
.compact-time-input {
    min-height: 40px;
    padding: 7px 8px;
}

.compact-date-input input,
.compact-time-input input {
    min-height: 24px;
    font-size: 15px;
}

.date-status-row .weekday-label {
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
}

.compact-status-select {
    width: 66px;
    min-width: 66px;
    min-height: 40px;
    padding: 7px 5px;
    font-size: 15px;
}

.destination-misc-row {
    grid-template-columns: auto minmax(58px, 1fr) auto minmax(58px, .85fr);
}

.destination-misc-row input {
    min-height: 40px;
    padding: 7px 8px;
    font-size: 15px;
}

.misc-label {
    font-size: .82rem;
}

.time-break-row {
    grid-template-columns: auto minmax(68px, 1fr) auto minmax(68px, 1fr) auto auto;
}

.time-separator {
    text-align: center;
    white-space: nowrap;
}

.compact-break-check,
.compact-overtime-check {
    min-height: 40px;
    gap: 4px;
    font-size: .88rem;
    white-space: nowrap;
}

.compact-break-check input[type="checkbox"],
.compact-overtime-check input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
}

.compact-row-validation {
    grid-column: 1 / -1;
    min-width: 0;
}

.compact-row-validation:empty {
    display: none;
}

@media (max-width: 359px) {
    main {
        padding-right: 5px;
        padding-left: 5px;
    }

    .card {
        padding-right: 10px;
        padding-left: 10px;
    }

    .date-status-row,
    .destination-misc-row,
    .time-break-row {
        gap: 3px;
    }

    .date-status-row {
        grid-template-columns: auto minmax(106px, 1fr) auto 62px;
    }

    .compact-status-select {
        width: 62px;
        min-width: 62px;
        padding-right: 3px;
        padding-left: 3px;
    }

    .inline-field-label,
    .date-status-row .weekday-label {
        font-size: .82rem;
    }

    .misc-label {
        font-size: .75rem;
    }

    .destination-misc-row input,
    .compact-date-input,
    .compact-time-input {
        padding-right: 5px;
        padding-left: 5px;
    }

    .time-break-row {
        grid-template-columns: auto minmax(58px, 1fr) auto minmax(58px, 1fr) auto auto;
    }

    .compact-break-check,
    .compact-overtime-check {
        gap: 2px;
        font-size: .76rem;
    }

    .compact-break-check input[type="checkbox"],
    .compact-overtime-check input[type="checkbox"] {
        width: 18px;
        min-height: 18px;
    }
}

@media (min-width: 721px) {
    .compact-entry-row {
        grid-column: span 12;
        gap: 8px;
    }

    .date-status-row {
        grid-template-columns: auto 190px auto 80px;
        justify-content: start;
    }

    .destination-misc-row {
        grid-template-columns: auto minmax(100px, 190px) auto minmax(100px, 150px);
        justify-content: start;
    }

    .time-break-row {
        grid-template-columns: auto 120px auto 120px auto auto;
        justify-content: start;
    }

    .compact-status-select {
        width: 80px;
        min-width: 80px;
    }
}

/* fixed14では複合行へ置き換えたため、旧個別フィールドのPC配置指定は適用対象外です。 */


/* 日報一覧の検索期間は、スマートフォンでも開始日～終了日～検索を1行に保つ。 */
.list-period-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.list-date-control {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border-color, #cfd5dc);
    border-radius: 6px;
    background: #fff;
    padding: 5px 6px;
}

.list-date-control input[type="date"] {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 16px;
    line-height: 1.4;
}

.period-separator {
    white-space: nowrap;
    text-align: center;
}

.list-search-button {
    width: auto;
    min-width: 52px;
    padding-left: 9px;
    padding-right: 9px;
    white-space: nowrap;
}

@media (max-width: 359px) {
    .list-period-row {
        gap: 2px;
    }

    .list-date-control {
        padding-left: 2px;
        padding-right: 2px;
    }

    .list-search-button {
        min-width: 46px;
        padding-left: 5px;
        padding-right: 5px;
    }
}

.report-entry-card {
    overflow: visible;
}

/* ===== fixed18: モバイル共通オートコンプリート =====
 * datalistのブラウザー差異を避け、候補を通常レイアウトの外側へ重ねて表示します。
 * 候補が開いても日報入力欄や隣接項目の配置を動かさないことが目的です。
 */
.autocomplete-host {
    position: relative;
    width: 100%;
    min-width: 0;
}

.compact-autocomplete-host {
    min-width: 0;
}

.autocomplete-popup {
    position: absolute;
    z-index: 3000;
    top: calc(100% + 2px);
    left: 0;
    display: none;
    width: max-content;
    min-width: 100%;
    max-width: min(92vw, 560px);
    max-height: min(320px, 45vh);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    background: #fff;
    border: 1px solid #aeb8c2;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

.autocomplete-popup.is-open {
    display: block;
}

.autocomplete-option {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    margin: 0;
    padding: 10px 12px;
    overflow: hidden;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #e2e7eb;
    border-radius: 0;
    color: var(--text);
    font-size: 16px;
    line-height: 1.35;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.autocomplete-option:last-child {
    border-bottom: 0;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible,
.autocomplete-option:active {
    background: #eef5fb;
}

/* 行先は雑工伝票No.と同じ行にあるため、候補幅は入力欄を基準にしつつ画面外へ出さないようにします。 */
.destination-misc-row .autocomplete-popup {
    width: max(100%, 150px);
    max-width: min(78vw, 280px);
}

@media (max-width: 430px) {
    .autocomplete-popup {
        max-width: calc(100vw - 24px);
    }

    .project-code-field .autocomplete-popup,
    .work-description-field .autocomplete-popup {
        width: 100%;
    }
}


/* ===== スマホ・タブレットのホーム画面起動（standalone） =====
 * ブラウザのアドレスバーが無い状態でもノッチやホームインジケータと重ならないよう、
 * OSが提供するsafe-area分だけ余白を確保します。通常のPC表示には影響しません。
 */
html.app-standalone body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

html.app-standalone header {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
}

html.app-standalone main {
    margin-top: 8px;
    margin-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}


/* ===== Android通常ブラウザ用コンパクト表示 =====
 * 社内テスト時は証明書事情によりAndroidをPWAインストールできない場合があるため、
 * Android Chromeの通常タブだけ余白を縮めて日報入力領域を広く使います。
 * iPhone/iPad・デスクトップPC・standalone起動時には適用しません。
 */
html.android-browser-compact body {
    background: var(--surface);
}

html.android-browser-compact header {
    gap: 2px;
    padding-top: 4px;
    padding-bottom: 4px;
}

html.android-browser-compact header strong {
    font-size: .9rem;
    line-height: 1.25;
}

html.android-browser-compact header a,
html.android-browser-compact header button {
    min-height: 36px;
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: .9rem;
}

html.android-browser-compact main {
    margin-top: 4px;
    margin-bottom: 4px;
    padding-right: 4px;
    padding-left: 4px;
}

html.android-browser-compact .card {
    margin-bottom: 6px;
    padding: 8px;
    border-radius: 4px;
    box-shadow: none;
}

html.android-browser-compact .card h1,
html.android-browser-compact .card h2 {
    margin-bottom: 6px;
}

html.android-browser-compact h1 {
    font-size: 1.15rem;
}

html.android-browser-compact h2 {
    font-size: 1.05rem;
}

html.android-browser-compact .report-form-grid {
    gap: 8px;
    margin-top: 8px;
}

html.android-browser-compact .form-actions {
    margin-top: 8px;
}

html.android-browser-compact .sticky-mobile-actions {
    margin-right: -8px;
    margin-bottom: -8px;
    margin-left: -8px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

html.android-browser-compact .message {
    margin-bottom: 6px;
    padding: 8px;
}

html.android-browser-compact .responsive-table tr {
    margin-bottom: 6px;
    padding: 6px 8px;
}

html.android-browser-compact .responsive-table td {
    padding: 5px 0;
}

/* タブレット幅でもAndroid通常ブラウザ時はPC向けの大きな余白へ戻さないよう上書きします。 */
@media (min-width: 721px) {
    html.android-browser-compact header {
        min-height: 44px;
        padding: 4px 8px;
    }

    html.android-browser-compact main {
        margin: 6px auto;
        padding: 0 6px;
    }

    html.android-browser-compact .card {
        margin-bottom: 8px;
        padding: 10px;
        border-radius: 6px;
    }

    html.android-browser-compact .report-form-grid {
        gap: 8px 10px;
        margin-top: 10px;
    }
}

/* ===== 端末記憶型 6テーマ =====
 * 新GT-PRO本体と同じ感覚で色調を選べるよう、業務画面の意味色をCSS変数へ集約します。
 * 配置寸法は既存のレスポンシブ設計を維持し、テーマ変更で操作位置が変わらないようにします。
 */
html[data-theme="blue"] { --page-bg:#eef5fb; --surface:#fff; --primary:#155d91; --primary-action:#1769aa; --accent:#2b7bbb; --label:#154b78; --input-bg:#fbfdff; --input-border:#8fb4d1; --focus:#1769aa; --soft:#eaf4fb; --text:#24323d; --muted:#617481; --border:#cfdae3; --shadow:rgba(21,75,120,.13); }
html[data-theme="green"] { --page-bg:#edf7f1; --surface:#fff; --primary:#28684e; --primary-action:#2e7d5b; --accent:#41966f; --label:#255f49; --input-bg:#fbfffc; --input-border:#8dbca5; --focus:#2e7d5b; --soft:#e6f5ed; --text:#26372f; --muted:#61766b; --border:#cfdfd6; --shadow:rgba(40,104,78,.13); }
html[data-theme="purple"] { --page-bg:#f4f0fa; --surface:#fff; --primary:#63468f; --primary-action:#7354a6; --accent:#8c6cba; --label:#5e4386; --input-bg:#fdfbff; --input-border:#ad9ac8; --focus:#7354a6; --soft:#f0e9f8; --text:#302b38; --muted:#736a7d; --border:#ddd3e8; --shadow:rgba(99,70,143,.14); }
html[data-theme="orange"] { --page-bg:#fff8e8; --surface:#fff; --primary:#c96d10; --primary-action:#f08a1a; --accent:#ffad33; --label:#ad5b0b; --input-bg:#fffdf7; --input-border:#e4ad61; --focus:#f08a1a; --soft:#fff1cf; --text:#3d3122; --muted:#7d6a52; --border:#efd7ad; --shadow:rgba(201,109,16,.15); }
html[data-theme="pink"] { --page-bg:#fff8fb; --surface:#fffefe; --primary:#c24f7f; --primary-action:#e16098; --accent:#f08ab3; --label:#9b365f; --input-bg:#ffffff; --input-border:#efb7cc; --focus:#e16098; --soft:#fff0f6; --text:#432b35; --muted:#7a5d69; --border:#f4d7e3; --shadow:rgba(194,79,127,.10); }
html[data-theme="dark"] { --page-bg:#141a22; --surface:#202936; --primary:#18212c; --primary-action:#4f8fca; --accent:#72a9d8; --label:#a9d3f3; --input-bg:#293544; --input-border:#61778b; --focus:#74b7ec; --soft:#263849; --text:#edf4f8; --muted:#b4c0c9; --border:#465666; --shadow:rgba(0,0,0,.30); }

body { transition: background-color .16s ease, color .16s ease; }
.card { border-color:var(--border); box-shadow:0 3px 12px var(--shadow); }
label, .inline-field-label, .time-fieldset legend { color:var(--label); font-weight:700; letter-spacing:.01em; }
input, select, textarea, .date-input-frame, .time-input-frame { background:var(--input-bg); border-color:var(--input-border); }
input:focus, select:focus, textarea:focus, .date-input-frame:focus-within, .time-input-frame:focus-within { border-color:var(--focus); box-shadow:0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
input[readonly] { background:var(--soft); color:var(--muted); }
.button { background:var(--surface); border-color:var(--input-border); color:var(--text); }
.autocomplete-popup { background:var(--surface); border-color:var(--input-border); box-shadow:0 7px 18px var(--shadow); }
.autocomplete-option { background:var(--surface); color:var(--text); border-bottom-color:var(--border); }
.autocomplete-option:hover, .autocomplete-option:focus-visible, .autocomplete-option:active { background:var(--soft); }

.header-top-row { display:flex; align-items:center; justify-content:space-between; min-width:0; gap:8px; }
.app-title { flex:1 1 auto; }
.header-tools { position:relative; display:flex; align-items:center; gap:7px; flex:0 0 auto; }
.user-chip { display:flex; align-items:center; gap:6px; min-width:0; max-width:min(54vw, 360px); }
.user-avatar { display:inline-flex; width:34px; height:34px; flex:0 0 34px; align-items:center; justify-content:center; overflow:hidden; border:2px solid rgba(255,255,255,.82); border-radius:50%; background:rgba(255,255,255,.18); color:#fff; font-weight:800; font-size:.9rem; }
/* 担当者名と部課名は業務上の確認情報なので省略記号にせず、狭い端末では折り返して全表示します。 */
.user-name { max-width:320px; overflow:visible; color:#fff; font-size:.85rem; font-weight:700; line-height:1.2; white-space:normal; overflow-wrap:anywhere; text-align:right; }
.theme-picker { position:relative; }
.theme-trigger { width:36px; min-width:36px; min-height:36px; padding:0; border:1px solid rgba(255,255,255,.65); border-radius:50%; background:rgba(255,255,255,.12); color:#fff; font-size:1rem; }
.theme-menu { position:absolute; z-index:3000; top:42px; right:0; display:none; width:154px; padding:6px; background:var(--surface); border:1px solid var(--border); border-radius:10px; box-shadow:0 8px 24px var(--shadow); }
.theme-menu.is-open { display:grid; gap:3px; }
.theme-menu button { display:flex; width:100%; min-height:38px; align-items:center; justify-content:flex-start; gap:8px; padding:6px 8px; border:0; border-radius:7px; background:transparent; color:var(--text); font-size:.9rem; }
.theme-menu button:hover, .theme-menu button:focus-visible, .theme-menu button.is-selected { background:var(--soft); font-weight:700; }
.theme-dot { width:16px; height:16px; flex:0 0 16px; border:2px solid rgba(255,255,255,.85); border-radius:50%; box-shadow:0 0 0 1px #8c98a2; }
.theme-dot-blue{background:#1769aa}.theme-dot-green{background:#2e7d5b}.theme-dot-purple{background:#7354a6}.theme-dot-orange{background:#f08a1a}.theme-dot-pink{background:#e16098}.theme-dot-dark{background:#202936}

html[data-theme="dark"] .message { background:#243d30; border-color:#47795b; color:#e7f6eb; }
html[data-theme="dark"] .danger-button { color:#ffd1cd; }
html[data-theme="dark"].android-browser-compact body { background:var(--page-bg); }

@media (max-width:600px) {
    /*
     * fixed28: スマホでもタイトルと利用者情報を1行に収めることを優先します。
     * space-betweenで中央に大きな空白を作らず、右側だけmargin-left:autoで寄せます。
     */
    header { padding-left:6px; padding-right:6px; }
    .header-top-row { flex-wrap:nowrap; align-items:center; justify-content:flex-start; gap:4px; }
    .app-title { flex:0 1 auto; min-width:0; white-space:nowrap; font-size:.92rem; line-height:1.1; }
    .header-tools { flex:0 1 auto; min-width:0; margin-left:auto; justify-content:flex-end; gap:3px; }
    .theme-trigger { width:30px; min-width:30px; min-height:30px; font-size:.85rem; }
    .user-chip { flex:0 1 auto; min-width:0; max-width:none; gap:3px; }
    .user-avatar { width:30px; height:30px; flex-basis:30px; }
    .user-name { display:block; max-width:none; min-width:0; white-space:nowrap; overflow:visible; overflow-wrap:normal; font-size:.76rem; line-height:1.1; text-align:right; }
    .theme-menu { right:0; }
}

@media (max-width:360px) {
    /* 極端に狭い端末だけは情報を欠落させないことを優先し、利用者名側の折返しを許可します。 */
    .app-title { font-size:.86rem; }
    .theme-trigger { width:28px; min-width:28px; min-height:28px; }
    .user-avatar { width:28px; height:28px; flex-basis:28px; }
    .user-name { white-space:normal; overflow-wrap:anywhere; font-size:.72rem; }
}


/* ===== fixed25: メインGT-PRO連携アバター / ダークテーマ視認性補正 =====
 * アバターはメインGT-PROと同じTANTO.TA_IMGを参照します。未登録時だけ頭文字を表示します。
 * ダークテーマでは固定の白背景を残さず、操作ボタン・登録済み明細のコントラストを十分に確保します。
 */
.user-avatar { position:relative; }
.user-avatar-image {
    display:block;
    width:100%;
    height:100%;
    border-radius:50%;
    object-fit:cover;
}
.user-avatar-fallback {
    display:flex;
    position:absolute;
    inset:0;
    align-items:center;
    justify-content:center;
}
.user-avatar.has-avatar .user-avatar-fallback { display:none; }

html[data-theme="dark"] {
    --surface:#202936;
    --soft:#2b3948;
    --text:#f5f8fb;
    --muted:#d9e3eb;
    --label:#d6edff;
    --border:#5e7182;
    --input-border:#748a9d;
}

/* モバイルで固定表示する操作領域だけが白い帯にならないよう、周囲と同じダーク面へ統一します。 */
html[data-theme="dark"] .sticky-mobile-actions {
    background:var(--surface);
    border-top-color:var(--border);
}

/* ダーク時は追加・更新・入力取消を白抜き枠で統一し、操作領域だけ明るく浮く状態を避けます。 */
html[data-theme="dark"] .form-actions .primary,
html[data-theme="dark"] .form-actions .button {
    background:transparent;
    border-color:#eef5fa;
    color:#ffffff;
}
html[data-theme="dark"] .form-actions .primary:hover,
html[data-theme="dark"] .form-actions .primary:focus-visible,
html[data-theme="dark"] .form-actions .button:hover,
html[data-theme="dark"] .form-actions .button:focus-visible {
    background:#304255;
    border-color:#ffffff;
    color:#ffffff;
}

/* 登録済み明細はカード背景・項目名・内容をそれぞれ十分な明度差で表示します。 */
html[data-theme="dark"] .responsive-table tr {
    background:#263240;
    border-color:#63778a;
    color:#f7fafc;
}
html[data-theme="dark"] .responsive-table td {
    border-bottom-color:#46596a;
    color:#f7fafc;
}
html[data-theme="dark"] .responsive-table td::before {
    color:#cfe8fa;
    font-weight:700;
}
html[data-theme="dark"] th {
    background:#2c3948;
    color:#e8f4fc;
}
html[data-theme="dark"] th,
html[data-theme="dark"] td {
    border-bottom-color:#526679;
}
html[data-theme="dark"] .empty-row { color:#d9e3eb; }
html[data-theme="dark"] .row-actions .button {
    background:transparent;
    border-color:#a9c3d7;
    color:#f5f8fb;
}
html[data-theme="dark"] .danger-button {
    background:transparent;
    border-color:#e5a6a1;
    color:#ffd9d5;
}
html[data-theme="dark"] input[readonly] {
    background:#263747;
    color:#e4edf4;
}

/* ===== fixed29: ダークテーマの日付入力可読性補正 =====
 * 日報一覧の期間指定は外枠が固定白背景だったため、ダークテーマ時だけ入力面・文字・
 * カレンダーUIまでOSのダーク配色へ揃えます。日付値は業務上の重要情報なので、
 * 薄い補助色ではなく通常本文と同等のコントラストを確保します。
 */
html[data-theme="dark"] .list-date-control {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text);
}

html[data-theme="dark"] .list-date-control:focus-within {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(116, 183, 236, .18);
}

html[data-theme="dark"] .list-date-control input[type="date"] {
    background: transparent;
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    opacity: 1;
    color-scheme: dark;
    caret-color: var(--text);
}

/* Chromium / Android / Safari系のネイティブ日付部品も暗色UIとして描画させます。 */
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit,
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit-text,
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit-month-field,
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit-day-field,
html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-datetime-edit-year-field {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
}

html[data-theme="dark"] .list-date-control input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: .95;
    cursor: pointer;
}

/* ダークテーマの全入力欄で文字色がブラウザー既定値へ戻らないよう統一します。 */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #aebbc6;
    -webkit-text-fill-color: #aebbc6;
    opacity: 1;
}

/* ===== fixed30: PC入力レイアウトの行構成調整 =====
 * 日報はモバイル利用が中心ですが、PC入力時に「作業者」と「日付」が別行になると
 * 視線移動が増えて入力状況を把握しづらいため、PC幅では必ず同一行に配置します。
 * 受注番号と工事名は、横幅が十分なPCでは同一行、タブレット等で横幅が不足する場合は
 * 受注番号を上段・工事名を下段に明示的に分け、中途半端な折返しを避けます。
 */
@media (min-width: 721px) and (max-width: 1023px) {
    .project-code-field,
    .project-name-field {
        grid-column: span 12;
    }
}

@media (min-width: 1024px) {
    /* 作業者と日付・曜日・平休日を1行で完結させる。 */
    .staff-field {
        grid-column: span 5;
    }

    .date-status-row {
        grid-column: span 7;
        align-self: end;
    }

    /* 受注番号は短く、工事名へ広い領域を割り当てて1行にまとめる。 */
    .project-code-field {
        grid-column: span 4;
    }

    .project-name-field {
        grid-column: span 8;
    }
}

/* ===== fixed31: ダークテーマ ログイン入力欄の視認性補正 =====
 * ログインID/パスワードはブラウザーの自動入力（autofill）の影響を強く受けます。
 * Chrome/Safari/Edgeが自動入力時に白背景を強制しても、ダークテーマの入力面と
 * 明るい文字色を維持し、認証情報が確実に読めるようにします。
 */
html[data-theme="dark"] .login input[type="text"],
html[data-theme="dark"] .login input[type="password"] {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text) !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
    opacity: 1;
    color-scheme: dark;
}

html[data-theme="dark"] .login input[type="text"]:focus,
html[data-theme="dark"] .login input[type="password"]:focus {
    background-color: var(--input-bg) !important;
    border-color: var(--focus) !important;
    color: var(--text) !important;
    -webkit-text-fill-color: var(--text) !important;
    box-shadow: 0 0 0 3px rgba(116, 183, 236, .20);
}

/* Chromium / Android Chrome / Safari / Edge のパスワード保存・自動入力時の白背景を抑止。 */
html[data-theme="dark"] .login input:-webkit-autofill,
html[data-theme="dark"] .login input:-webkit-autofill:hover,
html[data-theme="dark"] .login input:-webkit-autofill:focus,
html[data-theme="dark"] .login input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
    box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
    border-color: var(--input-border) !important;
    transition: background-color 9999s ease-out 0s;
}

/* Firefox系の自動入力にも同じコントラストを適用します。 */
html[data-theme="dark"] .login input:autofill {
    background-color: var(--input-bg) !important;
    color: var(--text) !important;
    -webkit-text-fill-color: var(--text) !important;
    box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
}

/* ログイン画面のラベル・説明文もダーク面で十分な明度を確保します。 */
html[data-theme="dark"] .login label {
    color: var(--label);
}

html[data-theme="dark"] .login p {
    color: var(--muted);
}

html[data-theme="dark"] .login .field-validation-error,
html[data-theme="dark"] .login .validation-summary-errors {
    color: #ffb4b4;
}


/* ===== fixed32: 日報一覧 日付・担当者列の改行禁止 =====
 * PC/タブレットの表表示では、日付と担当者が2行に割れると行の対応関係を追いにくくなるため、
 * この2列だけは常に1行表示に固定します。その他の列は内容に応じて折返し可能です。
 */
@media (min-width: 721px) {
    .report-list-table th.report-date-column,
    .report-list-table td.report-date-column,
    .report-list-table th.report-staff-column,
    .report-list-table td.report-staff-column {
        white-space: nowrap;
        word-break: keep-all;
        overflow-wrap: normal;
    }

    .report-list-table th.report-date-column,
    .report-list-table td.report-date-column {
        min-width: 108px;
    }

    .report-list-table th.report-staff-column,
    .report-list-table td.report-staff-column {
        min-width: 120px;
    }
}


/* ===== fixed33: 日報一覧 日付・担当者列の実テーブル改修 =====
 * fixed32では存在しない.report-list-tableを前提にしたため指定が効いていませんでした。
 * Index.cshtmlの一覧テーブルへreport-list-tableを明示し、日付と担当者は必ず1行表示に固定します。
 * 表全体はtable-wrapで横スクロール可能なため、列幅不足時もこの2列を折り返して詰め込みません。
 */
@media (min-width: 721px) {
    table.report-list-table th.report-date-column,
    table.report-list-table td.report-date-column,
    table.report-list-table th.report-staff-column,
    table.report-list-table td.report-staff-column {
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    table.report-list-table th.report-date-column,
    table.report-list-table td.report-date-column {
        width: 1%;
        min-width: 72px;
    }

    table.report-list-table th.report-staff-column,
    table.report-list-table td.report-staff-column {
        width: 1%;
        min-width: 120px;
    }
}

/* ===== fixed35: 日報一覧 カレンダー表示 =====
 * 一覧検索を残したまま、過去日報を月単位で探せるカレンダーモードを追加します。
 * 日報がある日だけタップ可能にし、詳細は画面を遷移せずボトムシートで確認します。
 */
.report-list-title-row {
    align-items: center;
}

.report-view-switch {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--soft);
}

.report-view-tab {
    min-height: 36px;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: .9rem;
    font-weight: 700;
}

/* 日報カレンダーの方向切替は見出しの直後に置き、説明文を増やさず記号だけで操作できるようにします。 */
.calendar-title-tools {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}

.calendar-title-tools h1 {
    margin-bottom: 4px;
}

.calendar-scroll-direction {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 4px;
}

.calendar-direction-button {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 4px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
}

.calendar-direction-button.is-active {
    background: var(--primary-action);
    border-color: var(--primary-action);
    color: #fff;
    box-shadow: 0 2px 5px var(--shadow);
}

/* 当月復帰は方向切替とは別操作なので、アイコン群との間に余白を設けて誤操作を避けます。 */
.calendar-current-month-button {
    min-height: 36px;
    margin-left: 8px;
    padding: 4px 12px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    line-height: 1;
}

.calendar-current-month-button:hover,
.calendar-current-month-button:focus-visible {
    border-color: var(--primary-action);
    color: var(--primary-action);
}

.report-view-tab.is-active {
    background: var(--primary-action);
    color: #fff;
    box-shadow: 0 2px 5px var(--shadow);
}

.report-view-panel[hidden],
.day-detail-overlay[hidden] {
    display: none !important;
}

.report-calendar-panel {
    width: 100%;
}

.calendar-card {
    overflow: visible;
}

/* 月DOMは常に「過去 → 現在」の順に保持します。表示方向だけをCSSで切り替えます。 */
.calendar-months {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 14px;
}

.calendar-card[data-scroll-direction="horizontal"] .calendar-months {
    width: max-content;
    min-width: 100%;
    flex-direction: row;
    align-items: flex-start;
}

.calendar-card[data-scroll-direction="horizontal"] .calendar-month {
    width: min(420px, calc(100vw - 52px));
    min-width: min(420px, calc(100vw - 52px));
    scroll-snap-align: center;
}

.calendar-month {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.calendar-month-title {
    margin: 0 0 8px;
    color: var(--label);
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
}

.calendar-weekday {
    padding: 3px 0 5px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
    text-align: center;
}

.calendar-weekday.sunday {
    color: #d65a5a;
}

.calendar-weekday.saturday {
    color: #4d79bb;
}

.calendar-day {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 50px;
    padding: 5px 2px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: .88rem;
}

.calendar-day:disabled {
    cursor: default;
    opacity: .75;
}

.calendar-day.is-empty {
    min-height: 50px;
}

.calendar-day.is-today {
    border-color: var(--focus);
}

/* 曜日見出しと日付の色を揃え、カレンダーを見ただけで休日区分を判断できるようにします。 */
.calendar-day.is-sunday .calendar-day-number,
.calendar-day.is-holiday .calendar-day-number {
    color: #d65a5a;
}

.calendar-day.is-saturday:not(.is-holiday) .calendar-day-number {
    color: #4d79bb;
}

/* 祝日は日曜と同じ赤を優先します。祝日名はtitle/aria-labelで確認できるため、セル内には追加表示しません。 */
.calendar-day.is-holiday .calendar-day-number {
    font-weight: 800;
}

.calendar-day.has-report {
    cursor: pointer;
    background: var(--soft);
    border-color: var(--input-border);
    color: var(--text);
}

/* 未登録日も日報入力の起点として操作できることを、無効状態に見せず自然に示します。
 * 登録済み日の強調は維持し、未登録日は通常背景のままクリック可能にします。 */
.calendar-day.is-unregistered {
    cursor: pointer;
}

.calendar-day.is-unregistered:active,
.calendar-day.is-unregistered:focus-visible,
.calendar-day.has-report:active,
.calendar-day.has-report:focus-visible {
    border-color: var(--focus);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 20%, transparent);
}

.calendar-day-number {
    font-weight: 800;
}

.calendar-report-marker {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-action);
}

.calendar-report-count {
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1;
}

.calendar-loading {
    padding: 12px;
    color: var(--muted);
    text-align: center;
}

.calendar-load-button {
    width: 100%;
    margin: 0 0 12px;
}

/* 詳細はスマホでは下から出るボトムシート、PCでは中央モーダルとして表示します。 */
.day-detail-overlay {
    position: fixed;
    z-index: 5000;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.day-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .48);
}

.day-detail-sheet {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: min(78vh, 720px);
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, .28);
}

.day-detail-header {
    display: flex;
    min-height: 48px;
    padding: 9px 12px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--soft);
}

.day-detail-header h2 {
    margin: 0;
    color: var(--label);
    font-size: 1rem;
}

.day-detail-close {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border-color: var(--input-border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.3rem;
    line-height: 1;
}

.day-detail-body {
    max-height: calc(min(78vh, 720px) - 50px);
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.day-detail-item {
    display: block;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 9px;
    background: var(--input-bg);
    color: var(--text);
    text-decoration: none;
}

.day-detail-item:active,
.day-detail-item:focus-visible {
    border-color: var(--focus);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 18%, transparent);
}

.day-detail-time {
    font-weight: 800;
}

.day-detail-actual {
    margin-left: 5px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
}

.day-detail-project {
    margin-top: 5px;
    color: var(--label);
    font-weight: 800;
}

.day-detail-work {
    margin-top: 4px;
    font-weight: 700;
}

.day-detail-sub {
    margin-top: 3px;
    color: var(--muted);
    font-size: .84rem;
}

.day-detail-loading,
.day-detail-empty {
    padding: 20px 8px;
    color: var(--muted);
    text-align: center;
}

html.day-detail-open {
    overflow: hidden;
}

@media (min-width: 721px) {
    .calendar-card[data-scroll-direction="horizontal"] .calendar-month {
        width: 390px;
        min-width: 390px;
    }

    .calendar-day {
        min-height: 58px;
    }

    .day-detail-overlay {
        align-items: center;
        padding: 20px;
    }

    .day-detail-sheet {
        width: min(680px, 90vw);
        border-radius: 14px;
    }
}

@media (min-width: 1180px) {
    .calendar-card[data-scroll-direction="horizontal"] .calendar-month {
        width: 360px;
        min-width: 360px;
    }
}

html[data-theme="dark"] .calendar-weekday.sunday {
    color: #ff9d9d;
}

html[data-theme="dark"] .calendar-weekday.saturday {
    color: #9fc3ff;
}

html[data-theme="dark"] .calendar-day.has-report,
html[data-theme="dark"] .day-detail-item {
    background: var(--input-bg);
    color: var(--text);
}

/* ===== fixed36: カレンダー詳細を重ね表示 + 前後日報ナビゲーション =====
 * 詳細表示のためにページ下端までスクロールさせないよう、スマホを含む全端末で
 * 現在のカレンダーの上へ固定モーダルとして重ねます。
 * 左右矢印は「前日/翌日」ではなく、日報が実際に存在する直近の日付へ移動します。
 */
.day-detail-overlay {
    align-items: center;
    padding: max(8px, env(safe-area-inset-top, 0px))
             max(8px, env(safe-area-inset-right, 0px))
             max(8px, env(safe-area-inset-bottom, 0px))
             max(8px, env(safe-area-inset-left, 0px));
}

.day-detail-sheet {
    width: min(680px, calc(100vw - 16px));
    max-height: min(82dvh, 720px);
    padding-bottom: 0;
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .34);
}

.day-detail-header {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px 38px;
    gap: 5px;
    padding: 7px 8px;
}

.day-detail-header h2 {
    min-width: 0;
    align-self: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-detail-nav,
.day-detail-close {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
}

.day-detail-nav {
    border-color: var(--input-border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 800;
}

.day-detail-nav:not(:disabled):active,
.day-detail-nav:not(:disabled):focus-visible {
    border-color: var(--focus);
    color: var(--focus);
}

.day-detail-nav:disabled {
    cursor: default;
    opacity: .28;
}

.day-detail-body {
    max-height: calc(min(82dvh, 720px) - 54px);
}

/* Androidの通常ブラウザでもモーダルはビューポート中央に固定し、
 * ブラウザUIの高さによって画面外へ押し出されないようdvhを優先します。 */
html.android-browser-compact .day-detail-sheet {
    max-height: min(80dvh, 680px);
}

html.android-browser-compact .day-detail-body {
    max-height: calc(min(80dvh, 680px) - 54px);
}

@media (max-width: 430px) {
    .day-detail-sheet {
        width: calc(100vw - 12px);
        border-radius: 12px;
    }

    .day-detail-header {
        grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
        gap: 3px;
        padding: 6px;
    }

    .day-detail-nav,
    .day-detail-close {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .day-detail-header h2 {
        font-size: .9rem;
    }
}


/* ===== fixed37: 一覧/入力ワークスペース高速切替 =====
 * 一覧DOMを破棄せず入力画面を同一ページ内iframeに保持し、過去月のスクロール位置や
 * カレンダー状態を残したまま編集画面へ切り替えます。同時表示はせず、操作対象だけを表示します。
 */
.daily-workspace-panel[hidden] { display:none !important; }
.daily-edit-workspace { width:100%; }
.edit-workspace-card { padding: 8px; overflow:hidden; }
.edit-workspace-toolbar { display:flex; justify-content:flex-start; margin-bottom:6px; }
.daily-edit-frame {
    display:block;
    width:100%;
    height:calc(100dvh - 150px);
    min-height:620px;
    border:0;
    border-radius:8px;
    background:var(--page-bg);
}
.list-edit-button { min-width:58px; min-height:34px; padding:5px 8px; }
.report-list-title-row { flex-wrap:wrap; justify-content:flex-start; }
.report-list-title-row h1 { margin-right:auto; }
@media (max-width:720px) {
    .report-list-title-row { gap:6px; }
    .report-view-switch { font-size:.82rem; }
    .report-view-tab { min-height:34px; padding:5px 7px; }
    .daily-edit-frame { height:calc(100dvh - 118px); min-height:520px; }
    .edit-workspace-card { padding:4px; }
}


/* ===== fixed38: ナビゲーション簡素化 + カレンダー明示編集 =====
 * 利用者へ見せる主操作はヘッダーの「入力」「一覧」「ログアウト」に限定します。
 * 内部の一覧/入力ワークスペースは高速切替のためだけに残し、重複したタブは表示しません。
 */
.main-nav-link.is-active {
    border-color: rgba(255, 255, 255, .92);
    background: rgba(255, 255, 255, .22);
    color: #fff;
    font-weight: 800;
}

/* カレンダー詳細は閲覧領域と編集操作を分離し、カード全体を誤タップして編集へ入らないようにします。 */
.day-detail-item {
    cursor: default;
}

.day-detail-actions {
    display: flex;
    margin-top: 9px;
    justify-content: flex-end;
}

.day-detail-edit-button {
    width: auto;
    min-width: 72px;
    min-height: 38px;
    padding: 6px 14px;
    font-weight: 800;
}

@media (max-width: 430px) {
    .day-detail-edit-button {
        min-width: 82px;
        min-height: 40px;
    }
}

/* ===== fixed40: 入力画面レイアウト統一 =====
 * 一覧からの編集もログイン直後と同じEdit.cshtml/CSSで描画します。
 * iframeが親mainの内幅でmedia query判定されるとスマホ/PCの配置が変わるため、
 * iframeのviewport幅を実ブラウザ幅へ合わせ、外側の二重カード・余白を除去します。
 */
.daily-edit-workspace {
    position: relative;
    left: 50%;
    width: 100vw;
    max-width: none;
    margin-left: -50vw;
}

.edit-workspace-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.daily-edit-frame {
    display: block;
    width: 100vw;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--page-bg);
}

/* iframe内では親画面側に共通ヘッダーが既に存在するため、子ヘッダーだけ非表示にします。
 * main/card/formの寸法は直接表示時から変更しません。
 */
html.embedded-daily-edit header.app-header {
    display: none !important;
}

/* iPhoneのsafe-areaやAndroidコンパクト表示も子画面自身の既存CSSに任せ、
 * 入力欄の幅・行構成が直接表示時と同じになるようにします。
 */
@media (max-width: 720px) {
    .daily-edit-workspace {
        left: 50%;
        width: 100vw;
        margin-left: -50vw;
    }

    .edit-workspace-card {
        padding: 0;
    }

    .daily-edit-frame {
        width: 100vw;
    }
}

/* ===== fixed41: カレンダー詳細高速化 + 明るいピンク =====
 * 矢印移動時は前後日の詳細を先読みするため、通常はキャッシュから即座に切り替わります。
 * ピンクは文字のコントラストを保ちつつ、ページ・カード・補助面を明るい淡色へ変更します。
 */
html[data-theme="pink"] body {
    background: var(--page-bg);
}

html[data-theme="pink"] .card,
html[data-theme="pink"] .calendar-month,
html[data-theme="pink"] .day-detail-sheet {
    background: var(--surface);
}

html[data-theme="pink"] .calendar-day.has-report,
html[data-theme="pink"] .day-detail-item {
    background: var(--soft);
}

html[data-theme="pink"] input,
html[data-theme="pink"] select,
html[data-theme="pink"] textarea,
html[data-theme="pink"] .date-input-frame,
html[data-theme="pink"] .time-input-frame,
html[data-theme="pink"] .list-date-control {
    background: var(--input-bg);
    color: var(--text);
}


/* ===== fixed42: カレンダー専用表示 + 詳細先行表示 =====
 * 旧一覧表・期間検索・一覧/カレンダー切替はソース上に残しますが、運用上は使用しません。
 * カレンダー詳細は前後日検索を待たずに表示し、矢印は押された時だけ移動先を検索します。
 */
#ListViewPanel,
#ListSearchArea,
.report-view-switch {
    display: none !important;
}

.day-detail-nav.is-searching {
    opacity: .65;
}

.day-detail-nav.is-searching::after {
    content: "";
    width: 10px;
    height: 10px;
    margin-left: 3px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: fixed42-nav-spin .7s linear infinite;
}

@keyframes fixed42-nav-spin {
    to { transform: rotate(360deg); }
}

/* ===== fixed43: カレンダー前後日検索メッセージ =====
 * 矢印先に日報が無い場合、操作を止めるダイアログではなくモーダル内へ短時間表示します。
 * 「日報なし」と通信エラーを利用者が区別でき、同じ方向の無駄な再検索も防ぎます。
 */
.day-detail-notice {
    margin: 7px 10px 0;
    padding: 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: 7px;
    background: var(--soft);
    color: var(--text);
    font-size: .86rem;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity .12s ease, transform .12s ease;
}

.day-detail-notice.is-visible {
    opacity: 1;
    transform: translateY(0);
}

html[data-theme="dark"] .day-detail-notice {
    background: var(--input-bg);
    color: var(--text);
    border-color: var(--input-border);
}

/* ===== fixed44: ヘッダー固定・カレンダー領域のみスクロール =====
 * カレンダー確認中にシステムメニューや画面タイトルが画面外へ流れると、
 * 入力画面への切替やログアウトがしづらいため、ページ全体のスクロールを止めます。
 * ヘッダーと「日報カレンダー」は常時表示し、月カレンダー部分だけを独立スクロール領域にします。
 */
html.calendar-list-page-root {
    height: 100%;
    overflow: hidden;
}

body.calendar-list-page {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

/* ヘッダーは通常フローに置いたまま画面全体をスクロールさせないことで、
 * sticky/fixedによる重なりや端末別高さ計算を避けます。 */
body.calendar-list-page > header.app-header {
    position: relative;
    z-index: 1000;
    flex: 0 0 auto;
}

/* mainを残り高さのコンテナにし、タイトルとカレンダーを縦方向へ分割します。 */
body.calendar-list-page > main {
    display: flex;
    width: 100%;
    max-width: var(--content-max);
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    margin: 0 auto;
    padding: 8px;
    overflow: hidden;
}

body.calendar-list-page #ReportListHeaderCard {
    flex: 0 0 auto;
    margin-bottom: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* 一覧ワークスペース自体は画面残り高さを受け取り、
 * その中のCalendarViewPanelまで高さを伝搬させます。 */
body.calendar-list-page #DailyListWorkspace {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

body.calendar-list-page #CalendarViewPanel {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

body.calendar-list-page #CalendarViewPanel[hidden] {
    display: none !important;
}

body.calendar-list-page .calendar-card {
    min-height: 0;
    flex: 1 1 auto;
    margin-bottom: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    /* 過去月の先頭挿入時はJavaScriptで表示中の月を基準に位置補正するため、
     * ブラウザー独自のスクロールアンカー補正と二重に動かないよう無効化します。 */
    overflow-anchor: none;
}

/* 縦方向では上が過去、下が現在です。初期表示はJavaScriptで最下部へ合わせます。 */
body.calendar-list-page .calendar-card[data-scroll-direction="vertical"] {
    overflow-x: hidden;
    overflow-y: auto;
}

/* 横方向では左が過去、右が現在です。月単位で止まりやすいようsnapを有効にします。 */
body.calendar-list-page .calendar-card[data-scroll-direction="horizontal"] {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
}

/* 入力ワークスペースへ切り替えた場合もページ本体はスクロールさせず、
 * iframe自身が入力画面の縦スクロールを受け持ちます。 */
body.calendar-list-page #DailyEditWorkspace:not([hidden]) {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

body.calendar-list-page #DailyEditWorkspace .edit-workspace-card {
    min-height: 0;
    flex: 1 1 auto;
}

body.calendar-list-page #DailyEditWorkspace .daily-edit-frame {
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
}

@media (max-width: 720px) {
    body.calendar-list-page > main {
        padding: 5px 6px 6px;
    }

    body.calendar-list-page #ReportListHeaderCard {
        margin-bottom: 5px;
        padding: 8px 10px;
    }

    body.calendar-list-page #ReportListHeaderCard h1 {
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    body.calendar-list-page .calendar-title-tools {
        gap: 7px;
    }

    body.calendar-list-page .calendar-direction-button {
        width: 34px;
        min-width: 34px;
        min-height: 34px;
        padding: 3px;
    }

    body.calendar-list-page .calendar-current-month-button {
        min-height: 34px;
        margin-left: 6px;
        padding: 3px 10px;
    }

    body.calendar-list-page .calendar-card[data-scroll-direction="horizontal"] .calendar-month {
        width: calc(100vw - 46px);
        min-width: calc(100vw - 46px);
        scroll-snap-align: center;
    }

    body.calendar-list-page .calendar-card {
        padding: 8px;
    }
}

/* ===== fixed45: セッションタイムアウト警告 =====
 * 外出先のスマホでは入力途中で画面を放置することがあるため、タイムアウト5分前に警告します。
 * 入力中の内容がある場合だけ注意文を追加し、自動保存は行いません。
 */
.session-timeout-modal {
    position: fixed;
    z-index: 9000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.session-timeout-modal[hidden] {
    display: none !important;
}

.session-timeout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}

.session-timeout-dialog {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 14px 38px rgba(0, 0, 0, .28);
    text-align: center;
}

.session-timeout-dialog h2 {
    margin: 0 0 10px;
    color: var(--label);
    font-size: 1.15rem;
}

.session-timeout-dialog p {
    margin: 7px 0;
}

.session-timeout-dirty {
    padding: 9px 10px;
    border: 1px solid #d9a248;
    border-radius: 8px;
    background: #fff7e7;
    color: #6e4700;
    font-weight: 700;
    text-align: left;
}

.session-timeout-countdown {
    margin: 14px 0;
    font-size: 1rem;
}

.session-timeout-countdown strong {
    font-size: 1.35rem;
    letter-spacing: .05em;
}

.session-timeout-dialog #SessionTimeoutContinue {
    width: 100%;
    min-height: 46px;
    font-weight: 800;
}

html.session-warning-open {
    overflow: hidden;
}

html[data-theme="dark"] .session-timeout-dirty {
    border-color: #9b7739;
    background: #3a3122;
    color: #ffe1a8;
}

/* ===== fixed47: ダークテーマ Date/Time Pickerコントラスト改善 =====
 * 実機ブラウザーではネイティブのカレンダー／時計アイコンがCSS filterで反転されない場合があります。
 * アイコン自体を無理に加工せず、日付・時刻入力欄だけ背景を一段明るい青灰色へ変更し、
 * ブラウザー標準の黒系アイコンとのコントラストを確保します。
 */
html[data-theme="dark"] .date-input-frame,
html[data-theme="dark"] .time-input-frame {
    background: #3a4b5d;
    border-color: #8196aa;
}

html[data-theme="dark"] .date-input-frame:focus-within,
html[data-theme="dark"] .time-input-frame:focus-within {
    background: #405367;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(116, 183, 236, .20);
}

/* 日付・時刻の値は背景を明るくしても十分な明度差を保つため、
 * 通常のダークテーマ本文と同じ明るい文字色を維持します。
 */
html[data-theme="dark"] .date-input-frame input,
html[data-theme="dark"] .time-input-frame input,
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"] {
    background: transparent;
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    color-scheme: dark;
}

/* ネイティブPickerアイコンはブラウザー標準描画を使用します。
 * filterによる反転は端末差が大きいため適用せず、背景とのコントラストで視認性を確保します。
 */
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] .date-input-frame input::-webkit-calendar-picker-indicator,
html[data-theme="dark"] .time-input-frame input::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    filter: none;
}

/* 日付・時刻の内部文字もネイティブ部品の既定色へ戻らないよう明色を維持します。 */
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-text,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-month-field,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-day-field,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-year-field,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-text,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-hour-field,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-minute-field,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-ampm-field {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
}


/* ===== fixed48: 残業チェック追加 ===== */
/*
 * メインシステムと同じNP_ZANGYOKBを操作できるよう、作業時間行へ残業チェックを追加します。
 * 昼休と同じ操作感にそろえ、スマホでも開始・終了・昼休・残業を一続きで確認できる配置にします。
 */
.compact-overtime-check {
    color: var(--label);
}

html[data-theme="dark"] .compact-overtime-check {
    color: var(--label);
}

/* ===== fixed49: TimePickerアイコン非表示・入力欄全体タップ =====
 * 残業チェック追加後も開始/終了時刻の表示幅を確保するため、時計アイコンは表示しません。
 * input[type=time] 自体はネイティブのままなので、時刻欄のどこをタップしても
 * iPhoneと同様にOS/ブラウザー標準のTimePickerを利用できます。
 */
.time-input-frame input[type="time"],
input.time-picker-no-icon {
    cursor: pointer;
}

/* Chrome / Edge / Android Chrome / Safari系で表示される時計アイコンだけを隠します。
 * DatePickerのカレンダーアイコンには影響させません。
 */
.time-input-frame input[type="time"]::-webkit-calendar-picker-indicator,
input.time-picker-no-icon::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    min-width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
}

/* 時計アイコン用に確保されていた右端余白をなくし、時刻文字へ使える幅を増やします。 */
.time-input-frame input[type="time"],
input.time-picker-no-icon {
    padding-right: 0;
}

/* Firefox等で独自のネイティブ装飾が残る場合も、可能な範囲で入力欄を簡素化します。
 * type=time自体は維持するため、Picker機能はブラウザー標準動作に任せます。
 */
.time-input-frame input[type="time"] {
    -moz-appearance: textfield;
}

/* スマホでは時刻表示が4～5文字確保できるよう、時間欄の最小幅を少し広げます。 */
@media (max-width: 430px) {
    .time-range .time-input-frame {
        min-width: 64px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .time-range input[type="time"] {
        min-width: 0;
        font-size: 15px;
    }
}

/* ===== fixed51: セッション延長2分安全マージン =====
 * 残り2分未満では延長操作を許可せず、再ログイン操作へ明確に切り替えます。
 */
#SessionTimeoutRelogin {
    width: 100%;
    margin-top: 8px;
}

.session-timeout-dialog #SessionTimeoutContinue[hidden],
.session-timeout-dialog #SessionTimeoutRelogin[hidden] {
    display: none !important;
}


/* ===== fixed52: 作業日報アバター編集 =====
 * メインGT-PROと同じTANTO.TA_IMGを日報サイトからも編集できるようにします。
 * スマホではOS標準の画像ピッカーを利用するため、専用のカメラ権限や端末フォルダ参照処理は持ちません。
 */
.user-avatar-button {
    display:inline-flex; align-items:center; justify-content:center; margin:0; padding:0; border:0; border-radius:50%; background:transparent; cursor:pointer;
}
.user-avatar-button:focus-visible { outline:2px solid #fff; outline-offset:2px; }
.user-avatar-file { position:fixed; width:1px; height:1px; opacity:0; pointer-events:none; }
.user-avatar-modal[hidden] { display:none !important; }
.user-avatar-modal { position:fixed; inset:0; z-index:3000; display:flex; align-items:center; justify-content:center; padding:16px; }
.user-avatar-modal-backdrop { position:absolute; inset:0; background:rgba(0,0,0,.48); }
.user-avatar-dialog { position:relative; z-index:1; width:min(92vw, 420px); padding:20px; border-radius:16px; background:var(--panel, #fff); color:var(--text, #222); box-shadow:0 18px 50px rgba(0,0,0,.28); text-align:center; }
.user-avatar-dialog h2 { margin:0 0 14px; font-size:1.2rem; }
.user-avatar-preview-frame { width:180px; height:180px; margin:0 auto 14px; overflow:hidden; border-radius:50%; border:1px solid var(--line, #ccd6e0); background:var(--surface, #f3f6f8); }
.user-avatar-preview-frame img { width:100%; height:100%; object-fit:cover; }
.user-avatar-help { margin:0 0 10px; font-size:.88rem; line-height:1.5; color:var(--muted, #667); }
.user-avatar-message { min-height:1.4em; margin:0 0 10px; font-size:.88rem; }
.user-avatar-message.error { color:#b00020; font-weight:700; }
.user-avatar-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.user-avatar-actions button { min-height:42px; padding:8px 14px; }
.user-avatar-actions .danger { border-color:#b3261e; color:#b3261e; background:transparent; }
.avatar-modal-open { overflow:hidden; }
@media (max-width:430px) {
    .user-avatar-dialog { width:calc(100vw - 24px); padding:16px; }
    .user-avatar-preview-frame { width:150px; height:150px; }
    .user-avatar-actions { display:grid; grid-template-columns:1fr 1fr; }
    .user-avatar-actions #UserAvatarClose { grid-column:1 / -1; }
}


/* タッチ端末ではtitle属性を確実に表示できないため、祝日セルの長押し時だけ一時表示する補助ポップアップです。
 * 日報セルの情報量を増やさず、PCの既存ツールチップと同じ「祝日名だけ」を確認できるようにします。 */
.holiday-long-press-popup {
    position: fixed;
    z-index: 2200;
    max-width: min(80vw, 280px);
    padding: 7px 11px;
    border: 1px solid var(--input-border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.35;
    pointer-events: none;
    white-space: nowrap;
}

/* 社内作業の受注番号入力補助。見出し＋入力欄の高さに2行の案内を収めます。 */
.project-code-assist-row {
    display: grid;
    /* 右側を内容依存(max-content)にすると小画面で横幅が膨らむため、
       案内側を固定上限内に収め、入力欄は残りの幅だけを使用します。 */
    grid-template-columns: minmax(0, 1fr) 160px;
    align-items: end;
    gap: 6px;
    width: 100%;
}
.project-code-entry { min-width: 0; max-width: 100%; }
.project-code-entry .autocomplete-host { width: 100%; max-width: 100%; }
/* 受注番号のテキストボックスの既定幅がグリッド外へはみ出さないようにします。 */
.project-code-entry input[type="text"] { width: 100%; max-width: 100%; min-width: 0; }
.internal-project-assist {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
}
.internal-project-assist-action {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.internal-project-assist-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 24px;
    min-height: 24px;
    padding: 0 6px;
    /* テーマごとの入力欄・文字色を使用し、ダークでも背景と文字の明度差を確保します。 */
    border: 1px solid var(--input-border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}
/* キーボード操作時も選択中のテーマに合ったフォーカス色を使用します。 */
.internal-project-assist-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* 雑工伝票No.廃止後は行先欄を横幅いっぱいに使います。 */
.destination-misc-row { grid-template-columns: auto minmax(0, 1fr); }
@media (min-width: 721px) {
    .destination-misc-row { grid-template-columns: auto minmax(100px, 310px); justify-content: start; }
}
/*
 * 画面幅330px前後でもヘッダーの担当者名が右へはみ出さないようにします。
 * 担当者名を省略せず折り返し、タイトルと操作領域が親幅を奪い合わない構成にします。
 */
@media (max-width: 430px) {
    .header-top-row { width: 100%; max-width: 100%; }
    .app-title { flex: 0 0 auto; font-size: .82rem; }
    .header-tools { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .user-chip { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .user-name { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

    /* 受注番号欄には残り幅を使い、案内側は右端まで含めて親幅内に固定します。 */
    .project-code-assist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 138px); gap: 5px; max-width: 100%; }
    .internal-project-assist { min-width: 0; font-size: 11px; line-height: 1.15; }
    .internal-project-assist-action { gap: 3px; }
    .internal-project-assist-button { flex: 0 0 auto; min-height: 22px; height: 22px; padding: 0 4px; font-size: 11px; }
}
/* 横幅がさらに狭い機種ではボタンの文字を読みやすく保ちながら空間を確保します。 */
@media (max-width: 359px) {
    .project-code-assist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 135px); gap: 4px; }
    .internal-project-assist { font-size: 10.5px; }
    .internal-project-assist-action { gap: 2px; }
    .internal-project-assist-button { padding: 0 3px; font-size: 10.5px; }
}

/* コピー先の日付選択は既存カレンダー内に収め、スマートフォンでも折り返します。 */
.day-detail-copy-picker:not([hidden]) { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:12px; }
.day-detail-copy-picker[hidden] { display:none !important; }
.day-detail-copy-picker input { max-width:100%; }
.day-detail-copy-button { margin-left:8px; }

/* 日付単位の操作はカードより上に置き、過去日にも新規入力を許可する。 */
.day-detail-top-actions { display:flex; gap:10px; padding:10px 16px; justify-content:flex-end; flex-wrap:wrap; }
.day-detail-top-actions button { min-height:36px; }
.day-detail-copy-check-label { display:inline-flex; align-items:center; gap:6px; color:var(--text); cursor:pointer; font-size:0.95em; }
.day-detail-copy-check-label input { width:18px; height:18px; accent-color:var(--focus); }
.batch-copy-list { display:flex; flex-direction:column; gap:14px; }
.batch-copy-item { border:1px solid var(--input-border); border-radius:10px; padding:14px; background:var(--surface); }
.batch-copy-item label { display:block; margin:8px 0 3px; }
.batch-copy-item input:not([type=checkbox]),.batch-copy-item select { width:100%; box-sizing:border-box; }
.batch-copy-row { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
/* 一括コピー画面の時刻入力も通常入力と同じラッパー構造にそろえ、
   iPhone のホーム画面アプリ表示でも時刻欄がはみ出さないようにします。 */
.batch-copy-time-field { min-width:0; }
.batch-copy-time-frame { min-width:0; }
.batch-copy-time-frame input[type="time"] { min-width:0; }
.batch-copy-actions { display:flex; gap:10px; justify-content:flex-end; margin:14px 0; }
.batch-copy-suggestions { max-height:175px; overflow:auto; border:1px solid var(--input-border); border-radius:5px; }
.batch-copy-suggestions button { display:block; width:100%; text-align:left; background:var(--surface); color:var(--text); padding:8px; }

/* ===== 20261030: 日報複数コピーのテーマ・スマホ操作表示修正 =====
 * 既存のフォーム共通 input 幅100%・高さ44px をチェックボックスへ継承させない。
 * すべてのテーマで入力とボタンを同じCSS変数から配色する。
 */
.day-detail-top-actions { justify-content:center; }
.day-detail-actions { align-items:center; gap:12px; }
.day-detail-copy-check-label,
.batch-copy-item .batch-copy-option {
    display:inline-flex;
    width:auto;
    min-width:0;
    min-height:32px;
    flex-direction:row;
    flex-wrap:nowrap;
    align-items:center;
    justify-content:flex-start;
    gap:6px;
    margin:0;
    white-space:nowrap;
    color:var(--text);
    font-weight:500;
    cursor:pointer;
}
.day-detail-copy-check-label input[type="checkbox"],
.batch-copy-item .batch-copy-option input[type="checkbox"] {
    display:inline-block;
    flex:0 0 18px;
    width:18px;
    height:18px;
    min-width:18px;
    min-height:18px;
    max-width:18px;
    max-height:18px;
    margin:0;
    padding:0;
    border-radius:3px;
    vertical-align:middle;
    accent-color:var(--focus);
    cursor:pointer;
}
.batch-copy-options { display:flex; flex-wrap:wrap; gap:12px 18px; margin-top:10px; }
.batch-copy-item { min-width:0; color:var(--text); background:var(--surface); border-color:var(--border); }
.batch-copy-item input:not([type="checkbox"]),
.batch-copy-item select {
    background:var(--input-bg);
    border-color:var(--input-border);
    color:var(--text);
    -webkit-text-fill-color:var(--text);
}
.batch-copy-item input[readonly] { background:var(--soft); color:var(--text); -webkit-text-fill-color:var(--text); }
.batch-copy-item .batch-copy-internal-button,
.batch-copy-actions button:not(.primary) {
    background:var(--surface);
    border-color:var(--input-border);
    color:var(--text);
}
.batch-copy-item .batch-copy-internal-button { width:auto; min-height:30px; padding:4px 9px; margin-top:5px; font-size:.82rem; }
.batch-copy-suggestions[hidden] { display:none !important; }
.batch-copy-suggestions button { background:var(--surface); color:var(--text); border-color:var(--border); }
.batch-copy-suggestions button:hover,
.batch-copy-suggestions button:focus-visible { background:var(--soft); }
.day-detail-copy-picker .day-copy-date-field { display:inline-flex; min-width:0; max-width:100%; align-items:center; gap:6px; }
.day-detail-copy-picker .day-copy-date-field input { width:auto; min-width:0; flex:1 1 auto; }
.day-copy-weekday { flex:0 0 auto; white-space:nowrap; font-weight:700; color:var(--text); }
@media (max-width:380px) {
    .batch-copy-options { gap:8px 12px; }
    .day-detail-actions { gap:9px; }
    .day-detail-top-actions { gap:8px; }
}

/* コピー先日付の「戻る」は共通buttonの白背景ではなく、選択テーマの配色で表示します。
   ダークテーマでも文字が消えないよう、背景・文字・枠線を一組で指定します。 */
.day-detail-copy-picker #DayCopyCancel.day-copy-cancel-button {
    background-color: var(--surface);
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    border: 1px solid var(--input-border);
}
.day-detail-copy-picker #DayCopyCancel.day-copy-cancel-button:hover,
.day-detail-copy-picker #DayCopyCancel.day-copy-cancel-button:focus-visible {
    background-color: var(--soft);
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    border-color: var(--focus);
}

/* 一括コピーの行先・作業内容の候補は各入力欄の直下に配置し、
   通常入力と同様に候補表示中も行の高さを変えません。 */
.batch-copy-autocomplete { position:relative; min-width:0; }
.batch-copy-autocomplete .batch-copy-suggestions {
    position:absolute; z-index:30; top:100%; left:0; right:0;
    background:var(--surface); color:var(--text);
    box-shadow:0 5px 15px rgba(0,0,0,.18);
}
.batch-copy-autocomplete .batch-copy-suggestions button {
    min-height:38px; border:0; border-bottom:1px solid var(--border);
}
