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

:root {
    --background: #f7f7f5;
    --surface: #ffffff;
    --text: #232a32;
    --muted: #7a8087;
    --heading: #344256;
    --border: #e4e7eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header h1 {
    font-size: 1.75rem;
    color: var(--heading);
    margin-bottom: 5px;
    font-weight: 500;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 30px;
}

.input-section,
.notes-section,
.total-section {
    margin-bottom: 20px;
}

.label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #eef0f2;
    border-radius: 4px;
    background: var(--surface);
    font-size: 0.95rem;
    color: var(--text);
}

input::placeholder,
textarea::placeholder {
    color: #A9A9A9;
    opacity: 1;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #9da7b5;
    box-shadow: 0 0 0 3px rgba(52, 66, 86, 0.08);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    margin-bottom: 20px;
}

.data-table thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 10px 8px;
    text-align: left;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    font-weight: 500;
}

.data-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.data-table td input {
    border: 1px solid #eef0f2;
    background: var(--surface);
}

.data-table td input:focus {
    border-color: #c8cdd3;
}

.col-qty,
.col-price {
    width: 110px;
}

.col-unit {
    width: 120px;
}

.col-total {
    width: 100px;
    text-align: right;
}

.qty-input,
.price-input {
    text-align: right;
}

.total-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.delete-row-cell {
    width: 56px;
    text-align: center;
}

.delete-row-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    color: var(--muted);
}

.delete-row-btn:hover {
    background: #edf0f3;
    color: #b43b3b;
}

.controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    background: var(--surface);
    color: var(--muted);
}

button:hover {
    background: var(--background);
}

button#addRowBtn {
    border-color: var(--border);
}

button#calculateBtn {
    background-color: #006400;
    color: white;
    border-color: var(--heading);
}

button#calculateBtn:hover {
    opacity: 0.9;
}

button#downloadBtn {
    border-color: var(--border);
}

.total-section {
    margin-top: 20px;
    text-align: center;
    padding: 15px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.download-menu {
    position: relative;
}

.download-options {
    position: absolute;
    right: 0;
    z-index: 20;
    min-width: 130px;
    margin-top: 6px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(35, 42, 50, 0.12);
}

.download-options button {
    width: 100%;
    text-align: left;
}

.download-options button:disabled {
    cursor: default;
    opacity: 0.45;
}

#grandTotal {
    font-size: 1.25rem;
    font-weight: 700;
    color: #006400;
}

.qty-full {
    display: inline;
}

.qty-short {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        margin-bottom: 20px;
    }

    .controls {
        flex-direction: column;
    }

    .controls button {
        width: 100%;
    }

    .download-options {
        right: auto;
        left: 0;
        width: 100%;
    }
}

@media (max-width: 600px) {
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        padding: 10px;
    }

    .container,
    .input-section,
    .table-scroll,
    .controls,
    .notes-section,
    .total-section {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    input[type="text"],
    input[type="number"],
    textarea {
        max-width: 100%;
        min-width: 0;
    }

    .table-scroll {
        overflow: hidden;
        margin-bottom: 20px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface);
    }

    .table-scroll .data-table {
        display: table;
        width: 100%;
        min-width: 0;
        margin-bottom: 0;
        table-layout: fixed;
        border-collapse: collapse;
    }

    .table-scroll .data-table thead,
    .table-scroll .data-table tbody,
    .table-scroll .data-table tr,
    .table-scroll .data-table td,
    .table-scroll .data-table th {
        display: table-cell;
    }

    .table-scroll .data-table thead {
        display: table-header-group;
    }

    .table-scroll .data-table tbody {
        display: table-row-group;
    }

    .table-scroll .data-table tr {
        display: table-row;
    }

    .table-scroll .data-table td,
    .table-scroll .data-table th {
        min-width: 0;
    }

    .table-scroll .data-table td {
        padding: 6px 2px;
        border: 0;
        border-bottom: 1px solid var(--border);
    }

    .table-scroll .data-table td::before {
        display: none;
    }

    .table-scroll .col-item,
    .table-scroll td:nth-child(1) { width: 34%; }

    .table-scroll .col-qty,
    .table-scroll td:nth-child(2) { width: 13%; }

    .table-scroll .col-unit,
    .table-scroll td:nth-child(3) { width: 13%; }

    .table-scroll .col-price,
    .table-scroll td:nth-child(4) { width: 16%; }

    .table-scroll .col-total,
    .table-scroll td:nth-child(5) { width: 16%; }

    .table-scroll .col-delete,
    .table-scroll td:nth-child(6) {
        width: 8%;
        text-align: center;
    }

    .table-scroll .data-table input {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: 8px 3px;
        font-size: 0.78rem;
    }

    .table-scroll .data-table th {
        padding: 8px 2px;
        font-size: 0.62rem;
        line-height: 1.15;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .qty-full {
        display: inline;
    }

    .qty-short {
        display: none;
    }

    .table-scroll .delete-row-btn {
        width: 26px;
        height: 26px;
        max-width: 100%;
        padding: 0;
    }

    .total-cell,
    .delete-row-cell {
        text-align: right;
    }

    .controls,
    .controls button,
    .download-menu,
    .download-options {
        width: 100%;
        max-width: 100%;
    }

    .notes-section textarea {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }

    .subtitle,
    .label {
        font-size: 0.85rem;
    }
}