/* 修復 Tailwind CSS 4 的 .collapse { visibility: collapse } 與 Bootstrap 5 accordion 的衝突 */
.collapse {
    visibility: visible;
}

.admin_function {
    display: none;
}

.btn-blue {
    background: #1976d2;
    color: white;
}

.btn-red {
    background: #d23e19;
    color: white;
}

.btn-gray {
    background: gray;
    color: white;
}

.custom-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: filter 0.2s;
}

.custom-btn:hover {
    filter: brightness(85%);
}

.custom-btn:focus {
    outline: 2px solid #64b5f6;
    outline-offset: 2px;
}

.smooth-collapse {
    transition: height 0.35s ease;
    overflow: hidden;
}

.nav-header-btn.collapsed i {
    transform: rotate(-90deg);
}

/* --------------- 個案管理 page1 --------------- */
.cm-page1-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cm-page1-sidebar {
    width: 320px;
    flex-shrink: 0;
}

.cm-page1-main {
    flex-grow: 1;
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* 側欄區塊標題 */
.cm-section-header {
    font-size: 18px;
    margin: 0;
    padding: 12px 14px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    color: #fff;
    user-select: none;
}

.cm-section-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cm-header-info {
    background-color: #17a2b8;
}

.cm-header-danger {
    background-color: #dc3545;
}

.cm-section-content {
    padding: 10px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-bottom: 16px;
}

/* 個案變動提醒卡片 */
.cm-alert-card {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.cm-alert-card:last-child {
    margin-bottom: 0;
}

.cm-alert-card .material-icons {
    font-size: 18px;
    margin-top: 2px;
}

.cm-alert-new {
    border: 1px solid #28a745;
    background-color: #e9f9ee;
    color: #155724;
}

.cm-alert-removed {
    border: 1px solid #dc3545;
    background-color: #fbeaea;
    color: #721c24;
}

/* 新分派個案卡片 */
.cm-newcase-card {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.cm-newcase-card:last-child {
    margin-bottom: 0;
}

.cm-case-name {
    font-weight: bold;
    color: #856404;
    margin-bottom: 4px;
    font-size: 16px;
}

.cm-case-detail {
    font-size: 13px;
    line-height: 1.5;
    color: #495057;
}

.cm-progress-bar {
    margin-top: 8px;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.cm-progress-fill {
    height: 100%;
    background-color: #007bff;
    border-radius: 4px;
}

.cm-progress-fill.cm-progress--info {
    background-color: #17a2b8;
}

.cm-progress-label {
    margin-top: 4px;
    font-size: 12px;
    color: #007bff;
    font-weight: bold;
}

.cm-progress-label.cm-progress--info {
    color: #17a2b8;
}

/* 右側主體 */
.cm-main-title {
    color: #007bff;
    font-size: 20px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 篩選列 */
.cm-filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.cm-filter-input {
    flex-grow: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
}

.cm-filter-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
}

.cm-filter-select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
}

.cm-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background-color: #28a745;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cm-filter-btn:hover {
    background-color: #218838;
}

.cm-filter-btn .material-icons {
    font-size: 18px;
}

/* --------------- 臨時照會 page3 --------------- */
.tc-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* 左側：待處理個案 */
.tc-case-panel {
    width: 360px;
    flex-shrink: 0;
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid #e0e0e0;
}

.tc-panel-title {
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tc-panel-title--alert {
    color: #d84315;
    border-bottom: 3px solid #d84315;
}

.tc-case-item {
    padding: 14px 16px;
    margin-bottom: 10px;
    background-color: #f5f5f0;
    border: 2px solid transparent;
    border-left: 5px solid #2b6cb0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.tc-case-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.tc-case-item span {
    font-size: 13px;
    color: #555;
}

.tc-case-item:hover {
    background-color: #e0dde4;
    transform: translateY(-1px);
    border-color: #7ebfda;
}

.tc-case-item--selected {
    background-color: #7ebfda;
    color: #fff;
    border-left-color: #d84315;
    border-color: #2b6cb0;
}

.tc-case-item--selected span {
    color: #fff;
}

/* 右側：詳細操作 */
.tc-detail-panel {
    flex-grow: 1;
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid #e0e0e0;
}

.tc-detail-title {
    margin: 0;
    color: #2b6cb0;
    font-size: 20px;
    font-weight: 800;
}

.tc-divider {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 16px 0;
}

/* 個案資訊區 */
.tc-case-info {
    padding: 16px 20px;
    border: 2px dashed #ccc;
    border-radius: 10px;
    background-color: #fffbea;
}

.tc-slot-title {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.tc-service-slot {
    color: #d84315;
    font-weight: 800;
    font-size: 15px;
}

.tc-case-info p {
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0;
}

.tc-allocation-status {
    color: #d84315;
    font-weight: 700;
}

/* 居服員列表容器 */
.tc-worker-container {
    border: 2px solid #2b6cb0;
    padding: 20px;
    border-radius: 12px;
    background-color: #f8fcff;
}

.tc-worker-container h4 {
    margin: 0 0 16px 0;
    color: #2b6cb0;
    font-size: 16px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 據點 accordion */
.tc-agency-item {
    list-style: none;
    margin-bottom: 12px;
    border: 2px solid #2b6cb0;
    border-radius: 10px;
    overflow: hidden;
}

.tc-agency-item summary {
    background: linear-gradient(145deg, #e8f4f8 0%, #d0e8f5 100%);
    padding: 14px 18px;
    font-weight: 700;
    color: #2b6cb0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.tc-agency-item summary:hover {
    background: linear-gradient(145deg, #d0e8f5 0%, #b8d4e6 100%);
}

.tc-agency-dist {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

/* 居服員列表 */
.tc-worker-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.tc-worker-row {
    padding: 14px 18px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.tc-worker-info {
    flex: 1;
    min-width: 200px;
}

.tc-worker-info strong {
    color: #d84315;
    font-size: 15px;
}

.tc-worker-info small {
    color: #555;
    font-size: 13px;
}

.tc-worker-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* 按鈕共用 */
.tc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.tc-btn .material-icons {
    font-size: 16px;
}

.tc-btn--schedule {
    background-color: #7ebfda;
}

.tc-btn--schedule:hover {
    background-color: #2b6cb0;
}

.tc-btn--assign {
    background-color: #f57c00;
}

.tc-btn--assign:hover {
    background-color: #d35400;
}

.tc-btn--confirm {
    background-color: #388e3c;
    margin-top: 10px;
}

.tc-btn--confirm:hover {
    background-color: #2e7d32;
}

/* 時段選擇器 */
.tc-time-selector-row {
    padding: 0 18px;
    border-top: none;
    list-style: none;
}

.tc-time-selector {
    padding: 14px 18px;
    background-color: #fffbea;
    border: 2px solid #f57c00;
    border-radius: 8px;
    margin-bottom: 10px;
}

.tc-time-selector strong {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
}

.tc-date-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 8px;
}

.tc-date-options label {
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tc-date-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 已分配標記 */
.tc-assigned-tag {
    display: inline-block;
    background-color: #388e3c;
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 6px;
}

/* 送出區域 */
.tc-action-area {
    text-align: right;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #e0e0e0;
}

.tc-assign-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #f57c00;
    color: #fff;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tc-assign-button:hover {
    background-color: #d35400;
    transform: translateY(-2px);
}

.tc-assign-button .material-icons {
    font-size: 20px;
}

/* --------------- 訊息管理 administration/page1 --------------- */
.msg-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    height: calc(100vh - 200px);
}

/* 左側分類 */
.msg-sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg-compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: linear-gradient(to right, #28a745, #1e7e34);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.msg-compose-btn:hover {
    background: #1e7e34;
    transform: translateY(-1px);
}

.msg-compose-btn .material-icons {
    font-size: 20px;
}

.msg-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.msg-category-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent;
    transition: background-color 0.2s;
    font-size: 14px;
}

.msg-category-item:hover {
    background-color: #d8eaff;
}

.msg-category-item--active {
    background-color: #cce5ff;
    color: #004d99;
    border-left-color: #007bff;
    font-weight: 700;
}

.msg-badge {
    background-color: #dc3545;
    color: #fff;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

/* 篩選 */
.msg-filter-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.msg-filter-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #004d99;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-filter-section h4 .material-icons {
    font-size: 18px;
}

.msg-filter-label {
    display: block;
    padding: 4px 0;
    font-size: 14px;
    cursor: pointer;
}

.msg-filter-label input {
    margin-right: 6px;
}

.msg-schedule-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-schedule-btn:hover {
    background-color: #0056b3;
}

.msg-schedule-btn .material-icons {
    font-size: 18px;
}

/* 右側主區 */
.msg-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

/* 訊息列表 */
.msg-list-panel {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #cce5ff;
    max-height: 40%;
    overflow-y: auto;
    flex-shrink: 0;
}

.msg-list-header {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    color: #004d99;
    background: linear-gradient(to right, #e8f3ff, #d0e8ff);
    border-bottom: 1px solid #d8eaff;
    position: sticky;
    top: 0;
}

.msg-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 14px;
}

.msg-row:hover {
    background-color: #f0f8ff;
}

.msg-row--unread {
    font-weight: 700;
    background-color: #f0faff;
}

.msg-row--selected {
    background-color: #e6f7ff;
    border-left: 4px solid #007bff;
}

.msg-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.msg-row-subject {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-row-time {
    flex-shrink: 0;
    font-size: 13px;
    color: #888;
    margin-left: 12px;
}

.msg-star {
    cursor: pointer;
    font-size: 16px;
    color: #ccc;
    flex-shrink: 0;
}

.msg-star--active {
    color: #ffc107;
}

/* 訊息詳情 */
.msg-detail-panel {
    flex-grow: 1;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #cce5ff;
    overflow-y: auto;
}

.msg-detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 15px;
}

.msg-detail-subject {
    font-size: 18px;
    color: #004d99;
    margin: 0 0 12px 0;
    font-weight: 700;
}

.msg-detail-meta {
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.msg-detail-meta p {
    margin: 4px 0;
}

.msg-detail-body {
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    margin-bottom: 16px;
}

.msg-read-status {
    text-align: right;
    font-size: 13px;
    color: #28a745;
    margin-bottom: 12px;
}

.msg-detail-actions {
    text-align: right;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.msg-placeholder-icon {
    font-size: 48px;
    color: #ccc;
}

.msg-check-icon {
    font-size: 16px;
    vertical-align: middle;
}

.msg-row--empty {
    justify-content: center;
    color: #999;
}

/* --------------- 機器人管理 administration/page2 --------------- */

/* KPI 卡片 */
.bot-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.bot-kpi-card {
    background-color: #fff;
    padding: 18px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    text-align: center;
    border-left: 5px solid #007bff;
    transition: transform 0.2s;
}

.bot-kpi-card:hover {
    transform: translateY(-2px);
}

.bot-kpi-card--success {
    border-left-color: #28a745;
}
.bot-kpi-card--warning {
    border-left-color: #f57c00;
}
.bot-kpi-card--danger {
    border-left-color: #dc3545;
}

.bot-kpi-label {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 4px;
}

.bot-kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: #007bff;
}

.bot-kpi-card--success .bot-kpi-value {
    color: #28a745;
}
.bot-kpi-card--warning .bot-kpi-value {
    color: #f57c00;
}
.bot-kpi-card--danger .bot-kpi-value {
    color: #dc3545;
}

/* Tab 切換 */
.bot-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.bot-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -2px;
}

.bot-tab .material-icons {
    font-size: 20px;
}

.bot-tab:hover {
    color: #007bff;
}

.bot-tab--active {
    color: #007bff;
    border-bottom-color: #007bff;
}

/* 卡片 */
.bot-card {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid #e0e0e0;
}

.bot-card-title {
    color: #004d99;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bot-card-title .material-icons {
    font-size: 20px;
}

.bot-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.bot-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.bot-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background-color: #28a745;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bot-add-btn:hover {
    background-color: #1e7e34;
}

.bot-add-btn .material-icons {
    font-size: 18px;
}

/* 操作按鈕（Grid 內） */
.bot-action-btn {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.bot-action-btn:hover {
    background-color: #e8f3ff;
}

.bot-action-btn--danger {
    color: #dc3545;
}

.bot-action-btn--danger:hover {
    background-color: #fbeaea;
}

/* 設定 Grid */
.bot-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.bot-setting-group {
    margin-bottom: 14px;
}

.bot-setting-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    color: #555;
    font-size: 14px;
}

.bot-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.bot-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.15);
}

.bot-card-footer {
    text-align: right;
    padding-top: 12px;
}

.bot-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #007bff;
    color: #fff;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bot-save-btn:hover {
    background-color: #0056b3;
}

.bot-save-btn .material-icons {
    font-size: 18px;
}

/* --------------- Chatbot 浮動元件 --------------- */
.cb-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 900;
    transition: transform 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-toggle-btn:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

.cb-toggle-btn .material-icons {
    font-size: 28px;
}

.cb-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 370px;
    height: 480px;
    background-color: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
    z-index: 899;
}

.cb-header {
    background-color: #007bff;
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 3px solid #0056b3;
}

.cb-header-icon {
    font-size: 28px;
    display: flex;
}

.cb-header-title {
    font-size: 15px;
    font-weight: 700;
}

.cb-header-sub {
    font-size: 12px;
    opacity: 0.8;
}

.cb-body {
    flex-grow: 1;
    padding: 14px;
    overflow-y: auto;
    background-color: #e5ddd5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cb-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-size: 14px;
}

.cb-msg--bot {
    align-self: flex-start;
    background-color: #fff;
    color: #333;
    border-bottom-left-radius: 2px;
}

.cb-msg--user {
    align-self: flex-end;
    background-color: #dcf8c6;
    color: #333;
    border-bottom-right-radius: 2px;
}

.cb-msg-time {
    font-size: 11px;
    color: #888;
    display: block;
    text-align: right;
    margin-top: 4px;
}

.cb-footer {
    padding: 8px 12px;
    background-color: #fff;
    border-top: 1px solid #ddd;
}

.cb-quick {
    padding: 4px 0 8px 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
}

.cb-quick::-webkit-scrollbar {
    height: 3px;
}

.cb-quick::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.cb-quick-tag {
    background-color: #e8f3ff;
    color: #007bff;
    border: 1px solid #007bff;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.cb-quick-tag:hover {
    background-color: #007bff;
    color: #fff;
}

.cb-input-area {
    display: flex;
    gap: 8px;
}

.cb-input {
    flex-grow: 1;
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.cb-input:focus {
    border-color: #007bff;
}

.cb-send-btn {
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.cb-send-btn:hover {
    background-color: #0056b3;
}

.cb-send-btn .material-icons {
    font-size: 20px;
}

/* --------------- 個案列表 case_management/page3 --------------- */
.cl-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.cl-sidebar {
    width: 310px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cl-main {
    flex: 1;
    min-width: 0;
}

.cl-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    padding: 16px;
}

.cl-card-title {
    font-size: 18px;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.cl-toggle {
    cursor: pointer;
    font-weight: 700;
    color: #6c757d;
    user-select: none;
}

.cl-alert-item {
    border: 1px solid #28a745;
    background: #e9f9ee;
    color: #155724;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 14px;
}

.cl-alert-removed {
    border-color: #dc3545;
    background: #fbeaea;
    color: #721c24;
}

.cl-newcase-item {
    border: 1px solid #ffc107;
    background: #fff8dd;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.cl-newcase-name {
    font-weight: 700;
    color: #856404;
    margin-bottom: 4px;
}

.cl-newcase-info {
    font-size: 13px;
    color: #495057;
    line-height: 1.5;
}

.cl-progress-bar {
    height: 8px;
    background: #eef2f5;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 8px;
}

.cl-progress-bar > span {
    display: block;
    height: 100%;
    background: #007bff;
}

.cl-case-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .cl-layout {
        flex-direction: column;
    }
    .cl-sidebar {
        width: 100%;
    }
}

.cl-page-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.cl-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    padding-bottom: 6px;
}

.cl-page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

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

.cl-btn {
    appearance: none;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cl-btn:hover {
    background-color: #f0f0f0;
}

.cl-btn-primary {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.cl-btn-primary:hover {
    background: #0056b3;
}

.cl-btn-ghost {
    background: transparent;
}

/* 篩選列 */
.cl-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    padding: 6px 0;
    flex-wrap: wrap;
}

.cl-input,
.cl-select {
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
}

.cl-input {
    flex: 1;
    min-width: 200px;
}

.cl-select {
    min-width: 160px;
}

.cl-multiselect {
    position: relative;
    min-width: 180px;
}

.cl-chipbox {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    min-height: 42px;
    align-items: center;
}

.cl-chip {
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f5;
    border: 1px solid #e9ecef;
    font-size: 12px;
}

.cl-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    max-height: 220px;
    overflow: auto;
    display: none;
    z-index: 20;
}

.cl-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    cursor: pointer;
}

.cl-dropdown label:last-child {
    border-bottom: 0;
}

/* 表格 */
.cl-table-wrap {
    overflow: auto;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    flex: 1;
    min-height: 0;
    margin-top: 12px;
}

#cl-case-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

#cl-case-table thead th {
    position: sticky;
    top: 0;
    background: #fafafa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    color: #495057;
    padding: 12px 10px;
    white-space: nowrap;
    font-size: 14px;
}

