:root {
    --wms-radius: 0.85rem;
    --wms-brand-blue: #1f5faa;
    --wms-brand-dark: #0a2f64;
    --wms-brand-green: #00aa55;
}

body {
    font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

/* TAI-TECH 品牌 */
.wms-header-brand {
    align-items: center;
    justify-content: center;
    width: 190px;
    height: 46px;
    padding: 5px 10px;
    border-radius: 0.7rem;
    background: #fff;
    box-shadow: 0 3px 16px rgba(17, 67, 120, 0.08);
}
.wms-header-brand img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.wms-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    padding: 7px 10px;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.18);
}
.wms-sidebar-brand img {
    display: block;
    width: 100%;
    max-width: 185px;
    height: 38px;
    object-fit: contain;
}

/* 登入頁 */
.wms-login-page {
    min-height: 100vh;
    overflow-x: hidden;
    background: #eef5fb;
}
.wms-login-background,
.wms-login-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
}
.wms-login-background {
    z-index: 0;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}
.wms-login-overlay {
    z-index: 1;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.34) 44%, rgba(235,245,255,0.72) 67%, rgba(229,241,253,0.92) 100%);
}
.wms-login-page .flex-root {
    z-index: 2;
}
.wms-login-brand-panel {
    display: inline-flex;
    align-items: center;
    width: min(680px, 90%);
    padding: 14px 20px;
    border-radius: 1rem;
    background: rgba(255,255,255,0.72);
    box-shadow: 0 8px 30px rgba(15, 65, 120, 0.08);
    backdrop-filter: blur(7px);
}
.wms-login-brand-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 118px;
    object-fit: contain;
}
.wms-login-card-logo {
    display: block;
    width: min(340px, 88%);
    height: auto;
    margin-inline: auto;
    object-fit: contain;
}
.wms-login-system-title {
    color: var(--wms-brand-dark);
    font-size: clamp(2rem, 3.2vw, 4.5rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-shadow: 0 2px 14px rgba(255,255,255,0.9);
}
.wms-login-system-subtitle {
    margin-top: 0.55rem;
    color: var(--wms-brand-blue);
    font-size: clamp(1rem, 1.5vw, 1.75rem);
    font-weight: 600;
    letter-spacing: 0.12em;
}
.wms-login-card {
    width: min(92vw, 560px) !important;
    max-width: 560px;
    margin-inline: auto;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.78) !important;
    box-shadow: 0 22px 65px rgba(7, 36, 78, 0.22) !important;
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    backdrop-filter: blur(18px) saturate(125%);
}
.wms-login-card .card-body {
    background: transparent;
}

/* Metronic 側欄 */
.app-sidebar {
    background: linear-gradient(180deg, #071437 0%, #0b214e 58%, #102f65 100%);
}
.app-sidebar .menu .menu-link .menu-title,
.app-sidebar .menu .menu-link .menu-icon i {
    color: rgba(255,255,255,.72);
}
.app-sidebar .menu .menu-link:hover .menu-title,
.app-sidebar .menu .menu-link:hover .menu-icon i,
.app-sidebar .menu .menu-link.active .menu-title,
.app-sidebar .menu .menu-link.active .menu-icon i {
    color: #fff;
}
.app-sidebar .menu .menu-link.active {
    background: rgba(27,132,255,.28);
}
.app-sidebar .menu-heading {
    color: rgba(255,255,255,.42)!important;
}
.app-sidebar-logo {
    min-height: 74px;
}

.wms-stat-card {
    overflow: hidden;
    border: 0;
}
.wms-stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--bs-primary);
}
.wms-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}
.wms-toolbar-card {
    position: sticky;
    top: 78px;
    z-index: 5;
}

