/* ===== Reset & Variables ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5A5A5A;
    --primary-light: #888888;
    --primary-dark: #333333;
    --accent: #C8A96E;
    --accent-light: #E8D5B0;
    --bg: #F5F5F3;
    --sidebar-bg: #FFFFFF;
    --card-bg: #FFFFFF;
    --text: #2D2D2D;
    --text-light: #8C8C8C;
    --border: #E8E8E6;
    --success: #6B9E78;
    --danger: #C75C5C;
    --warning: #D4A84B;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ===== Login Screen ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
}
.login-card h1 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 4px;
}
.login-subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 24px;
}
.login-card .form-group {
    text-align: left;
    margin-bottom: 16px;
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.logo {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.logo-img {
    width: 140px;
    height: auto;
    margin-bottom: 6px;
}

.logo span {
    font-size: 12px;
    color: var(--text-light);
    display: block;
    letter-spacing: 2px;
    text-transform: uppercase;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    padding: 11px 16px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary-dark);
    color: white;
    font-weight: 600;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px 40px;
    max-width: 1200px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    margin-bottom: 0;
}

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90, 90, 90, 0.08);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--primary-dark);
    color: white;
}

.btn-primary:hover {
    background: var(--text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background: white;
    color: var(--primary-dark);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: none;
    padding: 4px 8px;
    font-size: 18px;
}

.btn-danger:hover {
    background: #FDF2F2;
}

/* ===== Quick Add Tags ===== */
.quick-add {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
}

.quick-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: white;
    color: var(--primary-dark);
    transition: all 0.2s;
}

.tag:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

/* ===== Items Table ===== */
.items-table {
    overflow-x: auto;
}

.items-table table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background: var(--bg);
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.items-table input,
.items-table select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s;
}

.items-table input:focus,
.items-table select:focus {
    outline: none;
    border-color: var(--primary);
}

.col-no { width: 40px; text-align: center; }
.col-service { width: 160px; }
.col-desc { width: auto; }
.col-unit { width: 80px; }
.col-qty { width: 70px; }
.col-price { width: 120px; }
.col-subtotal { width: 120px; text-align: right; }
.col-action { width: 40px; }

.subtotal-cell {
    text-align: right;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

/* ===== Summary ===== */
.summary {
    margin-top: 20px;
    margin-left: auto;
    width: 380px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-light);
}

.summary-row + .summary-row {
    border-top: 1px solid var(--border);
}

.discount-row select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    margin-left: 8px;
}

.discount-row input {
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    margin-right: 8px;
}

.tax-included-row {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    background: rgba(200, 169, 110, 0.08);
    border-radius: 4px;
    padding: 10px 8px;
}

.total-row {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
    padding-top: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-dark);
}

/* ===== History Table ===== */
.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    background: var(--bg);
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.history-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    white-space: nowrap;
}

.history-table tr:hover {
    background: var(--bg);
}

/* 發票管理表格 — 操作按鈕不換行 */
#page-invoices .history-table td:last-child {
    white-space: nowrap;
}
#page-invoices .history-table td:last-child .btn {
    padding: 4px 8px;
    font-size: 12px;
}
/* 品名欄可以換行，其他不要 */
#page-invoices .history-table td:nth-child(4) {
    white-space: normal;
    min-width: 100px;
}
/* 表格可��向捲動 */
#page-invoices .card {
    overflow-x: auto;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 40px !important;
    font-style: italic;
}

.search-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 260px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Settings Presets ===== */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preset-item {
    display: grid;
    grid-template-columns: 1fr 100px 120px;
    gap: 10px;
    align-items: center;
}

.preset-item label {
    font-size: 14px;
    font-weight: 500;
}

.preset-item input,
.preset-item select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.hint {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
}

/* ===== Package Cards ===== */
.pkg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.pkg-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    background: white;
}

.pkg-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.pkg-card.selected {
    border-color: var(--primary-dark);
    background: #FAFAF8;
    box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.1);
}

