* {
    box-sizing: border-box;
}

/* ゴープラ ブランドカラー（コーポレートレッド＋差し色のイエロー）。全体の差し色に使う。 */
:root {
    --brand-red: #e7091b;
    --brand-red-dark: #c10817;
    --brand-yellow: #f7b500;
}

body {
    margin: 0;
    font-family: Meiryo, "Yu Gothic", "Hiragino Sans", -apple-system, BlinkMacSystemFont, "MS PGothic", sans-serif;
    background: #f4f5f7;
    color: #222;
    line-height: 1.6;
}

a {
    color: var(--brand-red);
}

/* 上段：ブランドバー（コーポレートレッド）。ロゴ＋システム名とユーザー情報だけを置き、
   ナビゲーションは下段の別バー（.app-nav）に分ける。赤地の上にメニューを並べると
   ボタンが見えづらいため、明るい背景の2段目に切り出している。 */
.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--brand-red);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ロゴマークは白い丸バッジに載せて、赤バーの上でもはっきり見えるようにする
   （白抜きのマークは形がつぶれて見えづらいため、赤ロゴ＋白背景の組み合わせにする）。 */
.app-header__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 46px;
    height: 46px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.app-header__mark {
    height: 30px;
    width: auto;
    display: block;
}

/* 「ゴープラ」と「誤差・手入力報告書システム」を1つのタイトルとして続けて読ませる。 */
.app-header__title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 10px;
}

.app-header__logo {
    font-weight: 800;
    font-size: 1.5em;
    letter-spacing: 0.03em;
}

.app-header__sys {
    font-size: 1.2em;
    font-weight: 700;
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.9em;
}

/* ログアウトは赤バー上でも読めるよう白文字に（既定の青リンク色だと赤地に埋もれる）。 */
.app-header__logout {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    font-size: 0.9em;
    text-decoration: underline;
}

.app-header__logout:hover {
    color: var(--brand-yellow);
}