#cl-case-table td {
    padding: 12px 10px;
    white-space: nowrap;
    border-bottom: 1px solid #e9ecef;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

#cl-case-table tbody tr:hover {
    background: #f7f7f7;
}

.cl-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.cl-status-active {
    background: #28a745;
    color: #fff;
}

.cl-status-pause {
    background: #ffc107;
    color: #333;
}

.cl-status-closed {
    background: #6c757d;
    color: #fff;
}

.cl-tag {
    background: #007bff;
    color: #fff;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 12px;
}

/* 分派按鈕 */
.cl-assign-btn {
    background-color: #34a0e0;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    gap: 4px;
    transition: background-color 0.2s;
}

.cl-assign-btn:hover {
    background-color: #2a79ae;
}

.cl-assign-btn i {
    font-size: 16px;
}

/* 欄位設定 Modal */
.cl-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.cl-show-modal {
    display: flex !important;
}

.cl-panel {
    background: #fff;
    width: min(750px, 92vw);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    padding: 18px;
}

.cl-col-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.cl-col-label {
    display: flex;
    gap: 8px;
    align-items: center;
    border: 1px solid #e9ecef;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
}

.cl-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

/* 分派 Modal */
.cl-assign-content {
    background: #fff;
    padding: 30px;
    border-radius: 18px;
    width: 500px;
    max-width: 92vw;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    position: relative;
}

