/* =========================
   GLOBAL
========================= */

body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    background: #f5f5f5;
    color: #222;
}

h2 {
    font-size: 26px;
    margin: 0 0 10px 0;
}

h3 {
    margin: 0;
}

/* =========================
   TOPBAR
========================= */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 30px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-img {
    height: 24px;
}

.topbar-buttons {
    display: flex;
    gap: 16px;
    align-items: center;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.logo-link:hover {
    opacity: 0.8;
}

/* =========================
   LANGUAGE
========================= */

.lang-toggle {
    font-size: 13px;
}

.lang-toggle a {
    text-decoration: none;
    font-weight: bold;
    color: #000;
}

.active-lang {
    text-decoration: underline;
}

/* =========================
   BUTTONS
========================= */

.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    text-decoration: none;
}

.btn-primary {
    background: #000;
    color: #fff;
}

.btn-secondary {
    background: #888;
    color: #fff;
}

/* =========================
   PAGE LAYOUT
========================= */

.page-container {
    padding: 20px 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* =========================
   MONTH NAV
========================= */

.month-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.month-nav a {
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
    color: #000;
}

.month-nav .disabled {
    opacity: 0.3;
}

/* =========================
   BOXES (SHARED STYLE)
========================= */

.summary-box,
.records-box {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #eee;
    overflow: hidden;
    min-height: 0;
}

#records-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.summary-box {
    height: 35vh;
    margin-bottom: 10px;
}

.records-box {
    height: 50vh;
}

/* =========================
   HEADERS
========================= */

.summary-header {
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.records-header {
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* records header layout */
.records-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* =========================
   SEARCH
========================= */

.search-box {
    display: flex;
    align-items: center;
}

.search-box input {
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    font-size: 13px;
    width: 200px;
}

.search-box input:focus {
    outline: none;
    border-color: #000;
}

/* =========================
   TABLE WRAPPERS (MATCHED)
========================= */

.summary-table-wrapper,
.records-table-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 0;
    padding-bottom: 15px;
}

.records-table-wrapper table,
.summary-table-wrapper table {
    min-width: 900px;
}

/* =========================
   TABLES
========================= */

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 12px;
    font-size: 13px;
    background: #f7f7f7;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

tbody td {
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f9f9f9;
}

.add-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.add-table {
    table-layout: fixed;
    min-width: 1100px;
}

.add-table th,
.add-table td {
    white-space: normal;
}

.add-table input,
.add-table select {
    min-width: 0;
}

/* sticky headers (both tables) */
.summary-table-wrapper thead th,
.records-table-wrapper thead th {
    position: sticky;
    top: 0;
    background: #f7f7f7;
    z-index: 2;
}

/* =========================
   SORTABLE HEADERS
========================= */

th a.sortable {
    text-decoration: none;
    color: #222;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

th a.sortable:hover {
    opacity: 0.7;
}

.arrow {
    font-size: 10px;
    opacity: 0.6;
}

/* =========================
   DELETE BUTTON
========================= */

.delete-btn {
    text-decoration: none;
    font-size: 14px;
    opacity: 0.6;
}

.delete-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* =========================
   SCROLLBAR
========================= */

.records-table-wrapper::-webkit-scrollbar,
.summary-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.records-table-wrapper::-webkit-scrollbar-thumb,
.summary-table-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* =========================
   NUMBER ALIGNMENT
========================= */

td:nth-child(2),
td:nth-child(3),
td:nth-child(8),
td:nth-child(9) {
    text-align: right;
}

/* =========================
   ALIGN NUMERIC COLUMNS
========================= */

/* Summary table (Retail + Cost) */
.summary-table-wrapper th:nth-child(2),
.summary-table-wrapper th:nth-child(3) {
    text-align: right;
}

/* Records table (Retail + Cost columns) */
.records-table-wrapper th:nth-child(8),
.records-table-wrapper th:nth-child(9) {
    text-align: right;
}

/* =========================
   FORMS (SHARED)
========================= */

.form-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

input,
select {
    font-family: inherit;
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

input:focus,
select:focus {
    outline: none;
    border-color: #000;
}

/* =========================
   ADD PAGE TABLE
========================= */

.add-table {
    table-layout: fixed;
}

.add-table th:nth-child(1),
.add-table td:nth-child(1) { width: 20%; }   /* Reason */

.add-table th:nth-child(2),
.add-table td:nth-child(2) { width: 8%; }    /* PLU */

.add-table th:nth-child(3),
.add-table td:nth-child(3) { width: 20%; }   /* Product */

.add-table th:nth-child(4),
.add-table td:nth-child(4) { width: 8%; }    /* Qty */

.add-table th:nth-child(5),
.add-table td:nth-child(5) { width: 12%; }   /* Staff */

.add-table th:nth-child(6),
.add-table td:nth-child(6) { width: 12%; }   /* Received Staff ID */

.add-table th:nth-child(7),
.add-table td:nth-child(7) { width: 20%; }   /* Notes */

/* =========================
   LOGIN
========================= */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 80px);
}

.login-box {
    width: 360px;
    padding: 30px;
    background: #fff;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    border-radius: 8px;
    text-align: center;
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 15px;
}

/* =========================
   CHANGE PASSWORD
========================= */

.change-password-form {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 20px;
    row-gap: 18px;
    max-width: 600px;
    margin-top: 20px;
}

.form-row {
    display: contents;
}

.form-row label {
    font-weight: bold;
    text-align: right;
    white-space: nowrap;
    font-size: 14px;
}

.form-row input {
    max-width: 320px;
}

/* =========================
   UTILITY / FORM MESSAGES
========================= */
.store-select { margin-bottom: 20px; }
.received-staff-id.is-hidden { display: none; }
.received-staff-message { margin-top: 4px; font-size: 12px; }
.message-error { color: red; }
.message-success { color: green; }
.staff-check-message { margin-top: 20px; }
.staff-check-code { margin-top: 15px; }

/* =========================
   OMS
========================= */

/* ---------- Executive summary ---------- */

.summary-box {
    height: auto;
    min-height: 0;
    margin-bottom: 12px;
}

.oms-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 14px;
    padding: 18px;
    margin: 0;
}

