/* 基本重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', Arial, sans-serif;
    background-color: #f0f2f5; /* 輕微的背景色 */
    color: #333;
    line-height: 1.6;
}

/* 保持H2、按鈕文字、span文字的字體大小不變 */
h2 {
    font-size: 18px; /* 保持當前大小 */
}

.btn {
    font-size: 14px; /* 保持當前大小 */
}

span {
    font-size: inherit; /* 保持繼承大小 */
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 頂部導航欄 */
.top-navbar {
    background-color: #fff;
    padding: 15px 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

.top-navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.company-name {
    font-size: 20px;
    font-weight: bold;
    color: #4CAF50; /* 綠色強調 */
}

.top-navbar-right {
    display: flex;
    align-items: center;
}

.user-session-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 30px;
}

.user-session-info i {
    font-size: 22px;
    color: #4CAF50;
}

.user-session-info .user-name {
    font-weight: 600;
    color: #2f3b4c;
}

.logout-btn {
    background-color: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.logout-btn:hover {
    background-color: #43a047;
}

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

.logout-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.25);
}

.top-icon-group {
    display: flex;
    gap: 25px; /* 圖標間距 */
}

.top-icon-item {
    color: #555;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.3s ease;
}

.top-icon-item:hover {
    color: #4CAF50;
}

.top-icon-item i {
    font-size: 18px;
}

.badge {
    background-color: #dc3545; /* 紅色標記 */
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 50%;
    margin-left: 5px;
    line-height: 1;
}

/* 工單狀態徽章 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
}

/* 待開始 - 藍色 */
.status-badge.scheduled,
.status-badge.pending,
span.status-badge.scheduled,
span.status-badge.pending {
    background-color: #e3f2fd !important;
    color: #1976d2 !important;
    border: 1px solid #bbdefb !important;
}

/* 進行中 - 綠色 */
.status-badge.in-progress {
    background-color: #e8f5e9;
    color: #388e3c;
    border: 1px solid #c8e6c9;
}

/* 已完成 - 灰色 */
.status-badge.completed {
    background-color: #f5f5f5;
    color: #616161;
    border: 1px solid #e0e0e0;
}

/* 暫停 - 橘色 */
.status-badge.paused {
    background-color: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffe0b2;
}

/* 已取消 - 紅色 */
.status-badge.cancelled {
    background-color: #ffebee;
    color: #d32f2f;
    border: 1px solid #ffcdd2;
}

/* 庫存狀態 */
.status-badge.in-stock {
    background-color: #e8f5e9;
    color: #388e3c;
    border: 1px solid #c8e6c9;
}

.status-badge.allocated {
    background-color: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffe0b2;
}