.pkg-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.pkg-popular {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.pkg-qty {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.2;
    margin-bottom: 4px;
}

.pkg-qty small {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.pkg-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.pkg-price small {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.pkg-price-range {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 4px;
}

.pkg-original {
    font-size: 12px;
    color: var(--text-light);
    text-decoration: line-through;
    margin-bottom: 12px;
}

.pkg-total {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    padding: 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.pkg-total-highlight {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--bg);
    padding: 8px 10px;
    border-radius: 6px;
    margin-top: 12px;
}

.pkg-card.selected .pkg-total-highlight {
    background: white;
}

/* ===== Edit Package Section ===== */
.edit-pkg-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.edit-pkg-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 10px;
    padding-left: 4px;
}

.edit-pkg-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.edit-pkg-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
}

.edit-pkg-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.edit-pkg-card.selected {
    border-color: var(--primary-dark);
    background: #FAFAF8;
}

.edit-pkg-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.edit-pkg-price {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
}

.edit-pkg-price small {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.edit-pkg-min {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Addon Grid ===== */
.addon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.addon-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s;
}

.addon-item:hover {
    border-color: var(--primary-light);
    background: #FAFAF8;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.addon-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.addon-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
}

.addon-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center;
    align-items: flex-start;
    padding: 40px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
}

.modal-header div {
    display: flex;
    gap: 8px;
}

.modal-body {
    padding: 0;
}

/* ===== Quote Preview (PDF Style) ===== */
.quote-preview {
    padding: 48px;
    font-family: 'Segoe UI', sans-serif;
}

.qp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--primary-dark);
}

.qp-brand h1 {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: 3px;
}

.qp-brand p {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
}

.qp-meta {
    text-align: right;
}

.qp-meta h2 {
    font-size: 22px;
    color: var(--primary-dark);
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.qp-meta p {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.8;
}

.qp-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 36px;
}

.qp-party h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.qp-party p {
    font-size: 14px;
    line-height: 1.8;
}

.qp-party strong {
    font-size: 16px;
    display: block;
    margin-bottom: 4px;
}

.qp-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.qp-table th {
    background: var(--primary-dark);
    color: white;
    padding: 11px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
}

.qp-table th:last-child,
.qp-table td:last-child {
    text-align: right;
}

.qp-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.qp-table tr:nth-child(even) {
    background: #FAFAF8;
}

.qp-table .desc-cell {
    color: var(--text-light);
    font-size: 13px;
}

.qp-summary {
    margin-left: auto;
    width: 300px;
    margin-bottom: 36px;
}

.qp-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-light);
}

.qp-summary-row + .qp-summary-row {
    border-top: 1px solid var(--border);
}

.qp-summary-total {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
    border-top: 2px solid var(--primary-dark);
    margin-top: 4px;
}

.qp-terms {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.qp-terms h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary-dark);
}

.qp-terms p, .qp-terms li {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.8;
}

.qp-terms ul {
    padding-left: 20px;
}

.qp-footer {
    margin-top: 48px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .pkg-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .addon-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        padding: 16px 8px;
    }
    .logo span, .nav-btn {
        font-size: 11px;
    }
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    .summary {
        width: 100%;
    }
    .pkg-grid {
        grid-template-columns: 1fr;
    }
    .edit-pkg-row {
        grid-template-columns: 1fr;
    }
    .addon-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ===== Stats Row ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.stat-card-lg {
    padding: 24px;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-dark);
}

.stat-success { color: #10B981; }
.stat-warning { color: #F59E0B; }
.stat-danger { color: #EF4444; }

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Filter Select ===== */
.header-actions select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text);
}

/* ===== General Modal Form ===== */
#generalModalContent .form-group {
    margin-bottom: 14px;
}

#generalModalContent .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#generalModalContent .form-group input,
#generalModalContent .form-group select,
#generalModalContent .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text);
}

#generalModalContent .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== Responsive Stats ===== */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .stats-row:has(.stat-card-lg) {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Reports page 3-column stats */
#page-reports .stats-row {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    #page-reports .stats-row {
        grid-template-columns: 1fr;
    }
}

/* ===== Dashboard Cards ===== */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.dash-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dash-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.dash-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.dash-income .dash-icon {
    background: #ECFDF5;
    color: #10B981;
}

