:root{
    --bg:#f7f7f2;
    --panel:#ffffff;
    --text:#263238;
    --muted:#718078;
    --border:#e3e7df;

    --sage:#b8d8c0;
    --sage-dark:#52745b;

    --peach:#f5d2bb;
    --rose:#efc7c7;
    --lavender:#d9d0e9;
    --blue:#c9deeb;

    --danger:#a94f4f;

    --shadow:0 8px 25px rgba(38,50,56,.07);
}

*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color:var(--text);
    background:var(--bg);
}

a{
    color:var(--sage-dark);
    text-decoration:none;
}

.topbar{
    height:72px;
    background:white;
    border-bottom:1px solid var(--border);
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 26px;
    position:sticky;
    top:0;
    z-index:30;
}

.brand{
    display:flex;
    align-items:center;
    gap:12px;
}

.brand-mark,
.login-logo{
    width:42px;
    height:42px;
    border-radius:14px;
    background:var(--sage);
    color:#34523c;
    display:grid;
    place-items:center;
    font-weight:800;
}

.brand small{
    display:block;
    color:var(--muted);
    margin-top:2px;
}

.layout{
    display:grid;
    grid-template-columns:235px minmax(0,1fr);
    min-height:calc(100vh - 72px);
}

.sidebar{
    background:#fff;
    border-right:1px solid var(--border);
    padding:24px 15px;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
}

.sidebar nav a{
    display:block;
    padding:11px 13px;
    border-radius:11px;
    margin:3px 0;
    color:#44524a;
}

.sidebar nav a:hover,
.sidebar nav a.active{
    background:#edf5ef;
    color:#355b40;
}

.nav-label{
    font-size:11px;
    font-weight:800;
    letter-spacing:.08em;
    color:#98a29c;
    margin:22px 12px 7px;
}

.sidebar-user{
    border-top:1px solid var(--border);
    padding-top:17px;
    display:grid;
    grid-template-columns:38px 1fr;
    gap:10px;
    align-items:center;
}

.sidebar-user small{
    display:block;
    color:var(--muted);
}

.avatar{
    width:38px;
    height:38px;
    border-radius:50%;
    display:grid;
    place-items:center;
    background:var(--lavender);
    font-weight:700;
}

.link-button{
    border:0;
    background:none;
    padding:4px 0;
    color:var(--sage-dark);
    cursor:pointer;
}

.content{
    padding:32px;
    min-width:0;
}

.page-header{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    margin-bottom:22px;
}

.page-header h1{
    margin:0 0 5px;
    font-size:28px;
}

.page-header p{
    margin:0;
    color:var(--muted);
}

.panel{
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:18px;
    padding:22px;
    margin-bottom:22px;
    box-shadow:var(--shadow);
}

.panel h2{
    margin-top:0;
    font-size:18px;
}

.stats{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(170px,1fr));
    gap:14px;
    margin-bottom:22px;
}

.stat{
    padding:20px;
    background:white;
    border:1px solid var(--border);
    border-radius:16px;
}

.stat:nth-child(4n+1){
    border-top:5px solid var(--sage);
}

.stat:nth-child(4n+2){
    border-top:5px solid var(--peach);
}

.stat:nth-child(4n+3){
    border-top:5px solid var(--lavender);
}

.stat:nth-child(4n){
    border-top:5px solid var(--blue);
}

.stat span{
    display:block;
    color:var(--muted);
    font-size:13px;
}

.stat strong{
    display:block;
    margin-top:8px;
    font-size:28px;
}

.quick-grid{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
    gap:14px;
}

.quick-card{
    padding:18px;
    border:1px solid var(--border);
    border-radius:14px;
}

.quick-card strong,
.quick-card span{
    display:block;
}

.quick-card span{
    color:var(--muted);
    margin-top:5px;
    font-size:13px;
}

label{
    display:block;
    font-size:13px;
    font-weight:700;
    margin-bottom:6px;
}

input,
select,
textarea{
    width:100%;
    border:1px solid #d9dfd8;
    border-radius:10px;
    padding:11px 12px;
    background:#fff;
    color:var(--text);
    font:inherit;
}

textarea{
    resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
    outline:2px solid #c9dfcf;
    border-color:#a7c9af;
}

.form-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:16px;
}

.span-2{
    grid-column:1 / -1;
}

.actions{
    display:flex;
    gap:10px;
    justify-content:flex-end;
    margin-top:14px;
}

.btn{
    border:0;
    border-radius:10px;
    padding:10px 16px;
    font:inherit;
    font-weight:700;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    justify-content:center;
}

.btn.primary{
    background:var(--sage);
    color:#294932;
}

.btn.secondary{
    background:#edf0ec;
    color:#48534b;
}

