:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #f1f5f9;
    --text-color: #334155;
    --border-color: #cbd5e1;
    --bg-color: #f8fafc;
    --error-color: #ef4444;
    --success-color: #10b981;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.form-wrapper {
    padding: 2rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    margin-top: 2rem;
}

.section-title:first-child {
    margin-top: 0;
}

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

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

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.required {
    color: var(--error-color);
    margin-left: 4px;
}

input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 読み取り専用（入力不可）の入力欄スタイル */
input[readonly] {
    background-color: var(--secondary-color);
    color: #64748b;
    cursor: default;
    border-color: var(--border-color);
}

input[readonly]:focus {
    outline: none;
    border-color: var(--border-color);
    box-shadow: none;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin-right: 0.5rem;
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary-color);
}

.suggest-group {
    position: relative;
}

.suggest-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    list-style: none;
    display: none;
    margin-top: 4px;
}

.suggest-results.active {
    display: block;
}

.suggest-results li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--secondary-color);
    font-size: 0.95rem;
    color: var(--text-color);
    transition: background-color 0.2s;
}

.suggest-results li:last-child {
    border-bottom: none;
}

.suggest-results li:hover,
.suggest-results li.selected {
    background-color: var(--secondary-color);
}

.suggest-results li.no-result {
    color: var(--error-color);
    cursor: default;
}

.suggest-results li.no-result:hover {
    background-color: transparent;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.detail-table th,
.detail-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.detail-table th {
    background-color: var(--secondary-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.detail-table input[type="text"],
.detail-table input[type="date"],
.detail-table textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none; /* 手動リサイズを無効にし、JS自動調整に任せる */
    box-sizing: border-box;
    display: block;
    overflow-y: hidden; /* スクロールバーを非表示にしてスッキリさせる */
}

.detail-table input[type="text"]:focus,
.detail-table input[type="date"]:focus,
.detail-table textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.detail-table tbody tr {
    background-color: white;
}

.btn-remove {
    background-color: #fee2e2;
    color: var(--error-color);
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: background-color 0.2s;
}

.btn-remove:hover {
    background-color: #fecaca;
}

.btn-outline {
    background-color: transparent;
    border: 2px dashed var(--border-color);
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: var(--secondary-color);
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:active {
    transform: translateY(2px);
}

.btn-primary:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.message-area {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    font-weight: 500;
    display: none;
}

.message-area.success {
    display: block;
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.message-area.error {
    display: block;
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* スマートフォン用レスポンシブスタイル */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .form-wrapper {
        padding: 1.25rem 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .detail-table {
        min-width: 0 !important; /* テーブルの最小幅600px指定を解除して横スクロールを防止 */
    }

    .detail-table thead {
        display: none; /* ヘッダーを非表示 */
    }

    .detail-table,
    .detail-table tbody,
    .detail-table tr,
    .detail-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .detail-table tbody tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 1.25rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
        background-color: #ffffff;
    }

    .detail-table td {
        border: none !important;
        padding: 0.5rem 0 !important;
    }

    /* data-labelを使って疑似ラベルを表示 */
    .detail-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--text-color);
        margin-bottom: 0.35rem;
        opacity: 0.8;
    }

    /* 削除ボタンセルの配置調整 */
    .detail-table td:last-child {
        margin-top: 0.5rem;
        padding-top: 0.75rem !important;
        border-top: 1px dashed var(--border-color) !important;
    }

    .btn-remove {
        max-width: 100px;
        float: right;
    }

    /* floatのクリア用 */
    .detail-table td:last-child::after {
        content: "";
        display: table;
        clear: both;
    }
}
