/* ==========================================
   順興隆工程項目管理系統 CSS 樣式表
   設計風格：現代高端商務藍、玻璃質感與微動畫
   ========================================== */

/* 1. 全域變數與重設 */
:root {
    --primary-color: #0f172a;       /* 深藍灰 - 主要文字與標題 */
    --primary-light: #1e293b;
    --accent-blue: #2563eb;         /* 皇家藍 - 主要按鈕及品牌 */
    --accent-teal: #0d9488;         /* 蒂芙尼綠 - 中標/完成狀態 */
    --accent-purple: #7c3aed;       /* 靛紫 - 提示與次要圖表 */
    --accent-orange: #d97706;       /* 橙黃 - 審批中 */
    --accent-red: #dc2626;          /* 紅色 - 未中標/警告 */
    
    --bg-main: #f8fafc;             /* 淺灰底色 */
    --bg-card: rgba(255, 255, 255, 0.85); /* 玻璃半透白色卡片 */
    --border-color: #e2e8f0;
    
    --text-main: #334155;           /* 深灰文字 */
    --text-muted: #64748b;          /* 輔助文字 */
    --text-light: #94a3b8;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 2. 導覽列 (Navbar) */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    height: 42px;
    width: 42px;
    border-radius: 8px;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.company-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #38bdf8;
    text-transform: uppercase;
}

.system-title {
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
}

.nav-menu {
    display: flex;
    gap: 6px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: #ffffff;
    background: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: translateY(-1px);
}

.role-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

/* 3. 佈局容器 */
.app-container {
    max-width: 1300px;
    margin: 30px auto;
    padding: 0 20px;
    min-height: calc(100vh - 140px);
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

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

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    border-bottom: 1.5px solid var(--border-color);
    padding-bottom: 16px;
}

.title-area h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.controls-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 4. 基本 UI 元件 - 按鈕、輸入框 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background-color: #ffffff;
    border-color: var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

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

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

.btn-group {
    display: flex;
    gap: 8px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    padding: 10px 14px 10px 40px;
    border-radius: 8px;
    font-size: 14px;
    width: 260px;
    transition: var(--transition-normal);
    outline: none;
    box-shadow: var(--shadow-sm);
}

.search-box input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    width: 320px;
}

.filter-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.filter-btn.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* 5. 卡片元件 (Cards) */
.card {
    background-color: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
    overflow: hidden;
}

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

.p-20 { padding: 20px; }
.p-30 { padding: 30px; }
.mb-20 { margin-bottom: 20px; }
.mt-10 { margin-top: 10px; }
.mt-30 { margin-top: 30px; }
.max-w-800 { max-width: 800px; }
.max-w-1000 { max-width: 1000px; }
.mx-auto { margin-left: auto; margin-right: auto; }

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.card-header-flex .card-title {
    margin-bottom: 0;
}

/* 前台工程目錄卡片格線 */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.project-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-top {
    padding: 20px;
    border-bottom: 1px dashed var(--border-color);
    position: relative;
}