.cl-close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 1.8em;
    cursor: pointer;
    color: #6c757d;
}

.cl-assign-title {
    color: #34a0e0;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.cl-caseload-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cl-caseload-item {
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cl-caseload-item:hover {
    background-color: #f7f7f7;
}

.cl-caseload-item.cl-selected {
    border: 2px solid #34a0e0;
    background-color: #e6f7ff;
}

.cl-caseload-item.cl-capacity-full {
    cursor: not-allowed;
    background: #f7f7f7;
    opacity: 0.72;
}

.cl-caseload-item.cl-capacity-full:hover {
    background: #f7f7f7;
}

.cl-caseload-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
}

.cl-caseload-bar {
    height: 10px;
    background-color: #f0f8ff;
    border-radius: 5px;
    overflow: hidden;
}

.cl-caseload-progress {
    height: 100%;
    background-color: #28a745;
    transition: width 0.5s;
}

.cl-caseload-progress.cl-medium {
    background-color: #34a0e0;
}

.cl-caseload-progress.cl-high {
    background-color: #e74c3c;
}

.cl-assign-actions {
    text-align: right;
    margin-top: 30px;
}

.cl-confirm-assign-btn {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.cl-confirm-assign-btn:hover {
    background-color: #218838;
}

@media (max-width: 1100px) {
    .cl-filters {
        flex-wrap: wrap;
    }
}

@media (max-width: 720px) {
    .cl-filters {
        flex-direction: column;
    }
    .cl-input,
    .cl-select,
    .cl-multiselect {
        width: 100%;
    }
}

/* --------------- 個人資料 administration/page1 --------------- */
.pa-profile-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 36px 48px;
    max-width: 720px;
    margin: 0 auto;
    border-left: 4px solid #e0e0e0;
}