/* 表格、功能欄與分頁 */
.wms-table-wrap {
    min-height: 260px;
    overflow: visible;
}
.wms-table-scroll {
    width: 100%;
    max-height: calc(100vh - 390px);
    overflow: auto;
    border-bottom: 1px solid var(--bs-gray-200);
}
.wms-table {
    margin-bottom: 0;
}
.wms-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bs-body-bg);
    white-space: nowrap;
}
.wms-table td {
    vertical-align: middle;
    white-space: nowrap;
}
.wms-table .text-wrap {
    min-width: 180px;
    white-space: normal;
}
.wms-table th:last-child,
.wms-table td:last-child {
    padding-right: 1rem;
}
.wms-table .wms-action-column {
    min-width: 110px;
    text-align: right;
    white-space: nowrap;
}
.wms-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
    min-width: max-content;
}
.wms-pagination {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto minmax(190px, 1fr);
    align-items: center;
    gap: 1rem;
    padding: 1rem 0.25rem 0.25rem;
}
.wms-page-summary {
    text-align: center;
    white-space: nowrap;
}
.wms-page-controls {
    justify-content: flex-end;
}
.wms-page-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.wms-pagination-single .wms-page-controls {
    opacity: 0.72;
}
tr[hidden] {
    display: none !important;
}

.wms-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
}
.wms-empty {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--bs-gray-500);
}
.wms-loading {
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wms-scan-input {
    font-size: 1.25rem;
    letter-spacing: 0.02em;
}
.wms-workflow-step {
    padding-left: 1rem;
    border-left: 3px solid var(--bs-gray-300);
}
.wms-workflow-step.active {
    border-color: var(--bs-primary);
}
.wms-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.swal2-container {
    z-index: 20000!important;
}

@media (max-width: 991.98px) {
    .wms-toolbar-card {
        position: static;
    }
    .wms-table-scroll {
        max-height: none;
    }
    .app-header {
        box-shadow: 0 1px 8px rgba(0,0,0,.08);
    }
    .wms-login-overlay {
        background: rgba(238,246,253,0.78);
    }
    .wms-login-brand-panel {
        width: 100%;
        margin-inline: auto;
    }
    .wms-login-brand-logo {
        max-height: 82px;
    }
    .wms-login-card {
        width: min(94vw, 520px) !important;
        border-radius: 1rem;
        background: rgba(255, 255, 255, 0.84) !important;
    }
}

@media (max-width: 767.98px) {
    .wms-pagination {
        grid-template-columns: 1fr;
    }
    .wms-page-summary {
        text-align: left;
    }
    .wms-page-controls {
        justify-content: flex-start;
    }
}

@media print {
    .app-sidebar,
    .app-header,
    .app-toolbar,
    .app-footer,
    .btn,
    .wms-toolbar-card,
    .wms-pagination {
        display: none!important;
    }
    .app-main,
    .app-wrapper {
        margin: 0!important;
        padding: 0!important;
    }
    .wms-table-wrap,
    .wms-table-scroll {
        max-height: none!important;
        overflow: visible!important;
    }
    .wms-table tbody tr {
        display: table-row!important;
    }
}

/* 2026-07-15 Fix3: Corporate login and numbered pager */
.wms-corporate-login-logo{max-width:360px;width:100%;height:auto;object-fit:contain}
.wms-corporate-login-aside{min-height:320px;background-repeat:no-repeat}
.wms-corporate-login-shade{background:linear-gradient(135deg,rgba(7,31,73,.2),rgba(20,72,135,.42))}
.wms-corporate-aside-logo{width:min(520px,80%);max-height:150px;object-fit:contain;background:rgba(255,255,255,.9);border-radius:1rem;padding:1rem 1.5rem}
.text-shadow{text-shadow:0 2px 12px rgba(0,0,0,.55)}
.wms-page-number{min-width:36px;justify-content:center;padding-inline:.7rem}
@media(max-width:575.98px){.wms-page-number{min-width:32px;padding-inline:.5rem}.wms-corporate-login-logo{max-width:280px}}

/* 2026-07-16 Fix4: full-background login, white header, single-page tables and collapsible sidebar */
.wms-login-page {
    min-height: 100vh;
    overflow: hidden;
    background: #dce9f6;
}
.wms-login-page .wms-login-background {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}
.wms-login-page .wms-login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(135deg, rgba(255,255,255,.28), rgba(235,245,255,.48));
    backdrop-filter: saturate(.95);
}
.wms-login-page #kt_app_root { z-index: 2; }
.wms-login-page .wms-login-card {
    width: min(450px, calc(100vw - 2rem));
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 1.15rem;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(14px);
}
.wms-login-page .wms-login-card-logo {
    display: block;
    width: min(330px, 92%);
    max-height: 100px;
    margin-inline: auto;
    object-fit: contain;
}
.wms-login-copyright {
    padding: .45rem .8rem;
    border-radius: .5rem;
    background: rgba(0, 31, 74, .42);
    text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

.wms-app-header,
#kt_app_header.app-header {
    background: #fff !important;
    border-bottom: 1px solid #eef0f4;
    box-shadow: 0 2px 12px rgba(22, 44, 76, .08);
}
[data-bs-theme="dark"] .wms-app-header,
[data-bs-theme="dark"] #kt_app_header.app-header {
    background: #fff !important;
}
[data-bs-theme="dark"] .wms-app-header .text-gray-900,
[data-bs-theme="dark"] .wms-app-header .btn i {
    color: #1e2432 !important;
}

