                /* ===============================
   BASE / RESET
================================ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, Arial, sans-serif;
    background: #f2f4f7;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 12px;
}

h1 {
    margin-bottom: 16px;
}

h2 {
    margin-bottom: 12px;
}


/* ===============================
   CARD
================================ */
.card {
    background: #fff;
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

/* ===============================
   SUMMARY (TOP)
================================ */
.summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f9fc;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 10px;
}

/* ===============================
   ACTION BUTTONS
================================ */
.actions {
    text-align: right;
    margin-bottom: 10px;
}

.actions button {
    background: #e11d48;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.actions button:hover {
    background: #be123c;
}

/* ===============================
   CURRENCY NOTE TABLE
================================ */
.note-table {
    width: 100%;
    border-collapse: collapse;
}

.note-table th,
.note-table td {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
    white-space: nowrap;
}

.note-table th {
    background: #f7f9fc;
    font-weight: 600;
}

.note-table input {
    width: 70px;
    height: 36px;
    padding: 4px;
    text-align: center;
    font-size: 14px;
}

/* ===============================
   DISCOUNT CALCULATORS
================================ */
.discount-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.discount-grid label {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.discount-grid input {
    width: 100%;
    height: 38px;
    padding: 6px;
    font-size: 15px;
}

.discount-footer {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.discount-result {
    font-size: 24px;
    font-weight: 700;
}

.reset-btn {
    background: #6b7280;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.reset-btn:hover {
    background: #4b5563;
}

/* ===============================
   DIFFERENCE CALCULATOR
================================ */
.diff-top {
    background: #f7f9fc;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.diff-highlight {
    font-size: 22px;
    font-weight: 700;
}

.diff-inputs.vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-inputs.vertical input {
    height: 36px;
    padding: 6px;
    font-size: 14px;
}

.reset-btn.small {
    margin-top: 8px;
    padding: 6px 14px;
    font-size: 13px;
}

/* ===============================
   FMCG PILLAR CALCULATOR (DESKTOP)
================================ */

/* Card wrapper */
.fmcg-pillar-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.08);
}

/* Title */
.fmcg-pillar-card h2 {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

/* Table container (scroll safety) */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

/* Table */
.fmcg-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px; /* keeps columns readable */
}

/* Header */
.fmcg-table thead th {
    background: #0f172a; /* strong FMCG dark */
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 8px;
    text-align: center;
    white-space: nowrap;
}

/* Body cells */
.fmcg-table tbody td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px;
    text-align: center;
}

/* Inputs (general) */
.fmcg-table input {
    width: 100%;
    height: 34px;
    padding: 4px 6px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
}

/* Focus */
.fmcg-table input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* Net Rate – highlight */
.fmcg-table .net-rate {
    background: #ecfeff;
    font-weight: 700;
    color: #0f766e;
    border-color: #67e8f9;
}

/* Flat % – highlight */
.fmcg-table .flat-percent {
    background: #fef3c7;
    font-weight: 700;
    color: #92400e;
    border-color: #fde68a;
}

/* Readonly inputs */
.fmcg-table input[readonly] {
    cursor: not-allowed;
}

/* Row hover */
.fmcg-table tbody tr:hover {
    background: #f9fafb;
}


/* ===============================
   TABLE ACTIONS
================================ */
.table-actions {
    display: flex;
    gap: 12px;
    margin-top: 14px;
}

.fmcg-table th:first-child,
.fmcg-table td:first-child {
    min-width: 240px;
    text-align: left;
}

.fmcg-table .product-name {
    text-align: left;
}

/* Buttons */
.table-actions button {
    background: #111827;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.table-actions button:hover {
    background: #020617;
    transform: translateY(-1px);
}

.table-actions button:active {
    transform: translateY(0);
}

/* Reset button variation (optional clarity) */
#resetAllBtn {
    background: #6b7280;
}

#resetAllBtn:hover {
    background: #4b5563;
}