.card-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.id-badge {
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

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

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

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

.card-client {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 4px;
}

.card-desc {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.4;
    min-height: 48px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-body-details {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.detail-row-flex {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.row-item {
    display: flex;
    flex-direction: column;
}

.row-item .lbl {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
}

.row-item .val {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.card-price-section {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.price-lbl {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.price-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-color);
    font-family: 'Outfit', sans-serif;
}

.card-actions-row {
    padding: 16px 20px;
    background: rgba(248, 250, 252, 0.6);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 6. 表格設計 */
.table-container {
    overflow-hidden: true;
    margin-bottom: 30px;
}

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

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

.data-table th, .data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f1f5f9;
    color: var(--primary-light);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}

.data-table tr:hover td {
    background-color: rgba(241, 245, 249, 0.5);
}

.data-table td .btn-group {
    justify-content: center;
}

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

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

.readonly-input {
    background-color: #f1f5f9 !important;
    cursor: not-allowed;
    font-weight: 600;
}

/* 7. 統計儀表板元件 */
.stats-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    border-radius: 12px;
    padding: 24px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
}

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

.bg-gradient-blue {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.bg-gradient-green {
    background: linear-gradient(135deg, #064e3b 0%, #10b981 100%);
}

.bg-gradient-cyan {
    background: linear-gradient(135deg, #164e63 0%, #06b6d4 100%);
}

.bg-gradient-purple {
    background: linear-gradient(135deg, #4c1d95 0%, #8b5cf6 100%);
}

.metric-icon {
    font-size: 32px;
    opacity: 0.85;
}

.metric-info h3 {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 26px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

.chart-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.chart-box h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
    border-left: 4px solid var(--accent-blue);
    padding-left: 10px;
}

.chart-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

/* 8. 後台控制台關係圖 */
.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
}

.relations-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.flow-node {
    width: 100%;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.flow-node:hover {
    border-color: var(--accent-blue);
    background: #f8fafc;
}

.flow-node.main-contractor {
    border-left: 4px solid var(--accent-purple);
}

.flow-node.subcontractor {
    border-left: 4px solid var(--accent-blue);
}

.flow-node.sub-subcontractor {
    border-left: 4px solid var(--accent-teal);
}

.flow-node strong {
    display: block;
    font-size: 13px;
    color: var(--primary-color);
}

.flow-node .label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.flow-arrow {
    font-size: 14px;
    color: var(--text-light);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

.rules-list {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.rules-list li {
    font-size: 13px;
    color: var(--text-main);
    position: relative;
    padding-left: 20px;
    line-height: 1.5;
}

.rules-list li::before {
    content: "\f058";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 2px;
    color: var(--accent-teal);
}

/* 9. 表單控制設計 (登錄與製作 PO) */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.span-2 {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-color);
}

.required {
    color: var(--accent-red);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
    background-color: #ffffff;
    font-family: inherit;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.section-divider {
    margin-top: 20px;
    border-bottom: 1.5px solid var(--border-color);
    padding-bottom: 8px;
}

.section-divider h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.po-input-group {
    display: flex;
    gap: 8px;
}

.po-input-group input {
    flex-grow: 1;
}

.po-input-group button {
    white-space: nowrap;
}

.field-hint {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.po-calc-summary {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.calc-row label {
    font-weight: 600;
}

.calc-row input {
    width: 120px;
    text-align: right;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.calc-row.total-row {
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-red);
}

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

/* 10. 互動式對話框 (Modal Detail Drawer) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-card {
    transform: scale(1);
}

.modal-card-header {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-card-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    color: #ffffff;
}

.modal-card-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.detail-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.m-id-tag {
    font-size: 13px;
    color: var(--text-muted);
}

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

.detail-section h4 {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-content-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.detail-item .label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
}

.detail-item .value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.pricing-detail-section {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.pricing-flex {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.price-box {
    display: flex;
    flex-direction: column;
}

.price-box .label {
    font-size: 11px;
    color: var(--text-muted);
}

.price-box .value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.total-price-box {
    grid-column: span 2;
    border-top: 1px dashed #cbd5e1;
    padding-top: 8px;
    margin-top: 4px;
}

.total-price-box .label {
    color: var(--accent-blue);
    font-weight: 700;
}

.total-price-box .value {
    font-size: 20px;
    color: var(--primary-color);
    font-weight: 800;
}

.modal-card-footer {
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 11. 吐司通知 */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: #1e293b;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* 12. PO 列印專用版面 (A4 尺寸與邊界) */
.po-sheet-paper {
    background: #ffffff;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 30px auto;
    padding: 15mm;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--border-color);
    border-radius: 4px;
    font-family: "Noto Sans TC", sans-serif;
    color: #000000;
    box-sizing: border-box;
    position: relative;
}

.show-print {
    display: none;
}

/* PO 抬頭樣式 */
.po-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #000000;
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.po-header-left .comp-title {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: #000000;
}

.po-header-left .comp-title-zh {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 6px;
}

.po-header-left .comp-addr {
    font-size: 11px;
    color: #333333;
    line-height: 1.4;
}

.po-header-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.po-title-block h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.po-title-block h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-top: 2px;
}

.po-meta-block {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.meta-row {
    font-size: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.meta-label {
    font-weight: 700;
    color: #333333;
}

.meta-val {
    font-weight: 600;
    min-width: 80px;
    text-align: left;
}

.meta-val.highlight {
    font-size: 14px;
    font-weight: 800;
}

/* 地址區塊 (Bill to / Ship to) */
.po-addresses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.addr-box {
    border: 1px solid #000000;
    border-radius: 4px;
    overflow: hidden;
}

.addr-box .box-title {
    background-color: #000000;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

.addr-box .box-content {
    padding: 10px;
    font-size: 11px;
    line-height: 1.4;
    min-height: 90px;
}

.addr-box .firm-name {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

/* PO 明細表格 */
.po-table-wrapper {
    margin-bottom: 20px;
    min-height: 250px;
}

.po-sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.po-sheet-table th, .po-sheet-table td {
    padding: 6px 8px;
    border: 1px solid #000000;
}

.po-sheet-table th {
    background-color: #f1f5f9;
    font-weight: 700;
    text-align: center;
}

.po-sheet-table td.no-border {
    border: none;
}

.po-sheet-table tr.no-border td {
    border: none;
}

.po-sheet-table .sub-item-row td {
    color: #475569;
}

.po-sheet-table .sub-item-row .desc-cell {
    padding-left: 24px;
}

.po-sheet-table .total-label {
    font-weight: 700;
    text-align: right;
    border: 1px solid #000000;
    background-color: #f8fafc;
}

.po-sheet-table .total-val {
    font-weight: 700;
    border: 1px solid #000000;
}

.po-sheet-table .border-top {
    border-top: 1px solid #000000;
}

.po-sheet-table .border-double {
    border-bottom: 3px double #000000;
}

.po-sheet-table .highlight-bg {
    background-color: #e2e8f0;
}

.po-sheet-table .highlight {
    font-size: 12px;
    font-weight: 800;
}

.company-signature-cell {
    vertical-align: bottom;
    padding-bottom: 4px;
}

.subcon-footer-name {
    font-size: 12px;
    font-weight: 800;
    border-bottom: 1.5px solid #000000;
    padding-bottom: 2px;
}

/* PO 底部與條款 */
.po-footer-section {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    font-size: 11px;
}

.po-footer-left {
    width: 60%;
}

.terms-title {
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

.terms-content {
    border: 1px solid #cccccc;
    padding: 8px;
    border-radius: 4px;
    min-height: 60px;
    margin-bottom: 10px;
    background: #fafafa;
}

.system-generated-notice {
    font-style: italic;
    color: #666666;
    font-size: 10px;
    margin-top: 15px;
}

.po-footer-right {
    width: 35%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

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

.sig-space {
    height: 60px;
}

.sig-line {
    border-bottom: 1.5px solid #000000;
    margin-bottom: 4px;
}

.sig-label {
    font-size: 11px;
    font-weight: 700;
}

.sig-label-en {
    font-size: 9px;
    color: #666666;
}

/* 13. PDF 列印核心樣式設定 */
@media print {
    /* 隱藏非列印元素 */
    .no-print, 
    .navbar, 
    .view-header, 
    .form-actions, 
    .modal-overlay,
    .toast-notification,
    .controls-area {
        display: none !important;
    }
    
    body {
        background-color: #ffffff;
        color: #000000;
        font-size: 12pt;
    }

    .app-container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 0 !important;
    }

    /* 將所有視圖隱藏，只顯示當前 active 且需要列印的 section */
    .view-section {
        display: none !important;
    }

    .view-section.active {
        display: block !important;
    }
    
    /* 中標分析列印最佳化 */
    #stats-view.active {
        padding: 0 !important;
    }

    #stats-view .show-print {
        display: block !important;
    }
    
    .stats-metrics-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin-bottom: 20px !important;
    }
    
    .metric-card {
        padding: 12px !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        background: #f8fafc !important;
        color: #000000 !important;
    }
    
    .metric-icon {
        display: none !important;
    }
    
    .metric-info h3 {
        color: #475569 !important;
        font-size: 10px !important;
    }
    
    .metric-value {
        color: #0f172a !important;
        font-size: 16pt !important;
    }
    
    #stats-view .table-container {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* 工程單 (PO) 與報價單 (Quotation) 列印設定 */
    #po-print-view.active,
    #quotation-print-view.active {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .po-sheet-paper {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        min-height: 100% !important;
    }

    .po-sheet-table th {
        background-color: #e2e8f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .po-sheet-table .highlight-bg {
        background-color: #cbd5e1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* 列印分頁規則 */
    .page-break {
        page-break-before: always;
    }
}

/* 額外輔助樣式 */
.relations-flow {
    margin-top: 15px;
}
.rules-list {
    margin-top: 15px;
}
.po-input-group {
    display: flex;
}
.po-input-group input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.po-input-group button {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.span-2.section-divider {
    border-bottom: 2px solid var(--primary-color);
}
.price-calc-trigger {
    font-weight: 600;
}
.modal-overlay.open {
    display: flex;
}

/* 統計列印的頁首標題 */
.print-header {
    border-bottom: 2px solid #000000;
    padding-bottom: 12px;
    margin-bottom: 24px;
}

.print-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.print-logo {
    height: 50px;
    width: 50px;
    border-radius: 8px;
}

.print-company-info h2 {
    font-size: 14px;
    font-weight: 700;
    color: #475569;
}

.print-company-info h1 {
    font-size: 18px;
    font-weight: 900;
    color: #0f172a;
}

.print-date {
    font-size: 11px;
    color: #64748b;
}

.print-signatures {
    display: flex;
    justify-content: flex-end;
    margin-top: 30px;
}

.print-footer-notice {
    text-align: center;
    border-top: 1px dashed #cbd5e1;
    margin-top: 20px;
    padding-top: 8px;
    font-size: 10px;
    color: #64748b;
}

/* 印章圖片效果 */
.signature-block {
    position: relative;
}

.sig-chop-img {
    height: 85px;
    width: auto;
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.85;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 5;
}

/* ==========================================
   14. 響應式手機板優化 (Mobile Responsiveness)
   ========================================== */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
        margin-top: 10px;
        width: 100%;
    }
    
    .navbar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .nav-right {
        margin-top: 5px;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .app-container {
        margin: 15px auto;
        padding: 0 10px;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .span-2 {
        grid-column: span 1;
    }
    
    .offset-3.span-2 {
        grid-column: span 1;
        margin-left: 0;
    }
    
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .controls-area {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .search-box input:focus {
        width: 100%;
    }
    
    .filter-group {
        width: 100%;
        overflow-x: auto;
        display: flex;
        justify-content: space-between;
    }
    
    .filter-btn {
        flex-grow: 1;
        text-align: center;
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .modal-card {
        width: 95%;
        margin: 10px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
}
