/* ==========================================
   経費予算実績管理システム 共通スタイル
   ========================================== */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
    background: #f4f6f9;
    color: #2c3e50;
    font-size: 14px;
    line-height: 1.6;
}

a { color: #2c5aa0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== ヘッダー ===== */
.site-header {
    background: #2c3e50;
    color: #fff;
    padding: 12px 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
}
.site-title {
    margin: 0;
    font-size: 18px;
    flex-shrink: 0;
}
.site-title a { color: #fff; }
.site-title a:hover { text-decoration: none; opacity: 0.8; }

/* メインメニュー（中央） */
.main-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.main-nav-link {
    color: #ecf0f1;
    font-size: 16px;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.main-nav-link:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
    color: #fff;
}
.main-nav-link.is-active {
    background: #2c5aa0;
    color: #fff;
}

/* ユーザー情報（右） */
.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.user-info {
    font-size: 14px;
    color: #bdc3c7;
}
.logout-link {
    color: #ecf0f1;
    font-size: 13px;
    padding: 6px 12px;
    border: 1px solid #95a5a6;
    border-radius: 4px;
}
.logout-link:hover {
    background: #95a5a6;
    color: #fff;
    text-decoration: none;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .main-nav-link {
        font-size: 14px;
        padding: 6px 10px;
    }
    .site-title { font-size: 16px; }
}


/* ===== メインコンテナ ===== */
.container {
    max-width: 1400px;
    margin: 24px auto;
    padding: 24px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

h2 {
    margin-top: 0;
    border-bottom: 2px solid #2c3e50;
    padding-bottom: 8px;
}

/* ===== フッター ===== */
.site-footer {
    text-align: center;
    padding: 16px;
    color: #95a5a6;
    font-size: 12px;
}

/* ===== ログイン画面 ===== */
.login-body {
    margin: 0;
    background: linear-gradient(135deg, #2c3e50 0%, #4a6fa5 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}
.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.login-card {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-title {
    text-align: center;
    font-size: 18px;
    margin: 0 0 4px;
    color: #2c3e50;
}
.login-subtitle {
    text-align: center;
    color: #7f8c8d;
    margin: 0 0 24px;
    font-size: 14px;
}
.login-form .form-group {
    margin-bottom: 16px;
}
.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #555;
}
.login-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.login-form input:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}
.login-hint {
    margin-top: 20px;
    padding: 12px;
    background: #fff8e1;
    border-left: 3px solid #ffa726;
    font-size: 12px;
    color: #6d4c1c;
    line-height: 1.5;
}

/* ===== ボタン ===== */
.btn-primary {
    background: #2c5aa0;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.btn-primary:hover { background: #234a85; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* ===== アラート ===== */
.alert-error {
    background: #fdecea;
    color: #c0392b;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    border-left: 3px solid #c0392b;
    font-size: 13px;
}

/* ===== メニューカード ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.menu-card {
    display: block;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e0e4e8;
    border-radius: 6px;
    transition: all 0.15s;
    text-decoration: none;
    color: inherit;
}
.menu-card:hover {
    background: #fff;
    border-color: #2c5aa0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-decoration: none;
}
.menu-card-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 6px;
}
.menu-card-desc {
    font-size: 12px;
    color: #7f8c8d;
}
.menu-card-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== テーブル ===== */
.info-table {
    border-collapse: collapse;
    margin-top: 8px;
    min-width: 360px;
}
.info-table th,
.info-table td {
    padding: 8px 16px;
    border: 1px solid #e0e4e8;
    text-align: left;
}
.info-table th {
    background: #f4f6f9;
    width: 160px;
    color: #555;
    font-weight: normal;
}
.info-table td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}
/* ===== フォーム共通 ===== */
.entry-form fieldset {
    border: 1px solid #d4d8dd;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
    background: #fafbfc;
}
.entry-form legend {
    font-weight: bold;
    color: #2c3e50;
    padding: 0 8px;
    background: #fff;
    border: 1px solid #d4d8dd;
    border-radius: 4px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}
.form-col label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: #555;
}
.form-col input,
.form-col select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}
.form-col input:focus,
.form-col select:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.15);
}
.form-col-wide { grid-column: span 1; }
.req { color: #c0392b; font-size: 12px; }
.hint {
    font-size: 12px;
    color: #7f8c8d;
    margin: 4px 0 0;
}

textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

/* ===== 金額入力テーブル ===== */
.amount-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.amount-table th,
.amount-table td {
    border: 1px solid #d4d8dd;
    padding: 8px;
}
.amount-table thead th {
    background: #ecf0f1;
    text-align: center;
    font-weight: normal;
    color: #555;
    font-size: 13px;
}
.amount-table .row-label {
    background: #f4f6f9;
    text-align: center;
    font-size: 13px;
    width: 100px;
}
.amount-table .row-label small {
    color: #95a5a6;
    font-size: 11px;
}
.amount-table input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* ===== ボタン群 ===== */
.form-actions {
    margin-top: 24px;
    text-align: right;
    border-top: 1px solid #e0e4e8;
    padding-top: 16px;
}
.btn-secondary {
    display: inline-block;
    padding: 10px 20px;
    background: #95a5a6;
    color: #fff;
    border-radius: 4px;
    margin-right: 8px;
    text-decoration: none;
}
.btn-secondary:hover { background: #7f8c8d; text-decoration: none; }
/* ===== 検索フォーム ===== */
.search-form {
    background: #f8f9fa;
    border: 1px solid #e0e4e8;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}
.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 10px;
    align-items: center;
}
.search-row label {
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-form input[type="text"],
.search-form select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

/* ===== 結果サマリー ===== */
.result-summary {
    background: #ecf6fc;
    border-left: 3px solid #2c5aa0;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}
.result-summary .sum-info {
    margin-left: 16px;
    color: #555;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* ===== DBテーブル ===== */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid #d4d8dd;
    border-radius: 4px;
}
.entry-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}
.entry-table th,
.entry-table td {
    padding: 6px 8px;
    border: 1px solid #e0e4e8;
    white-space: nowrap;
}
.entry-table thead th {
    background: #34495e;
    color: #fff;
    font-weight: normal;
    font-size: 12px;
    position: sticky;
    top: 0;
}
.entry-table tbody tr:nth-child(even) {
    background: #fafbfc;
}
.entry-table tbody tr:hover {
    background: #fffbe6;
}
.month-cell {
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
    text-align: center;
}
.amount-th,
.amount-td {
    text-align: right !important;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}
.action-cell {
    text-align: center;
}

/* ===== ミニボタン ===== */
.btn-mini {
    display: inline-block;
    padding: 3px 8px;
    background: #5a7fa8;
    color: #fff;
    border-radius: 3px;
    font-size: 11px;
    text-decoration: none;
    margin: 0 1px;
}
.btn-mini:hover { background: #3c5d85; text-decoration: none; }
.btn-mini-danger { background: #c0392b; }
.btn-mini-danger:hover { background: #962c20; }

/* ===== ページネーション ===== */
.pagination {
    margin-top: 16px;
    text-align: center;
}
.pagination a {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin: 0 4px;
    background: #fff;
    color: #2c5aa0;
}
.pagination a:hover { background: #ecf6fc; text-decoration: none; }
.page-info {
    margin: 0 12px;
    color: #555;
    font-size: 13px;
}

/* ===== 成功メッセージ ===== */
.alert-success {
    background: #e8f6ef;
    color: #1e7e4a;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    border-left: 3px solid #1e7e4a;
    font-size: 13px;
}
/* ===== 差異の色分け ===== */
.diff-over {
    color: #c0392b;
    font-weight: bold;
}
.diff-under {
    color: #2c5aa0;
}
/* ===== ダッシュボード表 ===== */
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}
.dashboard-table th,
.dashboard-table td {
    border: 1px solid #d4d8dd;
    padding: 8px 10px;
}
.dashboard-table thead th {
    background: #34495e;
    color: #fff;
    text-align: center;
    font-weight: normal;
    font-size: 12px;
}
.dashboard-table tbody .row-header {
    background: #ecf0f1;
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
    width: 90px;
}
.dashboard-table tbody .row-header small {
    color: #7f8c8d;
    font-weight: normal;
    font-size: 11px;
}
.dashboard-table .amount-td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}
.dashboard-table .total-col {
    background: #f4f6f9;
    font-weight: bold;
}
.dashboard-table thead .total-col {
    background: #2c3e50;
}
.dashboard-table tbody tr.diff-row {
    background: #fafbfc;
}
.dashboard-table tbody tr.rate-row {
    background: #fffaef;
}
/* ===== 科目タブ ===== */
.cat-tabs {
    display: flex;
    gap: 4px;
    margin: 16px 0 0;
    border-bottom: 2px solid #2c5aa0;
}
.cat-tab {
    display: inline-block;
    padding: 10px 24px;
    background: #ecf0f1;
    color: #555;
    border: 1px solid #d4d8dd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
}
.cat-tab:hover {
    background: #d6dde2;
    text-decoration: none;
}
.cat-tab-active {
    background: #2c5aa0;
    color: #fff;
    border-color: #2c5aa0;
}
.cat-tab-active:hover {
    background: #2c5aa0;
    color: #fff;
}

/* ===== ピボットテーブル ===== */
.pivot-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 75vh;
    border: 1px solid #d4d8dd;
    border-radius: 4px;
    margin-top: 16px;
}
.pivot-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    background: #fff;
    min-width: 100%;
}
.pivot-table th,
.pivot-table td {
    border-right: 1px solid #e0e4e8;
    border-bottom: 1px solid #e0e4e8;
    padding: 4px 6px;
    white-space: nowrap;
}
.pivot-table thead th {
    background: #34495e;
    color: #fff;
    font-weight: normal;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
}
.pivot-table thead tr:nth-child(2) th {
    top: 31px;
    background: #4a6483;
}
.pivot-table .col-dept   { min-width: 70px; }
.pivot-table .col-type   { min-width: 80px; }
.pivot-table .col-cus    { min-width: 100px; }
.pivot-table .col-brand  { min-width: 120px; }
.pivot-table .col-bea    { min-width: 75px; }

/* セル位置（固定列） */
.pivot-table tbody td.col-dept,
.pivot-table tbody td.col-type,
.pivot-table tbody td.col-cus,
.pivot-table tbody td.col-brand {
    background: #fff;
}

/* ブランド行 */
.pivot-table .row-brand:nth-child(even) td:not(.col-total) {
    background: #fafbfc;
}
.pivot-table .row-brand:hover td {
    background: #fffbe6 !important;
}
.pivot-table .row-brand .amount-td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* 種別小計行 */
.pivot-table .row-subtotal-type td {
    background: #eaf3fb;
    font-weight: bold;
    color: #2c3e50;
}
.pivot-table .row-subtotal-type .amount-td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* 部門小計行 */
.pivot-table .row-subtotal-dept td {
    background: #d4e3f2;
    font-weight: bold;
    color: #1a3a5c;
    font-size: 12.5px;
}
.pivot-table .row-subtotal-dept .amount-td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* 総計行 */
.pivot-table .row-grand td {
    background: #2c3e50;
    color: #fff;
    font-weight: bold;
    font-size: 13px;
}
.pivot-table .row-grand .amount-td {
    text-align: right;
    font-family: "Hiragino Sans", "Meiryo", sans-serif;
}

/* 全体合計列 */
.pivot-table .col-total {
    background: #f4f6f9;
    font-weight: bold;
}
.pivot-table thead .col-total {
    background: #1a3a5c;
}
.pivot-table .row-subtotal-type .col-total {
    background: #c8def0;
}
.pivot-table .row-subtotal-dept .col-total {
    background: #a8c7e3;
}
.pivot-table .row-grand .col-total {
    background: #1a3a5c;
}
/* ===== CSV取り込み画面 ===== */
.import-info {
    background: #f4f6f9;
    border-left: 3px solid #2c5aa0;
    padding: 16px 20px;
    border-radius: 4px;
    margin-bottom: 24px;
}
.import-info h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 15px;
}
.import-info ol {
    margin: 8px 0;
    padding-left: 20px;
}
.import-info li {
    margin-bottom: 4px;
}

.upload-form {
    background: #fff;
    border: 1px solid #d4d8dd;
    border-radius: 6px;
    padding: 20px;
}
.upload-form .form-group {
    margin-bottom: 16px;
}
.upload-form label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #2c3e50;
}
.upload-form input[type="file"] {
    padding: 8px;
    border: 1px dashed #aaa;
    border-radius: 4px;
    background: #fafbfc;
    width: 100%;
    max-width: 500px;
}
.radio-label, .checkbox-label {
    display: block !important;
    font-weight: normal !important;
    margin-bottom: 6px !important;
    cursor: pointer;
}
.radio-label input,
.checkbox-label input {
    margin-right: 6px;
}

.preview-summary {
    background: #ecf6fc;
    border: 1px solid #2c5aa0;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.preview-summary h3 {
    margin-top: 0;
    color: #2c3e50;
}

/* エラー行のハイライト */
.entry-table tr.row-error td {
    background: #fdecea !important;
}
/* ===== CSV取り込み結果 ===== */
.error-list {
    background: #fdecea;
    border: 1px solid #c0392b;
    border-radius: 4px;
    padding: 12px 16px;
    max-height: 400px;
    overflow-y: auto;
}