.oms-summary-card {
    display: flex;
    min-height: 105px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    border: 1px solid #d5d5d5;
    border-radius: 9px;
    background: #fff;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.oms-summary-label {
    display: block;
    margin-bottom: 7px;
    color: #666;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.oms-summary-value {
    display: block;
    font-size: 1.65rem;
    font-weight: 700;
}


/* ---------- Main OMS page ---------- */

.oms-page {
    width: 100%;
    max-width: none;
    min-height: calc(100vh - 85px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.oms-page .summary-box {
    height: auto;
    min-height: 0;
}

.oms-orders-box {
    flex: 1 1 auto;
    height: auto;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.oms-orders-box .records-table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.clickable-order-row {
    cursor: pointer;
}

.clickable-order-row:hover {
    background: rgba(0, 0, 0, 0.045);
}

.fulfilment-cell {
    min-width: 125px;
}

progress.fulfilment-bar {
    display: block;
    width: 100%;
    height: 8px;
    margin-top: 5px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #e5e5e5;
    appearance: none;
}

progress.fulfilment-bar::-webkit-progress-bar {
    background: #e5e5e5;
    border-radius: 999px;
}

progress.fulfilment-bar::-webkit-progress-value {
    background: #111;
    border-radius: 999px;
}

progress.fulfilment-bar::-moz-progress-bar {
    background: #111;
    border-radius: 999px;
}

.status-label {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ededed;
    font-size: 0.85rem;
    text-transform: capitalize;
    white-space: nowrap;
}

/*
 * Destination was added to the order list, so the numeric columns now
 * begin at column seven.
 */
#orders-table th:nth-child(n+7):not(:last-child),
#orders-table td:nth-child(n+7):not(:last-child) {
    text-align: right;
}


/* =========================
   OMS ORDER DETAIL
========================= */

.oms-detail-page {
    width: 100%;
    max-width: none;
    padding: 12px 24px 8px;
    box-sizing: border-box;
}

.oms-detail-page .oms-order-box {
    height: calc(100vh - 105px);
    min-height: 600px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
}

.oms-order-box .records-header {
    flex: 0 0 auto;
}


/* ---------- Order information cards ---------- */

.oms-detail-page .order-meta {
    display: grid;
    grid-template-columns: repeat(5, minmax(170px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 16px 18px;
}

.oms-detail-page .order-meta-item {
    display: flex;
    min-height: 58px;
    flex-direction: column;
    justify-content: center;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    text-align: left;
}

.order-meta-label {
    display: block;
    margin-bottom: 4px;
    color: #666;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.order-notes {
    margin: 0 18px 14px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    white-space: pre-wrap;
}


/* ---------- Detail table ---------- */

/*
 * The totals are intentionally NOT a sticky <tfoot>.
 * Chromium/WebKit can paint scrolling table rows around a sticky tfoot,
 * which is what caused the "table behind the totals" effect.
 *
 * Instead, the product rows have their own vertical scroller and the
 * totals are a separate fixed row beneath it. Both sit inside the same
 * horizontal scroller and use the same colgroup widths, so they remain
 * aligned.
 */
.oms-detail-table-shell {
    flex: 1 1 0;
    height: 0;
    min-height: 220px;
    margin: 0 18px;
    overflow-x: auto;
    overflow-y: hidden;
}

.oms-detail-table-inner {
    width: 100%;
    min-width: 1180px;
    height: 100%;
    min-height: 0;
    min-height: 0;
    position: relative;
}

/*
 * Safari has historically been less predictable than Chrome when a
 * scrolling table and a fixed totals row share a flex/grid sizing context.
 * Keep both pieces out of flex/grid layout entirely: the item scroller is
 * absolutely positioned above the totals bar, and the totals bar occupies
 * the final 46px of this container.
 */
.oms-detail-table-inner .records-table-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 46px;
    min-width: 0;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.oms-items-table,
.oms-totals-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
}

.oms-items-table th:nth-child(n+3),
.oms-items-table td:nth-child(n+3),
.oms-totals-table th:nth-child(n+2) {
    text-align: right;
}

.oms-items-table th:first-child,
.oms-items-table td:first-child {
    text-align: left;
}

.oms-items-table th:nth-child(2),
.oms-items-table td:nth-child(2) {
    text-align: left;
}


/* ---------- Shared detail-table column widths ---------- */

.oms-detail-table-inner.with-cost .col-plu {
    width: 6%;
}

.oms-detail-table-inner.with-cost .col-product {
    width: 24%;
}

.oms-detail-table-inner.with-cost .col-qty-ordered,
.oms-detail-table-inner.with-cost .col-qty-received {
    width: 8%;
}

.oms-detail-table-inner.with-cost .col-items-fulfilled {
    width: 10%;
}

.oms-detail-table-inner.with-cost .col-retail-ordered,
.oms-detail-table-inner.with-cost .col-retail-received,
.oms-detail-table-inner.with-cost .col-retail-fulfilled {
    width: 12%;
}

.oms-detail-table-inner.with-cost .col-cost {
    width: 8%;
}


.oms-detail-table-inner.without-cost .col-plu {
    width: 7%;
}

.oms-detail-table-inner.without-cost .col-product {
    width: 27%;
}

.oms-detail-table-inner.without-cost .col-qty-ordered,
.oms-detail-table-inner.without-cost .col-qty-received {
    width: 9%;
}

.oms-detail-table-inner.without-cost .col-items-fulfilled {
    width: 10%;
}

.oms-detail-table-inner.without-cost .col-retail-ordered,
.oms-detail-table-inner.without-cost .col-retail-received {
    width: 13%;
}

.oms-detail-table-inner.without-cost .col-retail-fulfilled {
    width: 12%;
}


/* ---------- Fixed totals bar ---------- */

.oms-totals-gutter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: block;
    width: 100%;
    height: 46px;
    min-height: 46px;
    overflow: hidden;
    box-sizing: border-box;
    background: #f7f7f7;
    border-top: 2px solid #ddd;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.08);
}

.oms-totals-table {
    width: 100%;
    height: 46px;
    background: #f7f7f7;
}

.oms-totals-table tbody tr:hover {
    background: #f7f7f7;
}

.oms-totals-table th {
    height: 44px;
    padding: 8px 12px;
    vertical-align: middle;
    border: 0;
    background: #f7f7f7;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.oms-totals-table th:first-child {
    text-align: center;
}


/* ---------- Back button ---------- */

.oms-detail-page .back-button-row {
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 18px 10px;
    text-align: center;
    background: #fff;
    border-top: 1px solid #eee;
}


/* =========================
   OMS RESPONSIVE
========================= */

@media (max-width: 1100px) {
    .oms-summary-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .oms-detail-page .order-meta {
        grid-template-columns: repeat(3, minmax(170px, 1fr));
    }
}

@media (max-width: 700px) {
    .oms-detail-page {
        padding: 10px;
    }

    .oms-detail-page .oms-order-box {
        height: auto;
        min-height: calc(100vh - 80px);
    }

    .oms-detail-page .order-meta {
        grid-template-columns: 1fr;
    }

    .oms-detail-table-shell {
        min-height: 320px;
        margin: 0 10px;
    }
}

@media (max-width: 480px) {
    .oms-summary-grid {
        grid-template-columns: 1fr;
    }
}

