/* 共通スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    font-size: 0.9rem;
}

/* ヘッダー */
.header {
    background-color: #2c3e50;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-top {
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user span {
    font-size: 0.9rem;
}

/* 上部メニュー */
.header-menu {
    background-color: #34495e;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.header-menu ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.header-menu li {
    border-right: 1px solid rgba(255,255,255,0.1);
}

.header-menu li:last-child {
    border-right: none;
}

.header-menu li.menu-right {
    border-left: 1px solid rgba(255,255,255,0.1);
    border-right: 1px solid rgba(255,255,255,0.1);
}

.header-menu li:not(.menu-right) + li.menu-right {
    margin-left: auto;
}

.header-menu li.menu-right:last-child {
    border-right: none;
}

.header-menu a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s;
    font-size: 0.95rem;
}

.header-menu a:hover,
.header-menu a.active {
    background-color: #4391df;
}

/* コンテナ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ボタン */
.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
}

/* カード */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-header {
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.3rem;
    color: #2c3e50;
}

/* フォーム */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #ecf0f1;
}

/* テーブル */
.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table thead {
    background-color: #34495e;
    color: white;
}

table th,
table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* 検索フォーム */
.search-form {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.25rem;
}

.search-form .form-row {
    margin-bottom: 0.875rem;
}

.search-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.875rem;
}

/* ステータスバッジ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-draft {
    background-color: #95a5a6;
    color: white;
}

.badge-sent {
    background-color: #3498db;
    color: white;
}

.badge-approved {
    background-color: #27ae60;
    color: white;
}

.badge-lost {
    background-color: #e74c3c;
    color: white;
}

.badge-issued {
    background-color: #9b59b6;
    color: white;
}

.badge-not-issued {
    background-color: #ecf0f1;
    color: #7f8c8d;
}

/* 明細行テーブル */
.detail-table {
    margin-top: 1rem;
}

.detail-table th {
    background-color: #ecf0f1;
    color: #2c3e50;
    font-weight: 600;
}

.detail-table input,
.detail-table select {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.detail-table .row-actions {
    white-space: nowrap;
}

.detail-table .row-actions button {
    margin: 0 0.2rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
}

/* 合計セクション */
.total-section {
    margin-top: 1.5rem;
    padding: 0.875rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    text-align: right;
}

.total-row {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    margin-bottom: 0.5rem;
}

.total-row label {
    min-width: 120px;
    text-align: right;
    font-weight: 600;
}

.total-row span {
    min-width: 150px;
    text-align: right;
    font-size: 1.1rem;
}

.total-row.total-final span {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2c3e50;
}

/* アラート */
.alert {
    padding: 0.875rem;
    border-radius: 4px;
    margin-bottom: 0.875rem;
}

.alert-info {
    background-color: #d1ecf1;
    border-left: 4px solid #3498db;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
}

.alert-error {
    background-color: #f8d7da;
    border-left: 4px solid #e74c3c;
    color: #721c24;
}

.alert-success {
    background-color: #27ae60;
    border-left: 4px solid #229954;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

/* ログイン画面 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e8e8e8;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 2px;
    border: 1px solid #d0d0d0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
}

.login-card .form-group {
    margin-bottom: 1.5rem;
}

.login-card .form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.login-card .form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #bbb;
    border-radius: 2px;
    font-size: 0.95rem;
    background-color: #fff;
}

.login-card .form-group input:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 1px #2c3e50;
}

.login-card .btn-primary {
    background-color: #2c3e50;
    color: white;
    font-weight: 600;
    padding: 0.75rem;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.login-card .btn-primary:hover {
    background-color: #1a252f;
}

/* レイアウト */
.layout {
    display: block;
}

.main-content {
    padding: 1.5rem;
}

/* 左右分割レイアウト */
.content-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.content-left {
    min-width: 0;
}

.content-right {
    min-width: 0;
}

@media (max-width: 1024px) {
    .content-split {
        grid-template-columns: 1fr;
    }
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 1.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 2px solid #ecf0f1;
}

.modal-header h2 {
    margin: 0;
}

.close {
    color: #aaa;
    font-size: 25px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* ファイルアップロード */
.file-upload {
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #fff;
}

.file-upload:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
}

.file-upload.drag-over {
    border-color: #27ae60;
    background-color: #e8f5e9;
    border-style: solid;
    transform: scale(1.02);
}

.file-upload input[type="file"] {
    display: none;
}

#fileDropZone {
    pointer-events: auto;
}

/* OCR結果レビュー */
.ocr-review-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.ocr-preview {
    background: white;
    padding: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ocr-preview h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.ocr-result-table {
    width: 100%;
    border-collapse: collapse;
}

.ocr-result-table th,
.ocr-result-table td {
    padding: 0.5rem;
    border: 1px solid #ddd;
    text-align: left;
}

.ocr-result-table th {
    background-color: #34495e;
    font-weight: 600;
}

.ocr-result-table input {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.ocr-result-table .row-error {
    background-color: #fff3cd;
}

/* ページネーション */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
}

.pagination button:hover:not(:disabled) {
    background-color: #f8f9fa;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* 統計カード */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background-color: #34495e;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-card h3 {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.9;
}

.stat-card p {
    font-size: 2.25rem;
    font-weight: bold;
    margin: 0;
}

.stat-card-primary {
    background-color: #3498db;
}

.stat-card-success {
    background-color: #27ae60;
}

.stat-card-warning {
    background-color: #f39c12;
}

.stat-card-secondary {
    background-color: #95a5a6;
}

.stat-card-info {
    background-color: #17a2b8;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* ダッシュボードセクション */
.dashboard-section {
    margin-bottom: 2.5rem;
}

.dashboard-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e0e0e0;
}

.chart-container {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 400px;
    position: relative;
}

/* チャートヘッダー（タイトルとプルダウン） */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e0e0e0;
}

.chart-header .section-title {
    margin: 0;
    padding: 0;
    border-bottom: none;
}

/* 年度選択プルダウン */
.fiscal-year-select {
    min-width: 160px;
    padding: 0.65rem 2.5rem 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #2c3e50;
    background-color: #ffffff;
    border: 2px solid #3498db;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233498db' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.1);
}

.fiscal-year-select:hover {
    border-color: #2980b9;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
    background-color: #f8f9fa;
}

.fiscal-year-select:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    background-color: #ffffff;
}

.fiscal-year-select option {
    padding: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.link-primary {
    color: #3498db;
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
}

/* スピナーオーバーレイ */
.spinner-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.spinner-overlay.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 200px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-message {
    color: #2c3e50;
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* OCRステータスバッジ */
.badge-processing {
    background-color: #f39c12;
    color: white;
}

.badge-not_started {
    background-color: #95a5a6;
    color: white;
}

.badge-done {
    background-color: #27ae60;
    color: white;
}

.badge-error {
    background-color: #e74c3c;
    color: white;
}

.badge-warning {
    background-color: #f39c12;
    color: white;
}