/* 僅保留水平捲動，表格高度由頁面自然撐開，避免頁面與表格雙層垂直捲動。 */
.wms-table-wrap {
    min-height: 0;
    overflow: visible !important;
}
.wms-table-scroll {
    width: 100%;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    border-bottom: 1px solid var(--bs-gray-200);
    -webkit-overflow-scrolling: touch;
}
.wms-table thead th {
    position: static;
}

#kt_app_sidebar_toggle {
    flex: 0 0 auto;
}
.wms-sidebar-mini-logo {
    display: none !important;
    width: 38px !important;
    height: 38px !important;
    object-fit: contain;
}
body[data-kt-app-sidebar-minimize="on"] .app-sidebar-logo-default {
    display: none !important;
}
body[data-kt-app-sidebar-minimize="on"] .wms-sidebar-mini-logo {
    display: block !important;
}
body[data-kt-app-sidebar-minimize="on"] .wms-sidebar-brand {
    min-height: 46px;
    padding: 4px;
    background: #fff;
}
body[data-kt-app-sidebar-minimize="on"] .app-sidebar-footer {
    display: none;
}
.app-sidebar .menu-icon {
    min-width: 2.25rem;
}
.app-sidebar .menu-icon i::before,
.app-sidebar .menu-icon i::after {
    opacity: 1 !important;
}

#toast-container,
.toastr-container,
.toast-container {
    z-index: 30000 !important;
}
#toast-container > div {
    opacity: .98;
    box-shadow: 0 8px 28px rgba(0,0,0,.22);
}

@media (max-width: 991.98px) {
    .wms-login-page { overflow-y: auto; }
    .wms-login-page .wms-login-overlay { background: rgba(238,246,253,.62); }
    .wms-login-page .wms-login-card { background: rgba(255,255,255,.94); }
}

/* 2026-07-16 Fix5: compact translucent login card */
.wms-login-page .wms-login-card {
    width: min(92vw, 520px) !important;
    max-width: 520px !important;
    margin-inline: auto;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 1.25rem;
    background-color: rgba(255, 255, 255, 0.74) !important;
    box-shadow: 0 24px 68px rgba(7, 36, 78, 0.24) !important;
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    backdrop-filter: blur(18px) saturate(125%);
}
.wms-login-page .wms-login-card .card-body {
    background: transparent !important;
}
@media (max-width: 575.98px) {
    .wms-login-page .wms-login-card {
        width: calc(100vw - 1.5rem) !important;
        max-width: 460px !important;
        border-radius: 1rem;
        background-color: rgba(255, 255, 255, 0.82) !important;
    }
    .wms-login-page .wms-login-card .card-body {
        padding: 1.75rem !important;
    }
}


