/* =====================================================
   AutoFlow – Modern admin theme (Shopify-inspired, orange brand)
   -----------------------------------------------------
   Loaded AFTER style.css / larkOrderSync.css.
   Visual only: no class/ID used by JavaScript is renamed
   and nothing the app relies on is hidden.
   ===================================================== */

/* =====================================================
   1. Design tokens
   ===================================================== */
:root {
    /* Brand – orange */
    --brand-50: #fff5ef;
    --brand-100: #ffe8dc;
    --brand-200: #ffcdb3;
    --brand-300: #ffa77d;
    --brand-400: #ff7c45;
    --brand-500: #ff5a1f;
    --brand-600: #f04a0c;
    --brand-700: #c7390a;
    --brand-ring: rgba(255, 90, 31, 0.18);
    --brand-gradient: linear-gradient(180deg, #ff7a3d 0%, #ff5a1f 55%, #f44d10 100%);
    --brand-gradient-hover: linear-gradient(180deg, #ff8650 0%, #ff6328 55%, #f75415 100%);

    /* Neutrals */
    --n-0: #ffffff;
    --n-25: #fcfcfc;
    --n-50: #fafafa;
    --n-100: #f4f4f5;
    --n-150: #efeff1;
    --n-200: #e4e4e7;
    --n-300: #d4d4d8;
    --n-400: #a1a1aa;
    --n-500: #71717a;
    --n-600: #52525b;
    --n-700: #3f3f46;
    --n-800: #27272a;
    --n-900: #18181b;

    --frame: #111113;
    --frame-2: #17171a;
    --nav-text: #d4d4d8;
    --nav-icon: #8b8b94;
    --nav-hover: rgba(255, 255, 255, 0.06);

    --surface-page: #f4f4f5;
    --focus-ring: 0 0 0 3px var(--brand-ring);

    --elev-1: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.05);
    --elev-2: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04), 0 4px 12px -2px rgba(24, 24, 27, 0.06);
    --elev-3: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 12px 32px -8px rgba(24, 24, 27, 0.18);
    --elev-modal: 0 0 0 1px rgba(24, 24, 27, 0.08), 0 24px 64px -12px rgba(24, 24, 27, 0.35);

    /* Remap the app's existing variables (everything built on them follows) */
    --primary: var(--brand-500);
    --primary-dark: var(--brand-600);
    --primary-light: var(--brand-400);
    --primary-bg: var(--brand-50);
    --primary-bg-hover: var(--brand-100);

    --secondary: var(--n-500);
    --secondary-dark: var(--n-700);
    --secondary-light: var(--n-400);

    --success: #16a34a;
    --success-bg: #ecfdf3;
    --danger: #e11d48;
    --danger-bg: #fff1f3;
    --warning: #d97706;
    --warning-bg: #fffaeb;
    --info: #2563eb;
    --info-bg: #eff6ff;
    --designers: #7c3aed;
    --designers-bg: #f5f3ff;

    --bg-primary: #ffffff;
    --bg-secondary: var(--surface-page);
    --bg-tertiary: var(--n-100);
    --bg-card: #ffffff;
    --bg-hover: var(--n-50);
    --bg-sidebar: var(--frame);

    --text-primary: var(--n-900);
    --text-secondary: var(--n-600);
    --text-muted: var(--n-500);
    --text-success: #067647;
    --text-danger: #c01048;

    --border-color: var(--n-200);
    --border-light: var(--n-150);
    --border-focus: var(--brand-500);

    --shadow-sm: var(--elev-1);
    --shadow-md: var(--elev-2);
    --shadow-lg: var(--elev-3);
    --shadow-card: var(--elev-1);

    --sidebar-width: 248px;
    --sidebar-collapsed: 68px;
    --header-height: 64px;

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --transition-fast: 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-normal: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* =====================================================
   2. Base
   ===================================================== */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--n-900);
    font-feature-settings: 'cv11', 'ss01', 'tnum' 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

a {
    color: var(--brand-600);
}

::selection {
    background: var(--brand-100);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1aa;
    background-clip: content-box;
}

:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand-500);
}

code {
    font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--n-100);
    border-radius: 5px;
    padding: 1px 5px;
}

/* =====================================================
   3. App frame – sidebar
   ===================================================== */
body.ui-app {
    background: var(--frame);
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--frame-2) 0%, var(--frame) 100%);
    border-right: 0;
}

.sidebar-header {
    padding: 18px 14px 14px 18px;
    border-bottom: 0;
}

.logo {
    gap: 10px;
    min-width: 0;
}

.logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
    background: var(--brand-gradient);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
}

.sidebar-toggle {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--nav-icon);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-nav {
    padding: 8px 10px 12px;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    position: relative;
    gap: 11px;
    padding: 8px 12px;
    min-height: 38px;
    border-radius: 10px;
    color: var(--nav-text);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 20px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-link i {
    width: 18px;
    font-size: 15px;
    color: var(--nav-icon);
    transition: color var(--transition-fast);
}

.nav-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--nav-hover);
    color: #ffffff;
}

.nav-link:hover i {
    color: #ffffff;
}

.nav-item.active .nav-link {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 600;
    box-shadow: none;
}

.nav-item.active .nav-link i {
    color: var(--brand-400);
}

.nav-item.active .nav-link::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-500);
}

.sidebar.collapsed .nav-link {
    padding: 10px;
}

/* Locked menu items (app.js appends an <i class="fa-lock"> to the link):
   a small, quiet badge instead of a bare padlock */
.nav-link>i.fa-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px !important;
    height: 22px;
    margin-left: auto !important;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    color: #a1a1aa !important;
    font-size: 9px !important;
}

/* Icon rail (collapsed sidebar on desktop / tablets): the badge sits on the icon's corner.
   Phones never use the rail – the drawer shows full labels even when .collapsed is set */
@media (min-width: 769px) {
    .sidebar.collapsed .nav-link>i.fa-lock {
        position: absolute;
        top: 4px;
        left: calc(50% + 3px);
        width: 16px !important;
        height: 16px;
        margin: 0 !important;
        border-radius: 50%;
        background: #27272a;
        box-shadow: 0 0 0 2px var(--frame);
        font-size: 7.5px !important;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .sidebar .nav-link>i.fa-lock {
        position: absolute;
        top: 4px;
        left: calc(50% + 3px);
        width: 16px !important;
        height: 16px;
        margin: 0 !important;
        border-radius: 50%;
        background: #27272a;
        box-shadow: 0 0 0 2px var(--frame);
        font-size: 7.5px !important;
    }
}

.sidebar-footer {
    padding: 10px 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Signed-in user (avatar + name + role), created by ui-shell.js */
.ui-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    text-align: left;
    min-width: 0;
}

.ui-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #c026d3 0%, #a21caf 100%);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.ui-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.ui-user-name {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-user-role {
    color: var(--nav-icon);
    font-size: 11.5px;
}

.sidebar.collapsed .ui-user-card {
    justify-content: center;
    padding: 6px 0;
    background: transparent;
    box-shadow: none;
}

.sidebar.collapsed .ui-user-meta {
    display: none;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--nav-text) !important;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.logout-link i {
    width: 18px;
    text-align: center;
    color: var(--nav-icon);
}

.logout-link:hover {
    background: rgba(225, 29, 72, 0.12);
    color: #ffffff !important;
}

.logout-link:hover i {
    color: #fb7185;
}

.sidebar.collapsed .logout-link {
    justify-content: center;
}

.sidebar.collapsed .logout-link span {
    display: none;
}

/* =====================================================
   4. App frame – main panel (rounded on all four corners)
   ===================================================== */
@media (min-width: 769px) {
    body.ui-app {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .main-content {
        /* style.css sets min-height: 100vh – it pushed the panel's bottom edge off-screen */
        min-height: 0;
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
        margin: 10px 10px 10px var(--sidebar-width);
        border-radius: 16px;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--surface-page);
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
        transition: margin-left var(--transition-normal);
        overscroll-behavior: contain;
    }

    .sidebar.collapsed~.main-content {
        margin-left: var(--sidebar-collapsed);
    }

    /* Panel scrollbar stays inside the straight edge: the track stops short of the
       16px rounded corners and the thumb is inset from the panel's right edge */
    /* Firefox only – in Chrome these would switch off the ::-webkit-scrollbar styling below */
    @supports not selector(::-webkit-scrollbar) {
        .main-content {
            scrollbar-width: thin;
            scrollbar-color: #d4d4d8 transparent;
        }
    }

    .main-content::-webkit-scrollbar {
        width: 12px;
    }

    .main-content::-webkit-scrollbar-track {
        background: transparent;
        margin: 16px 0;
    }

    .main-content::-webkit-scrollbar-thumb {
        background: #d4d4d8;
        border: 4px solid transparent;
        border-radius: 999px;
        background-clip: content-box;
    }

    .main-content::-webkit-scrollbar-thumb:hover {
        background: #a1a1aa;
        background-clip: content-box;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .main-content,
    .sidebar.collapsed~.main-content {
        margin-left: var(--sidebar-collapsed);
    }

    .sidebar .sidebar-header {
        flex-direction: column;
        gap: 12px;
        padding: 16px 0 12px;
    }

    .sidebar .logo-text,
    .sidebar .nav-link span,
    .sidebar .logout-link span,
    .sidebar .sidebar-toggle {
        display: none;
    }

    .sidebar .logo {
        justify-content: center;
        width: 100%;
    }

    .sidebar .logout-link,
    .sidebar .nav-link {
        justify-content: center;
        padding: 10px;
    }

    .sidebar .ui-user-card {
        justify-content: center;
        padding: 6px 0;
        background: transparent;
        box-shadow: none;
    }

    .sidebar .ui-user-meta {
        display: none;
    }
}

/* =====================================================
   5. Page header & content
   ===================================================== */
.main-header {
    height: var(--header-height);
    padding: 0 28px;
    background: rgba(244, 244, 245, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    box-shadow: none;
    border-bottom: 1px solid transparent;
    gap: 12px;
}

.header-left {
    min-width: 0;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--n-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* "Create Workflow" in the page header only belongs to the Workflows page
   (permission hiding by app.js still applies on that page) */
body:not(:has(#workflowsPage.active)) #createWorkflowBtn {
    display: none !important;
}

.page-content {
    padding: 4px 28px 36px;
}

.page.active {
    animation: uiPageIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes uiPageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* =====================================================
   6. Buttons
   ===================================================== */
.btn {
    gap: 7px;
    min-height: 36px;
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 20px;
    letter-spacing: -0.1px;
    border-radius: 10px;
    border: 0;
    transition: background var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), filter var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn-primary:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-success:hover {
    transform: none;
    filter: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.btn-primary {
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(199, 57, 10, 0.35), 0 4px 12px -4px rgba(255, 90, 31, 0.55);
}

.btn-primary:hover {
    background: var(--brand-gradient-hover);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(199, 57, 10, 0.35), 0 8px 20px -6px rgba(255, 90, 31, 0.65);
}

.btn-primary:active {
    background: var(--brand-600);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: #ffffff;
    color: var(--n-800);
    border: 0;
    box-shadow: inset 0 0 0 1px var(--n-200), 0 1px 2px rgba(24, 24, 27, 0.05);
}

.btn-secondary:hover {
    background: var(--n-50);
    color: var(--n-900);
    border-color: transparent;
    box-shadow: inset 0 0 0 1px var(--n-300), 0 1px 2px rgba(24, 24, 27, 0.06);
}

.btn-secondary:active {
    background: var(--n-100);
}

.btn-danger {
    background: linear-gradient(180deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(190, 18, 60, 0.35);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #fb5a75 0%, #e8294f 100%);
}

.btn-success {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(21, 128, 61, 0.35);
}

.btn-success:hover {
    background: linear-gradient(180deg, #2fd16a 0%, #18ad4f 100%);
}

.btn-warning {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    color: #3b2400;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 2px rgba(180, 83, 9, 0.3);
}

.btn-warning:hover {
    background: linear-gradient(180deg, #fcc93f 0%, #f7a61b 100%);
}

.btn-link {
    color: var(--brand-600);
    padding: 4px 8px;
    min-height: 0;
    box-shadow: none;
}

.btn-link:hover {
    background: var(--brand-50);
}

.btn-sm {
    min-height: 30px;
    padding: 5px 11px;
    font-size: 12.5px;
    border-radius: 8px;
}

/* History "Retry": same shape and size as the "Xem" button next to it, orange tint */
.btn-retry-badge {
    gap: 6px;
    min-height: 32px;
    padding: 6px 12px;
    font-size: 12.5px;
    line-height: 20px;
    border: 0;
    border-radius: 8px;
    background: #fff7ed;
    color: #ea580c;
    box-shadow: inset 0 0 0 1px #fed7aa, 0 1px 2px rgba(24, 24, 27, 0.05);
}

.btn-retry-badge:hover {
    background: #ffedd5;
    color: #c2410c;
    border-color: transparent;
    box-shadow: inset 0 0 0 1px #fdba74, 0 1px 2px rgba(24, 24, 27, 0.05);
}

.history-table td>.btn,
.history-table td>.btn-retry-badge {
    vertical-align: middle;
}

@media (max-width: 768px) {
    .btn-retry-badge {
        border-radius: 999px;
    }
}

.btn-icon {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
}

/* Small square icon actions inside workflow / sales cards */
.workflow-actions .btn-sm,
.sales-card .btn-sm {
    min-width: 32px;
    justify-content: center;
}

/* =====================================================
   7. Cards & surfaces
   ===================================================== */
.stat-card,
.dashboard-card,
.workflow-card,
.sales-card,
.settings-section,
.history-table-container,
.vnepacket-header-card,
.vnepacket-config-card,
.integration-card,
.wati-auto-card,
.att-tl-dept-card,
.attendance-check-panel,
.drive-container,
.team-tabs-container,
.user-management-header {
    background: #ffffff;
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-1);
}

.stat-card:hover,
.dashboard-card:hover,
.workflow-card:hover,
.sales-card:hover,
.integration-card:hover {
    transform: none;
}

.workflow-card,
.sales-card,
.stat-card {
    transition: box-shadow var(--transition-normal);
}

.workflow-card:hover,
.sales-card:hover,
.stat-card:hover {
    box-shadow: var(--elev-2);
}

.stat-card::after,
.workflow-card::before {
    display: none;
}

.card-header {
    padding: 16px 20px;
    background: transparent;
    border-bottom: 1px solid var(--n-150);
}

.card-header h2,
.card-header h3 {
    font-size: 15px;
    font-weight: 650;
    text-transform: none;
    letter-spacing: -0.2px;
    color: var(--n-900);
    gap: 10px;
}

.card-header h2 i,
.card-header h3 i {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--brand-600);
    background: var(--brand-50);
    box-shadow: inset 0 0 0 1px var(--brand-100);
}

.card-body {
    padding: 18px 20px;
}

/* Metric tiles */
.stats-grid {
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 18px;
    gap: 14px;
    align-items: center;
    overflow: hidden;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 17px;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: var(--brand-50);
    color: var(--brand-600);
    box-shadow: inset 0 0 0 1px var(--brand-100);
}

.stat-success .stat-icon {
    box-shadow: inset 0 0 0 1px #d1fadf;
}

.stat-danger .stat-icon {
    box-shadow: inset 0 0 0 1px #ffe4e8;
}

.stat-info .stat-icon {
    box-shadow: inset 0 0 0 1px #dbeafe;
}

.stat-designer .stat-icon {
    box-shadow: inset 0 0 0 1px #ede9fe;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.6px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--n-500);
}

.dashboard-grid {
    gap: 14px;
}

.chart-legend .legend-item,
.sales-distribution-item {
    border-radius: 10px;
}

.sales-avatar,
.sales-card-avatar {
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    color: #ffffff;
    box-shadow: 0 4px 10px -4px rgba(255, 90, 31, 0.6);
}

.activity-icon {
    border-radius: 10px;
}

/* =====================================================
   8. Workflows
   ===================================================== */
.workflows-list {
    gap: 14px;
}

.workflow-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
}

.workflow-header {
    padding-left: 0;
    margin-bottom: 14px;
    gap: 12px;
    align-items: flex-start;
}

.workflow-title {
    gap: 12px;
    min-width: 0;
    align-items: flex-start;
}

/* Name + description block: icon lines up with the name, both clamp at 2 lines */
.workflow-title>div:last-child {
    min-width: 0;
    padding-top: 1px;
}

.workflow-title .workflow-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    line-height: 1.3;
}

.workflow-title .workflow-name+p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-top: 3px;
    font-size: 12.5px !important;
    line-height: 1.4;
}

.workflow-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 16px;
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 14px -6px rgba(255, 90, 31, 0.7);
    flex-shrink: 0;
}

.workflow-name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.workflow-body {
    margin-left: 0;
    padding: 10px;
    gap: 10px;
    background: var(--n-50);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

.workflow-body .workflow-step {
    padding: 6px 12px 6px 6px;
    border: 0;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--elev-1);
    font-weight: 600;
    font-size: 13px;
}

.workflow-body .workflow-step:hover {
    transform: none;
}

.workflow-step-icon {
    border-radius: 8px;
}

.workflow-footer {
    margin-top: auto;
    padding-top: 14px;
    gap: 12px;
    flex-wrap: wrap;
}

.workflow-stats {
    gap: 24px;
}

.workflow-stat {
    text-align: left;
}

.workflow-stat-value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}

.workflow-stat-label {
    font-size: 12px;
    color: var(--n-500);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.workflow-actions {
    gap: 6px;
    flex-wrap: wrap;
}

/* Empty / loading state spans the whole grid so it is centred on the page */
.workflows-list>.empty-state-large,
.workflows-list>.empty-state {
    grid-column: 1 / -1;
    width: 100%;
}

/* Workflow modal steps reuse the class "workflow-step" – keep them as plain sections */
.workflow-step[data-step] {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    white-space: normal;
}

.workflow-step[data-step]:hover {
    transform: none;
    box-shadow: none;
}

.step-title {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.2px;
    margin-bottom: 18px;
}

.step-number {
    background: var(--brand-gradient) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px -4px rgba(255, 90, 31, 0.7);
}

.step-dot {
    border-radius: 999px;
}

.step-dot.active {
    background: var(--brand-500);
}

.trigger-card {
    border-radius: 14px;
    border: 0;
    background: #ffffff;
    box-shadow: var(--elev-1);
    transition: box-shadow var(--transition-fast), background var(--transition-fast);
}

.trigger-card:hover {
    box-shadow: var(--elev-2);
    transform: none;
}

.trigger-card.selected {
    background: var(--brand-50);
    box-shadow: 0 0 0 2px var(--brand-500), 0 6px 16px -6px rgba(255, 90, 31, 0.45);
}

/* =====================================================
   9. Badges
   ===================================================== */
.status-badge,
.badge,
.badge-chip,
.status-tag,
.carrier-badge,
.count-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    white-space: nowrap;
}

.status-badge.active,
.badge-success,
.badge-status-created,
.status-tag.success,
.success.status-badge {
    background: #ecfdf3;
    color: #067647;
    box-shadow: inset 0 0 0 1px #abefc6;
}

.status-badge.active::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #17b26a;
    box-shadow: 0 0 0 3px rgba(23, 178, 106, 0.18);
}

.status-badge.inactive,
.badge-secondary {
    background: var(--n-100);
    color: var(--n-600);
    box-shadow: inset 0 0 0 1px var(--n-200);
}

.badge-primary {
    background: var(--brand-50);
    color: var(--brand-700);
    box-shadow: inset 0 0 0 1px var(--brand-200);
}

.badge-danger,
.badge-status-error,
.status-tag.failed,
.failed.status-badge {
    background: #fff1f3;
    color: #c01048;
    box-shadow: inset 0 0 0 1px #fecdd6;
}

.badge-status-pending,
.status-tag.pending,
.pending.status-badge {
    background: #fffaeb;
    color: #b54708;
    box-shadow: inset 0 0 0 1px #fedf89;
}

.badge-status-returned {
    background: #eff8ff;
    color: #175cd3;
    box-shadow: inset 0 0 0 1px #b2ddff;
}

/* =====================================================
   10. Tables
   ===================================================== */
.history-table,
.simple-table,
.vnepacket-table,
.sync-preview-table,
.shopify-stats-table,
.attendance-shift-table {
    font-size: 13px;
    color: var(--n-800);
}

.history-table th,
.simple-table th,
.vnepacket-table th,
.sync-preview-table th,
.shopify-stats-table th,
.attendance-table th {
    background: var(--n-50) !important;
    color: var(--n-500);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    padding: 10px 14px;
    border-bottom: 1px solid var(--n-200);
    white-space: nowrap;
}

.history-table td,
.simple-table td,
.sync-preview-table td,
.shopify-stats-table td,
.vnepacket-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--n-150);
    vertical-align: middle;
}

