/* ===========================================
   新日本空調 KY書類自動生成システム
   テーマ: ティール / コーポレートブルー
   =========================================== */

/* リセットとベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background-color: #F0F4F5;
    color: #333;
    line-height: 1.6;
}

/* ビュー制御 */
.view {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===========================================
   ログイン画面 - SVGデザイン全面表示
   SVG viewBox: 0 0 1024.5 576
   ユーザー名入力: x=607.9 y=288.0 w=335.1 h=40.0
   パスワード入力: x=607.9 y=382.9 w=335.1 h=40.0
   ログインボタン: x=607.9 y=452.7 w=335.0 h=67.3
   =========================================== */

.login-fullscreen {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-image: url('../images/login-brand.svg');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

/* 透明フォーム — SVG内のフォーム位置にぴったり重ねる */
.login-form-overlay {
    position: absolute;
    /* SVG座標から算出: left=59.3% top=50% w=32.7% */
    left: 59.3%;
    top: 50%;
    width: 32.7%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.login-input {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
    padding: 0 3%;
    color: #333;
    font-size: clamp(12px, 1.4vw, 18px);
    caret-color: #0068B7;
    border-radius: 20px;
}

/* ユーザー名: h=6.9%vh */
.login-input-user {
    height: 6.9vh;
    margin-bottom: 9.6vh; /* gap to password = (66.5% - 50% - 6.9%) */
}

/* パスワード: h=6.9%vh */
.login-input-pass {
    height: 6.9vh;
    margin-bottom: 5.2vh; /* gap to button = (78.6% - 66.5% - 6.9%) */
}

/* ログインボタン: 透明 */
.login-submit-btn {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: transparent;
    height: 11.7vh;
    width: 100%;
    cursor: pointer;
    border-radius: 20px;
}

.login-submit-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* エラーメッセージ */
.login-error-msg {
    position: absolute;
    left: 59.3%;
    top: 46%;
    width: 32.7%;
    color: #FFD700;
    text-align: center;
    font-size: clamp(11px, 1vw, 15px);
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* 登録リンク: 透明 */
.login-register-link {
    position: absolute;
    left: 59.3%;
    top: 91%;
    width: 32.7%;
    color: transparent !important;
    display: block;
    text-align: center;
    height: 4vh;
    cursor: pointer;
}

/* 登録画面パネル */
.register-panel {
    position: absolute;
    top: 5%;
    right: 3%;
    width: 35%;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 24px 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-container {
    width: 100%;
}

.login-heading {
    font-size: 1.6rem;
    color: #2C3E50;
    margin-bottom: 32px;
    text-align: center;
    font-weight: 600;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2C3E50;
    font-size: 1.5rem;
}

/* === メニュー画面 === */
.menu-cards {
    display: flex;
    gap: 32px;
    justify-content: center;
    padding: 60px 24px;
    max-width: 1060px;
    margin: 0 auto;
}

.menu-card {
    flex: 1;
    max-width: 280px;
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid transparent;
    border-left: 4px solid #0D7377;
}

.menu-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(13,115,119,0.15);
    border-color: #0D7377;
}

.menu-card-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.menu-card h3 {
    font-size: 1.2rem;
    color: #2C3E50;
    margin-bottom: 8px;
}

.menu-card p {
    font-size: 0.9rem;
    color: #888;
}

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d0d7da;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #FAFBFC;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0D7377;
    box-shadow: 0 0 0 3px rgba(13,115,119,0.1);
    background: white;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #aab5ba;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-group.half {
    flex: 1;
}

/* ボタン */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #0D7377, #14919B);
    color: white;
    box-shadow: 0 2px 8px rgba(13,115,119,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0A5C5F, #0D7377);
    box-shadow: 0 4px 12px rgba(13,115,119,0.4);
}

.btn-secondary {
    background-color: #8B9DA4;
    color: white;
}

.btn-secondary:hover {
    background-color: #6E858D;
}

.btn-success {
    background-color: #00897B;
    color: white;
    box-shadow: 0 2px 8px rgba(0,137,123,0.3);
}

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

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

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

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
}

.btn-back {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* 音声入力ボタン */
.voice-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.voice-btn:hover {
    background-color: #E0F2F1;
}

.voice-btn .mic-icon {
    font-size: 1.2rem;
}

.voice-btn.recording {
    background-color: #fee;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, #0D7377, #14919B);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(13,115,119,0.3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

header h1 {
    font-size: 1.3rem;
    color: white;
}

header .btn-secondary {
    background-color: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
}

header .btn-secondary:hover {
    background-color: rgba(255,255,255,0.3);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-display-name,
#menu-user-display-name,
#history-user-display-name {
    color: rgba(255,255,255,0.9);
}

/* メインコンテンツ */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}

section h2 {
    margin-bottom: 20px;
    color: #2C3E50;
    font-size: 1.2rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #0D7377;
}

/* 生成ステータス */
#generation-status {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #E0F2F1;
    border-top: 4px solid #0D7377;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* KY項目表示 */
#ky-items-container,
#history-detail-items {
    margin-bottom: 24px;
}

.ky-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fafafa;
}

.ky-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ky-item-type {
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.ky-item-type.safety {
    background-color: #E0F2F1;
    color: #0D7377;
}

.ky-item-type.environment {
    background-color: #e8f5e9;
    color: #388e3c;
}

.ky-item-category {
    font-size: 0.85rem;
    color: #666;
}

.ky-item-content {
    display: grid;
    gap: 12px;
}

.ky-item-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
}

.ky-item-label {
    font-weight: 500;
    color: #555;
}

.risk-values {
    display: flex;
    gap: 24px;
}

.risk-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.risk-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

.risk-low {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.risk-medium {
    background-color: #fff9c4;
    color: #f57f17;
}

.risk-high {
    background-color: #ffcdd2;
    color: #c62828;
}

/* アクションボタン */
.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

/* === 履歴一覧 === */
.history-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 16px;
    padding: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: white;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    align-items: center;
}

.history-item:hover {
    background-color: #E0F2F1;
    box-shadow: 0 2px 8px rgba(13,115,119,0.1);
}

.history-item-date {
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.history-item-branch {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    background-color: #E0F2F1;
    color: #0D7377;
    text-align: center;
    white-space: nowrap;
}

.history-item-info {
    overflow: hidden;
}

.history-item-location {
    font-weight: 500;
    color: #333;
}

.history-item-content {
    font-size: 0.85rem;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.status-completed {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.status-draft {
    background-color: #fff9c4;
    color: #f57f17;
}

.status-generating {
    background-color: #E0F2F1;
    color: #0D7377;
}

.status-error {
    background-color: #ffcdd2;
    color: #c62828;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* === ページネーション === */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

/* === 履歴詳細ヘッダー === */
.history-detail-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: #F0F4F5;
    border-radius: 8px;
}

.history-detail-meta .meta-item {
    display: flex;
    gap: 8px;
}

.history-detail-meta .meta-label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

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

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    min-width: 300px;
}

.modal-content h3 {
    margin-bottom: 24px;
    color: #2C3E50;
}

#voice-status {
    margin-bottom: 24px;
}

.recording-indicator {
    width: 60px;
    height: 60px;
    background-color: #e74c3c;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* エラーメッセージ */
.error-message {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 12px;
    text-align: center;
}

/* === 認証画面リンク・成功メッセージ === */
.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #666;
}

.auth-link a {
    color: #0D7377;
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
    color: #0A5C5F;
}

.success-message {
    color: #00897B;
    font-size: 0.9rem;
    margin-top: 12px;
    text-align: center;
    font-weight: 500;
}

/* === 作業者名入力 === */
.worker-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.worker-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0D7377;
    color: white;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.worker-name-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d7da;
    border-radius: 8px;
    font-size: 0.95rem;
}

.worker-name-input:focus {
    outline: none;
    border-color: #0D7377;
    box-shadow: 0 0 0 3px rgba(13,115,119,0.1);
}

.remove-worker-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}

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