.pa-field {
    margin-bottom: 20px;
}

.pa-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 15px;
    color: #333;
}

.pa-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    background: #f9f9f9;
    color: #333;
    transition: border-color 0.2s, background-color 0.2s;
}

.pa-input:focus {
    outline: none;
    border-color: #007bff;
    background: #fff;
}

.pa-input[readonly] {
    background: #f5f5f5;
    color: #555;
}

.pa-input-disabled {
    background: #eee;
    color: #999;
}

.pa-radio-group {
    display: flex;
    gap: 20px;
    margin-top: 4px;
}

.pa-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    cursor: pointer;
}

.pa-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.pa-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pa-btn-edit {
    background: #17a2b8;
    color: #fff;
}

.pa-btn-edit:hover {
    background: #138496;
}

.pa-btn-save {
    background: #007bff;
    color: #fff;
}

.pa-btn-save:hover {
    background: #0056b3;
}

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

/* --------------- 請假/加班 administration/page14 --------------- */
.lo-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.lo-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #fff;
}

.lo-btn-primary {
    background: #007bff;
}

.lo-btn-primary:hover {
    background: #0056b3;
}

.lo-btn-info {
    background: #17a2b8;
}

.lo-btn-info:hover {
    background: #138496;
}

.lo-section {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 24px;
    margin-bottom: 20px;
}