.history-table tbody tr,
.simple-table tbody tr {
    border-bottom: 1px solid var(--n-150);
}

.history-table tbody tr:last-child td,
.simple-table tbody tr:last-child td {
    border-bottom: 0;
}

.history-table tbody tr:hover,
.simple-table tbody tr:hover,
.vnepacket-table tbody tr:hover,
.sync-preview-table tbody tr:hover,
.shopify-stats-table tbody tr:hover {
    background: #fffaf7;
}

.history-table-container,
.sync-preview-table-container,
.shopify-stats-table-container,
.attendance-table-wrapper,
.devices-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* =====================================================
   11. Forms
   ===================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 550;
    color: var(--n-800);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="time"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group textarea,
.form-control,
.search-box input,
.search-bar input,
.att-tl-input,
.vne-dim-input,
.weight-input {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--n-900);
    background: #ffffff;
    border: 1px solid var(--n-200);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-group input:hover,
.form-group textarea:hover,
.form-control:hover {
    border-color: var(--n-300);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-control:focus,
.search-box input:focus,
.search-bar input:focus,
.att-tl-input:focus,
.vne-dim-input:focus,
.weight-input:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--focus-ring);
    background: #ffffff;
}

.form-group input:disabled,
.form-group textarea:disabled,
.form-group select:disabled,
.form-control:disabled {
    background: var(--n-50) !important;
    border-color: var(--n-150) !important;
    color: var(--n-500);
    box-shadow: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.form-control::placeholder {
    color: var(--n-400);
}

.form-group select,
select.form-control,
.field-mapping-row select,
.form-select,
.vne-perm-select,
.filter-select,
.vne-select {
    height: auto;
    min-height: 38px;
    padding: 7px 36px 7px 12px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 22px;
    color: var(--n-900);
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 15px;
    border: 1px solid var(--n-200);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.form-group select:hover,
select.form-control:hover,
.field-mapping-row select:hover,
.form-select:hover,
.vne-perm-select:hover,
.filter-select:hover {
    border-color: var(--n-300);
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.form-group select:focus,
select.form-control:focus,
.field-mapping-row select:focus,
.form-select:focus,
.vne-perm-select:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--focus-ring);
}

.select-with-icon .filter-select {
    padding-left: 36px;
}

.select-with-icon i {
    left: 13px;
    font-size: 13px;
    color: var(--n-400);
}

.filter-select {
    min-width: 200px;
}

option:checked,
option:hover {
    background-color: var(--brand-50) !important;
    color: var(--n-900) !important;
    box-shadow: 0 0 10px 100px var(--brand-50) inset;
}

.hint {
    font-size: 12.5px;
    color: var(--n-500);
    margin-top: 6px;
}

.required {
    color: var(--danger);
}

/* Custom dropdown (History filters) */
.custom-select-trigger {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 13.5px;
    border: 1px solid var(--n-200);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.custom-select-trigger:hover {
    border-color: var(--n-300);
}

.custom-select-trigger {
    gap: 8px;
    min-width: 0;
}

.custom-select-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select.open .custom-select-trigger,
.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--brand-400);
    box-shadow: var(--focus-ring);
}

.custom-select-options {
    margin-top: 6px;
    padding: 4px;
    border: 0;
    border-radius: 12px;
    box-shadow: var(--elev-3);
}

.custom-select-option {
    padding: 8px 10px;
    border-bottom: 0;
    border-radius: 8px;
    font-size: 13.5px;
}

.custom-select-option:hover,
.custom-select-option.selected {
    background: var(--brand-50);
    color: var(--brand-700);
}

/* Toggle switches */
.toggle-slider,
.slider {
    background-color: var(--n-300);
}

input:checked+.toggle-slider,
input:checked+.slider {
    background-color: var(--brand-500);
}

/* =====================================================
   12. Tabs – segmented controls
   ===================================================== */
.team-tabs {
    gap: 2px;
    padding: 4px;
    background: var(--n-100);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

.att-tabs,
.dept-tabs,
.user-tabs {
    display: flex;
    gap: 2px;
    padding: 4px;
    background: #ebebed;
    border: 0;
    border-radius: 12px;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 18px;
    box-shadow: inset 0 0 0 1px rgba(24, 24, 27, 0.04);
}

.team-tab,
.tab-btn,
.att-tab,
.dept-tab {
    border: 0;
    border-radius: 9px;
    margin: 0;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 550;
    color: var(--n-600);
    background: transparent;
    box-shadow: none;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.team-tab:hover,
.tab-btn:hover,
.att-tab:hover,
.dept-tab:hover {
    color: var(--n-900);
    background: rgba(255, 255, 255, 0.55);
}

.team-tab.active,
.tab-btn.active,
.att-tab.active,
.dept-tab.active {
    background: #ffffff;
    color: var(--n-900);
    font-weight: 600;
    border: 0;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.08), 0 0 0 1px rgba(24, 24, 27, 0.04);
}

.team-tab.active i,
.tab-btn.active i,
.att-tab.active i,
.dept-tab.active i {
    color: var(--brand-500);
}

.team-tab.active::after,
.tab-btn.active::after,
.att-tab.active::after,
.dept-tab.active::after {
    display: none;
}

.team-tabs-container {
    padding: 10px 12px;
}

.user-management-header {
    padding: 10px 12px !important;
    align-items: center !important;
}

.user-management-header .user-tabs,
.team-tabs-container .team-tabs {
    margin-bottom: 0;
}

/* =====================================================
   13. Modals
   ===================================================== */
.modal {
    padding: 20px;
}

.modal-overlay {
    background: rgba(17, 17, 19, 0.5);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.modal-container {
    border-radius: var(--radius-xl);
    border: 0;
    box-shadow: var(--elev-modal);
    animation: uiModalIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes uiModalIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-header {
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--n-150);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    gap: 12px;
}

.modal-header h2,
.modal-header h3 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.2px;
    color: var(--n-900);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--n-100);
    color: var(--n-500);
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--n-200);
    color: var(--n-900);
    transform: none;
}