.btn.danger{
    background:var(--rose);
    color:#753c3c;
}

.btn.small{
    padding:7px 10px;
    font-size:12px;
}

.full{
    width:100%;
    margin-top:14px;
}

.table-wrap{
    width:100%;
}

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

th{
    text-align:left;
    font-size:12px;
    text-transform:uppercase;
    letter-spacing:.04em;
    color:var(--muted);
    padding:11px;
    border-bottom:1px solid var(--border);
}

td{
    padding:13px 11px;
    border-bottom:1px solid #edf0ec;
    vertical-align:top;
}

.status{
    display:inline-block;
    padding:5px 9px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    background:#edf0ec;
}

.status.pending{
    background:#fae8c8;
}

.status.approved{
    background:#d8eddc;
}

.status.rejected{
    background:#f4d2d2;
}

.status.returned{
    background:#e2dbf0;
}

.profile-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:22px;
}

.profile-grid p{
    margin:0;
}

.inline-edit{
    display:grid;
    gap:8px;
    padding:12px;
    min-width:250px;
}

.decision-form{
    min-width:220px;
}

.button-row{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    margin-top:8px;
}

.config-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:22px;
}

.config-row{
    display:grid;
    grid-template-columns:1fr auto auto auto;
    gap:8px;
    align-items:center;
    margin:10px 0;
}

.check{
    display:flex;
    align-items:center;
    gap:6px;
    white-space:nowrap;
}

.check input{
    width:auto;
}

.flash{
    border-radius:10px;
    padding:12px 14px;
    margin-bottom:16px;
}

.flash.success{
    background:#dceede;
}

.flash.danger{
    background:#f4d5d5;
}

.flash.warning{
    background:#fae9c9;
}

.empty{
    text-align:center;
    color:var(--muted);
    padding:30px;
}