/* 下段：ナビゲーションバー（黒ベース）。ボタンは半透明の白ピル（従来のスタイル）。 */
.app-nav {
    background: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.app-nav__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.app-nav a {
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.95em;
    font-weight: 600;
}

.app-nav a:hover {
    background: rgba(255, 255, 255, 0.28);
}

.app-main {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 16px;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card--narrow {
    max-width: 360px;
    margin: 60px auto;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 900px;
}

/* 文字入力欄は広げすぎず読みやすい幅に抑える（表はフォーム幅いっぱい使える） */
.form input[type="text"],
.form input[type="date"],
.form input[type="time"],
.form input[type="password"],
.form textarea,
.form select {
    max-width: 480px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9em;
    color: #374151;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}

.checkbox-label--inline {
    display: inline-flex !important;
    margin-left: 8px;
    font-size: 0.85em;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field__label {
    font-size: 0.9em;
    color: #374151;
}

.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.attachment-list li {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9em;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1em;
    width: 100%;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1em;
    border: none;
    cursor: pointer;
}

.btn--primary {
    background: var(--brand-red);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn--primary:hover {
    background: var(--brand-red-dark);
}

/* 新規作成ボタン（誤差報告書・手入力報告書の新規作成、対応選択画面の作成ボタン）。
   赤の主ボタンとは役割が違うため、従来の青系にして区別する。 */
.btn--create {
    background: #2563eb;
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn--create:hover {
    background: #1d4ed8;
}

/* 副ボタン（絞り込む・表示・取得など）。グレー1色だと「押せない」印象になるため、
   枠線と影を付けて、クリックできるボタンだと分かるようにする。 */
.btn--secondary {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #9ca3af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.btn--secondary:hover {
    background: #e5e7eb;
    border-color: #6b7280;
}

.link-button {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    font-size: 0.9em;
    text-decoration: underline;
}

.link-button--danger {
    color: #dc2626;
}

.inline-form {
    display: inline;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.table th,
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    font-size: 0.9em;
}

.table th {
    background: #f9fafb;
}

/* 横スクロール対応の箱（誤差データ表など幅が広い表を包む。画面に入らないときだけ横スクロール） */
.table-scroll {
    overflow-x: auto;
}

/* 列の間隔を広めにとった表（日付・項目・値・内訳が近すぎないように）。
   width:auto で内容ぴったりの幅にし、列が間延び（100%への引き伸ばし）しないようにする。 */
.table.table--spacious {
    width: auto;
}

.table--spacious th,
.table--spacious td {
    padding: 11px 15px;
}

/* 数値列（値・金額）のデータセルを右揃えにして円の位置をそろえる。
   .table td（左揃え）に負けないよう、要素付きで指定して優先度を上げる。見出しは下で中央揃え。 */
.table td.col-num {
    text-align: right;
}

/* 誤差データ表の見出し（日付・項目・値・内訳）だけ中央揃えにする（データセルはそのまま）。 */
.table.table--spacious th {
    text-align: center;
}

/* 列と列の間の薄い縦線（行間の線と同じ色）。値の列と内訳の列の間などに使う。 */
.col-divider {
    border-left: 1px solid #e5e7eb;
}

.table__actions {
    display: flex;
    gap: 12px;
}

.form--inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: none;
}

.form--inline label {
    flex-direction: column;
}

.dashboard-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.dashboard-row__date {
    flex: 0 0 110px;
    font-weight: bold;
    color: #374151;
    padding-top: 8px;
}

.dashboard-row__tiles {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #1f2937;
    font-size: 0.85em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tile__store {
    font-size: 0.85em;
    opacity: 0.7;
}

.tile__title {
    font-weight: bold;
}

.tile__note {
    font-size: 0.8em;
    font-style: italic;
    opacity: 0.75;
}

/* タイルの状態別カラーは base.php が settings から出力する CSS変数を参照する（管理者が変更可）。
   文字色も背景に応じた読みやすい色（--tile-*-text）を使う。 */
.tile--red {
    background: var(--tile-red);
    color: var(--tile-red-text);
}

.tile--pink {
    background: var(--tile-pink);
    color: var(--tile-pink-text);
}

.tile--lightblue {
    background: var(--tile-lightblue);
    color: var(--tile-lightblue-text);
}

/* 報告書提出不要 */
.tile--exempt {
    background: var(--tile-exempt);
    color: var(--tile-exempt-text);
}

/* コンパス上から消えた（解消された）未処理の誤差タイル */
.tile--resolved {
    background: var(--tile-resolved);
    color: var(--tile-resolved-text);
}

/* 人が触れた誤差がコンパス側で変化・解消したときの警告表示 */
.tile__warn {
    font-size: 0.78em;
    font-weight: bold;
    color: var(--tile-changed);
}

/* タイルの最終取得日時（鮮度） */
.tile__meta {
    font-size: 0.72em;
    opacity: 0.6;
}

.tile-legend {
    display: inline-block;
    width: 1em;
}

.tile-legend--red {
    color: var(--tile-red);
}

.tile-legend--pink {
    color: var(--tile-pink);
}

.tile-legend--lightblue {
    color: var(--tile-lightblue);
}

.tile-legend--exempt {
    color: var(--tile-exempt);
}

.tile-legend--resolved {
    color: var(--tile-resolved);
}

.tile-legend--changed {
    color: var(--tile-changed);
}

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.status-dot--red {
    background: var(--tile-red);
}

.status-dot--pink {
    background: var(--tile-pink);
}

.status-dot--lightblue {
    background: var(--tile-lightblue);
}

.status-dot--exempt {
    background: var(--tile-exempt);
}

/* ファイル添付ボタン（ネイティブの「ファイル選択」文言を任意ラベルに差し替えるための入れ物）。
   input[type=file] を隠し、ラベルをボタン風に見せる。選択状況は隣の .file-picker__status に表示。 */
.file-picker {
    display: inline-block;
    cursor: pointer;
}

.file-picker input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.file-picker__status {
    margin-left: 8px;
    font-size: 0.85em;
    color: #6b7280;
}

/* 定例文の「タイトル＋本文」入力行（設定 > 定例文管理） */
.phrase-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.phrase-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* 定例文の行内、並べ替えボタンを右寄せに置くバー */
.phrase-row__bar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* 並べ替え（上下）ボタン。指でもタップしやすい大きさにする（小さい下線リンクだと押しづらい）。 */
.btn-reorder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 38px;
    padding: 4px 10px;
    font-size: 1.15em;
    line-height: 1;
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #9ca3af;
    border-radius: 6px;
    cursor: pointer;
}

.btn-reorder:hover {
    background: #e5e7eb;
    border-color: #6b7280;
}

.btn-reorder:disabled {
    opacity: 0.4;
    cursor: default;
}

@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .dashboard-row {
        flex-direction: column;
        gap: 8px;
    }

    /* 縦積み時、日付枠の flex-basis(110px) が「高さ110px」になり大きな余白ができるのを防ぐ */
    .dashboard-row__date {
        flex-basis: auto;
        padding-top: 0;
    }
}

/* コンパス取得中の全画面オーバーレイ（error_reports/form.php の取得ボタン用） */
.fetch-overlay {
    position: fixed;
    inset: 0;
    display: none; /* JSで .is-active を付けたときだけ表示する */
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.55);
    z-index: 1000;
}

.fetch-overlay.is-active {
    display: flex;
}

.fetch-overlay__box {
    max-width: 90%;
    padding: 2rem 2.5rem;
    background: #fff;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.fetch-overlay__title {
    margin: 1rem 0 0.5rem;
    font-weight: bold;
}

.fetch-overlay__note {
    margin: 0;
    font-size: 0.85em;
    color: #6b7280;
    line-height: 1.6;
}

.spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border: 4px solid #d1d5db;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ログイン画面のブランド表示（ゴープラ ロゴタイプ＋システム名） */
.login-card {
    border-top: 4px solid var(--brand-red);
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.login-brand__logo {
    display: inline-block;
    font-size: 2em;
    font-weight: 800;
    color: var(--brand-red);
    letter-spacing: 0.04em;
}

.login-brand__mark {
    display: block;
    height: 72px;
    width: auto;
    margin: 0 auto 12px;
}

.login-brand__sys {
    display: block;
    margin-top: 6px;
    font-size: 0.9em;
    color: #6b7280;
}
