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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

h2 {
    color: #555;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 5px;
}

.dropdown-section {
    margin-bottom: 40px;
}

/* Row Layout Styles */
.input-rows-container {
    margin-bottom: 30px;
}

.input-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.input-row:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.input-row:first-child {
    background: #fff;
    border: 2px solid #007bff;
    margin-bottom: 25px;
}

.input-column {
    flex: 1;
    min-width: 150px;
}

.input-column:nth-child(1) {
    flex: 1;
    min-width: 120px;
    max-width: 150px;
}

.input-column:nth-child(2) {
    flex: 2;
    min-width: 200px;
    max-width: 300px;
}

.input-column:nth-child(3),
.input-column:nth-child(4) {
    flex: 1;
    min-width: 120px;
    max-width: 180px;
}

.input-column h3 {
    color: #555;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 14px;
    font-weight: 600;
}

/* Searchable Dropdown Styles */
.searchable-dropdown {
    position: relative;
    width: 100%;
    margin: 20px 0;
}

.dropdown-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    background: white;
    transition: border-color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-input:focus,
.dropdown-input.active {
    border-color: #007bff;
    outline: none;
}

.dropdown-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    transition: transform 0.3s ease;
}

.searchable-dropdown.open .dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow: hidden;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.searchable-dropdown.open .dropdown-content {
    display: block;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    outline: none;
    background: #f9f9f9;
}

.dropdown-options {
    max-height: 200px;
    overflow-y: auto;
}

.option {
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
    white-space: normal;
}

.option:hover {
    background-color: #f0f8ff;
}

.option.selected {
    background-color: #007bff;
    color: white;
}

.option.hidden {
    display: none;
}

/* Multi-select specific styles */
.multi-select .selected-items {
    min-height: 45px;
    padding: 8px 40px 8px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    background: white;
    transition: border-color 0.3s ease;
}

.multi-select .selected-items:hover,
.multi-select.open .selected-items {
    border-color: #007bff;
}