.modal-body {
    padding: 20px;
    background: #ffffff;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--n-150);
    background: var(--n-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    gap: 8px;
    flex-wrap: wrap;
}

.modal-actions {
    gap: 8px;
    flex-wrap: wrap;
}

/* =====================================================
   14. Toasts (bottom center)
   ===================================================== */
.toast-container {
    top: auto;
    right: auto;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    align-items: center;
    gap: 8px;
}

.toast {
    background: rgba(24, 24, 27, 0.96);
    color: #ffffff;
    border: 0;
    border-radius: 14px;
    padding: 12px 14px;
    gap: 12px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 16px 40px -8px rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: uiToastIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.hiding {
    animation: uiToastOut 0.3s ease forwards;
}

@keyframes uiToastIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes uiToastOut {
    to {
        opacity: 0;
        transform: translateY(14px);
    }
}

.toast-title {
    color: #ffffff;
    font-weight: 650;
    font-size: 13.5px;
}

.toast-message {
    color: #d4d4d8;
    font-size: 13px;
}

.toast-icon {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.toast-close {
    color: #a1a1aa;
    background: transparent;
}

.toast-close:hover {
    color: #ffffff;
}

/* =====================================================
   15. Misc components
   ===================================================== */
.empty-state,
.empty-state-large {
    color: var(--n-500);
}

.empty-state i,
.empty-state-large i {
    color: var(--n-300);
}

.pagination button,
.pagination .page-btn {
    border-radius: 9px;
    border: 0;
    background: #ffffff;
    color: var(--n-700);
    box-shadow: inset 0 0 0 1px var(--n-200);
}

.pagination button.active,
.pagination .page-btn.active {
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: 0 4px 10px -4px rgba(255, 90, 31, 0.7);
}

.settings-section {
    padding: 20px;
}

.settings-section h2 {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.settings-desc {
    color: var(--n-500);
    font-size: 13px;
}

.vnepacket-header-card {
    padding: 16px 20px;
    margin-bottom: 14px;
}

.drive-toolbar {
    background: #ffffff;
}

/* Shift calendar: 7 equal columns (long shift names truncate instead of widening a day) */
.calendar-header,
#scheduleCalendarGrid {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}

.calendar-header>div {
    font-size: 12px;
    font-weight: 600;
    color: var(--n-500);
}

#scheduleCalendarGrid .calendar-cell {
    min-width: 0;
    border-radius: 12px !important;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#scheduleCalendarGrid .calendar-cell:not(.empty):hover {
    box-shadow: 0 4px 12px -4px rgba(255, 90, 31, 0.35);
}

.file-card {
    border-radius: 12px;
    box-shadow: var(--elev-1);
    border: 0;
}

.file-card:hover {
    box-shadow: var(--elev-2);
}

/* =====================================================
   16. Responsive – laptops & tablets
   ===================================================== */
@media (max-width: 1280px) {
    .workflows-list {
        grid-template-columns: 1fr;
    }

    /* Google Drive toolbar wraps instead of pushing the search box out of the card */
    .drive-toolbar {
        flex-wrap: wrap;
        gap: 12px;
    }

    .toolbar-left,
    .toolbar-right,
    .toolbar-right>div {
        flex-wrap: wrap;
        gap: 8px;
        min-width: 0;
        max-width: 100%;
    }

    .search-box {
        max-width: 100%;
    }
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .settings-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 960px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .page-content {
        padding: 4px 20px 28px;
    }

    .main-header {
        padding: 0 20px;
    }
}

/* =====================================================
   17. Responsive – phones (off-canvas sidebar)
   ===================================================== */
.ui-mobile-bar,
.ui-sidebar-backdrop,
.ui-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    body.ui-app {
        display: block;
        background: var(--surface-page);
    }

    /* --- Top bar (Shopify app style): avatar · brand · spacer --- */
    body.ui-app {
        background: #0b0b0c;
    }

    /* App-like: the page scrollbar would run up beside the dark top bar (visible in
       narrow desktop windows) – hide it; scrolling by touch / wheel still works */
    html:has(body.ui-app) {
        scrollbar-width: none;
    }

    html:has(body.ui-app)::-webkit-scrollbar {
        display: none;
        width: 0;
    }

    .ui-mobile-bar {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 90;
        height: 64px;
        padding: 0 14px;
        background: #0b0b0c;
        color: #ffffff;
    }

    /* Rounded top edge of the content "sheet", pinned under the bar while scrolling */
    .ui-mobile-bar::before,
    .ui-mobile-bar::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        height: 22px;
        pointer-events: none;
    }

    /* 1px shorter than the light cap: on high-DPR screens an equal-height dark layer
       bleeds a hairline under the cap's bottom edge */
    .ui-mobile-bar::before {
        height: 21px;
        background: #0b0b0c;
    }

    .ui-mobile-bar::after {
        background: var(--surface-page);
        border-radius: 22px 22px 0 0;
    }

    .ui-mobile-bar .ui-avatar-btn {
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 50%;
        background: linear-gradient(135deg, #c026d3 0%, #a21caf 100%);
        color: #ffffff;
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 0.3px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
        -webkit-tap-highlight-color: transparent;
    }

    .ui-mobile-bar .ui-avatar-btn:active {
        transform: scale(0.95);
    }

    .ui-mobile-bar .ui-mobile-title {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        min-width: 0;
        font-size: 17px;
        font-weight: 650;
        letter-spacing: -0.3px;
        white-space: nowrap;
    }

    .ui-mobile-bar .ui-mobile-title span {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ui-mobile-bar .logo-icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
        font-size: 15px;
    }

    /* --- Floating bottom navigation --- */
    .ui-bottom-nav {
        position: fixed;
        left: 50%;
        bottom: calc(14px + env(safe-area-inset-bottom));
        transform: translateX(-50%);
        z-index: 900;
        display: flex;
        align-items: center;
        gap: 2px;
        padding: 4px;
        max-width: calc(100vw - 24px);
        background: rgba(255, 255, 255, 0.86);
        -webkit-backdrop-filter: saturate(180%) blur(18px);
        backdrop-filter: saturate(180%) blur(18px);
        border-radius: 999px;
        box-shadow: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 12px 32px -10px rgba(24, 24, 27, 0.35);
    }

    .ui-bottom-nav .ui-tab {
        width: 44px;
        height: 44px;
        flex: 0 0 auto;
        border: 0;
        border-radius: 50%;
        background: transparent;
        color: var(--n-800);
        font-size: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
    }

    .ui-bottom-nav .ui-tab:active {
        transform: scale(0.92);
    }

    .ui-bottom-nav .ui-tab.active {
        background: var(--n-100);
        color: var(--brand-600);
        box-shadow: inset 0 0 0 1px rgba(24, 24, 27, 0.04);
    }

    body.ui-nav-open .ui-bottom-nav {
        opacity: 0;
        pointer-events: none;
    }

    .sidebar,
    .sidebar.collapsed {
        width: min(288px, 86vw);
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
        z-index: 1200;
        box-shadow: none;
    }

    .sidebar.ui-open {
        transform: translateX(0);
        box-shadow: 24px 0 48px rgba(0, 0, 0, 0.35);
    }

    .sidebar .logo-text,
    .sidebar .nav-link span,
    .sidebar .logout-link span,
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-link span,
    .sidebar.collapsed .logout-link span {
        display: inline;
    }

    .sidebar .nav-link,
    .sidebar.collapsed .nav-link {
        justify-content: flex-start;
        padding: 10px 12px;
        min-height: 44px;
        font-size: 14.5px;
    }

    .sidebar .sidebar-header,
    .sidebar.collapsed .sidebar-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 18px 14px 14px 18px;
    }

    .sidebar.collapsed .logo {
        width: auto;
        justify-content: flex-start;
    }

    .sidebar.collapsed .logout-link {
        justify-content: flex-start;
    }

    /* Drawer always shows the full user card */
    .sidebar.collapsed .ui-user-card {
        justify-content: flex-start;
        padding: 8px 10px;
        background: rgba(255, 255, 255, 0.05);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    }

    .sidebar.collapsed .ui-user-meta {
        display: flex;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .ui-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1150;
        background: rgba(17, 17, 19, 0.5);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    .ui-sidebar-backdrop.ui-open {
        display: block;
    }

    body.ui-nav-open {
        overflow: hidden;
    }

    /* --- Content frame --- */
    .main-content,
    .sidebar.collapsed~.main-content {
        margin: 0;
        border-radius: 22px 22px 0 0;
        min-height: calc(100vh - 64px);
        height: auto;
        overflow: visible;
        padding-top: 16px;
    }

    .main-header {
        position: static;
        height: auto;
        min-height: 0;
        padding: 6px 16px 10px;
        flex-wrap: wrap;
        background: transparent;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .page-title {
        font-size: 24px;
        letter-spacing: -0.5px;
    }

    .header-actions .btn {
        min-height: 38px;
        padding: 7px 14px;
    }

    /* Leave room for the floating bottom navigation */
    .page-content {
        padding: 4px 14px calc(92px + env(safe-area-inset-bottom));
    }

    /* Shopify-app look: big rounded cards, pill buttons */
    .stat-card,
    .dashboard-card,
    .workflow-card,
    .sales-card,
    .settings-section,
    .history-table-container,
    .vnepacket-header-card,
    .integration-card,
    .attendance-check-panel,
    .drive-container,
    .team-tabs-container,
    .user-management-header,
    .tab-content {
        border-radius: 20px;
        box-shadow: 0 0 0 1px rgba(24, 24, 27, 0.07), 0 2px 6px -2px rgba(24, 24, 27, 0.06);
    }

    .btn {
        border-radius: 999px;
    }

    .workflow-actions {
        border-radius: 999px;
    }

    .team-tabs,
    .att-tabs,
    .dept-tabs,
    .user-tabs,
    body #addressConversionPage .team-tabs {
        border-radius: 999px;
    }

    .team-tab,
    .tab-btn,
    .att-tab,
    .dept-tab,
    body #addressConversionPage .team-tab {
        border-radius: 999px;
    }

    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="tel"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group textarea,
    .form-control,
    .form-group select,
    .form-select,
    .filter-select,
    .custom-select-trigger {
        border-radius: 14px;
    }

    /* --- Grids --- */
    .stats-grid,
    .page-content .stats-grid,
    .page-content .vnepacket-stats-grid,
    .page-content .attendance-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-auto-rows: 1fr;
        gap: 10px;
    }

    /* Odd card out (e.g. 5th dashboard stat) fills the row instead of leaving a hole */
    .stats-grid>.stat-card:last-child:nth-child(odd),
    .page-content .vnepacket-stats-grid>.stat-card:last-child:nth-child(odd),
    .page-content .attendance-stats-grid>.stat-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 14px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 12px;
    }

    .dashboard-grid,
    .workflows-list,
    .sales-grid,
    .form-row,
    .permission-grid,
    .dept-perm-grid,
    .settings-grid {
        grid-template-columns: 1fr !important;
    }

    /* Two/three-column form layouts written inline collapse to one column.
       Calendars (7 columns) and small label/value grids are left alone. */
    .modal-body [style*="grid-template-columns: 1fr 1fr"],
    .modal-body [style*="grid-template-columns: 2fr 1fr"],
    .modal-body [style*="grid-template-columns: 1fr 1fr 1fr"],
    .modal-body [style*="grid-template-columns: 2fr 1fr 1fr"],
    .modal-body [style*="grid-template-columns: repeat(2, 1fr)"],
    .page-content [style*="grid-template-columns: 1fr 1fr"],
    .page-content [style*="grid-template-columns: 2fr 1fr"],
    .page-content [style*="grid-template-columns: 1fr 1fr 1fr"],
    .page-content [style*="grid-template-columns: 2fr 1fr 1fr"],
    .page-content [style*="grid-template-columns: repeat(2, 1fr)"],
    .page-content [style*="grid-template-columns: 1.6fr 1fr"],
    .page-content [style*="minmax(300px, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Shift calendar keeps its 7 days and scrolls sideways */
    .calendar-header,
    #scheduleCalendarGrid {
        min-width: 620px;
        gap: 6px !important;
    }

    #scheduleCalendarGrid .calendar-cell {
        min-height: 78px !important;
        padding: 6px !important;
    }

    /* --- Cards --- */
    .card-header {
        padding: 14px;
    }

    .card-body {
        padding: 14px;
    }

    /* Only tables / calendars scroll sideways – the rest of the card stays in place */
    .card-body:has(> table),
    .card-body:has(> .calendar-header),
    .devices-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .devices-table-container>table {
        min-width: 680px;
    }

    /* Safety net: nothing can make the whole page pan sideways */
    .main-content {
        overflow-x: hidden;
        overflow-x: clip;
    }

    .card-header[style*="space-between"],
    .page-content [style*="space-between"][style*="display: flex"],
    .page-content [style*="space-between"][style*="display:flex"],
    .user-management-header,
    .vnepacket-header-card {
        flex-wrap: wrap;
        gap: 10px;
    }

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

    /* "Cấu hình" + "Đồng bộ từ Lark Base": fill the row together; on very narrow
       screens each takes its own full-width row instead of overflowing */
    .vnepacket-header-right {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .vnepacket-header-right>.btn {
        flex: 1 1 auto;
        justify-content: center;
        gap: 6px;
        min-height: 40px;
        padding: 0 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Control groups inside card headers wrap onto new lines */
    .card-header>div[style*="display: flex"],
    .card-header>div[style*="display:flex"],
    .card-header .table-controls {
        flex-wrap: wrap;
        min-width: 0;
        max-width: 100%;
    }

    /* Workflow cards: stats on one row, actions on the next */
    .workflow-card {
        padding: 14px;
    }

    .workflow-header {
        flex-wrap: wrap;
    }

    .workflow-icon {
        width: 36px;
        height: 36px;
        border-radius: 11px;
        font-size: 15px;
    }

    /* Compact header: icon | name (≤2 lines) + description (1 line) | status badge top-right */
    .workflow-card .workflow-header {
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 8px;
    }

    .workflow-card .workflow-header>.workflow-title {
        flex: 1 1 auto;
        min-width: 0;
    }

    .workflow-card .workflow-header>.workflow-status {
        flex-shrink: 0;
        margin-top: 1px;
    }

    .workflow-card .workflow-header>.workflow-status .status-badge {
        padding: 2px 8px;
        font-size: 11.5px;
    }

    .workflow-card .workflow-title .workflow-name+p {
        -webkit-line-clamp: 1;
    }

    /* Flow box: no visible scrollbar; ≤3 steps share the width (labels wrap to 2 lines),
       longer flows still swipe sideways with a fade on the right edge */
    .workflow-card .workflow-body {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 8px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .workflow-card .workflow-body::-webkit-scrollbar {
        display: none;
    }

    .workflow-card .workflow-body:has(> .workflow-step:nth-of-type(4)) {
        -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
        mask-image: linear-gradient(90deg, #000 85%, transparent);
    }

    .workflow-card .workflow-body>.workflow-step {
        gap: 8px;
        padding: 6px 10px 6px 6px;
        font-size: 12.5px;
        flex-shrink: 0;
    }

    .workflow-card .workflow-body:not(:has(> .workflow-step:nth-of-type(4))) {
        align-items: stretch;
    }

    .workflow-card .workflow-body:not(:has(> .workflow-step:nth-of-type(4)))>.workflow-step {
        flex: 1 1 0;
        min-width: 0;
        white-space: normal;
    }

    .workflow-card .workflow-body>.workflow-arrow {
        align-self: center;
    }

    .workflow-card .workflow-body>.workflow-step>.workflow-step-icon {
        flex-shrink: 0;
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .workflow-card .workflow-body>.workflow-step>span {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        min-width: 0;
        line-height: 1.25;
    }

    .workflow-card .workflow-body>.workflow-arrow {
        flex-shrink: 0;
        font-size: 11px;
        color: var(--n-400);
    }

    /* Stats: three equal columns, centred, separated by hairlines */
    .workflow-card .workflow-stats {
        gap: 0;
    }

    .workflow-card .workflow-stat {
        text-align: center;
    }

    .workflow-card .workflow-stat+.workflow-stat {
        border-left: 1px solid var(--n-150);
    }

    .workflow-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .workflow-stats {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .workflow-actions {
        justify-content: flex-start;
        padding-top: 12px;
        border-top: 1px solid var(--n-150);
    }

    .workflow-actions .btn-sm {
        min-width: 38px;
        min-height: 36px;
    }

    /* --- Filters & toolbars --- */
    .history-filters,
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .filter-select,
    .select-with-icon,
    .select-with-icon .filter-select,
    .custom-select-wrapper,
    .custom-select-trigger {
        width: 100%;
        min-width: 0;
    }

    /* History & Email Tracking: the last filter shares its row with the main button
       (Xuất Excel / Làm mới); "Xóa đã chọn" gets its own row when it appears */
    .history-filters {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .history-filters>.filter-group,
    .history-filters>.filter-actions {
        display: contents;
    }

    .history-filters .filter-item {
        grid-column: 1 / -1;
        min-width: 0;
        margin-bottom: 0;
    }

    .history-filters .filter-item:last-child {
        grid-column: 1;
    }

    .history-filters .filter-actions>.btn {
        grid-column: 2;
        grid-row: 3;
        align-self: stretch;
        white-space: nowrap;
    }

    .history-filters .filter-actions>.btn-danger {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .team-tabs-container {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px;
    }

    /* Teams page: full-width segmented control (2 equal tabs), add button full width below */
    #teamsPage .team-tabs-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #teamsPage .team-tabs {
        width: 100%;
    }

    #teamsPage .team-tab {
        flex: 1 1 0;
        justify-content: center;
        min-width: 0;
    }

    #teamsPage .team-tab-actions {
        display: flex;
    }

    /* nothing to add (no permission) → no empty row */
    #teamsPage .team-tab-actions:not(:has(> .btn:not([style*="display: none"]))) {
        display: none;
    }

    #teamsPage .team-tab-actions>.btn {
        width: 100%;
        justify-content: center;
    }

    .team-tabs,
    .att-tabs,
    .dept-tabs,
    .user-tabs {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .team-tabs::-webkit-scrollbar,
    .att-tabs::-webkit-scrollbar,
    .dept-tabs::-webkit-scrollbar,
    .user-tabs::-webkit-scrollbar {
        display: none;
    }

    .team-tab,
    .tab-btn,
    .att-tab,
    .dept-tab {
        flex-shrink: 0;
    }

    .drive-toolbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .toolbar-left,
    .toolbar-right,
    .toolbar-right>div {
        flex-wrap: wrap;
        gap: 8px;
        min-width: 0;
        max-width: 100%;
    }

    .search-box {
        width: 100%;
    }

    /* --- Touch targets & inputs --- */
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 34px;
    }

    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="tel"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group textarea,
    .form-control,
    .form-group select,
    .form-select,
    .filter-select,
    .custom-select-trigger {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* --- Modals become bottom sheets --- */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-container,
    .modal-container.modal-large,
    .modal .modal-container[style] {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        border-radius: 20px 20px 0 0 !important;
        animation: uiSheetIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    @keyframes uiSheetIn {
        from {
            transform: translateY(40px);
            opacity: 0;
        }

        to {
            transform: none;
            opacity: 1;
        }
    }

    .modal-header {
        position: relative;
        padding: 18px 16px 12px;
        border-radius: 20px 20px 0 0;
    }

    .modal-header::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        width: 36px;
        height: 4px;
        margin-left: -18px;
        border-radius: 4px;
        background: var(--n-300);
    }

    .modal-body {
        padding: 14px;
    }

    .modal-footer {
        border-radius: 0;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    }

    .modal-footer .btn,
    .modal-actions .btn {
        flex: 1 1 auto;
    }

    .modal-footer .step-indicators {
        flex: 0 1 auto;
        min-width: 0;
        gap: 6px;
        overflow: hidden;
    }

    .modal-footer .step-dot {
        flex-shrink: 1;
        min-width: 10px;
    }

    /* Workflow form footer: progress bar spans the full width in equal segments,
       the buttons share the row below in equal halves */
    .modal-footer:has(> .step-indicators) {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .modal-footer>.step-indicators {
        display: flex;
        width: 100%;
        gap: 6px;
    }

    .modal-footer>.step-indicators>.step-dot {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    .modal-footer:has(> .step-indicators)>.modal-actions {
        display: flex;
        width: 100%;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .modal-footer:has(> .step-indicators)>.modal-actions>.btn {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
    }

    /* --- Toasts --- */
    /* Toasts float above the bottom navigation */
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        transform: none;
        align-items: stretch;
    }

    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 340px) {

    .stats-grid,
    .page-content .stats-grid,
    .page-content .vnepacket-stats-grid,
    .page-content .attendance-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =====================================================
   18. Motion preferences
   ===================================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================
   19. Login page (login.html)
   ===================================================== */
body:not(.ui-app) {
    background:
        radial-gradient(900px 520px at 0% 0%, rgba(255, 122, 61, 0.22), transparent 60%),
        radial-gradient(800px 480px at 100% 100%, rgba(255, 90, 31, 0.12), transparent 60%),
        var(--n-100);
}

.login-card {
    border-radius: 20px;
    border: 0;
    padding: 36px 30px 30px;
    max-width: 410px;
    box-shadow: 0 0 0 1px rgba(24, 24, 27, 0.06), 0 24px 60px -16px rgba(24, 24, 27, 0.22);
}

.login-card::before {
    display: none;
}

.login-header {
    margin-bottom: 26px;
}

.login-logo {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    font-size: 22px;
    margin-bottom: 18px;
    background: var(--brand-gradient);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 24px -8px rgba(255, 90, 31, 0.7);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--n-900);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13.5px;
    color: var(--n-500);
}

.login-card .form-group label {
    color: var(--n-800);
    font-weight: 550;
}

.login-card .form-control {
    height: 46px;
    font-size: 15px;
}

.login-card .input-wrapper i {
    color: var(--n-400);
    font-size: 14px;
}

.btn-login {
    height: 46px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 650;
    background: var(--brand-gradient);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(199, 57, 10, 0.35), 0 8px 20px -8px rgba(255, 90, 31, 0.7);
}

.btn-login:hover {
    background: var(--brand-gradient-hover);
    transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(199, 57, 10, 0.35), 0 12px 24px -8px rgba(255, 90, 31, 0.75);
}

.otp-input {
    border: 1px solid var(--n-200);
    border-radius: 12px;
    background: #ffffff;
    color: var(--n-900);
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.otp-input:focus {
    border-color: var(--brand-400);
    box-shadow: var(--focus-ring);
    outline: none;
}

.init-link a {
    color: var(--brand-600);
}

.error-message {
    background: #fff1f3;
    color: #c01048;
    border-color: #fecdd6;
}

@media (max-width: 420px) {
    .login-card {
        padding: 28px 20px 22px;
    }

    .otp-inputs {
        gap: 6px;
    }

    .otp-input {
        width: 40px;
        height: 50px;
        font-size: 20px;
    }
}

/* =====================================================
   20. Screen-specific refinements
   ===================================================== */

/* ---- Dashboard donut charts: legend always shows names ---- */
.card-body:has(> .chart-container) {
    container-type: inline-size;
}

.chart-container {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    min-height: 0;
}

.chart-wrapper {
    flex: none;
    width: 184px;
    height: 184px;
    margin: 4px auto 0;
}

.chart-legend {
    width: 100%;
    max-height: 232px;
    padding-right: 2px;
}

@container (min-width: 540px) {
    .chart-container {
        flex-direction: row;
        align-items: center;
        gap: 24px;
    }

    .chart-wrapper {
        margin: 0;
    }

    .chart-legend {
        max-height: 280px;
    }
}

.legend-item {
    gap: 10px;
    padding: 7px 10px;
    border-radius: 10px;
}

.legend-item:hover {
    background: var(--n-50);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-label {
    min-width: 0;
    font-size: 13px;
    color: var(--n-800);
}

.legend-value {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 650;
    color: var(--n-900);
    font-variant-numeric: tabular-nums;
}

/* ---- Workflow card actions: one tidy toolbar ---- */
.workflow-footer {
    align-items: center;
}

.workflow-actions {
    gap: 2px;
    padding: 3px;
    background: var(--n-50);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

/* No permitted actions for this user → no empty toolbar */
.workflow-actions:not(:has(> *)) {
    display: none;
}

.workflow-actions .btn,
.workflow-actions .btn-sm {
    min-width: 34px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 9px;
    background: transparent;
    color: var(--n-600);
    box-shadow: none;
    font-size: 13px;
}

.workflow-actions .btn:hover {
    background: #ffffff;
    color: var(--n-900);
    box-shadow: var(--elev-1);
}

.workflow-actions .btn-danger {
    position: relative;
    margin-left: 7px;
    color: #e11d48;
    background: transparent;
}

.workflow-actions .btn-danger::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 7px;
    bottom: 7px;
    width: 1px;
    background: var(--n-200);
}

.workflow-actions .btn-danger:hover {
    background: #fff1f3;
    color: #be123c;
    box-shadow: inset 0 0 0 1px #fecdd6;
}

/* ---- Address Convert tabs (overrides the page's own embedded styles) ---- */
body #addressConversionPage .team-tabs-container {
    padding: 8px;
    margin-bottom: 14px;
}

body #addressConversionPage .team-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    width: fit-content;
    max-width: 100%;
    background: var(--n-100);
    border: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
    overflow-x: auto;
    scrollbar-width: none;
}

body #addressConversionPage .team-tabs::-webkit-scrollbar {
    display: none;
}

body #addressConversionPage .team-tab {
    top: 0;
    flex-shrink: 0;
    border: 0;
    border-radius: 9px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 550;
    color: var(--n-600);
    background: transparent;
    box-shadow: none;
    white-space: nowrap;
}

body #addressConversionPage .team-tab:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--n-900);
}

body #addressConversionPage .team-tab.active {
    background: #ffffff;
    color: var(--n-900);
    font-weight: 600;
    border: 0;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.08), 0 0 0 1px rgba(24, 24, 27, 0.04);
}

