/* ============================================================
   v7.3 MOBILE FIRST OPERATIONS
   - Phone: tables become cards, touch targets >= 44px
   - Desktop: normal table layout remains
   ============================================================ */

/* Admin master: prevent right-side "변경" controls from clipping on desktop. */
.tracking-master-table {
    min-width: 0;
    table-layout: fixed;
}
.tracking-master-table th:nth-child(1),
.tracking-master-table td:nth-child(1) { width: 12%; }
.tracking-master-table th:nth-child(2),
.tracking-master-table td:nth-child(2) { width: 25%; }
.tracking-master-table th:nth-child(3),
.tracking-master-table td:nth-child(3) { width: 25%; }
.tracking-master-table th:nth-child(4),
.tracking-master-table td:nth-child(4) { width: 9%; }
.tracking-master-table th:nth-child(5),
.tracking-master-table td:nth-child(5) { width: 13%; }
.tracking-master-table th:nth-child(6),
.tracking-master-table td:nth-child(6) { width: 16%; }

.tracking-master-table td {
    white-space: normal;
    overflow-wrap: anywhere;
}
.tracking-master-edit {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}
.tracking-master-edit select {
    width: 100%;
    min-width: 0;
    height: 38px;
}
.tracking-master-edit .btn {
    white-space: nowrap;
}

/* Buttons/inputs used in warehouse operation should be comfortable to tap. */
.part-barcode-input-wrap,
.form-grid input,
.form-grid select,
.form-grid textarea,
.filter-bar input,
.filter-bar select,
.modern-filter-select,
.modern-filter-btn,
.btn {
    min-height: 44px;
}
.btn.small {
    min-height: 38px;
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
}

/* Main responsive-card-table pattern. */
.responsive-card-table {
    width: 100%;
}
.responsive-card-table td {
    overflow-wrap: anywhere;
}