.selected-tag {
    background: #007bff;
    color: white;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.remove-tag {
    cursor: pointer;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.remove-tag:hover {
    background: rgba(255, 255, 255, 0.5);
}

.placeholder {
    color: #999;
    font-style: italic;
}

/* Controls for dynamic dropdown */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.controls input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.controls button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.controls button:hover {
    background: #0056b3;
}

/* Scrollbar styling */
.dropdown-options::-webkit-scrollbar {
    width: 6px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.dropdown-options::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Responsive design */
@media (max-width: 1100px) {
    .input-row {
        flex-wrap: wrap;
        gap: 15px;
        padding: 12px;
    }
    
    .input-column:nth-child(1),
    .input-column:nth-child(2) {
        flex: 1 1 calc(50% - 7.5px);
        min-width: 200px;
    }
    
    .input-column:nth-child(3),
    .input-column:nth-child(4) {
        flex: 1 1 calc(50% - 7.5px);
        min-width: 150px;
    }
}

@media (max-width: 700px) {
    .input-rows-container {
        margin-bottom: 20px;
    }
    
    .input-row {
        flex-direction: column;
        gap: 15px;
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    .input-column {
        max-width: 100%;
        min-width: auto;
        flex: 1 1 100%;
    }
    
    .input-column h3 {
        font-size: 12px;
        margin-bottom: 8px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    .searchable-dropdown {
        max-width: 100%;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .amount-controls,
    .number-controls {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .amount-btn,
    .preset-btn {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .panel-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .header-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .send-temp-btn,
    .clear-btn {
        width: 100%;
    }
    
    .header-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .panel-actions {
        flex-direction: column;
    }
    
    .table-header,
    .data-row {
        grid-template-columns: 1fr 2fr 1fr 1fr 1fr 60px;
        font-size: 11px;
        padding: 8px 10px;
        min-width: auto;
    }
    
    .table-header {
        font-size: 10px;
    }
    
    /* Better handling for long text on mobile */
    .table-header > div:nth-child(2),
    .data-row > div:nth-child(2) {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .table-header,
    .data-row {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 10px;
        text-align: left;
    }
    
    .table-header {
        display: none;
    }
    
    .data-row {
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 10px;
        background: white;
        display: block;
        padding: 15px;
    }
    
    .data-row > div {
        margin-bottom: 8px;
        display: flex;
        justify-content: space-between;
    }
    
    .data-row > div:before {
        content: attr(data-label);
        font-weight: 600;
        color: #495057;
        margin-right: 10px;
    }
    
    .col-actions {
        justify-content: flex-end;
        margin-top: 10px;
    }
}

/* Amount and Number Input Styles */
.input-group {
    margin: 20px 0;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

/* Date Input Styles */
.date-input-container {
    width: 100%;
    margin-bottom: 10px;
}

.dateInput {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.3s ease;
    background: white;
}

.dateInput:focus {
    border-color: #007bff;
}

/* Amount Input Styles */
.amount-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.currency-symbol {
    position: absolute;
    left: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    z-index: 1;
}

.amount-input {
    width: 100%;
    padding: 10px 12px 10px 30px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.3s ease;
}

.amount-input:focus {
    border-color: #007bff;
}

.amount-display {
    padding: 8px 15px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    color: #28a745;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.amount-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.amount-btn {
    padding: 8px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.amount-btn:hover {
    background: #0056b3;
}

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

/* Number Input Styles */
.simple-number-container {
    width: 100%;
    margin-bottom: 10px;
}

.simple-number-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.3s ease;
}

.simple-number-input:focus {
    border-color: #007bff;
}

/* Merchant Input Styles */
.merchant-input-container {
    width: 100%;
    position: relative;
}

.merchant-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.merchant-input:focus {
    border-color: #007bff;
}

.number-display {
    padding: 6px 10px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    font-size: 12px;
    color: #1976d2;
    font-weight: 600;
}

.number-display span {
    color: #0d47a1;
    font-weight: 700;
}

/* Output Panel Styles */
.add-section {
    margin: 20px 0;
    text-align: center;
}

.paste-hint {
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    color: #004085;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
}

.add-row-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.add-row-btn:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.add-row-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
}

.output-panel {
    margin-top: 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.panel-header {
    background: #007bff;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.merchant-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.merchant-section label {
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.global-merchant-input {
    padding: 8px 12px;
    border: 2px solid #ffffff;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    min-width: 200px;
}

.global-merchant-input:focus {
    border-color: #ffc107;
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.send-temp-btn {
    background: #28a745;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.send-temp-btn:hover:not(:disabled) {
    background: #218838;
}

.send-temp-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.output-content {
    padding: 0;
}

/* Table Styles */
.data-table {
    width: 100%;
    overflow-x: auto;
}

.table-header,
.data-row {
    display: grid;
    grid-template-columns: 120px minmax(200px, 3fr) 80px 100px 100px 80px;
    gap: 10px;
    padding: 12px 20px;
    align-items: center;
    min-width: 680px;
}

.table-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    font-size: 12px;
    text-transform: uppercase;
}

/* Item name column improvements */
.table-header > div:nth-child(2),
.data-row > div:nth-child(2) {
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    cursor: default;
}

/* Tooltip for long item names */
.data-row > div:nth-child(2):hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    max-width: 300px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    word-break: break-word;
    line-height: 1.3;
    margin-bottom: 5px;
}

.data-row > div:nth-child(2):hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1001;
}

.table-body {
    max-height: 300px;
    overflow-y: auto;
}

.data-row {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.data-row:hover {
    background: #f8f9fa;
}

.data-row:last-child {
    border-bottom: none;
}

.col-date,
.col-item,
.col-price,
.col-quantity,
.col-merchant,
.col-total {
    font-size: 13px;
}

.col-price,
.col-quantity,
.col-total {
    text-align: right;
}

.col-total {
    font-weight: 600;
    color: #28a745;
}

.col-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background-color 0.3s ease;
}

.delete-btn:hover {
    background: #c82333;
}

.table-footer {
    background: #f8f9fa;
    border-top: 2px solid #007bff;
    padding: 15px 20px;
}

.total-summary {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}

.total-label {
    font-weight: 600;
    color: #007bff;
    font-size: 14px;
}

.grand-total {
    color: #28a745;
    font-size: 18px;
    font-weight: 700;
}

.panel-actions {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
}

.send-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    flex: 1;
}

.send-btn:hover {
    background: #218838;
}

.export-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    flex: 1;
}

.export-btn:hover {
    background: #5a6268;
}

.send-btn:disabled,
.export-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Temp CSV Panel Styles */
.temp-csv-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    overflow: hidden;
}

.temp-csv-panel .panel-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.temp-csv-panel .panel-header h3 {
    margin: 0;
    color: #495057;
    font-size: 18px;
    font-weight: 600;
}

.csv-header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.clear-temp-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.clear-temp-btn:hover {
    background: #c82333;
}

.refresh-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.refresh-btn:hover {
    background: #138496;
}

.csv-preview-content {
    padding: 20px;
}

.csv-preview-container {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow: auto;
}

.csv-preview {
    margin: 0;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    color: #495057;
    white-space: pre-wrap;
    word-break: break-all;
}

.csv-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
}

.csv-stats span {
    font-weight: 500;
}

/* Responsive adjustments for temp CSV panel */
@media (max-width: 768px) {
    .temp-csv-panel .panel-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .csv-header-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .clear-temp-btn,
    .refresh-btn {
        width: 100%;
    }
    
    .csv-preview {
        font-size: 11px;
    }
    
    .csv-stats {
        flex-direction: column;
        gap: 5px;
    }
}

/* CSV Table Styles */
.csv-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin: 20px;
}

.csv-data-table {
    width: 100%;
    background: white;
}

.csv-table-header,
.csv-table-row {
    display: grid;
    grid-template-columns: 100px minmax(200px, 3fr) 80px 100px 150px;
    gap: 10px;
    padding: 12px 15px;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
}

.csv-table-header {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.csv-table-row:hover {
    background: #f8f9fa;
}

.csv-table-row:last-child {
    border-bottom: none;
}

.csv-col-date,
.csv-col-item,
.csv-col-price,
.csv-col-quantity,
.csv-col-merchant {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csv-col-price,
.csv-col-quantity {
    text-align: right;
}

.csv-col-item {
    text-align: left;
}

.csv-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 14px;
}

.csv-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.csv-view-toggle {
    display: flex;
    gap: 0;
    margin: 0 20px 10px 20px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background: white;
}

.view-toggle-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    background: #e9ecef;
}

.view-toggle-btn.active {
    background: #007bff;
    color: white;
}

@media (max-width: 768px) {
    .csv-table-header,
    .csv-table-row {
        grid-template-columns: 80px minmax(150px, 2fr) 60px 80px 120px;
        gap: 8px;
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .csv-table-container {
        margin: 15px;
        max-height: 300px;
    }
    
    .csv-view-toggle {
        margin: 0 15px 10px 15px;
    }
}