body #addressConversionPage .team-tab.active i {
    color: var(--brand-500);
}

/* ---- Attendance: legend, employee chips, shift view ---- */
.att-legend {
    width: auto;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--n-50);
    border: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

.att-legend-item {
    font-size: 12px;
    color: var(--n-600);
    white-space: nowrap;
}

/* "Chú thích" toggle (added by ui-shell.js) – phones only */
.att-legend-toggle {
    display: none;
}

@media (max-width: 768px) {
    .att-legend {
        gap: 0 !important;
        padding: 0 !important;
        overflow: hidden;
    }

    .att-legend-toggle {
        display: flex;
        flex: 0 0 100%;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        background: none;
        border: 0;
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        color: var(--n-700);
        cursor: pointer;
    }

    .att-legend-toggle .fa-circle-info {
        margin-right: 6px;
        color: var(--n-400);
    }

    .att-legend-toggle .fa-chevron-down {
        font-size: 11px;
        color: var(--n-400);
        transition: transform 0.2s ease;
    }

    .att-legend:not(.is-collapsed) .att-legend-toggle .fa-chevron-down {
        transform: rotate(180deg);
    }

    .att-legend.is-collapsed>.att-legend-item {
        display: none;
    }

    /* Expanded: items become compact chips that flow and wrap together */
    .att-legend:not(.is-collapsed) {
        gap: 6px !important;
        padding: 0 12px 12px !important;
    }

    .att-legend:not(.is-collapsed) .att-legend-toggle {
        margin: 0 -12px 2px;
    }

    /* chips grow to fill each row → straight left & right edges */
    .att-legend>.att-legend-item {
        display: inline-flex;
        flex: 1 1 auto;
        align-items: center;
        gap: 4px;
        max-width: 100%;
        padding: 5px 7px;
        background: var(--n-0);
        border-radius: 999px;
        box-shadow: inset 0 0 0 1px var(--n-200);
        font-size: 11.5px;
        line-height: 1.3;
        white-space: nowrap;
    }

    .att-legend>.att-legend-item>:first-child {
        flex-shrink: 0;
        margin: 0 !important;
    }

    /* pair the short "Ca sắp tới" with "Chưa chấm công đủ" so rows fill evenly
       (children: toggle, then the 6 items in app.js order) */
    .att-legend>.att-legend-item {
        order: 1;
    }

    .att-legend>.att-legend-item:nth-child(6) {
        order: 2;
    }

    .att-legend>.att-legend-item:nth-child(5),
    .att-legend>.att-legend-item:nth-child(7) {
        order: 3;
    }

    /* Shift view employee bar: name on its own line, department chip ↔ total below */
    .shift-view-employee-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "name name"
            "dept total";
        align-items: center;
        gap: 8px 12px;
        padding: 12px 14px;
    }

    .shift-view-employee-bar>div:first-child {
        display: contents !important;
    }

    .shift-view-employee-name {
        grid-area: name;
        min-width: 0;
        font-size: 15px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .shift-view-employee-dept {
        grid-area: dept;
        justify-self: start;
        padding: 2px 10px;
        font-size: 11.5px;
    }

    .shift-view-employee-total {
        grid-area: total;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 3px 10px;
        background: var(--n-0);
        border-radius: 999px;
        box-shadow: inset 0 0 0 1px var(--brand-200);
        font-size: 13px;
        white-space: nowrap;
    }
}

#attendanceDefaultView,
#shiftViewContent {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.shift-view-nav {
    gap: 6px;
}

.shift-emp-chip {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    color: var(--n-700);
    font-size: 12.5px;
    font-weight: 550;
    box-shadow: inset 0 0 0 1px var(--n-200);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.shift-emp-chip:hover {
    background: var(--n-50);
    box-shadow: inset 0 0 0 1px var(--n-300);
}

.shift-emp-chip.active {
    background: var(--brand-50);
    color: var(--brand-700);
    box-shadow: inset 0 0 0 1px var(--brand-300);
}

.shift-view-employee-bar {
    position: sticky;
    left: 0;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--brand-50) 0%, #ffffff 100%);
    border: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--brand-100);
}

.shift-view-employee-bar>div {
    flex-wrap: wrap;
    min-width: 0;
}

.shift-view-employee-dept {
    border-radius: 999px;
}

.shift-view-employee-total {
    color: var(--brand-700);
    font-weight: 650;
}

/* ---- Shift assignment modal: name / time / status never overlap ---- */
.shift-assign-group {
    border-radius: 12px !important;
}

.shift-assign-group>div:first-child {
    flex-wrap: wrap;
    row-gap: 8px;
}

.shift-assign-group>div:first-child>div:first-child {
    flex-wrap: wrap;
    row-gap: 6px;
}

.shift-assign-group>div:first-child>div:first-child>div:nth-child(2) {
    flex-wrap: wrap;
    row-gap: 2px;
}

.shift-assign-group>div:first-child>div:first-child>div:nth-child(2)>div {
    max-width: 100%;
}

/* ---- Attendance check-in / check-out: same button style, different colour ----
   (check-out is a plain .btn coloured inline in the HTML, so it needs !important) */
#btnAttendanceCheckIn,
#btnAttendanceCheckOut {
    border-radius: 12px;
    letter-spacing: -0.2px;
}

#btnAttendanceCheckOut {
    background: linear-gradient(180deg, #2fca69 0%, #1fb357 55%, #16a34a 100%) !important;
    color: #ffffff !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(21, 128, 61, 0.35), 0 4px 12px -4px rgba(22, 163, 74, 0.55);
}

#btnAttendanceCheckOut:hover {
    background: linear-gradient(180deg, #3bd474 0%, #26bd5e 55%, #19ad4f 100%) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(21, 128, 61, 0.35), 0 8px 20px -6px rgba(22, 163, 74, 0.6);
}

#btnAttendanceCheckOut:active {
    background: #15803d !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ---- VNEpacket row actions: same size & family for every button ----
   Buttons come from app.js with mixed variants (primary / warning with inline colours /
   undefined "btn-outline" / danger), so they are normalised here. */
#vneTable td .btn-sm {
    height: 34px;
    min-height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border: 0 !important;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1;
    vertical-align: middle;
    justify-content: center;
}

/* Icon-only buttons are perfect squares (the "Xem" button keeps its label) */
#vneTable td .btn-sm:not([title="Xem chi tiết"]) {
    width: 34px;
    padding: 0;
}

#vneTable td .btn-outline,
#vneTable td .btn-secondary {
    background: #ffffff;
    color: var(--n-700);
    box-shadow: inset 0 0 0 1px var(--n-200), 0 1px 2px rgba(24, 24, 27, 0.05);
}

#vneTable td .btn-outline:hover,
#vneTable td .btn-secondary:hover {
    background: var(--n-50);
    color: var(--n-900);
}

#vneTable td .btn-warning {
    background: #fffaeb !important;
    color: #b54708 !important;
    box-shadow: inset 0 0 0 1px #fedf89 !important;
}

#vneTable td .btn-warning:hover {
    background: #fef0c7 !important;
}

#vneTable td .btn-danger {
    background: #fff1f3;
    color: #e11d48;
    box-shadow: inset 0 0 0 1px #fecdd6;
}

#vneTable td .btn-danger:hover {
    background: #ffe4e8;
    color: #be123c;
}

/* Label download / print icons match the same size */
#vneTable .vne-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
}

/* ---- Selected Sales / Designer rows in the workflow form ----
   The name is a <span>, so its ellipsis never applied and long names ran into "Tỉ lệ:" */
.selected-sales-item .sales-item-info {
    min-width: 0;
    overflow: hidden;
}

.selected-sales-item .sales-item-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The generic ".form-group label" rule (block + 6px bottom margin) also hit the "Tỉ lệ:"
   label inside these rows and lifted it above the input */
.selected-sales-item .sales-item-weight {
    height: auto;
    align-items: center;
}

.selected-sales-item .sales-item-weight label {
    display: flex;
    align-items: center;
    height: auto;
    margin: 0;
    line-height: 1;
}

/* "Chèn biến" (insert variable) dropdown: its options include long Jotform question
   names and it was sized "auto" inline, so it grew past the form edge */
.variable-inserter {
    min-width: 0;
    max-width: 100%;
}

.variable-inserter select {
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
}

