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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 15px;
    text-align: center;
}

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

.search-container {
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.search-dropdown-item:hover {
    background: #f8f9fa;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item .company-name {
    font-weight: 600;
    color: #2c3e50;
}

.search-dropdown-item .property-name {
    color: #6c757d;
    font-size: 12px;
    margin-left: 8px;
}

.search-container input {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    width: 200px;
}

.search-container input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.property-row {
    display: flex;
    gap: 10px;
}

.property-row input {
    flex: 1;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.property-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.property-info input {
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.property-info input:focus {
    outline: none;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

main {
    padding: 40px;
}

.input-section, .cost-items, .summary {
    margin-bottom: 40px;
}

h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

.input-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.input-group label {
    flex: 0 0 200px;
    font-weight: 600;
    color: #555;
}

.input-group input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.cost-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cost-item label {
    flex: 0 0 200px;
    font-weight: 600;
    color: #555;
}

.cost-item input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.cost-item input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.cost-item input:read-only {
    background: #f5f5f5;
    cursor: not-allowed;
}

.property-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    align-items: center;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.summary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(52, 152, 219, 0.3);
}

.summary h2 {
    color: white;
    border-bottom: 3px solid rgba(255, 255, 255, 0.5);
}

.total-amount {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-top: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(231, 76, 60, 0.4);
}

.company-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.company-selector select {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    min-width: 150px;
}

#propertySelect {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    min-width: 150px;
    display: none;
}

#propertySelect:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.company-selector input[type="text"] {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
    min-width: 150px;
}

.company-selector input[type="text"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.property-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.property-selector select {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    min-width: 150px;
}

.property-selector input {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
}

.property-selector input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.property-selector select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.btn-small {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-small:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(230, 126, 34, 0.4);
}

.content-wrapper {
    display: flex;
    gap: 30px;
    padding: 30px;
}

.basic-info-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.cost-items-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.left-column {
    flex: 1;
    min-width: 300px;
}

.right-column {
    flex: 1.5;
}

.two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.two-column-grid .cost-item {
    margin-bottom: 0;
}

.remarks-section {
    margin-bottom: 30px;
}

.remarks-section h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

#remarks {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1.1rem;
    resize: vertical;
    transition: all 0.3s ease;
}

#remarks::placeholder {
    color: #6c757d;
    font-size: 0.9rem;
}

#remarks:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 右クリックメニューのスタイル */
#companySelect,
#propertySelect {
    cursor: context-menu;
}

#companySelect option,
#propertySelect option {
    cursor: pointer;
}

.csv-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.csv-actions select {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
}

.csv-actions .btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

#deleteCompanyBtn.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* 印刷とPDF保存ボタンのスタイル */
.print-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.print-actions .btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.print-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(52, 152, 219, 0.4);
}

/* 印刷用A4テンプレート */
.print-sheet {
    display: none;
    width: 190mm;
    min-height: 277mm;
    margin: 0 auto;
    background: white;
    padding: 10mm;
    box-sizing: border-box;
    font-size: 10pt;
    line-height: 1.15;
    color: #000;
}

.print-sheet h1 {
    text-align: center;
    font-size: 22pt;
    margin: 0 0 8pt 0;
    color: #2c3e50;
    border: none;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.print-sheet h2 {
    font-size: 12pt;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 3pt;
    margin: 8pt 0 6pt 0;
}

.print-sheet .property-header {
    text-align: center;
    margin-bottom: 15pt;
    font-size: 16pt;
    font-weight: bold;
    color: #34495e;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 8pt;
    border-radius: 5pt;
    border: 1px solid #dee2e6;
}

.print-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8mm !important;
    margin-bottom: 12pt !important;
}

.print-section {
    border: 1px solid #3498db !important;
    padding: 10pt !important;
    background: white !important;
    page-break-inside: avoid !important;
    border-radius: 4pt !important;
    margin-bottom: 8pt !important;
}

.print-section h2 {
    font-size: 13pt !important;
    color: white !important;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    padding: 6pt 8pt !important;
    margin: -10pt -10pt 8pt -10pt !important;
    border-bottom: 2px solid #2980b9 !important;
    border-radius: 4pt 4pt 0 0 !important;
}

.print-row {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 6pt !important;
    align-items: center !important;
    padding: 2pt 0 !important;
}

.print-label {
    font-weight: 600;
    font-size: 9pt;
}

.print-value {
    font-size: 9pt;
    text-align: right;
    font-family: monospace;
}

