:root {
    --primary-color: #003366;
    /* Deep Navy */
    --primary-light: #004d99;
    --accent-color: #007bff;
    /* Bright Blue */
    --bg-color: #f4f7f9;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --yellow-header: #FFF9E6;
    /* Soft yellow for better printing */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --font-main: 'Inter', 'Noto Sans KR', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 50px;
}

/* Main Content */
.main-content {
    width: 100%;
    max-width: 95%;
    /* Increased from 1000px to use more space */
    background: white;
    box-shadow: var(--shadow-md);
    min-height: 100vh;
}

.top-bar {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-title h1 {
    font-size: 32px;
    font-weight: 800;
    color: black;
    background-color: var(--yellow-header);
    display: inline-block;
    padding: 8px 16px;
    margin: 0;
}

.quote-selector {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    min-width: 200px;
}

.quote-selector:focus {
    outline: none;
    border-color: var(--accent-color);
}

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

/* ... existing code ... */


/* Explanation Section */
.print-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 20px;
}

.print-logo {
    height: 60px;
    width: auto;
    margin-bottom: 15px;
}

.print-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.total-display {
    text-align: right;
    margin-right: 16px;
}

.total-display .label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.total-display .value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.content-area {
    padding: 32px;
}

/* Explanation Section */
.explanation-section {
    margin-bottom: 40px;
}

.yellow-header {
    background-color: var(--yellow-header);
    padding: 8px 16px;
    margin-bottom: 12px;
}

.yellow-header h2 {
    font-size: 18px;
    font-weight: 800;
    color: black;
    margin: 0;
}

.yellow-header-small {
    background-color: var(--yellow-header);
    padding: 6px 12px;
    margin-bottom: 0;
    /* Attached to table */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.yellow-header-small h3 {
    font-size: 16px;
    font-weight: 700;
    color: black;
    margin: 0;
}

.desc-text {
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 500;
}

.note-text {
    font-size: 14px;
    font-weight: 700;
    margin-top: 12px;
}

.mt-40 {
    margin-top: 40px;
}

/* General Terms */
.general-terms-container {
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 24px 32px;
}

.general-terms-list {
    list-style: none;
    padding: 0;
}

.general-terms-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.general-terms-list li:last-child {
    border-bottom: none;
}

/* Info Table */
.info-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid black;
    font-size: 13px;
}

.info-table th {
    background-color: white;
    border: 1px solid black;
    padding: 6px 12px;
    text-align: left;
}

.info-table td {
    border: 1px solid black;
    padding: 6px 12px;
}

/* Flow List */
.flow-list {
    list-style: none;
    font-size: 14px;
    line-height: 1.6;
}

/* Category Section */
.category-section {
    margin-bottom: 32px;
    page-break-inside: avoid;
}

/* Rate Table */
.rate-table-container {
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    /* Header has border/bg */
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    overflow: hidden;
}

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

.rate-table th {
    background-color: #f8f9fa;
    padding: 10px;
    text-align: left;
    /* Changed from center to left */
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.rate-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    text-align: left;
    /* Ensure left alignment */
}

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

/* Inputs */
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 13px;
    text-align: left;
    /* Changed from right to left */
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

input.readonly {
    background-color: #f8f9fa;
    border: none;
    font-weight: 600;
    color: var(--text-color);
}