/* ---- Shopify "Store Fulfillment Sync" modal ---- */
#shopifySyncModal .btn-scan {
    height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    background: var(--brand-gradient);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(199, 57, 10, 0.35), 0 4px 12px -4px rgba(255, 90, 31, 0.55);
}

#shopifySyncModal .btn-scan:hover {
    transform: none;
    filter: none;
    background: var(--brand-gradient-hover);
}

#shopifySyncModal #syncAgencyFilter {
    min-width: 0;
}

/* The two summary tiles: equal columns that can shrink (they overflowed on phones) */
#shopifySyncModal .shopify-sync-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px !important;
}

#shopifySyncModal .stat-mini-card,
#shopifySyncModal .stat-mini-card>div {
    min-width: 0;
}

#shopifySyncModal .stat-mini-card>div:first-child {
    flex-shrink: 0;
}

#shopifySyncModal .sync-preview-table-container {
    border: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-200);
}

/* ---- Dashboard: Shopify fulfillment stats ---- */
.store-id-cell {
    gap: 10px;
    min-width: 0;
}

.store-brand-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 0;
    border-radius: 9px;
    font-size: 15px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

.store-brand-name {
    min-width: 0;
    font-size: 13.5px;
    font-weight: 650;
    line-height: 1.3;
    /* at most 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Dashboard: WATI distribution cards ----
   Name on the left (truncated), count always on the right */
#watiDistribution .sales-stat-card {
    flex-wrap: nowrap !important; /* the phone rule that wraps inline "space-between" rows must not apply here */
    gap: 12px;
    padding: 14px !important;
    border: 0 !important;
    border-radius: 14px !important;
    box-shadow: var(--elev-1);
}

#watiDistribution .sales-stat-card>div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

#watiDistribution .sales-stat-card>div:first-child>div:first-child {
    flex-shrink: 0;
}

#watiDistribution .sales-stat-card>div:first-child>div:last-child {
    min-width: 0;
}

#watiDistribution .sales-stat-card>div:first-child>div:last-child>div:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#watiDistribution .sales-stat-card>div:last-child {
    flex-shrink: 0;
}

/* ---- Settings: long store names / inputs never widen the page ---- */
.settings-grid>* {
    min-width: 0;
}

.input-with-button>input,
.input-with-button>.form-control {
    min-width: 0;
    flex: 1 1 auto;
}

.input-with-button>.btn {
    flex-shrink: 0;
}

.integration-card {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border: 0;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

.integration-card-content {
    flex: 1 1 200px;
    min-width: 0;
}

.integration-details {
    min-width: 0;
}

.integration-details h3,
.integration-status {
    overflow-wrap: anywhere;
}

.integration-icon {
    border-radius: 12px;
    flex-shrink: 0;
}

/* ---- User management: tab panel + table (no card-inside-card look) ---- */
.tab-content {
    padding: 16px;
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-1);
}

.tab-content .devices-table-container {
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--n-150);
}

/* ---- Phones ---- */
@media (max-width: 768px) {

    .tab-content {
        padding: 10px;
    }

    /* Users table: one line per cell, scroll sideways */
    #userListTab .devices-table-container>table {
        width: max-content;
        min-width: 100%;
    }

    #userListTab .devices-table-container td,
    #userListTab .devices-table-container th {
        white-space: nowrap;
    }

    /* History + Email Tracking tables: name columns wide enough for ≤2 lines
       (the table scrolls sideways inside its card) */
    .history-table:has(> #historyTableBody) td:nth-child(3) .table-cell-icon-text,
    .history-table:has(> #emailTrackingTableBody) td:nth-child(3) .table-cell-icon-text {
        min-width: 190px;
    }

    .history-table:has(> #historyTableBody) td:nth-child(4) .table-cell-icon-text,
    .history-table:has(> #emailTrackingTableBody) td:nth-child(5) .table-cell-icon-text {
        min-width: 190px;
    }

    .history-table:has(> #historyTableBody) .table-cell-icon-text,
    .history-table:has(> #emailTrackingTableBody) .table-cell-icon-text {
        gap: 8px;
    }

    .history-table:has(> #historyTableBody) td:nth-child(2) .table-cell-icon-text,
    .history-table:has(> #emailTrackingTableBody) td:nth-child(2) .table-cell-icon-text,
    .history-table:has(> #emailTrackingTableBody) td:nth-child(7) .table-cell-icon-text {
        min-width: 112px;
    }

    .history-table:has(> #historyTableBody) .status-badge,
    .history-table:has(> #emailTrackingTableBody) .status-badge {
        white-space: nowrap;
    }

    /* "Chi tiết" column: Xem + Retry side by side, same height */
    .history-table:has(> #historyTableBody) td:nth-child(6) {
        white-space: nowrap;
    }

    .history-table:has(> #historyTableBody) td:nth-child(6)>.btn,
    .history-table:has(> #historyTableBody) td:nth-child(6)>.btn-retry-badge {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        height: 32px;
        min-height: 32px;
        padding: 0 12px !important;
        font-size: 12.5px;
        vertical-align: middle;
    }

    .history-table:has(> #historyTableBody) td:nth-child(6)>.btn-retry-badge {
        margin-left: 6px !important;
    }

    /* Sales modal – Shopify store checklist: equal checkboxes aligned with the first text line */
    #salesIntegrationsContainer>label {
        align-items: flex-start !important;
        gap: 10px !important;
        line-height: 1.4;
    }

    #salesIntegrationsContainer>label>input[type="checkbox"] {
        flex: 0 0 18px;
        width: 18px;
        height: 18px;
        margin: 1px 0 0;
    }

    #salesIntegrationsContainer>label>span {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* store name on the first line, (domain) on its own line below */
    #salesIntegrationsContainer>label>span>.text-muted {
        display: block;
        margin-top: 1px;
    }

    /* Detailed permission pop-ups (Teams / Workflows / Chấm công) use .modal-content:
       make them full-width bottom sheets like every other modal */
    #teamsActionsModal>.modal-content,
    #workflowActionsModal>.modal-content,
    #attendanceActionsModal>.modal-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100% !important;
        max-height: 92vh;
        max-height: 92dvh;
        border: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        animation: uiSheetIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* these three have no .modal-overlay element – dim the page behind like other sheets */
    #teamsActionsModal,
    #workflowActionsModal,
    #attendanceActionsModal {
        background: rgba(17, 17, 19, 0.5);
    }

    #teamsActionsModal>.modal-content>.modal-body,
    #workflowActionsModal>.modal-content>.modal-body,
    #attendanceActionsModal>.modal-content>.modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 16px !important;
    }

    #attendanceActionsModal .att-action-cb {
        flex-shrink: 0;
        width: 18px;
        height: 18px;
    }

    #attendanceActionsModal .modal-body label {
        font-size: 14px !important;
        line-height: 1.4;
    }

    /* Attendance table header: month badge left, view-mode toggle pushed to the right edge */
    .card-header>div:has(> #attViewModeGroup) {
        width: 100%;
        flex-wrap: wrap;
    }

    /* Title always on its own row, so every phone width shows: badge left · toggle right */
    .card-header>div:has(> #attViewModeGroup)>h2 {
        flex-basis: 100%;
    }

    #attViewModeGroup {
        margin-left: auto;
    }

    /* Attendance header buttons: the (always empty) clock span must not take a gap,
       and when both settings buttons are shown they share one full-width row */
    #attendanceCheckPanel>.card-header #checkCurrentTime:empty {
        display: none;
    }

    #attendanceCheckPanel>.card-header>div:has(> #btnTimeLimitConfig:not([style*="display: none"])):has(> #btnShiftConfig:not([style*="display: none"])) {
        width: 100%;
    }

    #attendanceCheckPanel>.card-header>div:has(> #btnTimeLimitConfig:not([style*="display: none"])):has(> #btnShiftConfig:not([style*="display: none"]))>.btn {
        flex: 1 1 auto;
        justify-content: center;
        padding: 0 10px !important;
    }

    /* Filter rows inside card headers: neat 2-column grid */
    .card-header .table-controls {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px !important;
        width: 100%;
    }

    .card-header .table-controls .filter-item {
        margin: 0;
        min-width: 0;
    }

    .card-header .table-controls .filter-select {
        width: 100%;
        min-width: 0 !important;
    }

    .card-header .table-controls>.btn {
        width: 100%;
        height: auto !important;
        grid-column: 1 / -1;
    }

    .card-header .table-controls .filter-item:has(#attendanceEmployee),
    .card-header .table-controls .filter-item:has(#auditLogEmployee),
    .card-header .table-controls .filter-item:has(#auditLogStatus),
    .card-header .table-controls .filter-item:has(#vneAgencyFilter),
    .card-header .table-controls>.search-box {
        grid-column: 1 / -1;
    }

    .card-header .table-controls>.search-box {
        min-width: 0 !important;
    }

    .card-header .table-controls .filter-select,
    .card-header .table-controls .custom-select-trigger {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Employee chips scroll in one row */
    .shift-view-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .shift-view-nav::-webkit-scrollbar {
        display: none;
    }

    /* Workflow footer: stats row, then toolbar – both full width */
    .workflow-footer {
        align-items: stretch;
    }

    .workflow-stats {
        width: 100%;
    }

    /* Workflow toolbar fills the card width */
    .workflow-actions {
        width: 100%;
        padding: 3px;
        border-top: 0;
        justify-content: space-between;
    }

    .workflow-actions .btn,
    .workflow-actions .btn-sm {
        flex: 1 1 0;
        min-height: 38px;
    }

    /* Sales / Designer cards reuse .workflow-actions: keep the toolbar compact on the
       right so the "Tổng form" figure has room on the left */
    .sales-card-footer {
        gap: 16px;
        align-items: center;
    }

    .sales-card-footer .sales-card-stat {
        text-align: left;
    }

    .sales-card-footer .sales-card-stat-label {
        white-space: nowrap;
    }

    .sales-card-footer .workflow-actions {
        width: auto;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .sales-card-footer .workflow-actions .btn,
    .sales-card-footer .workflow-actions .btn-sm {
        flex: 0 0 auto;
        min-width: 40px;
    }

    /* User management header: full-width tabs + action */
    .user-management-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .user-management-header .user-tabs {
        width: 100%;
        max-width: 100%;
    }

    .user-management-header .user-tabs .tab-btn {
        flex: 1 1 0;
        text-align: center;
    }

    .user-management-header #userListActions .btn,
    .user-management-header #activeDevicesActions .btn {
        width: 100%;
    }

    /* Section headers inside modals wrap */
    .modal-body [style*="space-between"] {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* VNEpacket agency rules: agency / market on their own lines */
    .vne-agency-rule-row {
        flex-wrap: wrap;
        align-items: flex-end !important;
    }

    .vne-agency-rule-row>.form-group {
        flex: 1 1 100% !important;
    }

    .vne-agency-rule-row>.form-group:nth-of-type(3) {
        flex: 1 1 0 !important;
        min-width: 0;
    }

    .vne-agency-rule-row>button {
        flex: none;
        height: 44px !important;
    }

    /* Shift assignment: line 1 = shift name + time, line 2 = status badges */
    .shift-assign-group>div:first-child {
        padding: 12px !important;
        gap: 10px;
        flex-wrap: nowrap;
    }

    .shift-assign-group>div:first-child>div:first-child {
        gap: 8px !important;
    }

    .shift-assign-group>div:first-child>div:first-child>div:nth-child(2) {
        flex: 1 1 calc(100% - 24px) !important;
        gap: 4px 8px !important;
    }

    .shift-assign-group>div:first-child>label {
        margin-left: 0 !important;
        font-size: 12.5px !important;
    }

    /* Address Convert tabs: full width, scrollable */
    body #addressConversionPage .team-tabs {
        width: 100%;
    }

    /* ---- VNEpacket orders table ----
       The page scrolls vertically; the table only scrolls sideways.
       Checkbox + order ID stay pinned on the left. */
    #vneTableTopScroll {
        display: none !important;
    }

    #vneTableBottomScroll {
        max-height: none !important;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--n-300) transparent;
    }

    #vneTableBottomScroll::-webkit-scrollbar {
        height: 8px;
    }

    #vneTableBottomScroll::-webkit-scrollbar-thumb {
        background: var(--n-300);
        border: 0;
        border-radius: 8px;
    }

    .card-body:has(> #vneTableBottomScroll)::before {
        content: 'Vuốt ngang để xem thêm cột  →';
        display: block;
        padding: 8px 14px;
        font-size: 12px;
        font-weight: 500;
        color: var(--n-500);
        background: var(--n-50);
        border-bottom: 1px solid var(--n-150);
    }

    #vneTable th:nth-child(1),
    #vneTable td:nth-child(1) {
        position: sticky;
        left: 0;
        z-index: 3;
        background: #ffffff;
    }

    #vneTable th:nth-child(2),
    #vneTable td:nth-child(2) {
        position: sticky;
        left: 45px;
        z-index: 3;
        background: #ffffff;
        transition: box-shadow 0.15s ease;
    }

    .ui-x-scrolled #vneTable th:nth-child(2),
    .ui-x-scrolled #vneTable td:nth-child(2) {
        box-shadow: 8px 0 10px -8px rgba(24, 24, 27, 0.22);
    }

    #vneTable thead th:nth-child(1),
    #vneTable thead th:nth-child(2) {
        z-index: 25;
    }

    /* Row actions: equal circles on phones */
    #vneTable td .btn-sm,
    #vneTable .vne-btn-icon {
        border-radius: 999px;
    }

    /* ---- Pinned columns (classes added by ui-shell.js; offsets measured from real widths) ---- */
    /* "clip" keeps the rounded corners but, unlike "hidden", does not turn the table
       into a scroll container – so sticky (pinned) cells keep working */
    .ui-pinned-table {
        overflow: hidden !important;
        overflow: clip !important;
    }

    .ui-pin {
        position: sticky !important;
        left: var(--ui-pin-left, 0px) !important;
        z-index: 22 !important;
        background-color: #ffffff;
    }

    thead .ui-pin {
        z-index: 32 !important;
        background-color: var(--n-50) !important;
    }

    /* Divider shadow only while the table is scrolled sideways */
    .ui-pin-last {
        transition: box-shadow 0.15s ease;
    }

    .ui-x-scrolled .ui-pin-last {
        box-shadow: 8px 0 10px -8px rgba(24, 24, 27, 0.22) !important;
    }

    /* Attendance tables have their own rounded border: on phones the table itself becomes
       the horizontal scroll box, so that border (and its rounded corners) never moves and
       the content scrolls inside it – corners stay round at every scroll position */
    .attendance-table.ui-pinned-table,
    .attendance-shift-table.ui-pinned-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* As a scroll box the shift table no longer honours its <colgroup> widths:
       keep the "VÀO / RA" columns at their original 60px */
    .attendance-shift-table.ui-pinned-table thead tr:nth-child(2) th:nth-child(n+3) {
        min-width: 60px;
    }

    /* Rows under a rowspan: their first cell is a data cell, not a pinned one */
    .ui-unpin {
        position: static !important;
    }

    .simple-table tbody tr:hover>.ui-pin {
        background-color: #fffaf7;
    }

    /* Shift view: tinted rows use opaque colours on pinned cells (the originals are translucent) */
    .attendance-shift-table tbody tr:nth-child(even)>.ui-pin {
        background-color: #fafbfd !important;
    }

    .attendance-shift-table tbody tr.weekend-row>.ui-pin {
        background-color: #fef9f9 !important;
    }

    .attendance-shift-table tbody tr.weekend-row:nth-child(even)>.ui-pin {
        background-color: #fef6f6 !important;
    }

    .attendance-shift-table tbody tr:hover>.ui-pin {
        background-color: #eff6ff !important;
    }

    /* Narrower pinned columns so the rest of the table has room on a phone */
    #attendanceTableMain .emp-col {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        font-size: 13px !important;
        line-height: 1.35;
        padding-left: 10px !important;
        padding-right: 6px !important;
    }

    #attendanceTableMain .dept-col {
        width: 48px !important;
        min-width: 48px !important;
    }

    .simple-table:has(> #attendanceAuditLogBody) th:nth-child(1),
    .simple-table:has(> #attendanceAuditLogBody) td:nth-child(1) {
        width: 36px !important;
        min-width: 36px;
    }

    .simple-table:has(> #attendanceAuditLogBody) th:nth-child(2),
    .simple-table:has(> #attendanceAuditLogBody) td:nth-child(2) {
        width: 86px !important;
        min-width: 86px;
        max-width: 86px;
        white-space: normal !important;
    }

    .simple-table:has(> #attendanceAuditLogBody) th:nth-child(3),
    .simple-table:has(> #attendanceAuditLogBody) td:nth-child(3) {
        width: 100px !important;
        min-width: 100px;
        max-width: 100px;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    #userListTab .devices-table-container td:first-child,
    #userListTab .devices-table-container th:first-child {
        min-width: 120px;
        max-width: 150px;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    #activeDevicesTab .devices-table-container td:first-child,
    #activeDevicesTab .devices-table-container th:first-child {
        width: 150px;
        min-width: 150px;
        max-width: 150px;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    /* style.css also pins the 380px "recipient & address" column: 3 pinned columns
       (565px) are wider than a phone screen, so nothing could scroll into view */
    #vneTable th:nth-child(3),
    #vneTable td:nth-child(3) {
        position: static !important;
        left: auto !important;
        border-right: 0 !important;
        box-shadow: none !important;
    }

    #vneTable tbody tr:hover td:nth-child(1),
    #vneTable tbody tr:hover td:nth-child(2) {
        background: #fffaf7;
    }
}

/* History detail – "Thông tin chung" card: label/value tiles, 2 columns → 1 on phones */
.hd-info-card {
    margin-bottom: 28px;
    padding: 20px;
    background: var(--n-0);
    border-radius: 16px;
    box-shadow: var(--elev-1);
}

.hd-info-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 16px;
}

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

