:root {
    --primary: #00897b;
    /* Professional Teal */
    --primary-dark: #00695c;
    --accent: #e0f2f1;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-main: #263238;
    --text-light: #546e7a;
    --border: #cfd8dc;
    --danger: #ef5350;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Hind Siliguri', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    /* Prevents iOS zoom on focus */
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
}

/* --- Header Section --- */
.dashboard-header {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 5px solid var(--primary);
}

.header-title h1 {
    color: var(--primary-dark);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.header-title p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* Ensure wrapping on mobile */
    justify-content: center;
}

.month-selector {
    padding: 10px 15px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: #fff;
    color: var(--text-main);
    cursor: pointer;
    height: 45px;
}

.btn-print {
    background-color: var(--text-main);
    color: white;
    border: none;
    padding: 0 20px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: 0.2s;
    white-space: nowrap;
}

.btn-print:hover {
    background-color: #000;
}

/* Existing Download Button Style */
.btn-download {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    text-decoration: none;
    height: 45px;
    /* Match other buttons */
    transition: all 0.2s;
}

.btn-download:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* --- Add Item Form --- */
.input-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.add-form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 6px;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #fff;
    transition: border-color 0.2s;
    height: 45px;
    /* Touch friendly height */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.1);
}

.btn-add {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    height: 45px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-add:hover {
    background-color: var(--primary-dark);
}

/* --- Table Section --- */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header-info {
    padding: 15px 20px;
    background-color: var(--accent);
    color: var(--primary-dark);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #fff;
    color: var(--text-light);
    font-weight: 600;
    text-align: left;
    padding: 15px 20px;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--bg-color);
}

td {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #fafafa;
}

/* Inline Edit Inputs */
.edit-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 5px;
    font-family: inherit;
    font-size: 1rem;
    border-radius: 4px;
    color: var(--text-main);
    width: 100%;
    transition: 0.2s;
}

.edit-input:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
}

.qty-input {
    width: 70px;
    text-align: center;
    font-weight: 600;
}

.unit-select {
    width: 100px;
}

.btn-delete {
    color: #90a4ae;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: 0.2s;
    font-size: 1.1rem;
}

.btn-delete:hover {
    color: var(--danger);
    background-color: #ffebee;
}

/* --- Mobile Responsive & CSS Grid --- */
@media (max-width: 768px) {
    .container {
        margin: 10px auto;
        padding: 0 10px;
    }

    /* Header Stack */
    .dashboard-header {
        flex-direction: column;
        align-items: center;
        /* Centered on mobile */
        gap: 15px;
        text-align: center;
    }

    .header-controls {
        width: 100%;
        display: flex;
        flex-direction: column;
        /* Stack buttons on very small screens, or wrap */
        gap: 10px;
    }

    .header-controls {
        /* Revert to row for controls if space permits, or stack */
        flex-direction: row;
        justify-content: center;
    }

    .month-selector {
        width: 100%;
    }

    /* Form Stack */
    .add-form {
        grid-template-columns: 1fr 1fr;
        /* 2 columns for qty/unit */
        gap: 12px;
    }

    /* Item name takes full width */
    .form-group:first-child {
        grid-column: 1 / -1;
    }

    /* Button takes full width */
    .btn-add {
        grid-column: 1 / -1;
        margin-top: 5px;
    }

    /* --- Mobile Table (Inline Grid View) --- */
    thead {
        display: none;
    }

    .table-card {
        background: transparent;
        box-shadow: none;
    }

    .table-header-info {
        background: var(--card-bg);
        border-radius: 8px;
        margin-bottom: 10px;
        justify-content: center;
        gap: 15px;
        border: 1px solid var(--border);
    }

    table,
    tbody {
        display: block;
        width: 100%;
    }

    /* The Row becomes a Grid */
    tr {
        display: grid;
        /* Name | Qty | Unit | Delete */
        grid-template-columns: 1fr 60px 75px 30px;
        gap: 8px;
        align-items: center;
        background: #fff;
        border: 1px solid var(--border);
        margin-bottom: 8px;
        border-radius: 8px;
        padding: 12px 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    td {
        display: block;
        padding: 0;
        border: none;
    }

    /* Remove pseudo-elements (labels) */
    td::before {
        display: none !important;
    }

    /* 1. Name Column */
    td[data-label="পণ্যের নাম"] {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-main);
        /* Allow wrapping for long names */
        white-space: normal;
        line-height: 1.3;
    }

    /* 2. Quantity Column */
    td[data-label="পরিমাণ"] {
        justify-self: end;
    }

    .qty-input {
        width: 100% !important;
        border: 1px solid #ddd;
        background: #f9f9f9;
        border-radius: 4px;
        padding: 4px 0;
        font-size: 0.9rem;
        height: auto;
    }

    /* 3. Unit Column */
    td[data-label="একক"] {
        justify-self: end;
    }

    .unit-select {
        width: 100% !important;
        border: none;
        background: transparent;
        font-size: 0.85rem;
        padding: 0;
        text-align: center;
        /* Standard arrow is fine here for context */
    }

    /* 4. Action Column */
    td[data-label="অ্যাকশন"] {
        text-align: right;
    }

    .btn-delete {
        padding: 5px;
        color: #ff5252;
        background: transparent;
    }

    /* Hide the text "ডিলিট" on mobile, just icon */
    .btn-delete span {
        display: none !important;
    }
}

/* --- PDF / Print Styling --- */
@media print {
    body {
        background-color: white;
        font-size: 12pt;
    }

    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .no-print,
    .input-card,
    .btn-delete,
    .header-controls {
        display: none !important;
    }

    .dashboard-header {
        border: none;
        box-shadow: none;
        padding: 0;
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
        border-radius: 0;
        display: block;
    }

    .table-card {
        box-shadow: none;
        border: none;
    }

    .table-card table {
        display: table;
    }

    /* Reset mobile display */
    thead {
        display: table-header-group;
    }

    tbody tr {
        display: table-row;
        border: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    td {
        display: table-cell;
        border-bottom: 1px solid #ccc;
        padding: 8px;
        text-align: left;
    }

    td::before {
        display: none;
    }

    /* Hide mobile labels */

    th {
        background-color: #eee !important;
        color: #000;
        border-bottom: 1px solid #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .edit-input {
        border: none;
        background: transparent;
        padding: 0;
        width: auto;
        text-align: left;
    }

    select.edit-input {
        appearance: none;
        -webkit-appearance: none;
        background: none;
    }

    /* Print Header Info */
    .print-only-header {
        display: block !important;
        margin-bottom: 20px;
        text-align: center;
        border-bottom: 1px solid #000;
        padding-bottom: 10px;
    }

    .print-only-header h2 {
        font-size: 24px;
        margin-bottom: 5px;
    }

    .print-only-header p {
        font-size: 14px;
        color: #555;
    }
}

.print-only-header {
    display: none;
}