/* ==========================================
   グローバルスタイル
   ========================================== */
:root {
    --primary: #75140C;
    --primary-dark: #5a0f09;
    --primary-light: #9a1a10;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --info: #0dcaf0;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 6px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   ローディング
   ========================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none; /* デフォルトは非表示 */
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   ログイン画面
   ========================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #75140C 0%, #2d0a07 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 40px 24px;
    text-align: center;
}

.login-header i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.login-header h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.login-form {
    padding: 32px 24px;
}

/* ==========================================
   アプリケーションレイアウト
   ========================================== */
.app-container {
    display: grid;
    grid-template-areas: 
        "topbar topbar"
        "sidebar main";
    grid-template-columns: 240px 1fr;
    grid-template-rows: 64px 1fr;
    min-height: 100vh;
}

/* トップバー */
.top-bar {
    grid-area: topbar;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(117, 20, 12, 0.15);
    z-index: 100;
}

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

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--white);
    backdrop-filter: blur(10px);
}

.user-info i {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
}

/* サイドバー */
.sidebar {
    grid-area: sidebar;
    background: #fffafa;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    padding: 16px 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #111827;
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 500;
}

.menu-item i,
.menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: #fd5858;
    stroke-width: 2.2;
    transition: all 0.2s;
}

.menu-item i {
    font-size: 18px;
    text-align: center;
    color: #fd5858;
}

.menu-item:hover {
    background: rgba(253, 88, 88, 0.06);
    color: #111827;
}

.menu-item:hover i {
    color: #fd5858;
}

.menu-item.active {
    background: #fdd8d8;
    color: #111827;
    border-left: 4px solid #fd5858;
    border-radius: 0 8px 8px 0;
}

.menu-item.active i,
.menu-item.active svg {
    color: #fd5858;
    stroke: #fd5858;
}

/* ページタイトルアイコン（Lucide統一） */
h2 > svg {
    stroke: #fd5858;
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
    vertical-align: middle;
    margin-right: 4px;
}

