/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    min-height: 100vh;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Container */
.container {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

h1 {
    color: #e0e0e0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 24px;
    font-weight: 400;
}

/* Table Header */
.table-header {
    display: grid;
    grid-template-columns: 40px 150px 30px 150px 30px 150px 50px;
    gap: 10px;
    padding: 5px;
    border-bottom: 1px solid #3a3a3a;
    font-size: 14px;
    color: #999;
}

/* Position Rows */
.position-row {
    display: grid;
    grid-template-columns: 40px 150px 30px 150px 30px 150px 50px;
    gap: 10px;
    padding: 5px;
    align-items: center;
    border-bottom: 1px solid #333;
}

.position-row:hover {
    background: #333;
}

.row-number {
    color: #e0e0e0;
    font-weight: 500;
    text-align: center;
}

/* Input Fields */
input {
    background: #3a3a3a;
    border: 1px solid #4a4a4a;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 15px;
    width: 100%;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: #b8b8b8;
}

input:disabled {
    background: #2a2a2a;
    color: #999;
    cursor: not-allowed;
}

/* Separators */
.separator {
    color: #b8b8b8;
    font-size: 16px;
    text-align: center;
}

/* Delete Button */
.delete-btn {
    background: #d32f2f;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    margin: 0 auto;
}

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

/* Reset Button */
.reset-btn {
    background: #ff5722;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
}

.reset-btn:hover {
    background: #e64a19;
}

/* Summary Row */
.summary-row {
    display: grid;
    grid-template-columns: 40px 150px 30px 150px 30px 150px 50px;
    gap: 10px;
    padding: 5px;
    border-top: 2px solid #3a3a3a;
    margin-top: 5px;
    font-weight: 500;
}

.summary-value {
    color: #4caf50;
    font-size: 16px;
}

/* Add Button */
.add-btn {
    background: #4caf50;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px auto 0;
    transition: background 0.2s;
}

.add-btn:hover {
    background: #45a049;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.export-btn {
    background: #2196f3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.export-btn:hover:not(:disabled) {
    background: #1976d2;
}

.export-btn:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Profit Section */
.profit-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #3a3a3a;
}

.profit-input-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.profit-input-row label {
    color: #999;
    font-size: 15px;
    min-width: 120px;
}

.profit-input-row input {
    flex: 1;
    max-width: 200px;
}

.profit-result {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.profit-card {
    background: #333;
    padding: 5px;
    border-radius: 8px;
    text-align: center;
}

.profit-label {
    color: #999;
    font-size: 13px;
    margin-bottom: 10px;
}

.profit-value {
    font-size: 22px;
    font-weight: 500;
}

.profit-positive {
    color: #4caf50;
}

.profit-negative {
    color: #f44336;
}

/* Break-even Section */
.breakeven-section {
    margin-top: 15px;
    padding: 10px;
    background: #333;
    border-radius: 8px;
}

.breakeven-result {
    margin-top: 10px;
    padding: 10px;
    background: #2a2a2a;
    border-radius: 6px;
    border-left: 4px solid #ff9800;
}

.breakeven-text {
    color: #e0e0e0;
    font-size: 15px;
    line-height: 1.6;
}

.breakeven-highlight {
    color: #ff9800;
    font-weight: 600;
    font-size: 18px;
}

/* Target Price Section */
.target-section {
    margin-top: 20px;
    padding: 10px;
    background: #333;
    border-radius: 8px;
}

.target-result {
    margin-top: 10px;
    padding: 10px;
    background: #2a2a2a;
    border-radius: 6px;
    border-left: 4px solid #9c27b0;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }

    .container {
        padding: 20px 15px;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 20px;
    }

    /* Make table stack vertically on mobile */
    .table-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        font-size: 12px;
    }

    .table-header > div:not(:last-child) {
        display: none;
    }

    .table-header > div:last-child {
        display: block;
    }

    /* Stack position rows vertically */
    .position-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 15px;
        background: #333;
        border-radius: 8px;
        margin-bottom: 10px;
        border-bottom: none;
        position: relative;
    }

    .position-row .row-number {
        position: absolute;
        top: 10px;
        left: 10px;
        font-size: 12px;
        color: #999;
    }

    .position-row .delete-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .position-row > div:first-child,
    .position-row > button {
        display: none;
    }

    .position-row input {
        width: 100%;
        font-size: 16px;
    }

    .position-row .separator {
        display: none;
    }

    /* Summary row mobile */
    .summary-row {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        background: #333;
        border-radius: 8px;
        margin-top: 15px;
        border-top: none;
    }

    .summary-row > div:first-child,
    .summary-row .separator,
    .summary-row > div:last-child {
        display: none;
    }

    .summary-value {
        font-size: 14px;
        display: flex;
        justify-content: space-between;
    }

    .summary-value::before {
        color: #999;
        font-weight: normal;
    }

    #avgPrice::before {
        content: "Average Price: ";
    }

    #totalAmount::before {
        content: "Total Amount: ";
    }

    #totalInvested::before {
        content: "Total Invested: ";
    }

    /* Buttons */
    .add-btn {
        width: 25px;
        height: 25px;
        font-size: 24px;
    }

    .action-buttons {
        margin-top: 15px;
    }

    .export-btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }

    .reset-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Profit section */
    .profit-section {
        margin-top: 30px;
        padding-top: 20px;
    }

    .profit-input-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .profit-input-row label {
        min-width: auto;
        font-size: 14px;
    }

    .profit-input-row input {
        max-width: 100%;
        font-size: 16px;
    }

    .profit-result {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .profit-card {
        padding: 15px;
    }

    .profit-value {
        font-size: 20px;
    }

    /* Break-even section */
    .breakeven-section {
        padding: 15px;
        margin-top: 20px;
    }

    .breakeven-section h3 {
        font-size: 15px;
    }

    .breakeven-section p {
        font-size: 12px;
    }

    .breakeven-text {
        font-size: 14px;
    }

    .breakeven-highlight {
        font-size: 16px;
    }

    /* Target section */
    .target-section {
        padding: 15px;
        margin-top: 20px;
    }

    .target-section h3 {
        font-size: 15px;
    }

    .target-section p {
        font-size: 12px;
    }

    /* Empty state */
    .empty-state {
        padding: 30px 15px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px 10px;
    }

    h1 {
        font-size: 16px;
    }

    input {
        font-size: 16px;
        padding: 10px;
    }
}