/* Phone/tablet optimization */
@media (max-width: 820px) {
    html, body {
        overflow-x: hidden;
    }

    .sidebar {
        width: min(86vw, 320px);
        box-shadow: 18px 0 45px rgba(8, 18, 34, .22);
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 29;
        background: rgba(11, 20, 34, .42);
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop.open {
        display: block;
    }

    .topbar {
        height: 62px;
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-title {
        min-width: 0;
        flex: 1;
    }
    .topbar-title strong {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-actions {
        gap: 7px;
    }
    .scan-shortcut {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 11px;
    }
    .user-chip {
        display: none;
    }
    .menu-toggle {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        flex: 0 0 40px;
        border-radius: 9px;
        background: #f4f7fb;
    }

    .content {
        width: 100%;
        padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
    }

    .page-heading {
        margin-bottom: 16px;
        gap: 12px;
    }
    .page-heading h1 {
        font-size: 22px;
        margin-top: 4px;
    }
    .page-heading p {
        font-size: 11px;
        line-height: 1.55;
    }
    .eyebrow {
        font-size: 8.5px;
    }
    .heading-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .panel {
        border-radius: 12px;
        box-shadow: 0 3px 14px rgba(15, 27, 45, .05);
    }
    .panel-head {
        padding: 14px;
        align-items: flex-start;
    }
    .panel-head h2 {
        font-size: 15px;
    }
    .panel-note {
        font-size: 9px;
        text-align: right;
    }

    .filter-bar,
    .modern-filter-bar {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .filter-bar input,
    .filter-bar select,
    .filter-bar .search-input,
    .modern-filter-search,
    .modern-filter-select {
        width: 100%;
        min-width: 0 !important;
        grid-column: 1 / -1;
    }
    .filter-bar .btn,
    .filter-bar a.btn {
        width: 100%;
    }
    .modern-filter-actions {
        grid-column: 1 / -1;
        width: 100%;
    }
    .modern-filter-actions > * {
        flex: 1 1 0;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }
    .metric-card {
        min-height: 108px;
        padding: 13px;
    }
    .metric-card strong {
        margin: 8px 0 2px;
        font-size: 24px;
    }

    .workflow-overview,
    .workflow-note {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding-bottom: 10px;
    }
    .workflow-box {
        min-width: 210px;
        scroll-snap-align: start;
    }

    .form-panel,
    .form-panel.wide {
        max-width: none;
        width: 100%;
    }
    .form-panel form {
        padding: 14px;
    }
    .form-grid {
        gap: 12px;
    }
    .form-actions {
        position: sticky;
        bottom: 0;
        z-index: 8;
        margin: 18px -14px -14px;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--line);
    }
    .form-actions .btn {
        width: 100%;
        min-height: 50px;
        font-size: 13px;
    }

    .part-barcode-row {
        grid-template-columns: 1fr;
    }
    .part-barcode-input-wrap {
        padding-left: 10px;
    }
    .part-barcode-input-wrap .btn {
        min-width: 64px;
    }
    .barcode-inline-result {
        font-size: 10px;
    }

    .tracking-workflow-card {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 12px;
    }

    .linked-workflow {
        padding: 12px;
    }
    .request-context-strip,
    .request-detail-summary,
    .linked-case-summary {
        grid-template-columns: 1fr 1fr;
    }
    .request-context-strip > div,
    .request-detail-summary > div,
    .linked-case-summary > div {
        min-height: 62px;
        padding: 10px;
    }

    .prf-candidate {
        padding: 12px;
    }
    .prf-candidate-grid {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }
    .prf-candidate-top {
        flex-wrap: wrap;
    }

    .case-description-body,
    .case-description-entry-body {
        font-size: 11px;
        line-height: 1.65;
    }

    /* Turn selected operational tables into cards. No horizontal dragging. */
    .table-wrap:has(.responsive-card-table),
    .sf-stock-table-wrap:has(.responsive-card-table) {
        overflow: visible;
    }
    .responsive-card-table {
        display: block;
        min-width: 0 !important;
        border-collapse: separate;
        border-spacing: 0;
    }
    .responsive-card-table thead {
        display: none;
    }
    .responsive-card-table tbody {
        display: grid;
        gap: 10px;
        padding: 10px;
    }
    .responsive-card-table tbody tr {
        display: block;
        width: 100%;
        overflow: hidden;
        border: 1px solid #dfe5ee;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(15, 27, 45, .035);
    }
    .responsive-card-table tbody td {
        width: 100% !important;
        min-width: 0 !important;
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        padding: 9px 12px;
        border-bottom: 1px solid #edf1f5;
        white-space: normal;
        text-align: left !important;
        font-size: 11px;
    }
    .responsive-card-table tbody td:last-child {
        border-bottom: 0;
    }
    .responsive-card-table tbody td[data-label]::before {
        content: attr(data-label);
        color: #8490a1;
        font-size: 9px;
        font-weight: 800;
        line-height: 1.5;
    }
    .responsive-card-table tbody td.mobile-card-title {
        background: #f7f9fc;
    }
    .responsive-card-table tbody td.mobile-card-title::before {
        color: #637086;
    }
    .responsive-card-table tbody td.mobile-card-title {
        color: #23354c;
        font-size: 12px;
    }
    .responsive-card-table tbody td.mobile-card-qty strong {
        color: #1f5fbe;
        font-size: 15px;
    }
    .responsive-card-table tbody td.mobile-action-cell {
        display: block;
        padding: 10px 12px;
        background: #fbfcfe;
    }
    .responsive-card-table .mobile-action-cell::before {
        display: none;
    }
    .responsive-card-table .mobile-action-cell .btn,
    .responsive-card-table .mobile-action-cell .row-actions,
    .responsive-card-table .mobile-action-cell form {
        width: 100%;
    }
    .responsive-card-table .mobile-action-cell .row-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .responsive-card-table .mobile-action-cell .btn {
        min-height: 44px;
    }
    .responsive-card-table .empty-cell,
    .responsive-card-table .sf-empty-row {
        display: block !important;
        width: 100% !important;
        padding: 24px 14px;
        text-align: center !important;
    }
    .responsive-card-table .empty-cell::before,
    .responsive-card-table .sf-empty-row::before {
        display: none;
    }

    /* Admin master becomes a clean setting card. */
    .tracking-master-table tbody td.mobile-action-cell {
        padding: 12px;
    }
    .tracking-master-edit {
        display: grid;
        grid-template-columns: 1fr auto;
        width: 100%;
    }
    .tracking-master-edit select {
        min-height: 44px;
        font-size: 12px;
    }
    .tracking-master-edit .btn {
        min-width: 68px;
        min-height: 44px;
    }

    /* Inventory phone card: lower-priority Salesforce metadata is still shown,
       but visually quieter than part/qty. */
    .inventory-responsive-table .mobile-secondary {
        color: #7b8797;
    }

    .change-part-serial-pair {
        gap: 8px;
    }
    .serial-pair-card {
        padding: 12px;
    }
    .serial-pair-card input {
        min-height: 48px;
    }
}

/* Narrow phones */
@media (max-width: 480px) {
    .content {
        padding-left: 9px;
        padding-right: 9px;
    }
    .metric-grid {
        grid-template-columns: 1fr 1fr;
    }
    .metric-card {
        min-height: 100px;
    }
    .heading-actions {
        grid-template-columns: 1fr;
    }
    .request-context-strip,
    .request-detail-summary,
    .linked-case-summary {
        grid-template-columns: 1fr;
    }
    .responsive-card-table tbody {
        padding: 8px;
        gap: 8px;
    }
    .responsive-card-table tbody td {
        grid-template-columns: 92px minmax(0, 1fr);
        padding: 9px 10px;
    }
    .tracking-master-edit {
        grid-template-columns: 1fr;
    }
    .tracking-master-edit .btn {
        width: 100%;
    }
    .topbar-actions .scan-shortcut {
        padding-inline: 8px;
    }
}


/* ===== v8.0 : Salesforce source-of-truth / reservation / sync gate ===== */
.reserved-qty {
    font-weight: 800;
    color: var(--warning);
}

.sf-sync-pending-panel {
    border-left: 4px solid var(--warning);
}

.sf-sync-pending-list {
    display: grid;
    gap: 10px;
    padding: 0 20px 16px;
}

.sf-sync-pending-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffaf0;
}

.sf-sync-pending-item > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.sf-sync-pending-item span,
.sf-sync-pending-item small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.sf-sync-pending-item form {
    flex: 0 0 auto;
}

@media (max-width: 760px) {
    .sf-sync-pending-list {
        padding: 0 14px 14px;
    }

    .sf-sync-pending-item {
        align-items: stretch;
        flex-direction: column;
    }

    .sf-sync-pending-item form,
    .sf-sync-pending-item .btn {
        width: 100%;
    }
}


/* v8.0 CS test profile */
.cs-scope-bar { margin: 14px 24px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbff; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.cs-scope-bar strong { color: var(--ink); }
.cs-scope-role { padding: 4px 7px; border-radius: 999px; background: #e8f0ff; color: var(--accent); font-size: 9px; font-weight: 800; }
.scope-divider { color: #c1c8d3; }
.demo-login-area { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.demo-login-title { margin-bottom: 10px; }
.demo-login-title strong, .demo-login-title span { display: block; }
.demo-login-title strong { font-size: 12px; }
.demo-login-title span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.demo-user-card { width: 100%; border: 1px solid #d8e2f2; background: #f8fbff; border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: left; }
.demo-user-card:hover { border-color: #9db8eb; background: #f1f6ff; }
.demo-avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: white; font-weight: 800; }
.demo-user-copy { min-width: 0; flex: 1; }
.demo-user-copy strong, .demo-user-copy small { display: block; }
.demo-user-copy strong { font-size: 12px; color: var(--ink); }
.demo-user-copy em { margin-left: 5px; font-style: normal; font-size: 9px; color: var(--accent); }
.demo-user-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-arrow { color: var(--accent); font-size: 18px; }
@media (max-width: 680px) { .cs-scope-bar { margin: 10px 12px 0; } }

/* v8.0 CS: inventory is intentionally visible only while creating an outbound request. */
.cs-dashboard-grid { grid-template-columns: minmax(0, 1fr); }
.cs-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .cs-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cs-metric-grid { grid-template-columns: minmax(0, 1fr); }
}


/* ============================================================
   v8.0.3 - Role Scope / Barcode Label / Scan-to-Outbound
   ============================================================ */

.scan-scope-banner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 12px;
    align-items: center;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #dfe6ef;
    border-radius: 12px;
    background: #f8fbff;
}
.scan-scope-banner > span {
    color: #7a8798;
    font-size: 9px;
    font-weight: 800;
}
.scan-scope-banner > strong {
    color: #2d405a;
    font-size: 11px;
}
.scan-scope-banner > small {
    grid-column: 2;
    color: #8691a0;
    font-size: 8.5px;
}

.scan-result-grid {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 14px;
    margin-top: 14px;
}
.scan-stock-cards,
.scan-request-list {
    display: grid;
    gap: 10px;
    padding: 12px;
}
.scan-stock-card,
.scan-request-card {
    border: 1px solid #dfe5ee;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.scan-stock-card {
    display: grid;
    grid-template-columns: minmax(150px, .9fr) minmax(0, 1.4fr) minmax(120px, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
}
.scan-stock-card > div {
    min-width: 0;
}
.scan-stock-card span,
.scan-request-body span {
    display: block;
    margin-bottom: 4px;
    color: #8190a3;
    font-size: 8.5px;
    font-weight: 800;
}
.scan-stock-title strong,
.scan-stock-title small {
    display: block;
}
.scan-stock-title small,
.scan-stock-meta span {
    color: #7d8999;
    font-size: 9px;
}
.scan-stock-meta {
    display: grid;
    gap: 4px;
}
.scan-stock-qty {
    text-align: right;
}
.scan-stock-qty strong {
    color: #1f5eb9;
    font-size: 18px;
}

.scan-request-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    padding: 12px 13px;
    border-bottom: 1px solid #e9edf2;
    background: #f8fafc;
}
.scan-request-head > div {
    display: flex;
    align-items: center;
    gap: 8px;
}
.scan-request-head small {
    color: #8792a1;
    font-size: 8.5px;
}
.scan-request-body {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    background: #e8edf3;
}
.scan-request-body > div {
    min-height: 68px;
    padding: 10px;
    background: #fff;
}
.scan-request-body strong,
.scan-request-body small {
    display: block;
    overflow-wrap: anywhere;
}
.scan-request-body strong {
    font-size: 10px;
}
.scan-request-body small {
    margin-top: 3px;
    color: #8290a2;
    font-size: 8.5px;
}
.scan-request-actions {
    display: grid;
    grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr);
    gap: 8px;
    padding: 10px 12px 12px;
}
.scan-request-actions form {
    display: contents;
}
.scan-request-actions .btn {
    width: 100%;
}

.empty-state.compact {
    margin: 0;
    padding: 24px 14px;
    border: 0;
    border-radius: 0;
}

/* Barcode print page */
.barcode-label-filter {
    padding: 14px;
    margin-bottom: 0;
}
.label-print-options {
    display: grid;
    grid-template-columns: 130px 160px minmax(0, 1fr);
    gap: 12px;
    padding: 0 14px 14px;
}
.label-print-options label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.label-print-options label > span {
    color: #66758a;
    font-size: 9px;
    font-weight: 800;
}
.label-print-options input,
.label-print-options select {
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid #d5dde8;
    border-radius: 9px;
    background: #fff;
}
.label-format-note {
    padding: 10px 12px;
    border: 1px solid #dfe5ee;
    border-radius: 10px;
    background: #f8fafc;
}
.label-format-note strong,
.label-format-note span,
.label-format-note small {
    display: block;
}
.label-format-note strong {
    color: #38495f;
    font-size: 9px;
}
.label-format-note span {
    margin-top: 2px;
    color: #1f5eb9;
    font-size: 11px;
    font-weight: 900;
}
.label-format-note small {
    margin-top: 4px;
    color: #8591a0;
    font-size: 8.5px;
}

.barcode-label-table td {
    white-space: normal;
}
.barcode-print-root {
    display: none;
}
.semics-part-label {
    overflow: hidden;
    padding: 3mm 3.5mm 2.6mm;
    background: #fff;
    color: #000;
    font-family: Arial, "Noto Sans KR", sans-serif;
}
.semics-part-label.label-70x35 {
    width: 70mm;
    height: 35mm;
}
.semics-part-label.label-60x40 {
    width: 60mm;
    height: 40mm;
}
.semics-part-label.label-80x40 {
    width: 80mm;
    height: 40mm;
}
.part-label-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 3mm;
    margin-bottom: 1mm;
}
.part-label-head strong {
    font-size: 10pt;
    letter-spacing: .08em;
}
.part-label-head span {
    font-size: 6.5pt;
    font-weight: 700;
}
.part-label-part {
    display: flex;
    gap: 2mm;
    align-items: baseline;
    overflow: hidden;
    white-space: nowrap;
}
.part-label-part span {
    font-size: 5.5pt;
    font-weight: 700;
}
.part-label-part strong {
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 7pt;
}
.part-code128 {
    display: block;
    width: 100%;
    height: 12mm;
    margin: 1mm 0 .4mm;
}
.part-label-code {
    text-align: center;
    font-size: 8pt;
    font-weight: 900;
    letter-spacing: .06em;
}
.part-label-meta {
    display: flex;
    justify-content: space-between;
    gap: 2mm;
    margin-top: .7mm;
    overflow: hidden;
    font-size: 5.5pt;
}
.part-label-meta span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Demo login profiles */
.demo-login-area {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}
.demo-login-title {
    margin-bottom: 2px;
}
.demo-login-title strong,
.demo-login-title span {
    display: block;
}
.demo-login-title strong {
    font-size: 11px;
}
.demo-login-title span {
    margin-top: 3px;
    color: #7d8999;
    font-size: 9px;
}
.demo-user-card {
    width: 100%;
    min-height: 58px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid #dfe5ed;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.demo-user-card:hover {
    border-color: #a9c1e5;
    background: #f8fbff;
}
.demo-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #eaf1fd;
    color: #245eb4;
    font-weight: 900;
    font-size: 10px;
}
.demo-user-copy {
    min-width: 0;
}
.demo-user-copy strong,
.demo-user-copy small {
    display: block;
}
.demo-user-copy strong {
    color: #33445b;
    font-size: 10.5px;
}
.demo-user-copy em {
    margin-left: 5px;
    color: #2861b4;
    font-size: 7.5px;
    font-style: normal;
}
.demo-user-copy small {
    margin-top: 2px;
    overflow: hidden;
    color: #8490a0;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.demo-arrow {
    color: #8090a4;
}

@media (max-width: 900px) {
    .scan-result-grid {
        grid-template-columns: 1fr;
    }
    .scan-stock-card {
        grid-template-columns: 1fr 1fr;
    }
    .scan-stock-qty {
        text-align: left;
    }
    .scan-request-body {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .label-print-options {
        grid-template-columns: 1fr 1fr;
    }
    .label-format-note {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .scan-scope-banner {
        grid-template-columns: 1fr;
    }
    .scan-scope-banner > small {
        grid-column: 1;
    }
    .scan-stock-card,
    .scan-request-body {
        grid-template-columns: 1fr;
    }
    .scan-request-actions {
        grid-template-columns: 1fr;
    }
    .label-print-options {
        grid-template-columns: 1fr;
    }
    .label-format-note {
        grid-column: auto;
    }
}

@media print {
    body.printing-barcode-label {
        background: #fff !important;
    }

    body.printing-barcode-label > * {
        visibility: hidden !important;
    }

    body.printing-barcode-label .barcode-print-root,
    body.printing-barcode-label .barcode-print-root * {
        visibility: visible !important;
    }

    body.printing-barcode-label .barcode-print-root {
        display: block !important;
        position: absolute;
        inset: 0 auto auto 0;
        width: auto;
        padding: 0;
        margin: 0;
    }

    body.printing-barcode-label .semics-part-label {
        display: block;
        margin: 0;
        border: 0;
        box-shadow: none;
        break-after: page;
        page-break-after: always;
    }

    body.printing-barcode-label .semics-part-label:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    @page {
        margin: 0;
    }
}