.status-badge.shipped {
    background-color: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.status-badge.consumed {
    background-color: #f5f5f5;
    color: #616161;
    border: 1px solid #e0e0e0;
}

/* 質量狀態 */
.status-badge.qualified {
    background-color: #e8f5e9;
    color: #388e3c;
    border: 1px solid #c8e6c9;
}

.status-badge.quarantine {
    background-color: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffe0b2;
}

.status-badge.rejected {
    background-color: #ffebee;
    color: #d32f2f;
    border: 1px solid #ffcdd2;
}

/* 通用狀態 badge：success / danger / warning / secondary */
.status-badge.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-badge.danger {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.status-badge.warning {
    background-color: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.status-badge.secondary {
    background-color: #f5f5f5;
    color: #616161;
    border: 1px solid #e0e0e0;
}

.status-badge.active {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-badge.inactive {
    background-color: #fafafa;
    color: #9e9e9e;
    border: 1px solid #e0e0e0;
}

/* 庫存異動來源標籤 */
.source-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
}

.source-tag.work-order {
    background-color: #e3f2fd;
    color: #1565c0;
    border-color: #bbdefb;
}

.source-tag.order {
    background-color: #fff3e0;
    color: #e65100;
    border-color: #ffe0b2;
}

/* 詳情連結樣式 */
.link-text {
    color: #1976d2;
    text-decoration: none;
    cursor: pointer;
}

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

.text-muted {
    color: #9e9e9e;
    font-size: 0.85em;
}

/* 表格內次要文字 */
.subtext {
    font-size: 0.8em;
    color: #999;
    margin-top: 2px;
}

.row-inactive {
    opacity: 0.7;
    background-color: #fafafa;
}

.link.success {
    color: #4CAF50;
}

.link.warning {
    color: #ff9800;
}

.sidebar-toggle {
    border: none;
    background: rgba(76, 175, 80, 0.12);
    color: #2f3b4c;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-toggle i {
    font-size: 16px;
}

.sidebar-toggle:hover {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* 主內容區域佈局 */
.main-content-wrapper {
    display: flex;
    flex: 1; /* 讓主內容區塊佔滿剩餘空間 */
}

/* 左側導航欄 */
.sidebar {
    width: 250px; /* 固定寬度 */
    background-color: #313a46; /* 深色背景 */
    color: #e0e0e0;
    padding-top: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* 不讓它縮小 */
    transition: width 0.3s ease;
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
}

.menu-item {
    position: relative;
    margin-bottom: 5px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #e0e0e0;
    text-decoration: none;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
}

.menu-link:hover {
    background-color: #3e4a59; /* hover 背景色 */
    color: #fff;
}

.menu-icon {
    font-size: 18px;
    margin-right: 10px;
    width: 25px; /* 保持圖標對齊 */
    text-align: center;
}

.menu-text {
    flex-grow: 1;
}

/* active 主選單項 */
.menu-item.active > .menu-link {
    background-color: #2b333c; /* 當前選中項背景 */
    color: #4CAF50; /* 綠色文字 */
    border-left: 5px solid #4CAF50; /* 綠色左邊框 */
    padding-left: 15px; /* 補償左邊框寬度 */
}

.menu-item.active > .menu-link .menu-icon {
    color: #4CAF50; /* 當前選中項圖標綠色 */
}


/* 子選單 */
.submenu {
    list-style: none;
    padding: 0;
    background-color: #2b333c; /* 子選單背景色 */
    overflow: hidden; /* 隱藏超出部分，用於動畫 */
    max-height: 0; /* 預設隱藏 */
    transition: max-height 0.3s ease-out; /* 高度動畫 */
}

.menu-item.active .submenu {
    max-height: 500px; /* 展開時的最大高度，需足夠高 */
}

.submenu li a {
    display: block;
    padding: 10px 20px 10px 55px; /* 縮進子選單 */
    color: #a0a0a0;
    text-decoration: none;
    font-size: 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.submenu li a:hover {
    background-color: #3e4a59;
    color: #fff;
}

.submenu li a.active-submenu-item {
    color: #4CAF50; /* 子選單的活躍項 */
    font-weight: bold;
    background-color: #3e4a59;
}

.app-container.sidebar-collapsed .sidebar {
    width: 72px;
}

.app-container.sidebar-collapsed .menu-link {
    justify-content: center;
    padding: 12px 12px;
}

.app-container.sidebar-collapsed .menu-icon {
    margin: 0;
    width: auto;
}

.app-container.sidebar-collapsed .menu-text {
    display: none;
}

.app-container.sidebar-collapsed .submenu {
    display: none;
    max-height: 0 !important;
}

.app-container.sidebar-collapsed .menu-item.active > .menu-link {
    border-left: none;
    background-color: #2b333c;
}


/* 主要內容區 */
.main-content {
    flex-grow: 1; /* 佔滿剩餘空間 */
    padding: 20px;
    background-color: #f8f9fa; /* 內容區背景色 */
}

/* Tab 樣式 */
.tab-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-headers {
    display: flex;
    flex-wrap: wrap;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    padding: 5px 0;
}

.tab-header {
    padding: 10px 15px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px; /* Overlap border with content area */
    background-color: #f8f9fa;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s, border-color 0.2s;
}

.tab-header:hover {
    background-color: #e2e6ea;
    border-color: #dee2e6 #dee2e6 #e9ecef;
}

.tab-header.active {
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    color: #495057;
    font-weight: bold;
}

.tab-header .close-tab {
    font-size: 12px;
    margin-left: 5px;
    color: #6c757d;
}

.tab-header .close-tab:hover {
    color: #dc3545;
}

.tab-content-area {
    flex-grow: 1;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
    padding: 20px;
    overflow-y: auto; /* Enable scrolling for content */
}

.tab-content {
    display: none;
    height: 100%;
}

.tab-content.active {
    display: block;
}

/* 表格樣式 (參考銷貨單圖片) */
.example-table-container {
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table thead {
    background-color: #f5f5f5;
}

.data-table th, .data-table td {
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
    text-align: left;
    font-size: 15px;
}

.data-table th {
    font-weight: bold;
    color: #555;
    white-space: nowrap; /* 防止標題換行 */
}

/* 操作欄始終保持按鈕水平排列 */
.data-table td:last-child {
    white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9f9f9; /* 斑馬紋效果 */
}

.data-table tbody tr:hover {
    background-color: #f0f0f0;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    margin: 0 2px;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.edit-btn { color: #007bff; }
.delete-btn { color: #dc3545; }

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.data-table th i {
    margin-left: 5px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.data-table th:hover i {
    opacity: 1;
}

.data-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.data-table th[data-sort]:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.data-table th.sort-asc i:before {
    content: "\f145"; /* fa-sort-up */
}

.data-table th.sort-desc i:before {
    content: "\f144"; /* fa-sort-down */
}

.data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.hidden {
    display: none !important;
}

.hidden-column {
    display: none !important;
}

/* 登入頁面樣式 */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f2f5 0%, #e2e8f0 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 960px;
    padding: 32px 16px;
}

.login-card {
    background-color: #ffffff;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 48px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
    position: relative;
    overflow: hidden;
}

.login-brand {
    text-align: center;
    border-right: 1px solid #edf2f7;
    padding-right: 32px;
}

.login-brand h1 {
    font-size: 26px;
    margin-top: 18px;
    color: #1f3556;
}

.login-brand p {
    color: #6b7a99;
    margin-top: 8px;
}

.brand-logo {
    width: 76px;
    height: 76px;
    border-radius: 0;
    margin: 0 auto;
    background: rgba(76, 175, 80, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo i {
    font-size: 32px;
    color: #4CAF50;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group label {
    font-weight: 600;
    color: #1f3556;
    margin-bottom: 6px;
    display: inline-block;
}

.form-group .form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 0;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group .form-control:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.password-field {
    position: relative;
}

.toggle-password {
    position: absolute;
    top: 34px;
    right: 12px;
    border: none;
    background: transparent;
    color: #6b7a99;
    cursor: pointer;
    padding: 4px;
}

.login-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remember-me {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #4a5568;
}

.login-button {
    margin-top: 8px;
    background-color: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.login-button:hover {
    background-color: #43a047;
}

.login-button:active {
    transform: translateY(1px);
}

.login-error,
.login-success {
    display: none;
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 0;
    font-size: 14px;
}

.login-error {
    background-color: #ffe5e5;
    color: #d32f2f;
}

.login-success {
    background-color: #e6f7ed;
    color: #2e7d32;
}

.login-hint {
    background: #f8fafc;
    border-radius: 0;
    padding: 24px;
    border: 1px solid #e2e8f0;
}

.login-hint h2 {
    font-size: 18px;
    margin-bottom: 12px;
    color: #1f3556;
}

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

.sample-accounts th,
.sample-accounts td {
    padding: 10px;
    border-bottom: 1px solid #e1e7ef;
    text-align: left;
}

.sample-accounts th {
    color: #4a5568;
    font-weight: 600;
}

.sample-accounts code {
    background-color: rgba(31, 53, 86, 0.06);
    padding: 2px 5px;
    border-radius: 0;
}

.login-footer {
    grid-column: 1 / -1;
    text-align: center;
    color: #7a869a;
    font-size: 13px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .login-card {
        padding: 32px;
        grid-template-columns: 1fr;
    }

    .login-brand {
        border-right: none;
        border-bottom: 1px solid #edf2f7;
        padding-bottom: 24px;
        padding-right: 0;
    }
}

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

.content-header.with-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.content-header.with-actions .subtitle {
    font-size: 15px;
    color: #6c757d;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 24px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.btn.primary {
    background: linear-gradient(135deg, #4CAF50, #2f8a3b);
    color: #fff;
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}

.btn.primary:hover {
    background: linear-gradient(135deg, #43a047, #2c7d36);
}

.btn.outline {
    background-color: #fff;
    color: #2f8a3b;
    border-color: #2f8a3b;
}

.btn.outline:hover {
    background-color: rgba(47, 138, 59, 0.08);
}

.btn.success {
    background: linear-gradient(135deg, #4CAF50, #2f8a3b);
    color: #fff;
    border: none;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.btn.success:hover {
    background: linear-gradient(135deg, #43a047, #2c7d36);
}

.btn.text {
    padding: 8px;
    border: none;
    background: #007bff;
    color: #fff;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn.text[data-action="details"] {
    background: #ff9800;
}

.btn.text[data-action="details"]:hover {
    background: #f57c00;
}

.btn.text[data-action="copy-order-item"] {
    background: #9c27b0;
}

.btn.text[data-action="copy-order-item"]:hover {
    background: #7b1fa2;
}

.btn.text[data-action="create-work-order"] {
    background: #FFC107;
    color: #FFF;
}

.btn.text[data-action="create-work-order"]:hover {
    background: #FFB300;
    color: #FFF;
}

.btn.text[data-action="convert-to-inventory"] {
    background: #FFC107;
    color: #FFF;
}

.btn.text[data-action="convert-to-inventory"]:hover {
    background: #FFB300;
    color: #FFF;
}

.btn.text:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn.text.danger {
    background: #dc3545;
}

.btn.text.purple {
    background: #9c27b0;
}

.btn.text.purple:hover {
    background: #7b1fa2;
}

.btn.text.danger:hover {
    background: #a71d2a;
}

/* 列印按鈕樣式 - 未列印狀態 (綠底白字) */
.btn.btn-print-new {
    padding: 8px;
    border: none;
    background-color: #28a745;
    color: #fff;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn.btn-print-new:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

/* 列印按鈕樣式 - 已列印狀態 (綠框白底綠字) */
.btn.btn-print-done {
    padding: 8px;
    border: 2px solid #28a745;
    background-color: #fff;
    color: #28a745;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn.btn-print-done:hover {
    background-color: #f0fff4;
    transform: translateY(-1px);
}

.btn.ghost {
    background: none;
    border: 1px solid #ced4da;
    color: #495057;
}

.btn.ghost:hover {
    background-color: #f1f3f5;
}

/* Summary Cards */
.summary-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.summary-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 180px;
    flex: 1;
    max-width: 250px;
}

.summary-card .summary-icon {
    font-size: 1.5rem;
    color: #6c757d;
    width: 40px;
    text-align: center;
}

.summary-card .summary-content {
    display: flex;
    flex-direction: column;
}

.summary-card .summary-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.summary-card .summary-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: #212529;
}

.module-toolbar {
    margin-bottom: 20px;
}

.module-toolbar.compact {
    margin-top: 10px;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

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

.form-section {
    margin-bottom: 10px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.form-section h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
}

/* Info Grid for displaying related information */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.info-value {
    font-size: 0.95rem;
    color: #212529;
    font-weight: 600;
}

.work-order-info-section {
    background-color: #e3f2fd;
    border-color: #90caf9;
}

.work-order-info-section h4 {
    border-bottom-color: #1976d2;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 10px;
}

/* 載具設定與篩分服務的特殊比例 */
.form-row.tools-services-row {
    grid-template-columns: 2fr 3fr;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.form-row .form-section {
    margin-bottom: 0;
}

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

.form-grid label.full-width {
    grid-column: 1 / -1;
}

/* 住址欄位與 Email 欄位跨越兩欄 */
.form-grid label.inline-label[data-source-address],
.form-grid label.inline-label[data-target-address],
.form-grid label.inline-label[data-span-two-columns] {
    grid-column: 1 / -1;
}

/* 複製按鈕樣式 */
.form-grid label.full-width button[data-action="copy-registered-address"] {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 13px;
    align-self: flex-start;
}

/* 地址按鈕在 label 外的樣式 */
.form-grid button[data-action="copy-registered-address"] {
    grid-column: 1 / -1;
    padding: 6px 12px;
    font-size: 13px;
    width: fit-content;
    margin-top: 8px;
}

.form-grid label span {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #495057;
}

/* 平行長條樣式 */
.form-grid label.inline-label {
    display: flex;
    align-items: stretch;
    margin-bottom: 12px;
}

.form-grid label.inline-label span {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 120px;
    padding: 4px 10px;
    margin-bottom: 0;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-right: none;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.form-grid label.inline-label input,
.form-grid label.inline-label select {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 0;
    margin-bottom: 0;
    font-size: 15px;
}

.filter-form input,
.filter-form select,
.form-panel input,
.form-panel select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 0;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.filter-form input:focus,
.filter-form select:focus,
.form-panel input:focus,
.form-panel select:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions.align-right {
    justify-content: flex-end;
}

.form-actions button,
.pagination button {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    background-color: #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-size: 14px;
}

.form-actions button:hover,
.pagination button:hover {
    background-color: #dee2e6;
}

.form-actions .primary,
.form-actions .accent {
    color: #fff;
    border-color: transparent;
}

.form-actions .primary {
    background-color: #4CAF50;
}

.form-actions .primary:hover {
    background-color: #45a049;
}

.form-actions .accent {
    background-color: #17a2b8;
}

.form-actions .accent:hover {
    background-color: #138496;
}

.table-responsive {
    overflow-x: auto;
}

.pagination {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 15px;
}

.pagination button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.module-alert {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 15px;
    border: 1px solid transparent;
}

.module-alert.success {
    background-color: #eaf6ed;
    border-color: #c9e7d1;
    color: #2f8a3b;
}

.module-alert.error {
    background-color: #fdecea;
    border-color: #f5c6cb;
    color: #b02a37;
}

/* Modal 內部警告訊息 */
.modal-alert {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 6px;
    font-size: 15px;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideDown 0.3s ease-out;
}

.modal-alert::before {
    content: '\f06a'; /* FontAwesome info-circle icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.modal-alert.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.modal-alert.success::before {
    content: '\f058'; /* check-circle */
    color: #28a745;
}

.modal-alert.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.modal-alert.error::before {
    content: '\f06a'; /* exclamation-circle */
    color: #dc3545;
}

.modal-alert.warning {
    background-color: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}

.modal-alert.warning::before {
    content: '\f071'; /* exclamation-triangle */
    color: #ffc107;
}

.modal-alert.info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.modal-alert.info::before {
    content: '\f05a'; /* info-circle */
    color: #17a2b8;
}

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

.form-panel {
    margin-top: 25px;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-panel h3 {
    margin-bottom: 15px;
    color: #2f3b4c;
}

.form-panel small {
    display: block;
    margin-top: 4px;
    color: #6c757d;
    font-size: 12px;
}

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

/* 表格操作按鈕圖標樣式 */
.btn-icon {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-icon:hover {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

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

.btn-icon.primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.btn-icon.danger {
    background: transparent;
    border-color: #dc3545;
    color: #dc3545;
}

.btn-icon.danger:hover {
    background: #dc3545;
    color: #fff;
}

.link {
    background: #007bff;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    margin-right: 4px;
    border-radius: 4px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.link:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.link.danger {
    background: #dc3545;
}

.link.danger:hover {
    background: #a71d2a;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(33, 37, 41, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-window {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: min(1800px, 95%);
    max-height: 80vh;
    padding: 20px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.2s ease;
    overflow-y: auto;
}

.modal-window h3 {
    margin-bottom: 18px;
    color: #2f3b4c;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background-color: #f8f9fa;
    color: #495057;
}

.modal-close:active {
    transform: scale(0.95);
}

/* Column Selector Styles */
.column-selector {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 280px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 900;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.column-selector.hidden {
    display: none;
}

.column-selector-header {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.column-selector-header h4 {
    margin: 0;
    font-size: 16px;
    color: #2f3b4c;
}

.column-selector-header .close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.column-selector-header .close-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

.column-selector-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.column-selector-body .column-option {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.column-selector-body .column-option:hover {
    background-color: #f8f9fa;
}

.column-selector-body .column-option input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.column-selector-body .column-option span {
    font-size: 14px;
    color: #495057;
}

.column-selector-footer {
    padding: 12px 15px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background-color: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.modal-window form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-window form input,
.modal-window form select,
.modal-window form textarea {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 0;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

.modal-window form input:focus,
.modal-window form select:focus,
.modal-window form textarea:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.modal-window form input:invalid,
.modal-window form select:invalid,
.modal-window form textarea:invalid {
    border-color: #dc3545;
}

.modal-window form input:disabled,
.modal-window form select:disabled,
.modal-window form textarea:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-window form .form-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
    margin-bottom: 0;
}

.form-grid-two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.form-grid-three-columns {
    grid-template-columns: repeat(3, 1fr) !important;
}

.form-grid-four-columns {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

@media (max-width: 768px) {
    .form-grid-two-columns,
    .form-grid-three-columns,
    .form-grid-four-columns {
        grid-template-columns: 1fr !important;
    }
}

.form-address {
    margin-top: 8px;
}

.form-address label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.modal-window form .form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

/* 覆蓋預設的垂直排列，改為水平 */
.modal-window form .form-grid label.inline-label {
    flex-direction: row;
    gap: 0;
    margin-bottom: 12px;
}

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

.field-combo select {
    flex: 1 1 0;
    min-width: 0;
}

@media (max-width: 600px) {
    .field-combo {
        flex-direction: column;
        align-items: stretch;
    }
}

.screening-item-field .field-hint {
    color: #6c757d;
    font-size: 13px;
}

.screening-create-panel {
    margin-top: 8px;
}

.screening-create-panel.hidden {
    display: none;
}

.screening-create-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.screening-create-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
}

.screening-create-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #343a40;
}

.screening-create-body {
    padding: 16px;
    background: #fff;
}

.screening-create-body label.full-width {
    grid-column: 1 / -1;
}

.screening-create-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.screening-create-footer .btn.small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.checkbox-field {
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
}

.checkbox-field span {
    margin-bottom: 0 !important;
}

.checkbox-field input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.file-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-input-group input[type="file"] {
    display: none; /* 隱藏原生檔案輸入 */
}

/* 自訂檔案上傳按鈕 */
.file-input-group label.file-upload-btn {
    display: inline-block;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #4CAF50 0%, #2f8a3b 100%);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: fit-content;
}

.file-input-group label.file-upload-btn:hover {
    background: linear-gradient(135deg, #43a047 0%, #276f2e 100%);
    transform: translateY(-1px);
}

.file-input-group label.file-upload-btn:active {
    transform: translateY(0);
}

.file-input-group label.file-upload-btn i {
    margin-right: 6px;
}

.invoice-stamp-preview {
    margin-top: 8px;
    border: 1px dashed #ced4da;
    border-radius: 6px;
    padding: 8px;
    background-color: #fafafa;
}

.invoice-stamp-preview img {
    max-width: 100%;
    max-height: 200px;
    display: block;
    margin: 0 auto 8px;
    object-fit: contain;
    border-radius: 4px;
}

.invoice-stamp-preview .preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.invoice-stamp-preview .icon-button {
    width: 36px;
    height: 36px;
    padding: 8px;
}

.invoice-stamp-preview .icon-button i {
    font-size: 16px;
}

/* 通用附件預覽 */
.attachment-preview {
    margin-top: 8px;
    border: 1px dashed #ced4da;
    border-radius: 6px;
    padding: 12px;
    background-color: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.attachment-preview .preview-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #495057;
}

.attachment-preview .preview-info i {
    font-size: 20px;
    color: #4CAF50;
}

.attachment-preview .preview-actions {
    display: flex;
    gap: 12px;
}

.attachment-preview .icon-button {
    width: 36px;
    height: 36px;
    padding: 8px;
}

.attachment-preview .icon-button i {
    font-size: 16px;
}

.field-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #6c757d;
}

.link.disabled,
.link.disabled:focus,
.link.disabled:hover {
    color: #adb5bd;
    pointer-events: none;
    cursor: default;
    text-decoration: none;
}

.modal-window form .form-grid label small {
    display: block;
    margin-top: 4px;
    color: #6c757d;
    font-size: 12px;
}

.modal-window.xlarge {
    width: min(1800px, 95%);
}

.modal-window-large {
    width: min(1200px, 90%);
}

/* Detail Content Styles */
.detail-content {
    padding: 10px 0;
}

.detail-content dl {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.detail-content dl > div {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 15px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.detail-content dl > div:last-child {
    border-bottom: none;
}

.detail-content dt {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.detail-content dd {
    color: #212529;
    font-size: 14px;
    word-break: break-word;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #2f3b4c;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.detail-section p {
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    color: #495057;
    line-height: 1.6;
}

.detail-section .table-responsive {
    margin-top: 10px;
}

.detail-section table {
    font-size: 13px;
}

.detail-section table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Subsection Styles */
.subsection {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    background-color: #fff;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.subsection-header h4 {
    margin: 0;
    font-size: 16px;
    color: #2f3b4c;
    font-weight: 600;
}

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

.subsection-body {
    display: block;
}

.subsection-body.hidden {
    display: none;
}

/* Image Gallery Styles */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 12px;
    min-height: 100px;
}

.image-gallery .empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6c757d;
}

.image-gallery .empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.image-gallery .image-item {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 1;
}

.image-gallery .image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-gallery .image-item .btn-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-gallery .image-item:hover .btn-delete {
    opacity: 1;
}

.order-items-modal {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 85vh;
}

.order-items-modal form {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    min-height: 0;
}

.order-items-modal .order-items-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 20px 16px 0;
    margin-right: -16px;
}

.order-items-modal .order-items-modal-body::-webkit-scrollbar {
    width: 8px;
}

.order-items-modal .order-items-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.order-items-modal .order-items-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.order-items-modal .order-items-modal-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.order-items-modal .order-items-modal-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    margin: 0 -20px -20px;
    padding: 16px 20px 20px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
}

.order-items-modal .order-items-modal-footer .metrics-panel {
    margin: 0;
}

.metrics-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.metrics-panel .metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metrics-panel .metric-label {
    font-size: 13px;
    color: #6c757d;
}

.metrics-panel .metric strong {
    font-size: 18px;
    color: #1f2937;
}

/* Metrics Comparison Container for Work Orders */
.metrics-comparison-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.metrics-comparison-container .metrics-panel {
    margin: 0;
}

.metrics-comparison-container .metrics-subtitle {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.metrics-comparison-container .metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metrics-comparison-container .metrics-panel.metrics-diff {
    background-color: #fff5e6;
    border-color: #ffc107;
}

.metrics-comparison-container .diff-value {
    font-weight: 700;
}

.metrics-comparison-container .diff-value.positive {
    color: #10b981;
}

.metrics-comparison-container .diff-value.negative {
    color: #ef4444;
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: #ef4444 !important;
}

.table-primary {
    font-weight: 600;
    color: #1f2937;
}

.table-secondary {
    margin-top: 4px;
    font-size: 13px;
    color: #6c757d;
}

.stacked-inputs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stacked-inputs input {
    width: 100%;
}

/* Work Order Modal - Complete Layout Fix */
.modal-window.work-orders-modal {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    max-height: 90vh;
}

.work-orders-modal h3[data-modal-title] {
    margin-bottom: 15px;
    flex-shrink: 0;
    padding-right: 40px;
}

.work-orders-modal .modal-alert {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.work-orders-modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 0;
}

.work-orders-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
    margin-bottom: 15px;
}

.work-orders-modal-body::-webkit-scrollbar {
    width: 8px;
}

.work-orders-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.work-orders-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.work-orders-modal-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.work-orders-modal-footer {
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
    background-color: #fff;
}

/* Tabs & Search Styles */
.source-selection-section {
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    background-color: #fff;
}

.source-selection-section .tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 15px;
}

.source-selection-section .tab-btn {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 15px;
    color: #6c757d;
    font-weight: 500;
    transition: all 0.2s ease;
}

.source-selection-section .tab-btn:hover {
    color: #495057;
    background-color: #f8f9fa;
}

.source-selection-section .tab-btn.active {
    color: #4CAF50;
    border-bottom-color: #4CAF50;
    font-weight: bold;
}

.source-selection-section .tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.source-selection-section .tab-content.active {
    display: block;
}

.search-grid {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.search-grid .form-grid {
    flex-grow: 1;
    margin-bottom: 0;
}

.search-results {
    margin-top: 15px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.search-results .data-table {
    margin-top: 0;
}

.search-results .data-table th {
    background-color: #f1f3f5;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Read-only field styles */
.readonly-field {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    cursor: not-allowed !important;
    border-color: #e9ecef !important;
}

.info-section {
    background-color: #f8f9fa;
}

.info-section .section-title {
    color: #6c757d;
    font-size: 15px;
}

.info-section .section-title .text-muted {
    font-weight: normal;
    font-size: 13px;
}

/* Form row for side-by-side sections */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row > .subsection {
    margin-bottom: 0;
}

@media (max-width: 1200px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* 表格標題操作列 */
.table-header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

/* 下拉選單 - 已停用選項樣式 */
select option.inactive-option {
    color: #888;
    background-color: #f5f5f5;
}

select option:disabled {
    color: #aaa;
    font-style: italic;
}