.lo-section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 16px 0;
    padding-left: 12px;
}

.lo-title-blue {
    border-left: 5px solid #007bff;
    color: #333;
}

.lo-title-teal {
    border-left: 5px solid #17a2b8;
    color: #333;
}

.lo-table-wrap {
    overflow-x: auto;
}

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

.lo-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    padding: 12px 16px;
    border-bottom: 2px solid #dee2e6;
    text-align: left;
    font-size: 14px;
    white-space: nowrap;
}

.lo-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #333;
}

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

.lo-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.lo-badge-green {
    background: #28a745;
}

.lo-badge-red {
    background: #dc3545;
}

.lo-link {
    color: #17a2b8;
    text-decoration: none;
    font-weight: 500;
}

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

/* --------------- 個案詳細 Modal (CaseDetail) --------------- */
.cd-container {
    font-size: 14px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
.cd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.cd-title {
    margin: 0;
    font-size: 22px;
}
.cd-header-actions {
    display: flex;
    gap: 8px;
}

/* Tab 導覽 */
.cd-tabs-wrapper {
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 16px;
}
.cd-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    overflow-y: hidden;
}
.cd-tab {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    border-radius: 8px 8px 0 0;
}
.cd-tab:hover {
    color: #2b2b2b;
    background: #f7f7f7;
}
.cd-tab.active {
    color: #007bff;
    font-weight: 600;
    border-bottom-color: #007bff;
    background: #fff;
}

/* 管理資訊區 */
.cd-mgmt-bar {
    background: #e6f3ff;
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid #cce0f0;
}
.cd-mgmt-bar .cd-val {
    background: #e6f3ff;
    border-color: #a4c9e4;
    font-weight: 500;
}

/* Tab 內容 */
.cd-tab-content {
    flex: 1;
    overflow-y: auto;
}

/* 全螢幕 Modal 修正 */
.modal-dialog .modal-content {
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}
.modal-dialog .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    flex: 0 0 auto;
    background: #fff;
}
.modal-dialog .modal-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.modal-dialog .modal-footer {
    flex: 0 0 auto;
    background: #fff;
}
.modal-fullscreen .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}
.modal-dialog .modal-footer.modal-footer-empty {
    display: flex !important;
    min-height: 56px;
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    pointer-events: none;
}
.modal-dialog .modal-footer.modal-footer-empty > * {
    visibility: hidden;
}
.cd-pane {
    display: none;
}
.cd-pane.active {
    display: block;
}

/* 表單 */
.cd-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px 20px;
}
.cd-form-grid.cd-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}
.cd-form-grid.cd-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}
.cd-fg {
    display: flex;
    flex-direction: column;
}
.cd-fg label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 3px;
    font-weight: 500;
}
.cd-val {
    padding: 8px 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fcfcfc;
    font-size: 14px;
    min-height: 36px;
}