.login-page{
    min-height:100vh;
    display:grid;
    place-items:center;
    padding:20px;
    background:
        radial-gradient(circle at 20% 20%,#f4ded0,transparent 30%),
        radial-gradient(circle at 80% 30%,#dceadf,transparent 30%),
        var(--bg);
}

.login-card{
    width:min(420px,100%);
    background:#fff;
    border:1px solid var(--border);
    border-radius:22px;
    padding:32px;
    box-shadow:var(--shadow);
}

.login-card h1{
    margin-bottom:2px;
}

.login-card label{
    margin-top:15px;
}

.muted{
    color:var(--muted);
}

.conversation{
    display:grid;
    gap:12px;
    margin-bottom:20px;
}

.message{
    max-width:78%;
    background:#f0f1ee;
    padding:13px 15px;
    border-radius:14px;
}

.message.mine{
    margin-left:auto;
    background:#e2efe5;
}

.message-meta{
    display:flex;
    gap:10px;
    justify-content:space-between;
    color:var(--muted);
    font-size:12px;
}

.message p{
    margin-bottom:0;
}

.modal-overlay{
    display:none;
    position:fixed;
    inset:0;
    z-index:100;
    background:rgba(20,30,25,.38);
    align-items:center;
    justify-content:center;
    padding:20px;
}

.modal-overlay.show{
    display:flex;
}

.modal-card{
    width:min(430px,100%);
    background:#fff;
    border-radius:18px;
    padding:24px;
    box-shadow:0 20px 60px rgba(0,0,0,.2);
}

.modal-card h3{
    margin-top:0;
}

.modal-actions{
    display:flex;
    justify-content:flex-end;
    gap:10px;
    margin-top:22px;
}

.mobile-menu{
    display:none;
    border:0;
    background:#edf3ee;
    width:42px;
    height:42px;
    border-radius:10px;
    font-size:20px;
}

.back-link{
    display:inline-block;
    margin-bottom:14px;
}

hr{
    border:0;
    border-top:1px solid var(--border);
    margin:22px 0;
}

details summary{
    list-style:none;
    cursor:pointer;
    display:inline-flex;
}

details summary::-webkit-details-marker{
    display:none;
}

@media(max-width:760px){

    .topbar{
        padding:0 16px;
    }

    .mobile-menu{
        display:block;
    }

    .layout{
        display:block;
    }

    .sidebar{
        display:none;
        position:fixed;
        top:72px;
        left:0;
        bottom:0;
        width:260px;
        z-index:50;
        box-shadow:8px 0 30px rgba(0,0,0,.12);
    }

    .sidebar.open{
        display:flex;
    }

    .content{
        padding:20px 14px;
    }

    .form-grid,
    .profile-grid,
    .config-grid{
        grid-template-columns:1fr;
    }

    .span-2{
        grid-column:auto;
    }

    .panel{
        padding:16px;
        border-radius:14px;
    }

    /*
       Responsive table-to-card conversion.
       No horizontal scrolling required.
    */

    table,
    thead,
    tbody,
    tr,
    th,
    td{
        display:block;
        width:100%;
    }

    thead{
        display:none;
    }

    tr{
        background:#fff;
        border:1px solid var(--border);
        border-radius:13px;
        padding:10px;
        margin-bottom:12px;
    }

    td{
        border:0;
        display:grid;
        grid-template-columns:110px minmax(0,1fr);
        gap:10px;
        padding:8px 4px;
        overflow-wrap:anywhere;
    }

    td::before{
        content:attr(data-label);
        font-size:11px;
        text-transform:uppercase;
        letter-spacing:.04em;
        color:var(--muted);
        font-weight:800;
    }

    .config-row{
        grid-template-columns:1fr;
        padding:12px 0;
        border-bottom:1px solid var(--border);
    }

    .message{
        max-width:92%;
    }

    .actions{
        flex-wrap:wrap;
    }

}

/* ==========================================================
   EMPLOYEE ACTION / EDIT UX
   ========================================================== */

.employee-actions{
    display:flex;
    align-items:center;
    gap:7px;
    flex-wrap:nowrap;
}

.employee-actions form{
    margin:0;
}

.employee-actions .btn{
    white-space:nowrap;
}

.employee-edit.editing{
    background:var(--sage);
    color:#294932;
}

@media(max-width:760px){

    .employee-actions{
        justify-content:flex-start;
        flex-wrap:wrap;
    }

}

/* ==========================================================
   LEAVE EDIT UX
   ========================================================== */

.leave-actions{
    display:flex;
    align-items:center;
    gap:7px;
    flex-wrap:nowrap;
}

.leave-actions form{
    margin:0;
}

.leave-actions .btn{
    white-space:nowrap;
}

.leave-edit.editing{
    background:var(--sage);
    color:#294932;
}

.leave-existing-file{
    margin-top:7px;
    font-size:12px;
    color:var(--muted);
}

.leave-existing-file a{
    font-weight:700;
}

@media(max-width:760px){

    .leave-actions{
        justify-content:flex-start;
        flex-wrap:wrap;
    }

}

/* ==========================================================
   LEAVE DECISION / COMMENT HISTORY
   ========================================================== */

.leave-decision-actions{
    display:flex;
    align-items:center;
    gap:7px;
    margin-top:8px;
    flex-wrap:wrap;
}

.manager-comment-history{
    margin-bottom:8px;
    padding:8px 10px;
    border-radius:8px;
    background:#f5f4ee;
}

.manager-comment-label{
    font-size:11px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.03em;
    color:var(--muted);
    margin-bottom:3px;
}

.manager-comment-text{
    font-size:13px;
    line-height:1.4;
    white-space:pre-wrap;
}

.completed-leave-decision{
    min-width:180px;
    padding:8px 0;
}

.leave-decision-form textarea{
    width:100%;
    min-width:220px;
}

@media(max-width:760px){

    .leave-decision-form textarea{
        min-width:0;
    }

}

/* ==========================================================
   HR REQUEST CLOSE WORKFLOW
   ========================================================== */

.hr-thread-actions{
    display:flex;
    justify-content:flex-end;
    align-items:center;
    gap:9px;
}

.ticket-closed-state{
    margin-top:18px;
    padding:12px 14px;
    border-radius:10px;
    background:#f0f3ef;
    display:flex;
    align-items:center;
    gap:10px;
}

.ticket-closed-state strong{
    color:#294932;
}

.ticket-closed-state span{
    color:var(--muted);
    font-size:13px;
}

@media(max-width:760px){

    .hr-thread-actions{
        flex-wrap:wrap;
    }

    .ticket-closed-state{
        align-items:flex-start;
        flex-direction:column;
        gap:3px;
    }

}

/* ==========================================================
   INVENTORY
   ========================================================== */

.inventory-actions{
    display:flex;
    align-items:center;
    gap:7px;
    flex-wrap:nowrap;
}

.inventory-actions form{
    margin:0;
}

.inventory-actions .btn{
    white-space:nowrap;
}

.inventory-edit.editing{
    background:var(--sage);
    color:#294932;
}

@media(max-width:760px){

    .inventory-actions{
        justify-content:flex-start;
        flex-wrap:wrap;
    }

}

/* ==========================================================
   PRICING CONFIGURATION
   ========================================================== */

.config-launch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.config-launch-row p {
    margin-bottom: 0;
}

.pricing-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.pricing-actions form {
    margin: 0;
}

.pricing-filters {
    align-items: end;
}

.filter-action {
    align-self: end;
}

.pricing-edit.editing {
    outline: 2px solid currentColor;
}

.employee-inactive-panel,
.inventory-inactive-panel {
    margin-top: 1.25rem;
}

@media (max-width: 700px) {

    .config-launch-row {
        align-items: stretch;
        flex-direction: column;
    }

    .config-launch-row .btn {
        width: 100%;
        text-align: center;
    }

    .pricing-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .pricing-actions .btn,
    .pricing-actions form {
        width: 100%;
    }

    .pricing-actions form .btn {
        width: 100%;
    }
}

/* ==========================================================
   FACTORY POS + AUDIT
   ========================================================== */

.pos-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, .035);
}