/* メインコンテンツ */
.main-content {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* マスタ管理テーブル: ID列（UUID 全文表示） */
.col-id {
    min-width: 200px;
    width: auto;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ビュー */
.view {
    display: none;
    animation: fadeIn 0.3s;
}

.view.active {
    display: block;
}

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

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-header h2 i {
    color: var(--primary);
}

.view-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================
   カード
   ========================================== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 svg {
    stroke: #1e40af;
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}

.card-header h3 i.fas,
.card-header h3 i.far {
    color: #1e40af;
}

.card-body {
    padding: 24px;
}

/* ==========================================
   サマリーカード
   ========================================== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.summary-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.summary-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.summary-icon.blue { background: #dbeafe; color: var(--primary); }
.summary-icon.green { background: #d1fae5; color: var(--success); }
.summary-icon.orange { background: #fef3c7; color: var(--warning); }
.summary-icon.red { background: #fee2e2; color: var(--danger); }

.summary-content {
    flex: 1;
}

.summary-label {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-800);
}

/* ==========================================
   お知らせバナー（シンプル版）
   ========================================== */
.simple-announcement {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.simple-announcement:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.simple-announcement.priority-high {
    background: #fee2e2;
    border-left-color: var(--danger);
}

.simple-announcement.priority-high .simple-announcement-content > i {
    color: var(--danger);
}

.simple-announcement-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.simple-announcement-content > i {
    color: var(--warning);
    font-size: 18px;
    flex-shrink: 0;
}

.simple-announcement-content > span {
    flex: 1;
    font-size: 14px;
    color: var(--gray-800);
    font-weight: 500;
}

/* ==========================================
   通知バナー
   ========================================== */
.notification-banner {
    background: white;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid var(--primary);
}

.notification-banner:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.notification-banner.type-alert {
    border-left-color: var(--danger);
    background: #fef2f2;
}

.notification-banner.type-warning {
    border-left-color: var(--warning);
    background: #fffbeb;
}

.notification-banner.type-success {
    border-left-color: var(--success);
    background: #f0fdf4;
}

.notification-banner.type-info {
    border-left-color: var(--info);
    background: #eff6ff;
}

.notification-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-banner-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-banner.type-alert .notification-banner-icon {
    background: #fee2e2;
    color: var(--danger);
}

.notification-banner.type-warning .notification-banner-icon {
    background: #fef3c7;
    color: var(--warning);
}

.notification-banner.type-success .notification-banner-icon {
    background: #dcfce7;
    color: var(--success);
}

.notification-banner.type-info .notification-banner-icon {
    background: #dbeafe;
    color: var(--info);
}

.notification-banner-body {
    flex: 1;
}

.notification-banner-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.notification-banner-message {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.4;
}

.notification-banner-time {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

.notification-banner-close {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.notification-banner-close:hover {
    opacity: 1;
}

/* ==========================================
   取得可能性分析
   ========================================== */
.acquisition-result-item {
    transition: background 0.2s ease;
}

.acquisition-result-item:hover {
    background: var(--gray-50);
    border-radius: var(--radius);
    margin: 0 -12px;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.badge-score-high {
    background: var(--success);
    color: white;
    font-weight: 700;
}

.badge-score-medium {
    background: var(--warning);
    color: white;
    font-weight: 700;
}

.badge-score-low {
    background: var(--info);
    color: white;
    font-weight: 700;
}

.badge-score-very-low {
    background: var(--gray-400);
    color: white;
    font-weight: 700;
}

/* ==========================================
   フィルターバー
   ========================================== */
.standards-filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.standards-filter-bar .search-box {
    flex: 1;
    min-width: 250px;
}

.standards-filter-bar .select {
    min-width: 150px;
}

/* ==========================================
   レポートグリッド
   ========================================== */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   テーブル
   ========================================== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead tr {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

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

/* ==========================================
   ボタン
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(117, 20, 12, 0.2);
}

.btn-primary svg { stroke: #fff; }
.btn-danger svg { stroke: #fff; }
.btn-ghost svg { stroke: currentColor; }

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3a0a06 100%);
    box-shadow: 0 4px 8px rgba(117, 20, 12, 0.3);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray-600);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* トップバー内のボタン */
.top-bar .btn-icon,
.top-bar .btn-ghost {
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

.top-bar .btn-icon:hover,
.top-bar .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-sm svg {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 1.8;
    vertical-align: middle;
}


.btn-block {
    width: 100%;
    justify-content: center;
}

/* アクションボタン */
.action-btns {
    display: flex;
    gap: 8px;
}

/* アクションボタン共通 */
.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    gap: 4px;
}

.btn-action svg {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 1.8;
}

.btn-action:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

/* 中立操作（詳細・編集）→ グレー */
.btn-action.view { color: var(--gray-600); }
.btn-action.view svg { stroke: var(--gray-600); }
.btn-action.edit { color: var(--gray-600); }
.btn-action.edit svg { stroke: var(--gray-600); }
.btn-action.view:hover { background: var(--gray-100); border-color: var(--gray-400); }
.btn-action.edit:hover { background: var(--gray-100); border-color: var(--gray-400); }

/* 情報/参照操作（通知・告示・コメント・関連）→ 青 */
.btn-action.comment { color: #2563eb; }
.btn-action.comment svg { stroke: #2563eb; }
.btn-action.comment:hover { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.btn-action.comment:hover svg { stroke: #1d4ed8; }

/* メイン操作（入力）→ 赤ベタ */
.btn-action.monthly-check {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-action.monthly-check svg { stroke: #fff; }
.btn-action.monthly-check:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

/* テキストラベル付きアクションボタン */
.btn-action.with-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: auto;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-wrap: nowrap;
    min-width: 56px;
}

/* バッジ + インラインアイコンの横並び */
.inline-icon-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 削除 → 赤（線） */
.btn-action.delete { color: var(--danger); }
.btn-action.delete svg { stroke: var(--danger); }
.btn-action.delete:hover { background: #fef2f2; border-color: var(--danger); }

/* ==========================================
   バッジ
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.badge-primary {
    background: rgba(117, 20, 12, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-warning {
    background: #fef9c3;
    color: #854d0e;
}

.badge-secondary {
    background: #6c757d;
    color: #fff;
}

.badge-green {
    background: #d1fae5;
    color: #065f46;
}

.badge-yellow {
    background: #fef3c7;
    color: #92400e;
}

.badge-orange {
    background: #ffedd5;
    color: #9a3412;
}

.badge-red {
    background: #fee2e2;
    color: #991b1b;
}

/* 病院独自バッジ（赤背景・白文字） */
.badge-danger {
    background: var(--danger, #dc3545) !important;
    color: #fff !important;
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-700);
}

.badge-light {
    background: var(--gray-50);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

/* ステータス専用バッジ */
.status-active {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}

.status-preparing {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.status-considering {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.status-resigned {
    background: #6b7280;
    color: white;
    font-weight: 600;
}

.status-unregistered {
    background: #e5e7eb;
    color: #4b5563;
    font-weight: 600;
    border: 1px solid #d1d5db;
}

/* 配置区分専用バッジ */
.badge-assignment-senju {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.badge-assignment-sennin {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}

.badge-assignment-haichi {
    background: #ffedd5;
    color: #9a3412;
    font-weight: 600;
}

.badge-assignment-other {
    background: var(--gray-200);
    color: var(--gray-700);
    font-weight: 600;
}

/* Step4: 研修・資格バッジ（件数バッジ型） */
.badge-training {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
    cursor: pointer;
}

.badge-certification {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
    cursor: pointer;
}

/* 兼任バッジ */
.badge-assignment-kennin {
    background: #e0e7ff;
    color: #3730a3;
    font-weight: 600;
}

/* 独自・確定バッジ（濃い紫・白文字） */
.badge-purple {
    background: #7c3aed;
    color: #fff;
    font-weight: 600;
}

/* badge-custom = badge-purple と同値 */
.badge-custom {
    background: #7c3aed;
    color: #fff;
    font-weight: 600;
}

/* 通知・告示アイコン */
.source-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

.source-icon.notification {
    background: #dbeafe;
    color: #1e40af;
}

.source-icon.ordinance {
    background: #fef3c7;
    color: #92400e;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

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

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: inherit;
    transition: all 0.2s;
    background: var(--white);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.textarea {
    resize: vertical;
    min-height: 80px;
}

.search-filter {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--gray-400);
}

.search-box input {
    padding-left: 38px;
}

/* ==========================================
   タブ
   ========================================== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--gray-800);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* ==========================================
   モーダル
   ========================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ==========================================
   アラート
   ========================================== */
.alert {
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: start;
    gap: 12px;
    border-left: 4px solid;
}

.alert i {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-danger {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger-dark);
}

/* ==========================================
   要件管理
   ========================================== */
.requirement-item {
    padding: 20px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: all 0.2s;
}

.requirement-item:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow);
}

.requirement-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.requirement-title {
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
    text-align: left;
    min-width: 0;
}

.requirement-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-left: auto;
    font-weight: 500;
}

.requirement-status.compliant {
    color: var(--success);
}

.requirement-status.non-compliant {
    color: var(--danger);
}

.requirement-description {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 12px;
    line-height: 1.6;
}

.requirement-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.requirement-input-group .input {
    flex: 1;
}

/* Step3: 要件入力フォームの bare input/textarea を全体UI方針に合わせる */
#requirementItems input:not([type="checkbox"]):not([type="range"]),
#requirementItems textarea {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
    color: var(--gray-800);
    box-sizing: border-box;
}

#requirementItems input:not([type="checkbox"]):not([type="range"]):focus,
#requirementItems textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(117, 20, 12, 0.12);
}

#requirementItems textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

.requirement-threshold {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: var(--gray-600);
    white-space: nowrap;
}

.requirement-threshold .btn-icon {
    padding: 4px;
    font-size: 12px;
}

/* ==========================================
   設定
   ========================================== */
.settings-item {
    display: flex;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-200);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-label {
    width: 150px;
    font-weight: 500;
    color: var(--gray-700);
    flex-shrink: 0;
}

.settings-value {
    color: var(--gray-800);
}

/* ==========================================
   ファイルアップロード
   ========================================== */
.file-upload-area {
    margin-top: 12px;
    padding: 16px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-50);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.file-upload-area.dragging {
    border-color: var(--primary);
    background: #dbeafe;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.file-upload-label i {
    font-size: 24px;
    color: var(--gray-400);
}

.file-upload-label span {
    font-size: 13px;
    color: var(--gray-600);
}

.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.file-item-icon {
    color: var(--primary);
    font-size: 16px;
}

.file-item-name {
    color: var(--gray-800);
    font-weight: 500;
}

.file-item-size {
    color: var(--gray-500);
    font-size: 12px;
}

.file-item-actions {
    display: flex;
    gap: 6px;
}

/* ==========================================
   親子関係表示
   ========================================== */
/* 親要件カード — UPASカラー左アクセント */
.parent-requirement {
    border-left: 3px solid var(--primary);
    background: rgba(117, 20, 12, 0.03);
}

/* 子要件ツリーラッパー — インデント + 縦線 */
.child-requirements {
    margin-left: 20px;
    margin-top: 12px;
    padding-left: 16px;
    border-left: 2px solid var(--gray-200);
}

/* 子要件カード — 淡いグレー背景で親と区別 */
.child-requirement-item {
    margin-bottom: 10px;
    padding: 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

/* 親/子 タイプバッジ（分類系：淡い背景＋濃い文字）*/
.badge-req-parent {
    background: rgba(117, 20, 12, 0.10);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-req-child {
    background: #dbeafe;
    color: #1e40af;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.requirement-condition {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* ==========================================
   アクティビティログ（v4.0）
   ========================================== */
.activity-log-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-log-item {
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.activity-log-item:hover {
    box-shadow: var(--shadow);
}

.log-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.log-user {
    font-weight: 600;
    color: var(--gray-700);
}

.log-date {
    color: var(--gray-500);
    font-size: 12px;
    margin-left: auto;
}

.log-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-600);
}

.log-details > div {
    margin-top: 4px;
}

.log-details strong {
    color: var(--gray-700);
    font-weight: 600;
}

/* ロック状態の表示 */
.locked-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.locked-indicator i {
    font-size: 14px;
}

/* 病院独自バッジ（v4.0） */
.badge-hospital-custom {
    background: #f3e8ff;
    color: #6b21a8;
    font-weight: 600;
}

/* ==========================================
   表示設定（Phase 2）
   ========================================== */
.visibility-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 12px;
    transition: all 0.2s;
}

.visibility-item:hover {
    box-shadow: var(--shadow);
}

.visibility-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.visibility-item-content {
    flex: 1;
}

.visibility-item-name {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.visibility-item-description {
    font-size: 12px;
    color: var(--gray-600);
}

.visibility-item-badges {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* 研修・資格期限アラート用（青系・丸アイコン） */
.alert-item.alert-renewal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  border-radius: 8px;
  margin-bottom: 8px;
}

.alert-item.alert-renewal .alert-icon-renewal {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
}

.alert-item.alert-renewal .alert-content {
  font-size: 14px;
  color: #1e3a8a;
}

/* ==========================================
   トースト通知
   ========================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--gray-900);
    color: var(--white);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s;
}

.toast.show {
    display: flex;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================
   フッター
   ========================================== */
.app-footer {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    border-top: 3px solid var(--primary);
    padding: 32px 24px;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-logo {
    width: 48px;
    height: auto;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.1));
}

.footer-text {
    color: var(--white);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.footer-copy {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

/* ==========================================
   検索・フィルタスタイル
   ========================================== */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.filter-chip strong {
    color: var(--gray-700);
}

.filter-chip-remove {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.filter-chip-remove:hover {
    background: var(--gray-300);
    color: var(--gray-700);
}

/* ==========================================
   通知スタイル
   ========================================== */
.notification-container {
    position: relative;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 400px;
    max-height: 500px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.notification-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-text:hover {
    text-decoration: underline;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--gray-50);
}

.notification-item.unread {
    background: #eff6ff;
}

.notification-item.unread:hover {
    background: #dbeafe;
}

.notification-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.notification-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
}

.notification-item-time {
    font-size: 11px;
    color: var(--gray-500);
}

.notification-item-message {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}

.notification-item-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    margin-right: 8px;
    font-size: 12px;
}

.notification-item-icon.alert {
    background: #fee2e2;
    color: #991b1b;
}

.notification-item-icon.info {
    background: #dbeafe;
    color: #1e40af;
}

.notification-item-icon.success {
    background: #d1fae5;
    color: #065f46;
}

.notification-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.notification-footer a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.notification-footer a:hover {
    text-decoration: underline;
}

.notification-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.notification-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.notification-empty p {
    margin: 0;
    font-size: 14px;
}

/* ==========================================
   印刷スタイル
   ========================================== */
@media print {
    .top-bar,
    .sidebar,
    .view-header,
    .card-header button,
    .btn,
    .action-btns {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
        page-break-inside: avoid;
    }

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 8px;
    }
    
    /* 印刷時のページブレーク制御 */
    .summary-cards,
    .card,
    tr {
        page-break-inside: avoid;
    }
    
    h2, h3, h4 {
        page-break-after: avoid;
    }
    
    /* 印刷ヘッダー */
    @page {
        margin: 2cm;
    }
    
    /* 検索フィルタを非表示 */
    .search-filter,
    #advancedSearchPanel,
    #activeFilters {
        display: none !important;
    }
    
    /* チャートの印刷最適化 */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ==========================================
   レスポンシブ
   ========================================== */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 200px 1fr;
    }

    .app-title {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-areas: 
            "topbar"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr;
    }

    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 99;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        padding: 16px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .view-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .search-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

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

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 12px 8px;
    }

    .user-info span {
        display: none;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0 12px;
    }

    .summary-value {
        font-size: 24px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}
/* 返信モードラベル */
.reply-mode-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #eff6ff;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #1e40af;
}

.reply-mode-label span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cancel-reply-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.cancel-reply-btn:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

/* コメントアクションボタン */
.comment-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.comment-action-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-action-btn:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.comment-delete-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

.comment-item {
    margin-bottom: 12px;
    padding: 12px;
    background-color: #f9fafb;
    border-radius: 8px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comment-author-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-author {
    font-weight: 600;
    color: #1f2937;
}

.comment-time {
    font-size: 12px;
    color: #9ca3af;
}

.comment-content {
    margin-bottom: 8px;
    color: #374151;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* コメント空状態 */
.comments-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.comments-empty i {
    font-size: 48px;
    margin-bottom: 12px;
}

/* 施設基準編集: 診療区分（スーパー管理者以外は disabled）の見た目統一 */
#standardMedicalCategory:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    border-color: #d1d5db;
    cursor: not-allowed;
    opacity: 1;
}

/* 部署別承認状況: 部署名バッジ（視認性確保） */
.dept-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  color: #111;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.18);
}

/* BUG-019: 数値入力欄のサイズをテキスト欄より小さく制限 */
#requirementsView input[type="number"],
.requirement-item input[type="number"] {
  width: 110px;
  min-width: 70px;
  max-width: 140px;
}