.form-hint {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 8px;
}

.btn-secondary-small {
    padding: 6px 14px;
    border: 1px solid #d0d7da;
    border-radius: 8px;
    background: white;
    color: #555;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-secondary-small:hover {
    border-color: #0D7377;
    color: #0D7377;
}

/* === 修正チャットUI === */
#revision-chat-section {
    margin-top: 24px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: #fafafa;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #E0F2F1;
    border-bottom: 1px solid #B2DFDB;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #0D7377;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.chat-messages {
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
}

.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    max-width: 85%;
    line-height: 1.5;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.chat-message-assistant {
    background-color: #E0F2F1;
    color: #1a5276;
    margin-right: auto;
}

.chat-message-user {
    background: linear-gradient(135deg, #0D7377, #14919B);
    color: white;
    margin-left: auto;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d7da;
    border-radius: 20px;
    font-size: 0.95rem;
    outline: none;
}

.chat-input:focus {
    border-color: #0D7377;
    box-shadow: 0 0 0 3px rgba(13,115,119,0.1);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-voice {
    background: none;
    border: 1px solid #d0d7da;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-voice:hover {
    border-color: #0D7377;
    background-color: #E0F2F1;
}

.btn-voice.recording {
    background-color: #e74c3c;
    border-color: #e74c3c;
    color: white;
    animation: pulse 1s infinite;
}

/* === 転用通知 === */
.reuse-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #E0F2F1;
    border: 1px solid #B2DFDB;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #0D7377;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* マスキング警告（入力時） */
.masking-warning {
    font-size: 12px;
    color: #d68910;
    margin-top: 4px;
    padding-left: 4px;
}

/* マスキング通知（生成結果上部） */
.masking-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #E0F2F1;
    border: 1px solid #B2DFDB;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.masking-notice .notice-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.masking-notice .notice-text {
    font-size: 14px;
    color: #0D7377;
}

/* ========================================
   候補選定UI
   ======================================== */

.candidates-instruction {
    text-align: center;
    font-size: 1rem;
    color: #555;
    margin-bottom: 20px;
    padding: 12px;
    background: #E0F2F1;
    border-radius: 8px;
    border: 1px solid #B2DFDB;
}

.candidate-slot {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
}

.candidate-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #F0F4F5;
    border-bottom: 1px solid #e0e0e0;
}