.pos-summary div {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.pos-summary span {
    font-size: .85rem;
    opacity: .7;
}

.pos-summary strong {
    font-size: 1.25rem;
}

.pos-actions {
    display: flex;
    gap: .6rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.sale-confirm-details p {
    margin: .5rem 0;
}

.audit-filters {
    align-items: end;
}

#emailSaleModal.show,
#saleConfirmModal.show {
    display: flex;
}

@media (max-width: 700px) {

    .pos-summary {
        grid-template-columns: 1fr;
    }

    .pos-actions {
        flex-direction: column;
    }

    .pos-actions .btn {
        width: 100%;
    }
}

/* ==========================================================
   FACTORY POS - MULTI ITEM
   ========================================================== */

.pos-main-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.pos-actions-left {
    display: flex;
    align-items: center;
}

.pos-actions-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    flex-wrap: wrap;
}

.pos-items-heading {
    margin-top: 1.5rem;
    margin-bottom: .75rem;
}

.sale-history-line + .sale-history-line {
    margin-top: .35rem;
}

.confirm-items-list {
    margin: 1rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.confirm-item-line {
    padding: .6rem 0;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.confirm-grand-total {
    font-size: 1.15rem;
    margin-top: 1rem;
}

@media (max-width: 700px) {

    .pos-main-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .pos-actions-left,
    .pos-actions-right {
        width: 100%;
    }

    .pos-actions-left .btn {
        width: 100%;
    }

    .pos-actions-right {
        flex-direction: column;
    }

    .pos-actions-right .btn {
        width: 100%;
    }
}

/* PRIME-TABLE-SEARCH-START */

.table-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px 0;
}

.table-search-input {
    width: min(100%, 360px);
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #d9d9df;
    border-radius: 10px;
    background: #fff;
    font: inherit;
}

.table-search-input:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}

.table-search-count {
    color: #6b7280;
    font-size: .88rem;
    white-space: nowrap;
}

.status.cancelled {
    background: #f1f1f3;
    color: #555;
}

@media (max-width: 700px) {

    .table-search {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .table-search-input {
        width: 100%;
        max-width: none;
    }

    .table-search-count {
        text-align: right;
    }
}

/* PRIME-TABLE-SEARCH-END */

/* PRIME-POS-INLINE-MESSAGE-START */

.pos-inline-message {
    margin: 0 0 16px 0;
    padding: 12px 14px;
    border: 1px solid #e4b8b8;
    border-radius: 10px;
    background: #fff4f4;
    font-weight: 600;
}

.pos-inline-message[hidden] {
    display: none;
}

/* PRIME-POS-INLINE-MESSAGE-END */



/* ==========================================================
   PRIME TASTE ORDERS BUILD 2
   ========================================================== */

.history-header {
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    gap:18px;
    margin-bottom:16px;
}

.history-header h2,
.history-header p {
    margin-bottom:4px;
}

.date-filter {
    display:flex;
    align-items:flex-end;
    flex-wrap:wrap;
    gap:8px;
}

.date-filter label {
    width:100%;
    margin-bottom:0;
}

.date-filter input[type="date"] {
    width:auto;
    min-width:165px;
}

.report-tabs {
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-bottom:18px;
}

.gps-confirm-note {
    margin-top:14px;
    padding:10px 12px;
    border-radius:10px;
    background:#f3f6f2;
    font-size:13px;
}

.location-detail {
    margin-top:4px;
    font-size:12px;
    color:var(--muted);
}

.osm-attribution {
    margin-top:16px;
    font-size:11px;
    color:var(--muted);
}

code {
    white-space:nowrap;
}

@media (max-width: 700px) {

    .history-header {
        align-items:stretch;
        flex-direction:column;
    }

    .date-filter {
        width:100%;
    }

    .date-filter input[type="date"] {
        flex:1;
        width:auto;
        min-width:0;
    }

    .date-filter .btn {
        flex:0 0 auto;
    }

    .report-tabs .btn {
        flex:1;
        text-align:center;
    }
}