/* 區段 */
.cd-section {
    margin-bottom: 24px;
}
.cd-section h3 {
    font-size: 17px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
    margin: 0 0 14px;
    color: #007bff;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 巢狀卡片 */
.cd-nested {
    border: 1px solid #e9f2fb;
    background: #f4f9ff;
    border-radius: 10px;
    padding: 14px;
    margin-top: 10px;
}
.cd-nested h4 {
    font-size: 15px;
    margin: 0 0 10px;
    color: #17a2b8;
}

/* 表格 */
.cd-table {
    width: 100%;
    border-collapse: collapse;
}
.cd-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    padding: 10px 12px;
    border-bottom: 2px solid #dee2e6;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}
.cd-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.cd-table tbody tr:hover {
    background: #f8f9fa;
}
.cd-table-compact th,
.cd-table-compact td {
    padding: 6px 8px;
    font-size: 12px;
}
.cd-table-wrap {
    overflow-x: auto;
}

/* 按鈕 */
.cd-btn {
    appearance: none;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
.cd-btn:hover {
    background: #f0f0f0;
}
.cd-btn-primary {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}
.cd-btn-primary:hover {
    background: #0056b3;
}
.cd-btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}
.cd-btn-danger:hover {
    background: #c82f3e;
}
.cd-btn-warning {
    background: #ffc107;
    color: #333;
    border-color: #ffc107;
}
.cd-btn-success {
    background: #28a745;
    color: #fff;
    border-color: #28a745;
}
.cd-btn-sm {
    padding: 3px 8px;
    font-size: 12px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.cd-btn-sm:hover {
    background: #e8f3ff;
}
/* 小按鈕套用 primary 時，避免被 .cd-btn-sm 的白底蓋成白底白字 */
.cd-btn-sm.cd-btn-primary {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}
.cd-btn-sm.cd-btn-primary:hover {
    background: #0056b3;
}
.cd-btn-danger-sm {
    color: #dc3545;
}
.cd-btn-danger-sm:hover {
    background: #fbeaea;
}

/* Badge */
.cd-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}
.cd-badge-green {
    background: #28a745;
}
.cd-badge-yellow {
    background: #ffc107;
    color: #333;
}
.cd-badge-red {
    background: #dc3545;
}
.cd-badge-blue {
    background: #007bff;
}
.cd-badge-teal {
    background: #17a2b8;
}

/* 篩選列 */
.cd-filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.cd-filter-wrap {
    flex-wrap: wrap;
}
.cd-select {
    padding: 7px 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
}
.cd-input-sm {
    padding: 7px 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
}
.cd-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
    min-height: 80px;
    resize: vertical;
}
.cd-action-btns {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

/* 班表行事曆 */
.cd-schedule-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.cd-schedule-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cd-schedule-month {
    font-size: 18px;
    font-weight: 700;
}
.cd-schedule-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.cd-calendar {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}
.cd-cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
}
.cd-cal-header span {
    padding: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #495057;
}
.cd-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cd-cal-cell {
    border: 1px solid #f0f0f0;
    min-height: 120px;
    max-height: 150px;
    overflow-y: auto;
    padding: 4px;
    font-size: 12px;
}
.cd-cal-empty {
    background: #fafafa;
}
.cd-cal-day {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 13px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}
.cd-cal-cell::-webkit-scrollbar {
    width: 5px;
}
.cd-cal-cell::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.cd-sched-item {
    padding: 4px 5px;
    border-radius: 6px;
    margin-bottom: 3px;
    font-size: 10px;
    line-height: 1.4;
    cursor: pointer;
}
.cd-sched-done {
    background: #d4edda;
    color: #155724;
}
.cd-sched-in {
    background: #fff3cd;
    color: #856404;
}
.cd-sched-pending {
    background: #f8d7da;
    color: #721c24;
}

/* 家系圖 */
.cd-family-diagram {
    position: relative;
    height: 450px;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}
.cd-ft-node {
    position: absolute;
    text-align: center;
    z-index: 1;
}
.cd-ft-center {
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* 標準家系圖：白底深框黑字（圓=女、方=男） */
.cd-ft-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    margin: 0 auto;
    border: 2.5px solid #3a4a5a;
    background: #fff;
    color: #1a1a1a;
    line-height: 1.25;
    box-sizing: border-box;
}
.cd-ft-circle small {
    font-size: 10px;
    font-weight: 400;
    color: #6b7785;
}
/* 本人(個案)：黑底白字，保留性別形狀 */
.cd-ft-main {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}
.cd-ft-main small {
    color: #cfcfcf;
}
.cd-ft-label {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
}
.cd-ft-line {
    position: absolute;
    height: 2px;
    background: #aaa;
    transform-origin: 0 50%;
    pointer-events: none;
    z-index: 0;
}
.cd-val-blue {
    background: #e6f3ff;
    border-color: #a4c9e4;
    font-weight: 500;
}

/* 內嵌 Modal (暫停/結案) */
.cd-inline-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.cd-inline-panel {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: min(500px, 90vw);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
.cd-inline-panel h4 {
    margin: 0 0 16px;
    font-size: 18px;
}

/* 定期評估長表單：表頭與操作列固定，只有中間內容捲動。 */
#cd-add-form-modal .cd-assessment-panel {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
#cd-add-form-modal .cd-assessment-panel > .cd-inline-head {
    position: relative;
    flex: 0 0 auto;
    margin: 0;
    padding: 20px 24px 12px;
    border-radius: 16px 16px 0 0;
    background: #fff;
    z-index: 20;
}
#cd-add-form-modal .cd-inline-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 24px;
}
#cd-add-form-modal .cd-assessment-panel > .cd-inline-foot {
    flex: 0 0 auto;
    margin: 0;
    padding: 14px 24px 20px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}

/* 其他長表單的標題與關閉按鈕固定於 Modal 頂端。 */
.cd-inline-panel > .cd-inline-head {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: -24px -24px 16px;
    padding: 20px 24px 12px;
    border-radius: 16px 16px 0 0;
    background: #fff;
}

/* 自製 Modal：捲動表單內容時保留標題及關閉按鈕。 */
:is(.cd-inline-panel, .lo-panel, .share-modal-card, .msg-modal-card, .dash-assign-panel)
    > :is(h3, h4):first-child,
:is(.cd-inline-panel, .lo-panel, .share-modal-card, .msg-modal-card, .dash-assign-panel)
    > [class*="head"]:first-child {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}