.candidate-slot-header .slot-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.candidate-slot-header .slot-status {
    font-size: 0.8rem;
    color: #999;
}

.candidate-slot-header .slot-status.selected {
    color: #00897B;
    font-weight: 500;
}

.candidate-option {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.candidate-option:last-child {
    border-bottom: none;
}

.candidate-option:hover {
    background-color: #E0F2F1;
}

.candidate-option.selected {
    background-color: #E0F2F1;
    border-left: 4px solid #0D7377;
}

.candidate-option input[type="radio"] {
    margin-top: 4px;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: #0D7377;
}

.candidate-option-content {
    flex: 1;
    min-width: 0;
}

.candidate-option-id {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
}

.candidate-danger {
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.5;
}

.candidate-measures {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 6px;
    line-height: 1.5;
}

.candidate-risk-info {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
}

.candidate-risk-before,
.candidate-risk-after {
    display: flex;
    align-items: center;
    gap: 4px;
}

.candidate-risk-before .risk-badge,
.candidate-risk-after .risk-badge {
    font-size: 0.8rem;
    padding: 1px 6px;
}

#confirm-selection-btn {
    font-size: 1.05rem;
    padding: 12px 32px;
}

#confirm-selection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#candidates-section .action-buttons {
    margin-top: 20px;
}

/* ========================================
   生成モード選択
   ======================================== */

.generation-mode-selector {
    margin-bottom: 20px;
}

.generation-mode-selector label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.mode-buttons {
    display: flex;
    gap: 12px;
}

.mode-btn {
    flex: 1;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: #80CBC4;
    background: #E0F2F1;
}

.mode-btn.active {
    border-color: #0D7377;
    background: #E0F2F1;
}

.mode-icon {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.mode-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    margin-bottom: 4px;
}

.mode-desc {
    display: block;
    font-size: 0.8rem;
    color: #888;
}

/* ========================================
   エージェントチャット
   ======================================== */

.agent-chat-section {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.agent-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0D7377;
    color: #fff;
}

.agent-chat-header h3 {
    margin: 0;
    font-size: 1rem;
}

.ambiguity-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ambiguity-label {
    font-size: 0.85rem;
    white-space: nowrap;
}

.ambiguity-bar {
    width: 100px;
    height: 10px;
    background: rgba(255,255,255,0.3);
    border-radius: 5px;
    overflow: hidden;
}

.ambiguity-bar-fill {
    height: 100%;
    background: #f44336;
    border-radius: 5px;
    transition: width 0.5s, background-color 0.5s;
}

.ambiguity-score {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

#agent-chat-messages {
    max-height: 400px;
    min-height: 200px;
    overflow-y: auto;
    padding: 16px;
}

#agent-input-section .chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

#agent-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   言語選択UI（ダウンロード横）
   ======================================== */

.download-with-lang {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
}

/* ===========================================
   レスポンシブ
   =========================================== */