.dash-expense .dash-icon {
    background: #FEF2F2;
    color: #EF4444;
}

.dash-profit .dash-icon {
    background: #EFF6FF;
    color: #3B82F6;
}

.dash-profit.negative .dash-icon {
    background: #FEF2F2;
    color: #EF4444;
}

.dash-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.dash-amount {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary-dark);
}

.dash-income .dash-amount { color: #10B981; }
.dash-expense .dash-amount { color: #EF4444; }
.dash-profit .dash-amount { color: #3B82F6; }
.dash-profit.negative .dash-amount { color: #EF4444; }

.expense-filters {
    margin-bottom: 16px;
}

.expense-filters select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text);
}

.expense-category {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text);
}

.monthly-profit-positive { color: #10B981; font-weight: 700; }
.monthly-profit-negative { color: #EF4444; font-weight: 700; }

@media (max-width: 768px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-cards {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== Recurring Reminder Banner ===== */
.recurring-reminder {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1px solid #F59E0B;
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 20px;
    animation: reminderPulse 2s ease-in-out 1;
}

@keyframes reminderPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15); }
}

.reminder-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.reminder-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reminder-text strong {
    font-size: 14px;
    color: #92400E;
}

.reminder-text span {
    font-size: 12px;
    color: #A16207;
}

.reminder-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== Recurring Modal ===== */
.recurring-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.recurring-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.recurring-item.variable {
    border-color: var(--warning);
    background: #FFFBEB;
}

.recurring-check {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-dark);
}

.recurring-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.recurring-name small {
    font-weight: 400;
    color: var(--text-light);
    display: block;
    font-size: 12px;
}

.recurring-amount {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: right;
    min-width: 100px;
}

.recurring-amount input {
    width: 110px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: right;
}

.recurring-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--border);
    color: var(--text-light);
    font-weight: 600;
}

.recurring-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0;
    margin-top: 12px;
    border-top: 2px solid var(--border);
    font-size: 16px;
    font-weight: 700;
}

@media (max-width: 768px) {
    .reminder-content {
        flex-direction: column;
        align-items: flex-start;
    }
    .recurring-item {
        grid-template-columns: auto 1fr auto;
    }
    .recurring-tag {
        display: none;
    }
}

/* ===== Receipt Upload ===== */
.receipt-upload-area {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px dashed var(--border);
}

.receipt-upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.receipt-upload-box:hover {
    border-color: var(--primary-light);
    background: #FAFAF8;
    transform: translateY(-1px);
}

.receipt-upload-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.receipt-upload-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.receipt-upload-hint {
    font-size: 12px;
    color: var(--text-light);
}

.receipt-processing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    font-size: 14px;
    color: var(--primary-dark);
    font-weight: 600;
}

.receipt-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.receipt-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.receipt-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ===== Split Payment ===== */
.split-num-btn.active {
    background: var(--primary-dark);
    color: white;
    border-color: var(--primary-dark);
}

/* ===== Print ===== */
@media print {
    body * {
        visibility: hidden;
    }
    .quote-preview, .quote-preview * {
        visibility: visible;
    }
    .quote-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

/* ===== 財務總覽 — 新版設計 ===== */

/* 核心指標大卡 */
.finance-hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 32px;
    color: white;
    margin-bottom: 20px;
}
.finance-hero.negative {
    background: linear-gradient(135deg, #2e1a1a 0%, #3e1621 100%);
}
.hero-main {
    text-align: center;
    margin-bottom: 24px;
}
.hero-label {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 4px;
}
.hero-status {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.hero-amount {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
}
.hero-breakdown {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.15);
}
.hero-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.hero-dot.green { background: #34D399; }
.hero-dot.red { background: #F87171; }
.hero-item-label {
    font-size: 13px;
    opacity: 0.7;
}
.hero-item-amount {
    font-size: 18px;
    font-weight: 700;
}
.hero-sep {
    font-size: 20px;
    opacity: 0.4;
}

/* 待辦提醒 */
.finance-alerts {
    background: #FFF7ED;
    border: 1px solid #FED7AA;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}
.alert-title {
    font-size: 14px;
    font-weight: 700;
    color: #C2410C;
    margin-bottom: 10px;
}
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #9A3412;
    padding: 8px 12px;
    background: rgba(255,255,255,0.6);
    border-radius: 8px;
}
.alert-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.alert-amount {
    margin-left: auto;
    font-weight: 700;
    white-space: nowrap;
}

/* 快速數據卡 */
.finance-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.fin-stat {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.fin-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}
.fin-stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
}
.fin-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

/* 圖表區 */
.finance-charts {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}
.chart-container {
    position: relative;
    height: 260px;
}
.chart-container-pie {
    height: 240px;
}

/* 分頁切換 */
.finance-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 4px;
    box-shadow: var(--shadow);
}
.fin-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}
.fin-tab:hover {
    color: var(--text);
    background: var(--bg);
}
.fin-tab.active {
    background: var(--primary-dark);
    color: white;
}
.fin-tab-content {
    display: none;
}
.fin-tab-content.active {
    display: block;
}