input:disabled {
    background-color: transparent;
    color: #999;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

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

.btn-secondary {
    background-color: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #f8f9fa;
}

/* Utilities */
.font-bold {
    font-weight: 700;
}

.section-summary {
    background-color: #f0f4f8;
    padding: 12px 20px;
    display: flex;
    justify-content: flex-start;
    /* Changed from flex-end to flex-start */
    align-items: center;
    gap: 16px;
    border-top: 1px solid var(--border-color);
}

.section-summary span {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
}

.section-summary .amount {
    font-size: 18px;
    font-weight: 700;
}

/* Print Styles */
.print-only {
    display: none;
}

@media print {
    @page {
        size: A4;
        margin: 20mm 15mm 40mm 15mm;
        /* top right bottom left */
    }

    body {
        background-color: white;
        font-size: 12px;
        margin: 0;
        padding: 0;
    }

    .app-container {
        padding: 0;
        display: block;
    }

    .main-content {
        box-shadow: none;
        max-width: 100%;
        padding: 0;
        padding-bottom: 120px;
        /* Space for fixed footer */
    }

    /* Header shows normally on first page */
    .top-bar {
        display: flex !important;
        position: relative !important;
        background-color: white;
        border-bottom: 1px solid var(--border-color);
        padding: 20px 0;
        page-break-after: avoid;
    }

    /* Content area */
    .content-area {
        padding: 0;
    }

    /* Prevent page breaks between section headers and content */
    .yellow-header-small {
        page-break-after: avoid;
        break-after: avoid;
    }

    /* Prevent orphaned rows at page breaks */
    .rate-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Prevent general terms items from breaking */
    .general-terms-list li {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Keep section summaries with their sections */
    .section-summary {
        page-break-before: avoid;
        break-before: avoid;
    }

    /* Prefer page breaks between sections */
    .category-section {
        page-break-after: auto;
        break-after: auto;
    }

    .actions {
        display: flex !important;
    }

    /* Hide only the buttons, keep Grand Total */
    #reset-all-btn,
    #print-btn,
    .btn-icon-delete {
        display: none !important;
    }

    .content-area {
        padding: 0;
    }

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

    .no-print {
        display: none !important;
    }

    .yellow-header,
    .yellow-header-small,
    .header-title h1 {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background-color: #FFF9E6 !important;
    }

    input {
        border: none;
        padding: 0;
    }

    /* Hide placeholders in print */
    input::placeholder {
        color: transparent;
    }

    /* Print Header & Footer */
    .print-only {
        display: block !important;
    }

    .print-header {
        text-align: center;
        margin-bottom: 30px;
        padding-bottom: 20px;
        border-bottom: 2px solid var(--border-color);
    }

    .print-logo {
        height: 80px;
        width: auto;
        margin-bottom: 15px;
    }

    .print-header h1 {
        font-size: 28px;
        font-weight: 800;
        color: black;
        background-color: var(--yellow-header);
        display: inline-block;
        padding: 6px 12px;
        margin: 0;
    }

    .print-meta {
        display: flex;
        justify-content: space-between;
        font-size: 14px;
        margin-top: 10px;
    }

    /* Fixed Footer for Print (Repeats on every page) */
    .app-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: white;
        text-align: center;
        padding: 10px 20px;
        border-top: 1px solid #ddd;
        font-size: 9px;
        /* Smaller for print to fit everything */
        color: #666;
        z-index: 1000;
        line-height: 1.4;
    }

    .app-footer p {
        margin: 2px 0;
    }

    /* Add padding to body to prevent content overlap with fixed footer */
    .main-content {
        padding-bottom: 120px;
        /* Increased padding for taller footer */
    }
}

/* App Footer (Web) */
.app-footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 40px;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    background-color: #f9f9f9;
}

.footer-logo {
    height: 60px;
    width: auto;
    margin-bottom: 20px;
}

.app-footer p {
    margin: 4px 0;
}

.footer-copyright {
    font-weight: 700;
    color: #333;
}

.footer-link {
    color: var(--primary-color);
    font-weight: 600;
}

/* Dynamic Item Styles */
.btn-add-item {
    background-color: #f8f9fa;
    border: 1px dashed #ccc;
    color: var(--primary-color);
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-add-item:hover {
    background-color: #e6f0ff;
    border-color: var(--primary-color);
}

.btn-icon-delete {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.btn-icon-delete:hover {
    opacity: 1;
}

.input-text-full {
    flex: 1;
    border: none;
    font-size: 14px;
    padding: 4px;
    background: transparent;
}

.input-text-full:focus {
    outline: none;
    border-bottom: 1px solid var(--accent-color);
}

.add-item-area {
    padding: 0 16px 16px 16px;
}

/* Save Quote Section */
.save-quote-section {
    margin: 40px 0 20px 0;
    padding: 24px 32px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.save-quote-container h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.save-quote-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.quote-name-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 14px;
}

.quote-name-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.save-quote-message {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.save-quote-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.save-quote-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.print-hidden-row {
    display: none;
}