.hd-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 14px;
    background: var(--n-50);
    border: 1px solid var(--n-150);
    border-radius: 12px;
}

.hd-info-item--wide {
    grid-column: 1 / -1;
}

.hd-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--n-0);
    box-shadow: var(--elev-1);
    color: var(--n-500);
    font-size: 13px;
}

.hd-info-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.hd-info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--n-500);
    line-height: 1.3;
}

.hd-info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--n-900);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.hd-info-value .status-badge {
    width: fit-content;
    margin-top: 1px;
}

.hd-info-code {
    display: inline-block;
    max-width: 100%;
    padding: 3px 8px;
    background: var(--n-0);
    border: 1px solid var(--n-200);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 500;
    word-break: break-all;
}

/* Settings – Shopify store cards: edit / delete as two identical round buttons */
.integration-actions .btn-icon-only {
    flex: 0 0 36px;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px;
    min-height: 36px !important;
    padding: 0;
    background: var(--n-0) !important;
    border: 1px solid var(--n-200) !important;
    border-radius: 50% !important;
    color: var(--n-700) !important;
    font-size: 13.5px;
    transform: none !important;
}

.integration-actions .btn-icon-only:hover {
    background: var(--n-100) !important;
    border-color: var(--n-300) !important;
}

.integration-actions .btn-icon-only.danger {
    color: var(--danger) !important;
}

.integration-actions .btn-icon-only.danger:hover {
    background: var(--danger-bg) !important;
    border-color: #fecdd3 !important;
}

/* Phones: compact Shopify store row – logo | name + actions, domain on its own full-width line */
@media (max-width: 768px) {
    #shopifyIntegrationsList>.integration-card {
        display: grid;
        grid-template-columns: 36px minmax(0, 1fr) auto;
        grid-template-areas:
            "icon name actions"
            "icon domain domain";
        column-gap: 10px;
        row-gap: 2px;
        align-items: center;
        padding: 12px;
    }

    #shopifyIntegrationsList .integration-card-content,
    #shopifyIntegrationsList .integration-details {
        display: contents;
    }

    #shopifyIntegrationsList .integration-icon {
        grid-area: icon;
        align-self: center;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 18px;
    }

    /* Store name: never cut the distinguishing suffix (GB / AU / CA…) – wrap to 2 lines at most */
    #shopifyIntegrationsList .integration-details h3 {
        grid-area: name;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        min-width: 0;
        overflow: hidden;
        font-size: 14px !important;
        line-height: 1.3;
    }

    #shopifyIntegrationsList .integration-status {
        grid-area: domain;
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    #shopifyIntegrationsList .integration-actions {
        grid-area: actions;
        gap: 6px !important;
    }

    #shopifyIntegrationsList .integration-actions .btn-icon-only {
        flex-basis: 34px;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px;
        min-height: 34px !important;
        font-size: 13px;
    }
}

/* Phones: compact Google Drive card – logo | name | button, connection status as a full-width strip */
@media (max-width: 768px) {
    #googleDriveConnectContainer>.integration-card {
        display: grid;
        grid-template-columns: 36px minmax(0, 1fr) auto;
        grid-template-areas:
            "icon name actions"
            "status status status";
        column-gap: 10px;
        row-gap: 10px;
        align-items: center;
        padding: 12px;
    }

    #googleDriveConnectContainer .integration-card-content,
    #googleDriveConnectContainer .integration-details {
        display: contents;
    }

    #googleDriveConnectContainer .integration-icon {
        grid-area: icon;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 18px;
    }

    #googleDriveConnectContainer .integration-details h3 {
        grid-area: name;
        min-width: 0;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14.5px;
    }

    #googleDriveConnectContainer .integration-status {
        grid-area: status;
        min-width: 0;
        padding: 8px 10px;
        background: var(--n-100);
        border-radius: 8px;
        font-size: 13px;
        overflow-wrap: anywhere;
    }

    #googleDriveConnectContainer .integration-status.connected {
        background: var(--success-bg);
    }

    #googleDriveConnectContainer .integration-actions {
        grid-area: actions;
    }

    #googleDriveConnectContainer .integration-actions .btn {
        height: 36px;
        min-height: 36px;
        padding: 0 14px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* Shopify Fulfillment config (all screens): the "Tự động gửi email…" row spans the full
   width (it sits alone in a 2-column .form-row) with the toggle on the right of the text */
.workflow-step[data-step="7"] .form-row:has(> .status-group) {
    grid-template-columns: minmax(0, 1fr) !important;
}

.workflow-step[data-step="7"] .toggle-label {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.workflow-step[data-step="7"] .toggle-label .toggle-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    line-height: 1.45;
}

.workflow-step[data-step="7"] .toggle-label .toggle-switch {
    flex-shrink: 0;
}

.workflow-step[data-step="7"] .status-group .hint {
    white-space: normal;
}

/* Phones: Shopify Fulfillment config (data-step 7) – store/prefix rows and excluded products */
@media (max-width: 768px) {
    .workflow-step[data-step="7"] .form-group:has(#shopifyStoresList),
    .workflow-step[data-step="7"] .form-group:has(#excludedProductsList) {
        padding: 14px !important;
        margin-bottom: 14px !important;
    }

    /* Section header: title + "Thêm …" button on one row */
    .workflow-step[data-step="7"] .form-group:has(#shopifyStoresList)>div:first-child,
    .workflow-step[data-step="7"] .form-group:has(#excludedProductsList)>div:first-child {
        flex-wrap: nowrap !important;
        gap: 10px;
        margin-bottom: 12px !important;
    }

    .workflow-step[data-step="7"] .form-group:has(#shopifyStoresList)>div:first-child>label,
    .workflow-step[data-step="7"] .form-group:has(#excludedProductsList)>div:first-child>label {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 13.5px;
        line-height: 1.4;
    }

    .workflow-step[data-step="7"] .form-group:has(#shopifyStoresList)>div:first-child>.btn,
    .workflow-step[data-step="7"] .form-group:has(#excludedProductsList)>div:first-child>.btn {
        flex-shrink: 0;
        height: 34px;
        min-height: 34px;
        padding: 0 12px;
        font-size: 12.5px;
        white-space: nowrap;
    }

    /* Rows reuse .field-mapping-row: drop the Jotform 2-line grid areas */
    #shopifyStoresList>.shopify-store-row,
    #excludedProductsList>.excluded-product-row {
        display: grid !important;
        grid-template-areas: none;
        gap: 8px !important;
        align-items: center !important;
        padding: 8px;
        margin-bottom: 8px !important;
    }

    /* Store name must stay readable (GB / AU / IE…): store + delete on top, prefix below */
    #shopifyStoresList>.shopify-store-row {
        grid-template-columns: minmax(0, 1fr) 40px;
        grid-template-areas:
            "store del"
            "prefix .";
    }

    #shopifyStoresList>.shopify-store-row>div:first-child {
        grid-area: store;
    }

    #shopifyStoresList>.shopify-store-row>div:nth-child(2) {
        grid-area: prefix;
    }

    #shopifyStoresList>.shopify-store-row>.btn {
        grid-area: del !important;
    }

    #excludedProductsList>.excluded-product-row {
        grid-template-columns: minmax(0, 1fr) 40px;
    }

    #shopifyStoresList>.shopify-store-row>div,
    #excludedProductsList>.excluded-product-row>div {
        min-width: 0;
    }

    #shopifyStoresList input,
    #excludedProductsList input {
        padding-right: 12px;
    }

    #shopifyStoresList>.shopify-store-row>.btn,
    #excludedProductsList>.excluded-product-row>.btn {
        grid-area: auto;
        width: 40px;
        height: 40px;
        min-height: 40px;
        padding: 0;
        background: var(--n-0) !important;
        border: 1px solid var(--n-200) !important;
        border-radius: 10px;
        box-shadow: none !important;
        color: var(--danger) !important;
    }

    .workflow-step[data-step="7"] .form-group:has(#shopifyStoresList)>.hint,
    .workflow-step[data-step="7"] .form-group:has(#excludedProductsList)>.hint {
        margin-top: 8px !important;
        font-size: 12px;
        line-height: 1.5;
    }

    .workflow-step[data-step="7"] .status-group {
        margin-top: 6px !important;
        padding-top: 14px !important;
    }

    .workflow-step[data-step="7"] .status-group .hint {
        white-space: normal;
        font-size: 12px;
        line-height: 1.5;
    }

    /* Master Webhook URL box */
    #routerUrlContainer {
        margin-top: 12px !important;
        padding: 14px !important;
        border-radius: 12px !important;
    }

    #routerUrlContainer>label {
        text-transform: none !important;
        letter-spacing: 0 !important;
        font-size: 13px !important;
        font-weight: 600;
        color: var(--n-700) !important;
        white-space: normal;
        line-height: 1.4;
    }

    #routerUrlContainer>div:has(> #unifiedRouterUrl) {
        gap: 8px !important;
    }

    #unifiedRouterUrl {
        flex: 1 1 auto;
        min-width: 0;
        height: 44px;
        text-overflow: ellipsis;
    }

    /* copy button: icon-only square, like the webhook step */
    #routerUrlContainer>div:has(> #unifiedRouterUrl)>.btn {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0 !important;
        justify-content: center;
        border-radius: 12px;
        font-size: 0 !important;
    }

    #routerUrlContainer>div:has(> #unifiedRouterUrl)>.btn i {
        font-size: 15px;
    }

    #routerUrlContainer>.hint {
        font-size: 12px;
        line-height: 1.5;
    }

    /* Admin key controls: checkbox aligned with the first text line, button full width */
    #fulfillmentWebhookKeyAdmin>div {
        gap: 10px !important;
    }

    #fulfillmentWebhookKeyAdmin label {
        align-items: flex-start !important;
        line-height: 1.45;
    }

    #fulfillmentWebhookKeyAdmin label>input {
        flex-shrink: 0;
        margin-top: 2px;
    }

    #fulfillmentWebhookKeyAdmin .btn {
        width: 100%;
        justify-content: center;
        height: 38px;
        min-height: 38px;
    }
}

/* Phones: WATI auto message step (data-step 9) */
@media (max-width: 768px) {

    /* Feature status: text left, toggle right on the same row */
    .workflow-step[data-step="9"] label[for="watiAutoMessageEnabled"] {
        flex-wrap: nowrap !important;
        gap: 12px;
        padding: 14px 16px !important;
    }

    .workflow-step[data-step="9"] label[for="watiAutoMessageEnabled"]>div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .workflow-step[data-step="9"] label[for="watiAutoMessageEnabled"] h4 {
        font-size: 14px !important;
    }

    .workflow-step[data-step="9"] label[for="watiAutoMessageEnabled"] p {
        margin-top: 3px !important;
        line-height: 1.45;
    }

    .workflow-step[data-step="9"] label[for="watiAutoMessageEnabled"] .toggle-switch {
        flex-shrink: 0;
    }

    .workflow-step[data-step="9"]>.wati-auto-card:first-of-type {
        margin-bottom: 0;
    }

    #watiAutoMessageConfig {
        margin-top: 14px !important;
    }

    /* Template / Session: two equal halves, one line each */
    .workflow-step[data-step="9"] .wati-message-type-selector {
        gap: 4px;
        padding: 4px;
        margin-bottom: 16px;
    }

    .workflow-step[data-step="9"] .wati-type-option {
        flex: 1 1 0;
        min-width: 0;
        gap: 6px;
        padding: 10px 6px;
        font-size: 12.5px;
        white-space: nowrap;
    }

    .workflow-step[data-step="9"] .wati-placeholder-container {
        gap: 6px;
        margin-top: 10px;
    }

    .workflow-step[data-step="9"] #watiAutoMessageConfig>.form-group,
    .workflow-step[data-step="9"] #watiAutoMessageConfig>div[style*="fffbeb"] {
        margin-top: 16px !important;
    }
}

/* Phones: Lark Order Sync field mapping (data-step 11) – both tool buttons fill one row
   (each takes a full row only when the screen is too narrow), compact status line */
@media (max-width: 768px) {
    .workflow-step[data-step="11"] .los-toolbar {
        gap: 8px;
        margin-bottom: 10px;
    }

    .workflow-step[data-step="11"] .los-toolbar>.btn {
        flex: 1 1 auto;
        justify-content: center;
        height: 40px;
        min-height: 40px;
        padding: 0 10px;
        font-size: 12.5px;
        white-space: nowrap;
    }

    .workflow-step[data-step="11"] .los-status {
        padding: 10px 12px;
        margin-bottom: 12px;
        font-size: 12.5px;
        border-radius: 12px;
    }
}