/* 響應式 */
@media (max-width: 768px) {
    .finance-hero {
        padding: 24px 16px;
    }
    .hero-amount {
        font-size: 32px;
    }
    .hero-breakdown {
        flex-direction: column;
        gap: 12px;
    }
    .hero-sep {
        display: none;
    }
    .finance-stats {
        grid-template-columns: 1fr;
    }
    .finance-charts {
        grid-template-columns: 1fr;
    }
    .finance-tabs {
        overflow-x: auto;
    }
}

/* ===== 營運儀表板 ===== */
.dash-hero-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.dash-hero-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--text-light);
}
.dash-hero-card.green { border-left-color: #10B981; }
.dash-hero-card.red { border-left-color: #EF4444; }
.dash-hero-card .dash-hero-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}
.dash-hero-card .dash-hero-amount {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}
.dash-hero-card.profit-positive { border-left-color: #10B981; }
.dash-hero-card.profit-positive .dash-hero-amount { color: #10B981; }
.dash-hero-card.profit-negative { border-left-color: #EF4444; }
.dash-hero-card.profit-negative .dash-hero-amount { color: #EF4444; }

/* 收款進度條 */
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}
.progress-bar-track {
    height: 20px;
    background: #F3F4F6;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #34D399);
    border-radius: 10px;
    transition: width 0.6s ease;
    min-width: 2px;
}
.progress-legend {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-light);
}
.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* 待辦 & 動態 */
.dash-todo-list, .dash-activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}
.dash-todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    background: #FFF7ED;
    border: 1px solid #FED7AA;
    color: #9A3412;
}
.dash-todo-item.danger {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #991B1B;
}
.dash-todo-icon { font-size: 16px; flex-shrink: 0; }
.dash-todo-amount { margin-left: auto; font-weight: 700; white-space: nowrap; }

.dash-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg);
}
.dash-activity-icon { font-size: 14px; flex-shrink: 0; }
.dash-activity-date { margin-left: auto; font-size: 11px; color: var(--text-light); white-space: nowrap; }

/* ===== 帳齡分析 ===== */
.aging-bars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.aging-bar-item {
    text-align: center;
}
.aging-bar-label {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 6px;
    font-weight: 600;
}
.aging-bar-track {
    height: 40px;
    background: #F3F4F6;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin-bottom: 6px;
}
.aging-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 8px;
    transition: height 0.5s ease;
}
.aging-bar-amount {
    font-size: 14px;
    font-weight: 700;
}
.aging-bar-count {
    font-size: 11px;
    color: var(--text-light);
}

.aging-detail {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.aging-client-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
}
.aging-client-row.green { background: #F0FDF4; }
.aging-client-row.yellow { background: #FFFBEB; }
.aging-client-row.orange { background: #FFF7ED; }
.aging-client-row.red { background: #FEF2F2; }
.aging-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.aging-client-name { font-weight: 600; }
.aging-client-days { font-size: 11px; color: var(--text-light); }
.aging-client-amount { margin-left: auto; font-weight: 700; }

@media (max-width: 768px) {
    .dash-hero-row { grid-template-columns: 1fr; }
    .aging-bars { grid-template-columns: repeat(2, 1fr); }
}