/* 2026-07-16 Fix7: compact and consistent WMS toolbar cards */
.wms-toolbar-card {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    margin-bottom: 1.25rem !important;
    border: 1px solid var(--bs-gray-200);
    border-radius: .85rem;
    box-shadow: 0 4px 16px rgba(29, 53, 87, .055);
}
.wms-toolbar-card > .card-body,
.wms-toolbar-card .card-body.wms-toolbar-body {
    padding: 1rem 1.25rem !important;
}
.wms-toolbar-form,
.wms-toolbar-card .wms-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
    gap: .75rem 1rem;
    width: 100%;
}
.wms-toolbar-form--compact {
    grid-template-columns: minmax(260px, 720px) auto;
    justify-content: start;
}
.wms-toolbar-form--inline {
    grid-template-columns: minmax(260px, 720px) auto auto;
    justify-content: start;
}
.wms-product-history-toolbar {
    grid-template-columns: minmax(320px, 760px) auto;
    justify-content: start;
    max-width: 1120px;
}
.wms-toolbar-field {
    min-width: 0;
}
.wms-toolbar-card .form-label,
.wms-toolbar-form .form-label {
    margin-bottom: .35rem;
    font-size: .875rem;
    line-height: 1.3;
}
.wms-toolbar-card .form-control:not(textarea),
.wms-toolbar-card .form-select,
.wms-toolbar-form .form-control:not(textarea),
.wms-toolbar-form .form-select {
    min-height: 40px;
    height: 40px;
    padding-top: .5rem;
    padding-bottom: .5rem;
    font-size: .95rem;
}
.wms-toolbar-card .form-control-lg,
.wms-toolbar-form .form-control-lg {
    min-height: 42px !important;
    height: 42px !important;
    font-size: 1rem !important;
}
.wms-toolbar-card .form-text,
.wms-toolbar-form .form-text {
    margin-top: .35rem;
    font-size: .78rem;
    line-height: 1.35;
}
.wms-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    align-self: end;
    justify-self: end;
    gap: .5rem;
    min-width: max-content;
}
.wms-toolbar-actions .btn {
    width: auto !important;
    min-width: 88px;
    min-height: 40px;
    flex: 0 0 auto !important;
    padding: .55rem 1rem;
    white-space: nowrap;
}
.wms-toolbar-actions .btn.btn-lg {
    min-height: 40px;
    padding: .55rem 1rem;
    font-size: .95rem;
}
.wms-toolbar-check {
    min-height: 40px;
    display: flex;
    align-items: center;
    align-self: end;
}
.wms-toolbar-check .form-check {
    margin: 0 !important;
}
.wms-toolbar-embedded {
    padding: .9rem 1rem;
    border: 1px solid var(--bs-gray-200);
    border-radius: .75rem;
    background: var(--bs-body-bg);
}
.wms-toolbar-card .position-relative > .form-control {
    padding-left: 2.75rem !important;
}
.wms-toolbar-card .position-relative > i {
    margin-left: .85rem !important;
}
@media (min-width: 1200px) {
    .wms-toolbar-card .wms-filter-grid.wms-filter-grid-wide {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (max-width: 991.98px) {
    .wms-toolbar-form--compact,
    .wms-toolbar-form--inline,
    .wms-product-history-toolbar {
        grid-template-columns: 1fr;
        max-width: none;
    }
    .wms-toolbar-actions {
        justify-self: stretch;
        min-width: 0;
    }
    .wms-toolbar-actions .btn {
        flex: 1 1 auto !important;
    }
}
@media (max-width: 575.98px) {
    .wms-toolbar-card > .card-body,
    .wms-toolbar-card .card-body.wms-toolbar-body {
        padding: .85rem !important;
    }
    .wms-toolbar-form,
    .wms-toolbar-card .wms-filter-grid {
        grid-template-columns: 1fr;
        gap: .7rem;
    }
    .wms-toolbar-actions {
        width: 100%;
    }
    .wms-toolbar-actions .btn {
        min-width: 0;
    }
}

/* 2026-07-16 Fix8: workflow server-side pagination */
.wms-server-pager .btn {
    min-width: 38px;
}
.wms-server-pager {
    border-top: 1px solid var(--bs-gray-200);
    padding-top: 1rem;
}