/* Phones: workflow step "Tóm tắt & Cài đặt Webhook" (data-step 8) */
@media (max-width: 768px) {
    .workflow-step[data-step="8"] .webhook-url-display {
        margin-top: 12px;
        padding: 14px;
        border-radius: 14px;
    }

    .workflow-step[data-step="8"] .webhook-url-display>label {
        font-size: 12.5px;
        font-weight: 600;
        margin-bottom: 8px;
    }

    .workflow-step[data-step="8"] .copy-input {
        gap: 8px;
        align-items: stretch;
    }

    .workflow-step[data-step="8"] .copy-input input {
        min-width: 0;
        height: 44px;
        padding: 0 12px;
        text-overflow: ellipsis;
    }

    .workflow-step[data-step="8"] .copy-input>.btn {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
        justify-content: center;
        border-radius: 12px;
    }

    .workflow-step[data-step="8"] .webhook-url-display .hint {
        margin: 8px 0 0;
        font-size: 12px;
        line-height: 1.5;
    }

    /* Lark help box */
    .workflow-step[data-step="8"] .lark-config-help {
        margin-top: 12px !important;
        padding: 14px !important;
        border-radius: 14px !important;
    }

    .workflow-step[data-step="8"] .lark-config-help>h4 {
        align-items: flex-start !important;
        font-size: 14px !important;
        line-height: 1.4;
        margin-bottom: 12px !important;
    }

    .workflow-step[data-step="8"] .lark-config-help>h4>i {
        margin-top: 3px;
        flex-shrink: 0;
    }

    .workflow-step[data-step="8"] .lark-config-help .help-section>label {
        align-items: center;
        gap: 8px;
    }

    /* "Content-Type: application/json" + Copy stay on one row */
    .workflow-step[data-step="8"] .lark-config-help .help-section>div:has(> code) {
        flex-wrap: nowrap !important;
        gap: 10px;
        padding: 10px 12px !important;
    }

    .workflow-step[data-step="8"] .lark-config-help .help-section>div:has(> code)>code {
        min-width: 0;
        overflow-wrap: anywhere;
        font-size: 12.5px !important;
    }

    .workflow-step[data-step="8"] .lark-config-help .btn-link {
        flex-shrink: 0;
        min-height: 0;
        height: auto;
        white-space: nowrap;
        font-size: 12.5px;
    }

    .workflow-step[data-step="8"] #larkBodyTemplate {
        height: 150px !important;
        padding: 12px !important;
    }
}

/* Phones: workflow step "Cấu hình Thông báo Đơn hàng Shopify" (data-step 10) */
@media (max-width: 768px) {

    /* Sender banner: text wraps in its own column, small "Cài đặt" button stays on the right */
    #workflowEmailSenderInfoBanner {
        flex-wrap: nowrap !important;
        align-items: center !important;
        padding: 10px 12px !important;
    }

    #workflowEmailSenderInfoBanner>div:first-child {
        flex: 1 1 auto;
        min-width: 0;
        align-items: flex-start !important;
    }

    #workflowSenderEmailText {
        display: block;
        overflow-wrap: anywhere;
        line-height: 1.45;
    }

    #workflowEmailSenderInfoBanner>.btn,
    .workflow-step[data-step="10"] .btn-xs {
        flex-shrink: 0;
        height: 32px;
        min-height: 32px;
        padding: 0 12px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }

    /* Subject: label on top, variable chips below */
    .workflow-step[data-step="10"] .form-group:has(> #workflowShopifyEmailSubject)>div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
        margin-bottom: 8px !important;
    }

    .workflow-step[data-step="10"] .form-group:has(> #workflowShopifyEmailSubject)>div:first-child>div {
        flex-wrap: wrap;
        gap: 4px !important;
    }

    .workflow-step[data-step="10"] .form-group:has(> #workflowShopifyEmailSubject) .badge-chip {
        padding: 3px 7px;
        font-size: 11.5px;
    }

    /* Template mode: "Mẫu Email" + "Xem trước" on one row, the two options as equal cards below */
    .workflow-step[data-step="10"] div:has(> div > label > input[name="workflowShopifyEmailTemplateMode"]) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 8px;
        align-items: center !important;
    }

    .workflow-step[data-step="10"] div:has(> label > input[name="workflowShopifyEmailTemplateMode"]) {
        display: contents !important;
    }

    .workflow-step[data-step="10"] div:has(> label > input[name="workflowShopifyEmailTemplateMode"])>span {
        grid-column: 1;
        grid-row: 1;
        white-space: nowrap;
    }

    .workflow-step[data-step="10"] div:has(> div > label > input[name="workflowShopifyEmailTemplateMode"])>.btn {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .workflow-step[data-step="10"] label:has(> input[name="workflowShopifyEmailTemplateMode"]) {
        grid-row: 2;
        align-self: stretch;
        justify-content: center;
        min-height: 42px;
        padding: 8px 6px;
        white-space: nowrap;
        background: var(--n-0);
        border: 1px solid var(--n-200);
        border-radius: 10px;
        font-size: 13px !important;
        font-weight: 500;
        text-align: center;
    }

    .workflow-step[data-step="10"] label:has(> input[name="workflowShopifyEmailTemplateMode"]:checked) {
        background: var(--brand-50);
        border-color: var(--brand-400);
        color: var(--brand-700);
        font-weight: 600;
    }

    /* Sales selection header: title + "Chọn tất cả" on one row, buttons share the next row */
    .workflow-step[data-step="10"] .form-group:has(#workflowShopifySalesOverview)>div:first-child {
        flex-wrap: wrap;
        gap: 8px;
    }

    .workflow-step[data-step="10"] .form-group:has(#workflowShopifySalesOverview)>div:first-child>div {
        width: 100%;
    }

    .workflow-step[data-step="10"] .form-group:has(#workflowShopifySalesOverview)>div:first-child>div:first-child {
        justify-content: space-between;
    }

    .workflow-step[data-step="10"] .form-group:has(#workflowShopifySalesOverview)>div:first-child>div:last-child>.btn {
        flex: 1 1 0;
        justify-content: center;
    }

    /* Sales table scrolls sideways instead of squeezing every column */
    #workflowShopifySalesOverview {
        overflow-x: auto;
    }

    #workflowShopifySalesOverview table {
        min-width: 560px;
    }

    #workflowShopifySalesOverview td,
    #workflowShopifySalesOverview th {
        white-space: nowrap;
    }
}

/* Settings – email "Gửi thử nghiệm / Lưu" and 2FA status stay on one row on phones */
.settings-email-actions {
    flex-wrap: nowrap !important;
    gap: 10px;
}

.settings-email-actions>.btn {
    white-space: nowrap;
}

#twoFAStatusContainer>div {
    flex-wrap: nowrap !important;
    gap: 10px;
}

#twoFAStatusContainer>div>div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

#twoFAStatusContainer>div>div:first-child>div:first-child {
    flex-shrink: 0;
}

#twoFAStatusContainer>div>div:last-child {
    flex-shrink: 0;
}

#twoFAStatusContainer .btn {
    white-space: nowrap;
}

@media (max-width: 480px) {
    #twoFAStatusContainer>div>div:first-child {
        gap: 10px !important;
    }

    /* "Trạng thái: Đã kích hoạt" on one line next to the button */
    #twoFAStatusContainer>div>div:first-child>div:last-child>div:first-child {
        font-size: 13px !important;
    }
}

/* History detail – step header: the round status icon must never shrink when the title wraps */
.step-header {
    gap: 12px;
}

.step-title-group {
    flex: 1 1 auto;
    min-width: 0;
}

.step-title-group>div:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.step-status-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
}

.step-header>.status-badge {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Phones: title gets the full width, status badge sits under it (aligned with the text) */
@media (max-width: 600px) {
    .step-header {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .step-title-group {
        flex-basis: 100%;
    }

    .step-header>.status-badge {
        margin-left: 40px;
    }
}

/* VNEpacket bulk actions: one tidy toolbar instead of loose coloured buttons.
   app.js still shows / hides each button and fills the counts. */
.vne-bulk-actions:has(> .btn:not([style*="display: none"])) {
    padding: 4px;
    gap: 4px !important;
    background: var(--n-50);
    border: 1px solid var(--n-150);
    border-radius: 12px;
}

.vne-bulk-actions>.btn {
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    min-height: 34px;
    padding: 0 12px;
    background: var(--n-0) !important;
    border: 1px solid var(--n-200) !important;
    border-radius: 9px;
    box-shadow: none !important;
    color: var(--n-800) !important;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transform: none !important;
}

.vne-bulk-actions>.btn:hover {
    background: var(--n-100) !important;
    border-color: var(--n-300) !important;
}

.vne-bulk-actions .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    margin-left: 0 !important;
    padding: 0 6px !important;
    background: var(--n-100) !important;
    color: var(--n-700) !important;
    border-radius: 999px !important;
    font-size: 11px !important;
    font-weight: 600;
}

/* "Bỏ chọn": same white button, muted text so it stays secondary to the actions */
.vne-bulk-actions>#vneClearSelectionBtn {
    color: var(--n-600) !important;
}

.vne-bulk-actions>#vneClearSelectionBtn i {
    color: var(--n-400);
}

/* Main action */
.vne-bulk-actions>#vneBulkCreateBtn {
    background: var(--brand-gradient) !important;
    border-color: var(--brand-600) !important;
    color: #fff !important;
    box-shadow: 0 1px 2px rgba(240, 74, 12, 0.25) !important;
}

.vne-bulk-actions>#vneBulkCreateBtn:hover {
    background: var(--brand-gradient-hover) !important;
}

.vne-bulk-actions>#vneBulkCreateBtn .badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
}

.vne-bulk-actions>#vneBulkReturnTrackingBtn i {
    color: #0d9488;
}

.vne-bulk-actions>#vneBulkDownloadLabelsBtn i {
    color: #dc2626;
}

.vne-bulk-actions>#vneBulkPrintLabelsBtn i {
    color: #2563eb;
}

.vne-bulk-actions>#vneBulkDeleteBtn {
    color: var(--danger) !important;
}

.vne-bulk-actions>#vneBulkDeleteBtn:hover {
    background: var(--danger-bg) !important;
    border-color: #fecdd3 !important;
}

.vne-bulk-actions>#vneBulkDeleteBtn .badge {
    background: var(--danger-bg) !important;
    color: var(--danger) !important;
}

@media (max-width: 768px) {

    /* Phones: equal 2-column buttons, delete on its own row */
    .vne-bulk-actions:has(> .btn:not([style*="display: none"])) {
        width: 100%;
    }

    .vne-bulk-actions>.btn {
        flex: 1 1 calc(50% - 2px);
        min-width: 0;
        height: 38px;
        min-height: 38px;
        padding: 0 10px;
    }

    .vne-bulk-actions>#vneBulkDeleteBtn {
        flex-basis: 100%;
    }
}

/* Styled option list for native selects (ui-shell.js, mouse devices only) */
select.ui-select-open {
    border-color: var(--brand-400) !important;
    box-shadow: var(--focus-ring) !important;
}

.ui-select-menu {
    position: fixed;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--n-0);
    border-radius: 12px;
    box-shadow: var(--elev-3);
    overflow: hidden;
    animation: ui-select-in 0.12s ease-out;
}

@keyframes ui-select-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.ui-select-search {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 6px;
}

.ui-select-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--n-400);
    font-size: 12px;
    pointer-events: none;
}

.ui-select-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 32px;
    background: var(--n-50);
    border: 1px solid var(--n-200);
    border-radius: 8px;
    font: inherit;
    font-size: 13.5px;
    color: var(--n-900);
    outline: none;
}

.ui-select-search input:focus {
    background: var(--n-0);
    border-color: var(--brand-400);
    box-shadow: var(--focus-ring);
}

.ui-select-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ui-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--n-800);
    cursor: pointer;
}

.ui-select-option.is-active {
    background: var(--n-100);
}

.ui-select-option.is-selected {
    color: var(--brand-700);
    font-weight: 600;
}

.ui-select-option.is-selected.is-active {
    background: var(--brand-50);
}

.ui-select-option.is-placeholder {
    color: var(--n-500);
}

.ui-select-option.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ui-select-check {
    flex: 0 0 14px;
    color: var(--brand-500);
    font-size: 11px;
    visibility: hidden;
}

.ui-select-option.is-selected .ui-select-check {
    visibility: visible;
}

.ui-select-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-select-meta {
    flex-shrink: 0;
    padding: 2px 8px;
    background: var(--n-100);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--n-600);
    white-space: nowrap;
}

.ui-select-option.is-selected .ui-select-meta {
    background: var(--brand-100);
    color: var(--brand-700);
}

.ui-select-empty {
    padding: 14px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--n-500);
}

/* Attendance notices: 2-line preview, "Xem thêm / Thu gọn" toggle (ui-shell.js) */
.att-notice {
    align-items: flex-start !important;
}

.att-notice>i {
    margin-top: 2px;
    flex-shrink: 0;
}

.att-notice-body {
    flex: 1 1 auto;
    min-width: 0;
}

.att-notice-text {
    display: block;
    line-height: 1.5 !important;
}

.att-notice.is-collapsed .att-notice-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.att-notice-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 2px 0;
    background: none;
    border: 0;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.att-notice-toggle[hidden] {
    display: none;
}

.att-notice-toggle i {
    font-size: 10px;
}

.att-notice--warn .att-notice-toggle {
    color: #b45309;
}

.att-notice--info .att-notice-toggle {
    color: #0369a1;
}

/* Shift settings list: name + round actions on top, time / department chips below */
.shift-card {
    display: block;
    padding: 12px 12px 12px 16px;
    border: 1px solid var(--n-200);
    border-radius: 14px;
    margin-bottom: 10px;
}

.shift-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shift-card .shift-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14.5px;
    font-weight: 650;
    color: var(--n-900);
}

.shift-card .shift-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.shift-card .shift-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 12.5px;
}