.print-total {
    background: linear-gradient(135deg, #2980b9 0%, #1e5a8e 100%);
    color: white;
    padding: 12pt;
    text-align: center;
    margin: 12pt 0;
    page-break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-radius: 6pt;
    box-shadow: 0 3pt 8pt rgba(0,0,0,0.15);
}

.print-total h2 {
    color: white !important;
    border: none !important;
    background: transparent !important;
    margin: 0 0 6pt 0 !important;
    padding: 0 !important;
    font-size: 14pt !important;
}

.print-total-amount {
    font-size: 18pt;
    font-weight: bold;
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.print-remarks {
    border: 1px solid #ccc;
    padding: 4pt;
    font-size: 8pt;
    min-height: 40pt;
    page-break-inside: avoid;
}

/* 印刷時の設定 */
@media print {
    /* Ensure perfect A4 sizing - 210mm x 297mm */
    @page {
        size: A4 portrait;
        margin: 10mm;
    }
    
    /* Hide all unnecessary elements */
    .csv-actions, .company-selector, .search-container, 
    #addItem, .remove-item, .actions, .print-actions,
    .btn-secondary, .btn-primary, .btn-small, .btn-danger {
        display: none !important;
    }
    
    /* Reset body and container */
    body {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 10pt !important;
        line-height: 1.15 !important;
        color: #000 !important;
    }
    
    .container {
        display: none !important;
    }
    
    .print-sheet {
        display: block !important;
        box-shadow: none !important;
    }
    
    /* Compact layout for content */
    .content-wrapper {
        display: block !important;
        padding: 5mm !important;
        margin: 0 !important;
    }
    
    .basic-info-section, .cost-items-section {
        width: 100% !important;
        margin: 0 0 10px 0 !important;
        padding: 8px !important;
        border: none !important;
        background: white !important;
        box-shadow: none !important;
    }
    
    /* Compact headers */
    h1 {
        font-size: 24px !important;
        margin: 0 0 12px 0 !important;
        text-align: center !important;
        color: #000 !important;
        font-weight: bold !important;
    }
    
    h2 {
        font-size: 12px !important;
        margin: 0 0 6px 0 !important;
        padding: 0 0 3px 0 !important;
        border-bottom: 1px solid #000 !important;
        color: #000 !important;
    }
    
    /* Compact property info */
    .property-row {
        margin-bottom: 8px !important;
    }
    
    .property-row input {
        padding: 4px !important;
        font-size: 11px !important;
        border: none !important;
        border-bottom: 1px solid #000 !important;
        background: white !important;
    }
    
    /* Compact input groups */
    .input-group {
        margin-bottom: 6px !important;
    }
    
    .input-group label {
        font-size: 10px !important;
        flex: 0 0 100px !important;
    }
    
    .input-group input {
        padding: 4px !important;
        font-size: 10px !important;
        border: 1px solid #ccc !important;
    }
    
    /* Two column grid for cost items */
    .two-column-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        margin-bottom: 8px !important;
    }
    
    .cost-item {
        margin: 0 !important;
        padding: 2px !important;
    }
    
    .cost-item label {
        font-size: 9px !important;
        flex: 1 !important;
        margin-right: 4px !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    .cost-item input {
        width: 70px !important;
        padding: 3px 4px !important;
        font-size: 9px !important;
        border: 1px solid #000 !important;
        text-align: right !important;
        color: #000 !important;
        background: white !important;
    }
    
    /* Compact summary section */
    .summary {
        padding: 8px !important;
        margin: 8px 0 !important;
        background: #e6f3ff !important;
        border: 1px solid #3498db !important;
    }
    
    .summary h2 {
        font-size: 11px !important;
        margin: 0 0 4px 0 !important;
    }
    
    .total-amount {
        font-size: 14px !important;
        margin: 4px 0 !important;
        color: #000 !important;
        font-weight: bold !important;
    }
    
    /* Compact remarks */
    #remarks {
        padding: 4px !important;
        font-size: 8px !important;
        border: 1px solid #000 !important;
        min-height: 40px !important;
        line-height: 1.2 !important;
    }
    
    /* Remove all shadows and gradients */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Ensure black text and white background */
    body, .cost-item label, .cost-item input, .input-group label, 
    .input-group input, #remarks, .total-amount, h1, h2 {
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body, .basic-info-section, .cost-items-section, .summary {
        background: white !important;
    }
    
    /* Compact spacing */
    * {
        line-height: 1.1 !important;
    }
    
    /* Ensure everything fits on one page */
    .basic-info-section, .cost-items-section {
        page-break-inside: avoid !important;
    }
}

/* PDF generation specific styles */
.pdf-generating {
    background: white !important;
}

.pdf-generating .csv-actions,
.pdf-generating .company-selector,
.pdf-generating .search-container,
.pdf-generating #addItem,
.pdf-generating .remove-item,
.pdf-generating .actions,
.pdf-generating .print-actions {
    display: none !important;
}

.pdf-generating .container {
    max-width: 794px !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.pdf-generating .content-wrapper {
    padding: 15px !important;
}

.pdf-generating h1 {
    font-size: 22px !important;
    margin: 0 0 12px 0 !important;
}

.pdf-generating h2 {
    font-size: 14px !important;
    margin: 0 0 8px 0 !important;
}

.pdf-generating .cost-item label {
    font-size: 11px !important;
    font-weight: bold !important;
}

.pdf-generating .cost-item input {
    font-size: 11px !important;
    padding: 4px 6px !important;
    width: 80px !important;
}

.pdf-generating .two-column-grid {
    gap: 8px !important;
}

.pdf-generating .summary {
    padding: 10px !important;
    margin: 10px 0 !important;
}

.pdf-generating .total-amount {
    font-size: 16px !important;
}

.pdf-generating #remarks {
    font-size: 9px !important;
    min-height: 50px !important;
}

/* Number input fields half width */
.cost-item input[type="number"], 
.input-group input[type="number"] {
    width: 50%;
}

/* Add yen symbol to number inputs */
.cost-item input[type="number"]:not([data-item="guaranteeRate"]):not([readonly])::after,
.input-group input[type="number"]:not(#guaranteeRate)::after {
    content: '円';
    margin-left: 5px;
    font-size: 0.9em;
    color: #666;
}