.cd-inline-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* --- 需求 1: 服務進度 Timeline --- */
.cd-progress-timeline {
    position: relative;
    padding: 10px 20px 10px;
    overflow-x: auto;
}
.cd-progress-timeline-wrap {
    --branch-pad: 0px;
    min-width: 720px;
    padding-top: var(--branch-pad);
    position: relative;
}
.cd-progress-main-track {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    min-height: 112px;
    position: relative;
}
.cd-progress-line {
    position: absolute;
    top: 24px;
    left: 60px;
    right: 60px;
    height: 3px;
    background: #e0e0e0;
    z-index: 0;
}
.cd-progress-branch-layer {
    inset: 0 0 auto;
    height: var(--branch-pad);
    pointer-events: none;
    position: absolute;
    z-index: 2;
}
.cd-progress-branch-line-wrap {
    cursor: pointer;
    height: 46px;
    left: var(--branch-left);
    pointer-events: auto;
    position: absolute;
    top: var(--branch-top);
    width: var(--branch-width);
}
.cd-progress-branch-line-wrap.active {
    --branch-color: #ffc107;
    --branch-bg: #fff3cd;
    --branch-text: #856404;
}
.cd-progress-branch-line-wrap.ended {
    --branch-color: #28a745;
    --branch-bg: #d4edda;
    --branch-text: #155724;
}
.cd-progress-branch-line {
    border-left: 3px solid var(--branch-color);
    border-top: 3px solid var(--branch-color);
    border-radius: 14px 0 0 0;
    height: 32px;
    position: absolute;
    top: 14px;
    width: calc(100% - 12px);
}
.cd-progress-branch-line-wrap.chain .cd-progress-branch-line {
    border-left: 0;
    border-radius: 0;
    height: 0;
    left: 12px;
    width: calc(100% - 24px);
}
.cd-progress-branch-dot {
    align-items: center;
    background: var(--branch-bg);
    border: 2px solid var(--branch-color);
    border-radius: 999px;
    color: var(--branch-text);
    display: flex;
    font-size: 13px;
    font-weight: 900;
    height: 24px;
    justify-content: center;
    left: 100%;
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    width: 24px;
}
.cd-progress-branch-date {
    color: var(--branch-text);
    font-size: 11px;
    font-weight: 600;
    left: 100%;
    line-height: 1;
    position: absolute;
    text-align: center;
    top: 31px;
    transform: translateX(-50%);
    white-space: nowrap;
}
.cd-progress-step {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    min-width: 96px;
    position: relative;
    z-index: 1;
    text-align: center;
}
.cd-branch-step {
    cursor: pointer;
}
.cd-ps-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.cd-ps-done {
    background: #28a745;
}
.cd-ps-current {
    background: #007bff;
    border: 4px solid #ffc107;
    box-sizing: border-box;
}
.cd-ps-pending {
    background: #e0e0e0;
}
.cd-ps-branch-active {
    background: #ffc107;
}
.cd-ps-branch-ended {
    background: #28a745;
}
.cd-branch-chip {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 999px;
    color: #856404;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    padding: 2px 8px;
}
.cd-branch-chip-ended {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}
.cd-ps-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}
.cd-ps-date {
    font-size: 11px;
    color: #6c757d;
}

/* --- 需求 7: 家系圖形狀 --- */
.cd-ft-square {
    width: 88px;
    height: 88px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    margin: 0 auto;
    border: 2.5px solid #3a4a5a;
    background: #fff;
    color: #1a1a1a;
    line-height: 1.25;
    box-sizing: border-box;
}
.cd-ft-square small {
    font-size: 10px;
    font-weight: 400;
    color: #6b7785;
}
/* 本人為男性：黑底白字、維持方形 */
.cd-ft-square.cd-ft-main {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
    border-radius: 6px;
}
.cd-ft-square.cd-ft-main small {
    color: #cfcfcf;
}
.cd-ft-cohabit-group {
    position: absolute;
    top: 20%;
    left: 20%;
    width: 60%;
    height: 60%;
    border: 3px dashed #007bff;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
}