.shift-card .shift-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.shift-card .shift-time,
.shift-card .shift-dept,
.shift-card .shift-paused {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.shift-card .shift-time {
    background: var(--n-100);
    color: var(--n-600);
    font-variant-numeric: tabular-nums;
}

.shift-card .shift-paused {
    background: var(--danger-bg);
    color: var(--danger);
}

@media (max-width: 600px) {
    .hd-info-card {
        padding: 16px;
        margin-bottom: 22px;
    }

    .hd-info-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .hd-info-item {
        padding: 11px 12px;
    }
}

/* =====================================================
   21. Workflow form on phones
   ===================================================== */
@media (max-width: 768px) {

    /* The form never pans sideways: on iPhone a single over-wide field made the whole
       step slide left and leave an empty band on the right */
    .modal-body {
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }

    .modal-body select,
    .modal-body input,
    .modal-body textarea,
    .modal-body .ql-container,
    .modal-body .ql-toolbar {
        max-width: 100%;
    }

    .modal-body .form-row>*,
    .modal-body .input-with-button>select,
    .modal-body .input-with-button>input,
    .modal-body [style*="display: flex"]>select,
    .modal-body [style*="display: flex"]>input,
    .modal-body [style*="display: flex"]>.form-group,
    .modal-body [style*="display:flex"]>select,
    .modal-body [style*="display:flex"]>input,
    .modal-body [style*="display:flex"]>.form-group {
        min-width: 0;
    }

    .modal-body .ql-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
    }

    .modal-body .ql-editor {
        overflow-wrap: anywhere;
    }

    /* iOS zooms into any field below 16px – keep every form control at 16px */
    .modal-body select,
    .modal-body input:not([type="checkbox"]):not([type="radio"]),
    .modal-body textarea {
        font-size: 16px;
    }

    /* Field mapping rows: 2 lines instead of 3 squeezed dropdowns
       line 1 = source type + Jotform field, line 2 = → Lark field + remove */
    .field-mapping-row {
        display: grid;
        grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr) auto;
        grid-template-areas:
            "src src val val"
            "arr lark lark del";
        gap: 8px;
        padding: 12px;
        align-items: center;
    }

    .field-mapping-row>.mapping-source {
        grid-area: src;
    }

    .field-mapping-row>.mapping-value {
        grid-area: val;
    }

    .field-mapping-row>i {
        grid-area: arr;
        justify-self: center;
    }

    .field-mapping-row>.lark-field {
        grid-area: lark;
        width: 100%;
    }

    .field-mapping-row>.btn,
    .field-mapping-row>button {
        grid-area: del;
        margin-left: 0;
        width: 40px;
        height: 40px;
        min-height: 40px;
    }

    .field-mapping-row select,
    .field-mapping-row input {
        min-height: 42px;
        height: 42px;
        padding-left: 12px;
        padding-right: 30px;
        background-position: right 9px center;
        text-overflow: ellipsis;
    }

    /* WATI rows reuse .field-mapping-row with different children (and an inline
       grid-template-columns), so they get their own 2-line layouts */
    #watiParameterList>.field-mapping-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px !important;
        grid-template-areas:
            "id id id"
            "name desc del";
    }

    #watiParameterList .wati-field-id {
        grid-area: id;
    }

    #watiParameterList .wati-display-name {
        grid-area: name;
    }

    #watiParameterList .wati-description {
        grid-area: desc;
    }

    #watiTemplateParamsList>.field-mapping-row {
        grid-template-columns: minmax(0, 1fr) 40px !important;
        grid-template-areas:
            "name name"
            "val del";
    }

    #watiTemplateParamsList .wati-param-name {
        grid-area: name;
    }

    #watiTemplateParamsList .field-mapping-row>div {
        grid-area: val;
        min-width: 0;
    }

    #watiParameterList .field-mapping-row input,
    #watiTemplateParamsList .field-mapping-row input {
        width: 100%;
        min-width: 0;
        padding-right: 12px;
    }

    /* Dashboard tables on phones: readable name column (pinned by ui-shell.js), the rest scrolls */
    .shopify-stats-table {
        min-width: 520px;
    }

    .shopify-stats-table th,
    .shopify-stats-table td {
        padding: 10px 12px !important;
    }

    .shopify-stats-table th:first-child,
    .shopify-stats-table td:first-child {
        width: 172px;
        min-width: 172px;
        max-width: 172px;
    }

    #workflowStatsTable {
        min-width: 500px;
    }

    #workflowStatsTable th:first-child,
    #workflowStatsTable td:first-child {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
        white-space: normal;
    }

    #watiDistribution .sales-stat-card {
        padding: 12px !important;
    }

    #watiDistribution .sales-stat-card>div:last-child>div:first-child {
        font-size: 18px !important;
    }

    /* Shopify sync modal on phones */
    #shopifySyncModal .modal-body {
        padding: 14px !important;
    }

    #shopifySyncModal .sync-filter-container {
        padding: 12px !important;
        margin-bottom: 12px !important;
    }

    #shopifySyncModal .sync-filter-container>div {
        flex-wrap: wrap;
        gap: 8px !important;
    }

    #shopifySyncModal #syncAgencyFilter {
        flex: 1 1 100% !important;
    }

    #shopifySyncModal .btn-scan {
        flex: 1 1 100%;
        height: 44px;
    }

    #shopifySyncModal .shopify-sync-stats {
        gap: 10px !important;
        margin-bottom: 12px !important;
    }

    #shopifySyncModal .stat-mini-card {
        padding: 12px !important;
        gap: 10px !important;
    }

    #shopifySyncModal .stat-mini-card>div:first-child {
        width: 34px !important;
        height: 34px !important;
        font-size: 15px !important;
    }

    #shopifySyncModal .sync-preview-table-container {
        margin-top: 0;
    }

    #shopifySyncModal .table-responsive {
        max-height: 48vh !important;
    }

    #shopifySyncModal .sync-preview-table {
        min-width: 640px;
    }

    /* Footer: selected count on its own line, then the two buttons side by side */
    #shopifySyncModal .modal-footer>div:first-child {
        flex: 1 1 100% !important;
        text-align: center !important;
    }

    #shopifySyncModal .modal-footer .btn {
        flex: 1 1 0;
    }

    /* "Chèn biến" sits on its own full-width line under the "Nội dung email" label */
    .modal-body label:has(> .variable-inserter) {
        flex-wrap: wrap;
        gap: 8px;
    }

    .variable-inserter {
        flex: 1 1 100%;
    }

    .variable-inserter select {
        flex: 1 1 auto;
        width: 100% !important;
        height: 40px !important;
        border-radius: 12px !important;
        font-size: 16px !important; /* inline 12px would make iOS zoom in on tap */
    }

    /* Selected Sales / Designer rows: compact */
    .selected-sales-item {
        gap: 10px;
        padding: 10px 12px;
    }

    .selected-sales-item .sales-item-weight {
        gap: 6px;
    }

    .selected-sales-item .sales-item-weight label {
        font-size: 12px;
        color: var(--n-500);
    }

    .selected-sales-item .weight-input {
        width: 56px;
        min-height: 40px;
        text-align: center;
    }
}


/* "Thời gian" filter: the two date boxes of "Chọn khoảng ngày…" (History, Email Tracking, attendance audit log) */
.period-dates { display: flex; align-items: center; gap: 8px; }
.period-dates[hidden] { display: none !important; }
.period-date { height: 38px; min-width: 0; padding: 0 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font: inherit; font-size: 14px; }
.period-date:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.table-controls .period-date { height: 36px; }
.period-sep { color: var(--text-muted); }
/* "Xóa tất cả / Xóa n mục theo bộ lọc": a quiet button in the danger colour */
.btn-delete-filtered:not(:disabled) { color: var(--danger); }
.btn-delete-filtered:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 768px) {
    /* pages with a time filter: the filters stacked, the buttons in one wrapping row below them */
    .history-filters.has-period { display: flex; flex-direction: column; align-items: stretch; }
    .history-filters.has-period > .filter-group { display: flex; flex-direction: column; gap: 8px; }
    .history-filters.has-period > .filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .history-filters.has-period .filter-actions > .btn { flex: 1 1 auto; grid-column: auto; grid-row: auto; justify-content: center; }
    .period-dates .period-date { flex: 1 1 0; }
}

/* Settings → Cảnh báo sự cố */
.alert-status-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 14px; padding: 10px 14px; border-radius: 6px; background: var(--bg-primary); border: 1px solid var(--border-color); font-size: 13px; }
.alert-last-sent { font-size: 12px; color: var(--text-muted); }
.alert-toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px; background: var(--bg-primary); border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.alert-lark-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.alert-burst-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary, var(--text-muted)); }
.alert-burst-row > input.form-control { width: 110px !important; flex: 0 0 110px; }
.alert-burst-row > span { flex: 1 1 auto; min-width: 0; }
@media (max-width: 768px) {
    .alert-lark-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .alert-burst-row { flex-wrap: wrap; }
}

/* =====================================================
   User permissions · Teams: actions + who can be seen
   ===================================================== */
.teams-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.teams-scope-note { margin-bottom: 16px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-secondary); border: 1px solid var(--border-color); font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.teams-scope-note[hidden], .teams-scope-box[hidden] { display: none; }
.teams-scope { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border-color); }
#teamsActionsGrid[style*="none"] + .teams-scope { margin-top: 0; padding-top: 0; border-top: 0; }
.teams-scope-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; color: var(--text-primary); }
.teams-scope-title .fas { color: var(--brand-500, var(--primary)); }
.teams-scope-hint { margin: 4px 0 14px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.teams-scope-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.teams-scope-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.teams-scope-col > label { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.teams-scope-col > select { width: 100%; }
.teams-scope-box { display: flex; flex-direction: column; gap: 8px; }
.teams-scope-search { width: 100%; }
.teams-scope-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }

.teams-scope-count { flex: 1 1 auto; min-width: 0; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.teams-scope-count.is-warn { color: var(--danger, #d92d20); font-weight: 600; }
.teams-scope-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: #fff; }
.teams-scope-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0; cursor: pointer; border-top: 1px solid var(--border-color); font-size: 13px; }
.teams-scope-item:first-child { border-top: 0; }
.teams-scope-item:hover { background: var(--bg-secondary); }
.teams-scope-item.is-picked { background: var(--primary-bg, rgba(255, 74, 0, 0.06)); }
.teams-scope-item input { width: 16px; height: 16px; margin: 0; flex: none; cursor: pointer; }
.teams-scope-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.teams-scope-dot.is-on { background: #12b76a; }
.teams-scope-dot.is-off { background: #f04438; }
.teams-scope-who { display: flex; flex-direction: column; min-width: 0; }
.teams-scope-name { font-weight: 550; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teams-scope-sub { font-size: 11.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teams-scope-empty { padding: 14px; text-align: center; font-size: 12.5px; color: var(--text-secondary); }
@media (max-width: 768px) {
    .teams-actions-grid, .teams-scope-grid { grid-template-columns: minmax(0, 1fr); }
}
.teams-scope-col.form-group { margin-bottom: 0; }
.teams-scope-link { background: none; border: 0; padding: 2px 6px; border-radius: 6px; color: var(--brand-600, var(--primary)); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.teams-scope-link:hover { background: var(--brand-50, var(--primary-bg)); }
/* the picker sits in a .form-group (standard fields): keep its own row layout over ".form-group label" */
.teams-scope-list .teams-scope-item { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 13px; font-weight: 400; color: inherit; text-transform: none; letter-spacing: 0; }
.teams-scope-list .teams-scope-dot { display: inline-block; }
.teams-scope-tools .teams-scope-count { order: 3; flex: 1 1 100%; }
/* tick boxes of this dialog: look from the site-wide rule below, no extra margin here */
#teamsActionsModal input[type="checkbox"] { margin: 0; }

/* =====================================================
   Search on the Teams and Users pages
   ===================================================== */
#teamsPage .team-search { margin-left: auto; }
.user-list-actions { display: flex; align-items: center; gap: 12px; }
.user-list-actions .search-box { width: 280px; }
.user-list-actions .search-box:focus-within { width: 340px; }
@media (max-width: 768px) {
    #teamsPage .team-search,
    .user-list-actions .search-box,
    .user-list-actions .search-box:focus-within { width: 100%; margin-left: 0; }
    .user-list-actions { flex-direction: column; align-items: stretch; gap: 10px; }
}

/* =====================================================
   Tick boxes: one look across the whole site
   18px, rounded, light border; orange with a white tick when ticked (a dash when partly ticked).
   Switches (.switch, .toggle-switch) and custom tick marks (.checkbox-container) hide their own input
   and are left out. Specific enough to win over the older per-page sizes (15 / 16 / 20px, accent-color);
   margins are left to each page's layout.
   ===================================================== */
input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input) {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 0;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background: #fff center / 12px no-repeat;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input):checked {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
}

input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input):indeterminate {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='6' y1='12' x2='18' y2='12'/%3E%3C/svg%3E");
}

input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input):hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input[type="checkbox"]:not(.switch input):not(.toggle-switch input):not(.checkbox-container input):disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
/* Teams dialog: a group whose "Quyền Sales / Designer" is off cannot be seen at all */
.teams-scope-off { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-secondary); border: 1px dashed var(--border-color); font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; }
.teams-scope-off[hidden] { display: none; }
.teams-scope-off .fas { color: var(--text-muted); }

/* =====================================================
   Dropdown lists: one look across the site
   Native selects open .ui-select-menu (ui-shell.js). The filter dropdowns built by initCustomSelects
   (History, Email tracking, Attendance, shipping filters) get the same list: tick on the chosen one,
   grey on hover, orange text for the choice.
   ===================================================== */
.ui-select-group {
    padding: 8px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--n-400);
}

.ui-select-group:not(:first-child) {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--n-150);
}

.custom-select.open .custom-select-trigger { border-radius: 10px; }

.custom-select-options {
    padding: 6px;
    border-radius: 12px;
    background: var(--n-0, #fff);
    max-height: 320px;
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--n-800);
    background: transparent;
}

.custom-select-option::before {
    content: "\f00c";
    flex: 0 0 14px;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
    color: var(--brand-500);
    visibility: hidden;
}

.custom-select-option:hover { background: var(--n-100); color: var(--n-800); }
.custom-select-option.selected { background: transparent; color: var(--brand-700); font-weight: 600; }
.custom-select-option.selected::before { visibility: visible; }
.custom-select-option.selected:hover { background: var(--brand-50); color: var(--brand-700); }

/* Option list: when room runs short the grey note on the right gives way first (shrinks 4x faster, with "…")
   instead of covering the main text, e.g. "Chỉnh sửa · tạo vận đơn, trả tracking, cấu hình" */
.ui-select-meta { flex: 0 4 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ui-select-option { overflow: hidden; }

/* =====================================================
   Workflow Shopify notification: sender account (shared one in Cài đặt, or the workflow's own Gmail / Lark Mail)
   ===================================================== */
.wf-sender-mode { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.wf-sender-mode label { margin: 0; font-weight: 600; font-size: 12px; white-space: nowrap; }
.wf-sender-mode select { flex: 1 1 auto; min-width: 0; max-width: 320px; height: 38px; font-size: 13px; }
.wf-sender-custom { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); }
.wf-sender-custom[hidden] { display: none; }
.wf-sender-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; }
.wf-sender-grid .form-group { margin-bottom: 0; min-width: 0; }
.wf-sender-grid label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 12px; }
.wf-sender-grid select, .wf-sender-grid .form-control { width: 100%; height: 38px; font-size: 13px; }
.wf-sender-hint { margin: 8px 0 10px; font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.wf-sender-test { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wf-sender-result { font-size: 12.5px; color: var(--text-secondary); min-width: 0; overflow-wrap: anywhere; }
.wf-sender-result.is-ok { color: #067647; }
.wf-sender-result.is-bad { color: var(--danger, #d92d20); }
@media (max-width: 768px) {
    .wf-sender-mode { flex-direction: column; align-items: stretch; gap: 6px; }
    .wf-sender-mode select { max-width: none; }
    .wf-sender-grid { grid-template-columns: minmax(0, 1fr); }
}
.wf-sender-mode.form-group { margin-bottom: 10px; }
.wf-sender-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.2fr); }
@media (max-width: 768px) { .wf-sender-grid { grid-template-columns: minmax(0, 1fr); } }

/* Workflow Shopify notification: brand colour of the email */
.wf-brand-row { display: flex; align-items: center; gap: 10px; }
.wf-brand-row select { flex: 0 1 220px; min-width: 0; height: 38px; font-size: 13px; }
.wf-brand-row input[type="color"] { width: 42px; height: 38px; padding: 3px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; cursor: pointer; flex: none; }
.wf-brand-code { font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text-secondary); }
.wf-brand-hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-secondary); line-height: 1.45; }
