body{
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    margin: 0;
    padding: 0;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
}

*{
    box-sizing: border-box;
}

a{
    text-decoration: none;
}

/* TOPBAR */
.topbar{
    background: #111827;
    color: #fff;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

.title{
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.2;
    letter-spacing: .2px;
}

.buttons{
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.buttons a{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    height: 38px;
    padding: 0 14px;
    background: #2563eb;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: .2s ease;
}

.buttons a:hover{
    background: #1d4ed8;
}

/* LAYOUT */
.container{
    max-width: 1280px;
    margin: auto;
    padding: 20px;
}

.card{
    background: #fff;
    padding: 18px;
    margin-bottom: 18px;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(15,23,42,.06);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

h3{
    margin: 0 0 14px 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

/* SEARCH FORM */
.search-form{
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-form input{
    flex: 1;
    min-width: 220px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.search-form input:focus{
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}

.search-form button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s ease;
}

.search-form button:hover{
    background: #1d4ed8;
}

/* BULK IMEI FORM */
.imei-form{
    width: 100%;
}

.imei-input-wrapper{
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.imei-input-wrapper .form-group{
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.imei-input-wrapper .form-group label{
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.imei-input-wrapper select{
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    background: #fff;
}

.imei-input-wrapper select:focus{
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}

.imei-input-wrapper textarea{
    width: 100%;
    min-height: 130px;
    padding: 12px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: vertical;
    outline: none;
    background: #fff;
}

.imei-input-wrapper textarea:focus{
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}

.imei-input-wrapper button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 38px;
    padding: 0 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: .2s ease;
}

.imei-input-wrapper button:hover{
    background: #1d4ed8;
}

/* SERVICE FORM */
.service-form{
    margin-top: 8px;
}

.form-row{
    display: grid;
    grid-template-columns: 1fr 160px 200px;
    gap: 14px;
    margin-bottom: 14px;
}

.form-group{
    display: flex;
    flex-direction: column;
}

.form-group label{
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.form-group input,
.form-group select{
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus{
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}

.form-submit{
    margin-top: 4px;
}

.form-submit button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 38px;
    padding: 0 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: .2s ease;
}

.form-submit button:hover{
    background: #1d4ed8;
}

/* TABLES */
.table-wrap{
    width: 100%;
    overflow-x: auto;
}

table,
.services-table{
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th,
.services-table th{
    background: #111827;
    color: #fff;
    padding: 11px 10px;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}

td,
.services-table td{
    padding: 11px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
    color: #374151;
}

.service-name{
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
    color: #111827;
}

.api-link-box{
    display: block;
    width: 100%;
    max-width: 100%;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    word-break: break-all;
    color: #374151;
}

/* BUTTONS */
.status-badge,
.btn-toggle,
.btn-delete,
.btn-edit,
.btn-action{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 105px;
    height: 34px;
    padding: 0 10px;
    border-radius: 7px;
    font-weight: 600;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
    border: none;
}

.status-badge{
    color: #fff;
}

.badge-active{
    background: #16a34a;
}

.badge-disabled{
    background: #ef4444;
}

.btn-toggle{
    background: #2563eb;
    color: #fff;
}

.btn-delete{
    background: #ef4444;
    color: #fff;
}

.btn-edit{
    background: #f59e0b;
    color: #fff;
}

.btn-action{
    background: #2563eb;
    color: #fff;
}

.actions-cell{
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    white-space: normal;
}

.services-table td{
    vertical-align: middle;
}

/* STATUS LABELS */
.status-pending,
.status-success,
.status-rejected,
.status-inprocess{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 105px;
    height: 34px;
    padding: 0 12px;
    color: #fff;
    border-radius: 7px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.status-pending{
    background: #f59e0b;
}

.status-success{
    background: #16a34a;
}

.status-rejected{
    background: #ef4444;
}

.status-inprocess{
    background: #2563eb;
}

.status-cell .status-pending,
.status-cell .status-success,
.status-cell .status-rejected,
.status-cell .status-inprocess{
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ALERTS */
.alert-success{
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
    font-size: 13px;
}

.alert-error{
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
    font-size: 13px;
}

/* CODE PREVIEW */
.code-pre{
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.code-html{
    font-size: 12px;
    line-height: 1.5;
}

.code-preview{
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 68px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.4;
}

/* ORDER HISTORY TABLE SAFE FIX */
.table-wrap table{
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.table-wrap th,
.table-wrap td{
    padding: 11px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    font-size: 13px;
}

.table-wrap td{
    vertical-align: top;
}

.table-wrap td.status-cell{
    vertical-align: middle;
    text-align: center;
}

.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1){
    width: 80px;
}

.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2){
    width: 200px;
}

.table-wrap th:nth-child(3),
.table-wrap td:nth-child(3){
    width: 150px;
}

.table-wrap th:nth-child(4),
.table-wrap td:nth-child(4){
    width: 360px;
}

.table-wrap th:nth-child(5),
.table-wrap td:nth-child(5){
    width: 170px;
}

.table-wrap td:nth-child(4){
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
}

.table-wrap .code-pre,
.table-wrap .code-html{
    margin: 0;
}

/* STATS GRID */
.stats-grid{
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.stat-box{
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,.05);
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-title{
    font-size: 14px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 10px;
    line-height: 1.3;
}

.stat-value{
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    color: #111827;
}

/* Accent top borders */
.stat-total{
    border-top: 4px solid #2563eb;
}

.stat-pending{
    border-top: 4px solid #f59e0b;
}

.stat-inprocess{
    border-top: 4px solid #3b82f6;
}

.stat-success{
    border-top: 4px solid #16a34a;
}

.stat-rejected{
    border-top: 4px solid #ef4444;
}

/* COLOR BARS */
.stats-bars{
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stat-bar{
    width: 100%;
    border-radius: 12px;
    padding: 18px 22px;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0,0,0,.07);
    display: flex;
    align-items: center;
}

.stat-total{
    background: linear-gradient(135deg,#3b82f6,#1d4ed8);
}

.stat-pending{
    background: linear-gradient(135deg,#f59e0b,#d97706);
}

.stat-inprocess{
    background: linear-gradient(135deg,#3b82f6,#2563eb);
}

.stat-success{
    background: linear-gradient(135deg,#22c55e,#15803d);
}

.stat-rejected{
    background: linear-gradient(135deg,#ef4444,#b91c1c);
}

/* ACTION BUTTONS */
.result-preview{
    cursor: pointer;
    position: relative;
}

.view-btn,
.copy-btn,
.order-id-btn{
    border: none;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.view-btn,
.copy-btn{
    background: #111827;
    color: #fff;
}

.view-btn{
    margin-top: 8px;
}

.order-id-btn{
    background: #2563eb;
    color: #fff;
}

/* ORDER MODAL */
.order-modal{
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    padding: 20px;
}

.order-modal.show{
    display: flex;
    align-items: center;
    justify-content: center;
}

.order-modal-box{
    width: 100%;
    max-width: 720px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    border: 1px solid #e5e7eb;
}

.order-modal-head,
.order-modal-foot{
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
}

.order-modal-foot{
    border-top: 1px solid #eee;
    border-bottom: 0;
}

.order-modal-body{
    padding: 18px;
    max-height: 70vh;
    overflow-y: auto;
}

.close-modal{
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    float: right;
}

.detail-row{
    margin-bottom: 12px;
    word-break: break-word;
    font-size: 13px;
}

.modal-code-box {
    background: #f8f8f8;
    padding: 12px;
    border-radius: 8px;
    word-break: break-word;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.8;
}

/* POPUP */
.popup-overlay{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.popup-box{
    background: #fff;
    width: 100%;
    max-width: 420px;
    padding: 24px 20px;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.20);
    text-align: center;
    animation: popupFade .25s ease;
}

.popup-icon{
    width: 58px;
    height: 58px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.popup-box h3{
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 700;
    color: #111827;
}

.popup-box p{
    margin: 0 0 18px 0;
    font-size: 14px;
    color: #4b5563;
}

.popup-buttons{
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.popup-buttons .btn-toggle,
.popup-buttons .btn-delete{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 38px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* ANIMATION */
@keyframes popupFade{
    from{
        opacity: 0;
        transform: scale(.95);
    }
    to{
        opacity: 1;
        transform: scale(1);
    }
}

/* DESKTOP */
@media (min-width:992px){
    .container{
        max-width: 1280px;
        padding: 24px;
    }

    .card{
        padding: 20px;
    }

    .title{
        font-size: 24px;
    }

    .buttons a{
        min-width: 115px;
        height: 38px;
    }

    .form-row{
        grid-template-columns: 1fr 160px 200px;
    }
}

/* TABLET */
@media (max-width:991px){
    .container{
        padding: 16px;
    }

    .title{
        font-size: 20px;
    }

    .buttons{
        width: 100%;
    }

    .buttons a{
        flex: 1 1 calc(50% - 10px);
        min-width: unset;
    }

    .form-row{
        grid-template-columns: 1fr 1fr;
    }

    .form-row .form-group:first-child{
        grid-column: 1 / -1;
    }

    .status-badge,
    .btn-toggle,
    .btn-delete,
    .btn-edit,
    .btn-action{
        width: 100px;
        height: 34px;
        font-size: 12px;
    }

    .stats-grid{
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* MOBILE */
@media (max-width:767px){
    .topbar{
        padding: 12px 14px;
        align-items: flex-start;
    }

    .title{
        font-size: 18px;
        width: 100%;
    }

    .buttons{
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .buttons a{
        width: 100%;
        min-width: 0;
        height: 36px;
        font-size: 12px;
        padding: 0 8px;
        margin: 0;
    }

    .container{
        padding: 12px;
    }

    .card{
        padding: 14px;
        border-radius: 10px;
    }

    h3{
        font-size: 16px;
        margin-bottom: 12px;
    }

    .search-form{
        flex-direction: column;
        align-items: stretch;
    }

    .search-form input,
    .search-form button{
        width: 100%;
        min-width: 0;
    }

    .imei-input-wrapper textarea{
        min-height: 120px;
        font-size: 13px;
    }

    .imei-input-wrapper button{
        width: 100%;
        height: 38px;
        font-size: 13px;
    }

    .form-row{
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }

    .form-submit button{
        width: 100%;
        height: 38px;
        font-size: 13px;
    }

    th,
    td,
    .services-table th,
    .services-table td{
        padding: 9px 8px;
        font-size: 12px;
    }

    .status-badge,
    .btn-toggle,
    .btn-delete,
    .btn-edit,
    .btn-action{
        width: 100%;
        max-width: 130px;
        height: 34px;
        font-size: 12px;
        border-radius: 7px;
    }

    .actions-cell{
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .status-pending,
    .status-success,
    .status-rejected,
    .status-inprocess{
        min-width: 95px;
        height: 32px;
        font-size: 11px;
        padding: 0 10px;
    }

    .imei-input-wrapper button{
        width: 100%;
    }

    .popup-box{
        max-width: 100%;
        padding: 20px 16px;
    }

    .popup-box h3{
        font-size: 20px;
    }

    .popup-box p{
        font-size: 13px;
    }

    .popup-buttons{
        flex-direction: column;
        align-items: center;
    }

    .popup-buttons .btn-toggle,
    .popup-buttons .btn-delete{
        width: 100%;
        max-width: 200px;
        height: 38px;
        font-size: 13px;
    }

    .stats-grid{
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .stat-box{
        min-height: 100px;
        padding: 18px;
    }

    .stat-title{
        font-size: 14px;
        margin-bottom: 10px;
    }

    .stat-value{
        font-size: 30px;
    }

    .order-modal-body{
        padding: 14px;
    }
}