/* --- 需求 9: 狀態警示條 --- */
.cd-status-banner {
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
}
.cd-status-banner-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}
.cd-status-banner-danger {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

/* 新增個案 Modal */
.addcase-avatar-box {
    width: 140px;
    height: 140px;
    border: 1px dashed #e9ecef;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fafafa;
}

/* 主責設定 Modal */
.os-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 14px;
}
.os-tab {
    appearance: none;
    border: 1px solid #e9ecef;
    background: #fff;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}
.os-tab.active {
    background: #fff;
    border-color: #007bff;
    color: #007bff;
    font-weight: 600;
}

@media (max-width: 768px) {
    .cd-form-grid.cd-cols-3,
    .cd-form-grid.cd-cols-4 {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    .cd-schedule-controls {
        flex-direction: column;
    }
}

/* --------------- 訊息管理 (messaging) --------------- */
.msg-center {
    display: flex;
    gap: 16px;
    height: calc(100vh - 220px);
}
.msg-sidebar-inner {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.msg-detail-area {
    flex: 1;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 20px;
    border: 1px solid #cce5ff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.msg-detail-area h3 {
    margin: 0 0 10px;
    color: #004d99;
    font-size: 18px;
}
.msg-meta {
    font-size: 13px;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.msg-body {
    font-size: 14px;
    line-height: 1.7;
    flex: 1;
}
.msg-read-status {
    text-align: right;
    font-size: 13px;
    color: #28a745;
    margin-top: 10px;
}
.msg-reply-area {
    text-align: right;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.msg-reply-btn {
    background: #007bff;
    color: #fff;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}
.msg-reply-btn:hover {
    background: #0056b3;
}

.msg-compose-btn {
    background: linear-gradient(to right, #28a745, #1e7e34);
    color: #fff;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
}
.msg-compose-btn:hover {
    background: #1e7e34;
}
.msg-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
}

.msg-cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    flex: 1;
}
.msg-cat {
    padding: 12px 16px;
    cursor: pointer;
    border-left: 4px solid transparent;
    transition: background 0.2s;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.msg-cat:hover {
    background: #d8eaff;
}
.msg-cat.active {
    background: #cce5ff;
    color: #004d99;
    border-left-color: #007bff;
    font-weight: 700;
}
.msg-badge-unread {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    margin-left: 6px;
}

.msg-sys-banner {
    background: #fff7e6;
    border: 1px dashed #ffa94d;
    color: #b35c00;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
}

/* 撰寫 Modal */
.msg-compose-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.msg-compose-panel {
    background: #fff;
    padding: 24px;
    border-radius: 14px;
    width: min(700px, 92vw);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* 個人訊息聊天 */
.msg-chat {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.msg-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}
.msg-bubble strong {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}
.msg-bubble p {
    margin: 0;
}
.msg-time {
    font-size: 11px;
    color: #888;
    display: block;
    text-align: right;
    margin-top: 4px;
}
.msg-peer {
    align-self: flex-start;
    background: #f0f0f0;
    border-bottom-left-radius: 4px;
}
.msg-me {
    align-self: flex-end;
    background: #dcf8c6;
    border-bottom-right-radius: 4px;
}
.msg-input-area {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.msg-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 14px;
}
.msg-send-btn {
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
}
.msg-send-btn:hover {
    background: #0056b3;
}

/* 排程信件 */
.msg-schedule-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.msg-schedule-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}
.msg-schedule-table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@media (max-width: 900px) {
    .msg-center {
        flex-direction: column;
        height: auto;
    }
    .msg-sidebar-inner {
        width: 100%;
    }
}

/* ======================== 儀表板：重要通知 (db-) ======================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}
.dashboard-grid .card {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}
.dashboard-grid .card h3 {
    font-size: 1.3em;
    color: #2b6cb0;
    border-bottom: 2px solid #7ebfda;
    padding-bottom: 10px;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    font-weight: 700;
}
.dashboard-grid .card h3 i {
    margin-right: 10px;
    font-size: 1.3em;
}
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 告警卡片 */
.alert-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
.alert-item {
    padding: 20px;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
}
.alert-item.critical {
    background: #d84315;
}
.alert-item.warning {
    background: #f57c00;
}
.alert-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 1.15em;
}
.alert-item-header i {
    font-size: 1.3em;
}
.alert-item small {
    display: block;
    font-size: 0.9em;
    margin-bottom: 6px;
    font-weight: 400;
}
.alert-item p {
    font-size: 1.05em;
    margin: 6px 0 0;
    font-weight: 700;
}
.alert-action {
    display: block;
    margin-top: 14px;
    text-align: right;
    font-size: 0.95em;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}
.alert-action:hover {
    opacity: 0.8;
}

/* 訊息列表 */
.message-list {
    padding: 0;
    margin: 0;
    list-style: none;
}
.message-item {
    padding: 16px 0;
    border-bottom: 1px dashed #ccc;
    display: flex;
    align-items: center;
}
.message-item:last-child {
    border-bottom: none;
}
.message-item > i {
    margin-right: 14px;
    font-size: 1.6em;
    flex-shrink: 0;
}
.message-content strong {
    display: block;
    font-size: 1.05em;
    margin-bottom: 4px;
    color: #2d2d2d;
    font-weight: 700;
}
.message-content small {
    color: #666;
    font-size: 0.92em;
    line-height: 1.5;
}

/* 新個案提醒 */
.new-case-item {
    padding: 16px 0;
    border-bottom: 1px dashed #ccc;
}
.new-case-item:last-child {
    border-bottom: none;
}
.new-case-item strong {
    display: block;
    font-size: 1.1em;
    color: #388e3c;
    margin: 6px 0;
    font-weight: 700;
}
.new-case-item small {
    color: #666;
    font-size: 0.92em;
    line-height: 1.5;
    display: block;
    margin: 4px 0;
}
.new-case-action {
    background: #2b6cb0;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    margin-top: 10px;
    display: inline-block;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.2s;
}
.new-case-action:hover {
    background: #1565c0;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

@media (max-width: 960px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .alert-card-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 家系圖／生態圖節點 hover 操作列 ===== */
.cd-node-wrap {
    position: absolute;
}

.cd-node-tools {
    position: absolute;
    top: -12px;
    right: -14px;
    display: none;
    gap: 4px;
    z-index: 5;
}

.cd-node-wrap:hover .cd-node-tools {
    display: flex;
}

.cd-node-tool {
    width: 22px;
    height: 22px;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    background: #fff;
    color: #495057;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cd-node-tool:hover {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.cd-node-tool.cd-danger:hover {
    background: #dc3545;
    border-color: #dc3545;
}