/* ===============================
   MOBILE FMCG PILLAR
================================ */
@media (max-width: 768px) {

    /* Hide desktop pillar table */
    .fmcg-pillar-card {
        display: none;
    }

    /* Mobile wrapper */
    .fmcg-mobile-wrapper {
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin-top: 12px;
    }

    /* Product card */
    .fmcg-mobile-card {
        background: #ffffff;
        border-radius: 14px;
        padding: 14px;
        box-shadow: 0 8px 22px rgba(0,0,0,0.08);
    }

    /* Header (summary always visible) */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 10px;
        margin-bottom: 12px;
    }

    .mobile-title {
        font-size: 15px;
        font-weight: 700;
        color: #111827;
    }

    .mobile-summary {
        text-align: right;
    }

    .mobile-summary .net-rate {
        display: block;
        font-size: 18px;
        font-weight: 800;
        color: #0f766e;
    }

    .mobile-summary .flat-percent {
        display: block;
        font-size: 13px;
        font-weight: 600;
        color: #92400e;
    }

    /* Body */
    .mobile-body {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Input rows */
    .mobile-row {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-row label {
        font-size: 13px;
        font-weight: 600;
        color: #374151;
    }

    .mobile-row input {
        height: 42px;
        padding: 8px 10px;
        font-size: 15px;
        border-radius: 8px;
        border: 1px solid #d1d5db;
    }

    .mobile-row input:focus {
        outline: none;
        border-color: #2563eb;
        box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
    }

    /* Actions */
    .mobile-actions {
        display: flex;
        gap: 12px;
        margin-top: 6px;
    }

    .mobile-actions button {
        flex: 1;
        background: #111827;
        color: #ffffff;
        border: none;
        padding: 12px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 10px;
        cursor: pointer;
    }

    .mobile-actions button:active {
        transform: scale(0.98);
    }

    #resetMobileAll {
        background: #6b7280;
    }
}


/* ===============================
   DEFAULT (DESKTOP FIRST)
================================ */

/* Grid desktop layout */
.grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* Right column stack */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Desktop FMCG pillar VISIBLE by default */
.fmcg-pillar-card {
    display: block;
    grid-column: 1 / -1; /* span under all 3 cards */
}

/* Mobile FMCG pillar HIDDEN by default */
.fmcg-mobile-wrapper {
    display: none;
}

/* ===============================
   MOBILE LAYOUT
================================ */
@media (max-width: 768px) {

    /* Switch grid to single column */
    .grid {
        grid-template-columns: 1fr;
    }

    /* CARD ORDER (IMPORTANT) */
    .flat-discount-card { order: 1; }
    .mrp-net-card       { order: 2; }
    .buyxy-card         { order: 3; }
    .currency-card      { order: 4; }

    /* FMCG pillar cards */
    .fmcg-pillar-card   { display: none; }   /* hide desktop table */
    .fmcg-mobile-wrapper {
        display: flex;                        /* show mobile cards */
        flex-direction: column;
        gap: 14px;
        order: 5;
    }

    /* Hide desktop-only cards */
    .desktop-only {
        display: none;
    }

    /* Unwrap right column */
    .right-column {
        display: contents;
    }

    /* Discount grid stack */
    .discount-grid {
        grid-template-columns: 1fr;
    }
}
/* ===============================
   GRID AREAS (DESKTOP STRUCTURE)
================================ */
.currency-card { grid-area: currency; }
.desktop-only { grid-area: diff; }
.right-column { grid-area: right; }
.fmcg-pillar-card { grid-area: fmcg; }
.fmcg-mobile-wrapper { grid-area: fmcgmobile; }

/* ===============================
   DESKTOP GRID
================================ */
.grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    grid-template-areas:
        "currency diff right"
        "fmcg fmcg fmcg";
    gap: 20px;
}

/* ===============================
   MOBILE GRID (FINAL FIX)
================================ */
@media (max-width: 768px) {

    .grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "right"
            "currency"
            "fmcgmobile";
    }

    /* Hide desktop FMCG pillar completely */
    .fmcg-pillar-card {
        display: none !important;
    }

    /* Show mobile FMCG wrapper properly */
    .fmcg-mobile-wrapper {
        display: flex !important;
        flex-direction: column;
        gap: 14px;
    }

    /* Hide only difference calculator */
    .desktop-only {
        display: none;
    }

    /* Right column stacked */
    .right-column {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* Make FMCG table scrollable if needed */
    .table-wrap {
        overflow-x: auto;
    }
}
}