@media (max-width: 768px) {
    /* スマホ: 縦長SVGに切り替え */
    /* viewBox: 0 0 292.5 633 */
    /* ユーザー名: x=69.0 y=118.1 w=143.0 h=17.1 */
    /* パスワード: x=69.0 y=158.6 w=143.0 h=17.1 */
    /* ログインボタン: x=69.0 y=188.4 w=142.9 h=28.7 */

    .login-fullscreen {
        background-image: url('../images/login-brand-mobile.svg');
        background-size: 100% 100%;
        background-position: center;
        height: 100svh; /* small viewport height — excludes address bar */
    }

    /* 各要素を.login-fullscreen基準でabsolute配置 */
    /* viewBox: 292.5 x 633 */
    .login-form-overlay {
        position: static;
        display: contents;
    }

    .login-input {
        position: absolute;
        left: 23.6%;   /* 69.0/292.5 */
        width: 48.9%;  /* 143.0/292.5 */
        height: 2.7%;  /* 17.1/633 */
        margin: 0;
        font-size: clamp(12px, 3.5vw, 16px);
    }

    .login-input-user {
        top: 18.66%;   /* 118.1/633 */
        height: 2.7%;
        margin-bottom: 0;
    }

    .login-input-pass {
        top: 25.06%;   /* 158.6/633 */
        height: 2.7%;
        margin-bottom: 0;
    }

    .login-submit-btn {
        position: absolute;
        left: 23.6%;
        top: 29.76%;   /* 188.4/633 */
        width: 48.9%;
        height: 4.53%; /* 28.7/633 */
    }

    .login-error-msg {
        left: 23.6%;
        top: 16.5%;
        width: 48.9%;
        font-size: clamp(10px, 2.8vw, 14px);
    }

    .login-register-link {
        left: 15%;
        top: 35.5%;    /* (188.4+28.7)/633 ≈ 34.3% + margin */
        width: 65%;
    }

    .register-panel {
        width: 90%;
        right: 5%;
        top: 3%;
        padding: 16px 20px;
    }
}

@media (min-width: 769px) and (max-width: 900px) {
    /* タブレット: PC用SVGをcoverで表示 */
    .login-fullscreen {
        background-size: cover;
        background-position: center;
    }
}

@media (max-width: 600px) {

    header {
        flex-direction: column;
        gap: 12px;
    }

    .header-left {
        flex-direction: column;
        gap: 8px;
    }

    main {
        padding: 16px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .action-buttons {
        flex-direction: column;
    }

    .risk-values {
        flex-direction: column;
        gap: 8px;
    }

    .menu-cards {
        flex-direction: column;
        align-items: center;
        padding: 32px 16px;
    }

    .menu-card {
        max-width: 100%;
        width: 100%;
    }

    .history-item {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .history-detail-meta {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   SDS管理画面
   =========================================== */

/* 検索バー */
.sds-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.sds-search-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.sds-search-bar select {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

/* カテゴリグリッド */
.sds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.sds-category-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.sds-category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    border-color: #0D7377;
}

.sds-category-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.sds-category-count {
    font-size: 13px;
    color: #888;
}

.count-badge {
    font-size: 14px;
    color: #666;
    font-weight: normal;
}

/* 製品一覧テーブル */
.sds-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sds-table thead th {
    background: #0D7377;
    color: white;
    padding: 12px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
}

.sds-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.sds-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.sds-table tbody tr:hover {
    background: #f5f9fa;
}

/* リスクバッジ */
.risk-badge-sds {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-critical {
    background: #ffebee;
    color: #c62828;
}

.risk-high {
    background: #fff3e0;
    color: #e65100;
}

.risk-medium {
    background: #fffde7;
    color: #f57f17;
}

.risk-low {
    background: #e8f5e9;
    color: #2e7d32;
}

.risk-unknown {
    background: #f5f5f5;
    color: #757575;
}

/* 製品詳細 */
.sds-detail-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 12px 0 20px;
    flex-wrap: wrap;
}

.sds-detail-meta span {
    font-size: 14px;
    color: #555;
}

/* タブ */
.sds-detail-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sds-tab {
    padding: 10px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.sds-tab:hover {
    color: #0D7377;
}

.sds-tab.active {
    color: #0D7377;
    border-bottom-color: #0D7377;
    font-weight: 600;
}

.sds-tab-content {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 詳細テーブル */
.sds-detail-table {
    width: 100%;
    border-collapse: collapse;
}

.sds-detail-table th {
    text-align: left;
    padding: 8px 12px;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 13px;
    width: 30%;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: top;
}

.sds-detail-table td {
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid #e8e8e8;
    word-break: break-word;
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    .sds-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sds-search-bar {
        flex-direction: column;
    }

    .sds-detail-tabs {
        overflow-x: auto;
    }

    .sds-detail-table th {
        width: 35%;
    }
}
